CN103713154A - Method for judging motor rotating direction by using trigger and coder - Google Patents
Method for judging motor rotating direction by using trigger and coder Download PDFInfo
- Publication number
- CN103713154A CN103713154A CN201410005699.0A CN201410005699A CN103713154A CN 103713154 A CN103713154 A CN 103713154A CN 201410005699 A CN201410005699 A CN 201410005699A CN 103713154 A CN103713154 A CN 103713154A
- Authority
- CN
- China
- Prior art keywords
- motor
- flip
- flop
- signal
- output
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 15
- 230000000630 rising effect Effects 0.000 claims description 4
- 238000011897 real-time detection Methods 0.000 abstract description 3
- 238000001514 detection method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Images
Landscapes
- Control Of Electric Motors In General (AREA)
Abstract
本发明涉及一种利用触发器和编码器判断电机转向的方法,其特征在于,步骤为:第一步、由速度脉冲编码器根据获取的电机旋转信息输出两相脉冲信号,两相脉冲信号中的任意一相脉冲信号接入触发器的输入端,作为输入信号,另一相脉冲信号接入触发器的时钟端,作为时钟控制信号;第二步、由微控制器检测触发器的输出,当电机转向后,时钟控制信号反相,触发器的输出由高电平变化为低电平,或由低电平变化为高电平。本发明利用编码器的两相输出和触发器的特点,将转向信息转变为电平信号提供给微控制器,其具有装置简单、成本较低、准确率高、能够实时检测等优点。The invention relates to a method for judging the steering direction of a motor by using a trigger and an encoder, which is characterized in that the steps are as follows: the first step, the speed pulse encoder outputs a two-phase pulse signal according to the obtained motor rotation information, and the two-phase pulse signal Any phase pulse signal of any phase is connected to the input terminal of the flip-flop as an input signal, and the other phase pulse signal is connected to the clock terminal of the flip-flop as a clock control signal; the second step is to detect the output of the flip-flop by the microcontroller, When the motor turns, the clock control signal is reversed, and the output of the flip-flop changes from high level to low level, or from low level to high level. The invention uses the two-phase output of the encoder and the characteristics of the trigger to convert the steering information into a level signal and provide it to the microcontroller. It has the advantages of simple device, low cost, high accuracy, and real-time detection.
Description
技术领域technical field
本发明涉及一种利用触发器与速度脉冲编码器相配合,根据TTL逻辑电平判断电机的旋转方向的方法,通过将电平信号接入单片机等微控制器可实现对电机转向信息的实时检测。The invention relates to a method for judging the rotation direction of a motor according to a TTL logic level by using a trigger and a speed pulse encoder, and real-time detection of motor steering information can be realized by connecting the level signal to a microcontroller such as a single-chip microcomputer .
背景技术Background technique
随着计算机与电子技术的发展,越来越多基于嵌入式的电机控制系统被应用到生产生活中。与传统控制系统不同在于,这种控制系统利用逻辑电平信号传输信息,实现自动控制的闭环反馈。如果将电机转向信息利用电路直接转化为逻辑电平信号,微控制器只需检测相应引脚的电压即可实时获取当前电机的转向信息,不仅提高了系统的效率,而且提高了检测的准确性,具有非常好的应用前景。With the development of computer and electronic technology, more and more embedded motor control systems are applied to production and life. The difference from traditional control systems is that this control system uses logic level signals to transmit information to achieve closed-loop feedback for automatic control. If the motor steering information is directly converted into a logic level signal by using the circuit, the microcontroller only needs to detect the voltage of the corresponding pin to obtain the current steering information of the motor in real time, which not only improves the efficiency of the system, but also improves the accuracy of detection , has a very good application prospect.
在判断电机转向时,常使用速度编码器先将电机的速度信息转化为脉冲信号,如欧姆龙公司生产的E6A2系列编码器,采用正交的两相脉冲编码输出,两相具有90度相差。经测试,脉冲低电平小于0.5V,高电平根据所接上拉电阻的电压可以在5V-12V之间,两相间相位稳定度较高、电压较稳定。When judging the steering of the motor, a speed encoder is often used to convert the speed information of the motor into a pulse signal. For example, the E6A2 series encoder produced by Omron Corporation adopts an orthogonal two-phase pulse code output, and the two phases have a 90-degree phase difference. After testing, the low level of the pulse is less than 0.5V, and the high level can be between 5V-12V according to the voltage of the pull-up resistor connected. The phase stability between the two phases is relatively high, and the voltage is relatively stable.
当前方法根据收集到的两相脉冲个数在微控制器中编程实现对电机转向的判断,这种方式增加了系统的复杂度,由于需要每隔一定时间读取两个脉冲计数寄存器的值,降低了微控制器的运转效率。另外,在一定时间内可能接收到的脉冲数目相同而导致无法判断电机转向,识别成功率不高。The current method uses the collected two-phase pulse numbers to program the microcontroller to realize the judgment of the motor steering. This method increases the complexity of the system. Since the values of the two pulse count registers need to be read at regular intervals, Reduced operating efficiency of the microcontroller. In addition, the same number of pulses may be received within a certain period of time, so it is impossible to judge the direction of the motor, and the recognition success rate is not high.
发明内容Contents of the invention
本发明要解决的技术问题是降低电机转向检测的复杂度,同时,提高其识别成功率。The technical problem to be solved by the invention is to reduce the complexity of motor steering detection, and at the same time, improve the recognition success rate.
为了达到上述目的,本发明的技术方案提供了一种利用触发器和编码器判断电机转向的方法,其步骤为:In order to achieve the above object, the technical solution of the present invention provides a method for using a trigger and an encoder to judge the steering of a motor, the steps of which are:
第一步、由速度脉冲编码器根据获取的电机旋转信息输出两相脉冲信号,两相脉冲信号中的任意一相脉冲信号接入触发器的输入端,作为输入信号,另一相脉冲信号接入触发器的时钟端,作为时钟控制信号;In the first step, the speed pulse encoder outputs two-phase pulse signals according to the obtained motor rotation information. Any one phase pulse signal of the two-phase pulse signals is connected to the input terminal of the trigger as an input signal, and the other phase pulse signal is connected to Input the clock terminal of the flip-flop as a clock control signal;
第二步、由微控制器检测触发器的输出,当电机转向后,时钟控制信号反相,触发器的输出由高电平变化为低电平,或由低电平变化为高电平。In the second step, the microcontroller detects the output of the flip-flop. When the motor turns, the clock control signal is reversed, and the output of the flip-flop changes from high level to low level, or from low level to high level.
优选地,当所述电机正向转动时,在所述时钟控制信号的上升沿时,所述输入信号位于高电平,则所述触发器的输出为高电平;当所述电机反向转动时,所述时钟控制信号反相,在所述时钟控制信号的上升沿时,所述输入信号位于低电平,则所述触发器的输出为低电平。Preferably, when the motor rotates in the forward direction, at the rising edge of the clock control signal, the input signal is at a high level, and the output of the flip-flop is at a high level; when the motor rotates in the reverse direction When rotating, the clock control signal is inverted, and when the clock control signal rises, the input signal is at low level, and the output of the flip-flop is at low level.
优选地,通过所述微控制器设置等待时间,在等待时间内,由微控制器统计接收到的高电平及低电平的个数来判断所述电机的转向,防止电机转向过程中的抖动现象。Preferably, the waiting time is set by the micro-controller, and within the waiting time, the micro-controller counts the number of received high levels and low levels to judge the turning direction of the motor, so as to prevent the turning of the motor during the turning process. Jitter phenomenon.
本发明利用编码器的两相输出和触发器的特点,将转向信息转变为电平信号提供给微控制器,其具有装置简单、成本较低、准确率高、能够实时检测等优点。The invention uses the two-phase output of the encoder and the characteristics of the trigger to convert the steering information into a level signal and provide it to the microcontroller. It has the advantages of simple device, low cost, high accuracy, and real-time detection.
附图说明Description of drawings
图1为实施例中电机正向转动时,输入信号及时钟控制信号示意图;Fig. 1 is a schematic diagram of input signals and clock control signals when the motor rotates forward in the embodiment;
图2为实施例中电机反向转动时,输入信号及时钟控制信号示意图。Fig. 2 is a schematic diagram of input signals and clock control signals when the motor rotates in reverse in the embodiment.
具体实施方式Detailed ways
为使本发明更明显易懂,兹以优选实施例,并配合附图作详细说明如下。In order to make the present invention more comprehensible, preferred embodiments are described in detail below with accompanying drawings.
本发明提供了一种利用触发器和编码器判断电机转向的方法,步骤为:The invention provides a method for judging the steering of a motor by using a trigger and an encoder, the steps are:
第一步、由速度脉冲编码器根据获取的电机旋转信息输出两相脉冲信号,两相脉冲信号中的任意一相脉冲信号接入触发器的输入端,作为输入信号,另一相脉冲信号接入触发器的时钟端,作为时钟控制信号;In the first step, the speed pulse encoder outputs two-phase pulse signals according to the obtained motor rotation information. Any one phase pulse signal of the two-phase pulse signals is connected to the input terminal of the trigger as an input signal, and the other phase pulse signal is connected to Input the clock terminal of the flip-flop as a clock control signal;
第二步、由微控制器检测触发器的输出,当电机转向后,时钟控制信号反相,触发器的输出由高电平变化为低电平,或由低电平变化为高电平,本领域技术人员可以根据实际情况来进行设定,例如高电平时为电机正向转动,低电平时为电机反向转动;也可以高电平时为电机反向转动,低电平时为电机正向转动,本实施例采用的是前者,具体如下:The second step is to detect the output of the flip-flop by the microcontroller. When the motor turns, the clock control signal is reversed, and the output of the flip-flop changes from high level to low level, or from low level to high level. Those skilled in the art can set it according to the actual situation. For example, when the power level is high, the motor rotates forward, and when the power level is low, the motor rotates reversely; Rotation, what this embodiment adopts is the former, specifically as follows:
当电机正向转动时,在时钟控制信号的上升沿时,输入信号位于高电平,则触发器的输出为高电平,如图1所示。电压表检测触发器输出端为高电平。当电机反向转动时,时钟控制信号反相,在时钟控制信号的上升沿时,输入信号位于低电平,则触发器的输出为低电平,如图2所示。电压表检测触发器输出端为低电平。When the motor rotates in the forward direction, at the rising edge of the clock control signal, the input signal is at a high level, and the output of the flip-flop is at a high level, as shown in Figure 1. The voltmeter detects that the output terminal of the flip-flop is high level. When the motor rotates in the reverse direction, the clock control signal is reversed. When the clock control signal rises, the input signal is at low level, and the output of the flip-flop is at low level, as shown in Figure 2. The voltmeter detects that the output terminal of the flip-flop is low level.
为了防止电机转向过程中的抖动现象,还可以通过微控制器设置等待时间,在等待时间内,由微控制器统计接收到的高电平及低电平的个数来判断所述电机的转向,例如在本实施例中,在等待时间内,若微控制器接收到的高电平数为2个,而低电平数为6个,则可以判定为电机由正向转动转向为了反向转动,反之亦然。In order to prevent the jitter phenomenon during the motor steering process, the waiting time can also be set by the microcontroller. During the waiting time, the microcontroller can count the number of high and low levels received to judge the steering of the motor. , for example, in this embodiment, during the waiting time, if the number of high levels received by the microcontroller is 2, and the number of low levels is 6, it can be determined that the motor is turning from forward to reverse Turn and vice versa.
将本发明的转向控制方法应用到两轮直立平衡小车中,在小车行驶中需要快速实时地检测当前车轮的转动情况以达到车速控制的闭环反馈,使用该方法来实时检测车轮的旋转方向,达到了较稳定的直立效果。Apply the steering control method of the present invention to a two-wheeled upright balance trolley. When the trolley is running, it is necessary to detect the rotation of the current wheels quickly and in real time to achieve closed-loop feedback of vehicle speed control. Use this method to detect the rotation direction of the wheels in real time to achieve A more stable upright effect.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410005699.0A CN103713154A (en) | 2014-01-07 | 2014-01-07 | Method for judging motor rotating direction by using trigger and coder |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410005699.0A CN103713154A (en) | 2014-01-07 | 2014-01-07 | Method for judging motor rotating direction by using trigger and coder |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103713154A true CN103713154A (en) | 2014-04-09 |
Family
ID=50406288
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410005699.0A Pending CN103713154A (en) | 2014-01-07 | 2014-01-07 | Method for judging motor rotating direction by using trigger and coder |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103713154A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107656093A (en) * | 2017-10-16 | 2018-02-02 | 深圳市路畅科技股份有限公司 | A kind of detection method and device of rotary encoder |
CN112146686A (en) * | 2019-06-27 | 2020-12-29 | 西安诺瓦星云科技股份有限公司 | Rotation information acquisition method, device and system and computer readable storage medium |
CN112924716A (en) * | 2021-01-25 | 2021-06-08 | 武汉先同科技有限公司 | Digital direction discrimination method for improved two-phase encoder |
CN113848466A (en) * | 2021-08-02 | 2021-12-28 | 惠州市德赛西威汽车电子股份有限公司 | Detection circuit and detection method for realizing rapid response of knob |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101003930A (en) * | 2006-01-18 | 2007-07-25 | 上海鲍麦克斯电子科技有限公司 | Control system in new type computer controlled sewing machine |
CN101216711A (en) * | 2008-01-08 | 2008-07-09 | 哈尔滨工程大学 | Hierarchical control device and control method for amphibious mechanical crabs |
CN102880181A (en) * | 2012-09-06 | 2013-01-16 | 中山大学 | Inverted pendulum system as well as control circuit and control method thereof |
CN103441717A (en) * | 2013-08-06 | 2013-12-11 | 毛振刚 | Digital direct-current speed regulating system of electric excavator |
-
2014
- 2014-01-07 CN CN201410005699.0A patent/CN103713154A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101003930A (en) * | 2006-01-18 | 2007-07-25 | 上海鲍麦克斯电子科技有限公司 | Control system in new type computer controlled sewing machine |
CN101216711A (en) * | 2008-01-08 | 2008-07-09 | 哈尔滨工程大学 | Hierarchical control device and control method for amphibious mechanical crabs |
CN102880181A (en) * | 2012-09-06 | 2013-01-16 | 中山大学 | Inverted pendulum system as well as control circuit and control method thereof |
CN103441717A (en) * | 2013-08-06 | 2013-12-11 | 毛振刚 | Digital direct-current speed regulating system of electric excavator |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107656093A (en) * | 2017-10-16 | 2018-02-02 | 深圳市路畅科技股份有限公司 | A kind of detection method and device of rotary encoder |
CN112146686A (en) * | 2019-06-27 | 2020-12-29 | 西安诺瓦星云科技股份有限公司 | Rotation information acquisition method, device and system and computer readable storage medium |
CN112924716A (en) * | 2021-01-25 | 2021-06-08 | 武汉先同科技有限公司 | Digital direction discrimination method for improved two-phase encoder |
CN113848466A (en) * | 2021-08-02 | 2021-12-28 | 惠州市德赛西威汽车电子股份有限公司 | Detection circuit and detection method for realizing rapid response of knob |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN202754140U (en) | Digital servo | |
CN103713154A (en) | Method for judging motor rotating direction by using trigger and coder | |
CN103592455A (en) | Digital detection device and method for speed of electric bicycle | |
CN102890183B (en) | Method and device for automatic voltage correction of zero crossing detection circuit | |
CN111959656B (en) | Pedal information sensing device and bicycle | |
CN103760921A (en) | Low-precision multi-sensor fused original point precise positioning system and positioning method | |
CN203705526U (en) | Voltage polarity judgment circuit and system | |
Xiao | A high-accuracy steering wheel angle sensor based on GMR | |
CN106247915A (en) | A kind of PLCD sensor signal conditioning circuit followed based on peak value and method thereof | |
CN204313787U (en) | A kind of testing circuit of angular encoder | |
CN106787996B (en) | A kind of brshless DC motor commutation deviation real-time correction method | |
CN104133407A (en) | Counting device and method for incremental encoder | |
CN103868451B (en) | A kind of angular transducer and angle measurement method | |
CN204168481U (en) | A kind of volume control inputs circuit | |
CN102914703B (en) | Phase sequence rapid measuring method based on instantaneous point | |
CN102708665B (en) | Broadband code signal detection circuit and wireless remote signal decoding circuit thereof | |
CN204733150U (en) | A kind of electric assisted bicycle axis rotating and step on frequency testing circuit | |
CN202798678U (en) | Quadrature encoded pulse decoding circuit | |
CN203632476U (en) | Out-of-step prevention structure for step motor | |
CN203218868U (en) | An IGBT overcurrent classification protection circuit | |
CN202043034U (en) | Level shift circuit realizing shifting from 5v signal to 3.3v signal for singlechip system | |
CN206533352U (en) | A kind of voltage is to time converting circuit | |
CN213414145U (en) | Pedal information sensing device and bicycle | |
CN207019697U (en) | Encoder rotating detection and sub-circuit | |
CN108075697A (en) | A kind of switched reluctance machines phase current iterative learning control method of position signal frequency multiplication |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C02 | Deemed withdrawal of patent application after publication (patent law 2001) | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20140409 |