CN101825481A - Method and device for applying encoder to count - Google Patents

Method and device for applying encoder to count Download PDF

Info

Publication number
CN101825481A
CN101825481A CN 201010104019 CN201010104019A CN101825481A CN 101825481 A CN101825481 A CN 101825481A CN 201010104019 CN201010104019 CN 201010104019 CN 201010104019 A CN201010104019 A CN 201010104019A CN 101825481 A CN101825481 A CN 101825481A
Authority
CN
China
Prior art keywords
pulse signals
counting
pulse
phase
encoder
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.)
Granted
Application number
CN 201010104019
Other languages
Chinese (zh)
Other versions
CN101825481B (en
Inventor
潘征宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Institute of Measurement and Testing Technology
Original Assignee
Shanghai Institute of Measurement and Testing Technology
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Institute of Measurement and Testing Technology filed Critical Shanghai Institute of Measurement and Testing Technology
Priority to CN 201010104019 priority Critical patent/CN101825481B/en
Publication of CN101825481A publication Critical patent/CN101825481A/en
Application granted granted Critical
Publication of CN101825481B publication Critical patent/CN101825481B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention relates to a method and a device for counting, belonging to the field of microprocessor unit control. The method for applying an encoder to count is characterized by comprising the following steps: setting output pulse signals of the encoder, when defining the angle rotating direction of the encoder to be forward or reverse toward the expected direction, storing the status words of the three paths of output pulse signals as standard status words, starting to count, receiving the three paths of pulse signals outputted by the encoder by a microprocessor unit (MCU), when detecting that triggering points occur on the pulse signals, reading out the levels of the three paths of pulse signals at the moment as real-time status words, carrying out comparison on the real-time status words with the standard status words, if being accordant, correspondingly making forward or reverse counting, and if not, ignoring without counting. The invention also discloses a device for applying the encoder to count, which applies the method. The invention utilizes the encoder to output three-phase pulse signals for counting, thus avoiding the phenomena that the signals drop, counting errors are generated along interference and the pulses are counted more or leaked and the like.

Description

A kind of method and apparatus of applying encoder to count
Technical field
The present invention relates to a kind of method of counting and device, relate in particular to a kind of method and apparatus of applying encoder to count.
Background technology
Scrambler is a kind of the most common measurement of angle sensor, is equipped with other mechanical values such as all right Displacement Measurement of some physical constructions, all is widely used in all trades and professions.Scrambler is with the rotational angle in the rotating shaft, utilizes grating (magnetic grid) measuring technique to convert square-wave pulse output to, by the counting assembly of outside the output pulse is counted, and obtains and the corresponding digital quantity of tested angle.Generally all used up-down counter to count, along with the development and the maturation of microprocessor technology, we can omit counter circuit fully, directly use microprocessor to count in the past.But when reality is used, tend to the degree of accuracy that occurrence count is inaccurate and some waveform disturbing effects are counted, also must before measurement, stipulate the sense of rotation of a counting forward simultaneously in advance, make and use microprocessor and count and become not as using up-down counter to count simple and easily use, and the degree of accuracy of counting also differs and guarantees surely.
Summary of the invention
Technical matters to be solved by this invention provides a kind of method of applying encoder to count, solve to set in advance when utilizing microprocessor and scrambler to count now to cause and use inconvenience, and because some waveforms of scrambler disturb the not high defective of degree of accuracy that causes counting.
Technical scheme
The present invention proposes a kind of method of applying encoder to count, it is characterized in that comprising the steps:
Set the output pulse signal of scrambler, scrambler dephased two pulse signals A of output device and signal B simultaneously are set, wherein one road pulse signal A is anti-phase by anti-phase general is A, and exports simultaneously with above-mentioned two pulse signals;
When the rotary direction of angle of definition scrambler be past desired directions forward or reverse, more than the status word of three road output pulse signals store as the standard state word, when rotary encoder when wishing that the direction of counting is rotated forward or backwards forward or backwards, as the trigger point, the level of noting three road pulse signals this moment is as the standard state word with the rising edge of pulse signal A or A or negative edge;
Begin counting, microprocessor MCU receives three road pulse signals of scrambler output, when detecting pulse signal A or A and the trigger point occurs, the level of reading three road pulse signals this moment is as the real-time status word, described real-time status word and above-mentioned standard state word are compared, as meeting fully, the then corresponding counting forward or backwards of doing, as not in full conformity with, then ignore.
The phase differential of described pulse signal A and B is 90 degree, adopts negative edge with pulse signal A or A as the trigger point.
The invention allows for a kind of device of applying encoder to count, it is characterized in that: comprise that the output two-way has the scrambler of phase differential pulse signal, wherein one tunnel output signal of scrambler is carried out anti-phase phase inverter, and the synthetic follower that this inversion signal and described two pulse signals are exported simultaneously, the three-way output signal of described synthetic follower links to each other with three ports of microprocessor respectively, the middle fracture that has the output connecting microprocessor of positive and anti-phase pulse signal simultaneously, other one tunnel pulse signal with phase differential connects the I/O port of microprocessor, comprise the status word of level of the storer of status word of level of storage pulse signal and the pulse signal that relatively receives and the comparer that default status word compares in the described microprocessor, and the counter of counting according to comparator results.
Described scrambler adopts two-phase alternating binary coding device.
Beneficial effect
Method and apparatus of the present invention utilizes scrambler output three-phase pulse signal and detects counting, avoid one road signal negative edge wherein that utilizes the two-phase pulse signal to count to be prone to commonly used to disturb and produced counting error, or many meters of pulse or error of omission phenomenon during scrambler rotating conversion, and improved and determined now can not change the defective that direction is counted again after the rotating direction.
Description of drawings
Fig. 1 is the present invention two-phase output pulse sequence figure commonly used now.
Fig. 2 is scrambler output three-phase pulse sequential chart of the present invention
Embodiment
Below in conjunction with specific embodiment, further set forth the present invention.
We are example with the raster pattern two-phase alternating binary coding device of 2048 pulses of every circle output, so-called two-phase promptly simultaneously phase difference output be 90 ° of two pulse signals, two-wayly can carry out rotating exactly and carry out positive and negative counting, its output pulse sequence figure sees Fig. 2.Pulse be the A pulse obtain by a negative circuit with the opposite signal of A pulse logic, the B pulse be with the A pulse phase difference be 90 ° of pulse signals.During actual the use, adopt the Atmel89C52 microprocessor to carry out the step-by-step counting of scrambler, A and A pulse are given burst transmissions on CPU external interrupt 0 and external interrupt 1 port (INT0, INT1) by the light idol respectively, and the B pulse receives with an I/O mouth.During programming, at first in E2ROM, store the positive-negative rotation state word of definition by the phase sequence measurement function, just earlier along the direction rotary encoder of wishing counting forward, the negative edge of A pulse triggers external interrupt 0, the level that externally interrupts reading in 0 service routine A, A, B pulse is and just changes status word, again along the direction rotary encoder of wishing counting in reverse, the negative edge of pulse triggers external interrupt 1, and the level that externally interrupts reading in 1 service routine A, A, B pulse is the inverted status word.During actual count, if definition phase sequence 1 → 2 is for just changeing, when external interrupt 0 triggers, externally interrupt judging in 0 service routine level of A, A, B pulse, if be 011 (just changeing status word) then counter adds 1, be 010 invalid, promptly the A pulse negative edge of phase place 2 interrupts effectively, scrambler just changes; When external interrupt 1 triggers, judge this level equally, if be 101 (inverted status words) then counter subtracts 1, be 100 invalid, promptly the pulse A negative edge of phase place 2 interrupts effectively, the scrambler counter-rotating.If the definition 2 → 1 of phase sequence process of measurement is for just changeing, then just changeing status word is 010, and the inverted status word is 100, in 1 state A trigger action external interrupt 0, counter is added 1, in 1 state A trigger action external interrupt 1, counter is subtracted 1, and the interruption that other situations produce is invalid.
When general at present use microprocessor is counted scrambler, all be only to use A, B two-phase pulse, as shown in Figure 1.Must stipulate to add, subtract the sense of rotation of counting during programming earlier.Suppose definition phase sequence 1 → 2 for just changeing, when A phase pulse negative edge triggered interruption, the level of judgement B phase pulse interrupted if high level is then represented just changeing to trigger, and shown in phase sequence figure state 2, counter adds 1; If the level of B phase pulse is a low level, then the expression counter-rotating triggers and interrupts, and shown in phase sequence figure state 1, counter subtracts 1.Above-mentioned method of counting has bigger defective in some cases.At first be might many meters or count umber of pulse less, this situation occurs in when scrambler and is just going between 1 and 2, becomes counter-rotating and then subtracts 1 (leaking the meter pulse) in state 1 place's meeting more; Become in counter-rotating equally and can add 1 (counting pulse) more when just changeing again.If frequent changes sense of rotation then this situation can be brought very big counting error.When second kind of problem occurs in the negative edge triggering, a plurality of negative edges occur because preparing grating or undesired signal make in a pulse, rolling counters forward is made mistakes.The third situation is if can't determine the rotating direction when programming, then miscount can take place.
Adopt method of the present invention can overcome the problems referred to above fully, have the following advantages:
The many meters of pulse or leakage meter phenomenon when 1〉having avoided the rotating conversion;
If definition phase sequence 1 → 2 is forward, if just going to 2 and next state between the time, at first interrupt making counter add 1 in the triggering of 2 state A trailing edges, at this moment reverse and then interrupt making counter subtract 1 in 2 position A pulse-triggered, can the many meters of pulsing or leakage meter phenomenon.
2〉avoided because trailing edge disturbs the counting error that produces;
If definition phase sequence 1 → 2 is forward, the interfering signal of trailing edge occurs or when falling edge is shaken, adds 1 at A pulse trailing edge in the A of state 2 pulse, will subtract 1 at the trailing edge of A pulse, disturb or shake thereby eliminated;
3〉can set in the phase sequence that panel carry out rotating;
When programming, can determine earlier the positive and negative rotation direction, only need to pass through in use the phase sequence setting operation of panel, determine its direction of rotation.

Claims (4)

1. the method for an applying encoder to count is characterized in that comprising the steps:
Set the output pulse signal of scrambler, scrambler dephased two pulse signals A of output device and signal B simultaneously are set, wherein one road pulse signal A is anti-phase by anti-phase general is A, and exports simultaneously with above-mentioned two pulse signals;
When the rotary direction of angle of definition scrambler be past desired directions forward or reverse, more than the status word of three road output pulse signals store as the standard state word, when rotary encoder when wishing that the direction of counting is rotated forward or backwards forward or backwards, as the trigger point, the level of noting three road pulse signals this moment is as the standard state word with the rising edge of pulse signal A or A or negative edge;
Begin counting, microprocessor MCU receives three road pulse signals of scrambler output, when detecting pulse signal A or A and the trigger point occurs, the level of reading three road pulse signals this moment is as the real-time status word, described real-time status word and above-mentioned standard state word are compared, as meeting fully, the then corresponding counting forward or backwards of doing, as not in full conformity with, then ignore.
2. the method for applying encoder to count as claimed in claim 1 is characterized in that: the phase differential of described pulse signal A and B is 90 degree, adopts negative edge with pulse signal A or A as the trigger point.
3. device of using the applying encoder to count of the method for claim 1, it is characterized in that: comprise that the output two-way has the scrambler of phase differential pulse signal, wherein one tunnel output signal of scrambler is carried out anti-phase phase inverter, and the synthetic follower that this inversion signal and described two pulse signals are exported simultaneously, the three-way output signal of described synthetic follower links to each other with three ports of microprocessor respectively, the middle fracture that has the output connecting microprocessor of positive and anti-phase pulse signal simultaneously, other one tunnel pulse signal with phase differential connects the I/O port of microprocessor, comprise the status word of level of the storer of status word of level of storage pulse signal and the pulse signal that relatively receives and the comparer that default status word compares in the described microprocessor, and the counter of counting according to comparator results.
4. the device of applying encoder to count as claimed in claim 3 is characterized in that: described scrambler employing two-phase alternating binary coding device.
CN 201010104019 2010-01-29 2010-01-29 Method and device for applying encoder to count Expired - Fee Related CN101825481B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201010104019 CN101825481B (en) 2010-01-29 2010-01-29 Method and device for applying encoder to count

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201010104019 CN101825481B (en) 2010-01-29 2010-01-29 Method and device for applying encoder to count

Publications (2)

Publication Number Publication Date
CN101825481A true CN101825481A (en) 2010-09-08
CN101825481B CN101825481B (en) 2011-10-12

Family

ID=42689528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201010104019 Expired - Fee Related CN101825481B (en) 2010-01-29 2010-01-29 Method and device for applying encoder to count

Country Status (1)

Country Link
CN (1) CN101825481B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103308078A (en) * 2012-03-15 2013-09-18 欧姆龙株式会社 Rotary encoder and method of detecting abnormality of rotary encoder
CN103994781A (en) * 2014-05-06 2014-08-20 盛铂科技(上海)有限公司 Two-phase signal processing circuit of rotary encoder and signal processing method thereof
CN104133407A (en) * 2014-08-01 2014-11-05 常州华达科捷光电仪器有限公司 Counting device and method for incremental encoder
CN105676685A (en) * 2016-01-05 2016-06-15 深圳市雷赛软件技术有限公司 Method for feeding back initial absolute position of motor, apparatus and encoder frequency-dividing apparatus
CN107356274A (en) * 2015-01-09 2017-11-17 杭州谷立电气技术有限公司 The method that motor positioning is carried out using novel encoder structure
CN107449376A (en) * 2017-09-15 2017-12-08 深圳大学 A kind of steering wheel angle acquisition system in real time
CN110186488A (en) * 2019-05-29 2019-08-30 合肥工业大学 It is a kind of for improving the detection method of orthogonal coding rotary angle transmitter counting precision
CN112924716A (en) * 2021-01-25 2021-06-08 武汉先同科技有限公司 Digital direction discrimination method for improved two-phase encoder
CN113919472A (en) * 2021-09-30 2022-01-11 广州思拓力测绘科技有限公司 Counting mode based on incremental encoder and counting device thereof

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005283274A (en) * 2004-03-29 2005-10-13 Fujinon Corp Position detector
JP4875889B2 (en) * 2005-12-08 2012-02-15 ハイデンハイン株式会社 Encoder count error detection circuit and encoder count error detection method
CN2903920Y (en) * 2006-05-12 2007-05-23 西安石油大学 High precision photoelectric coding deep testing circuit
CN100445696C (en) * 2006-06-02 2008-12-24 中国科学院长春光学精密机械与物理研究所 Quasi absolute type photoelectric shaft-position encoder processing circuit

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103308078B (en) * 2012-03-15 2017-04-26 欧姆龙株式会社 Rotary encoder and method of detecting abnormality of rotary encoder
CN103308078A (en) * 2012-03-15 2013-09-18 欧姆龙株式会社 Rotary encoder and method of detecting abnormality of rotary encoder
CN105910629B (en) * 2014-05-06 2018-01-12 盛铂科技(上海)有限公司 A kind of rotary encoder biphase signaling process circuit and its signal processing method
CN105910629A (en) * 2014-05-06 2016-08-31 盛铂科技(上海)有限公司 Rotary encoder two-phase signal processing circuit and signal processing method thereof
CN103994781B (en) * 2014-05-06 2016-11-16 盛铂科技(上海)有限公司 A kind of rotary encoder biphase signaling processes circuit and signal processing method thereof
CN103994781A (en) * 2014-05-06 2014-08-20 盛铂科技(上海)有限公司 Two-phase signal processing circuit of rotary encoder and signal processing method thereof
CN104133407A (en) * 2014-08-01 2014-11-05 常州华达科捷光电仪器有限公司 Counting device and method for incremental encoder
CN107356274A (en) * 2015-01-09 2017-11-17 杭州谷立电气技术有限公司 The method that motor positioning is carried out using novel encoder structure
CN107356274B (en) * 2015-01-09 2019-11-05 杭州谷立电气技术有限公司 The method for carrying out motor positioning using coder structure
CN105676685A (en) * 2016-01-05 2016-06-15 深圳市雷赛软件技术有限公司 Method for feeding back initial absolute position of motor, apparatus and encoder frequency-dividing apparatus
CN107449376A (en) * 2017-09-15 2017-12-08 深圳大学 A kind of steering wheel angle acquisition system in real time
CN110186488A (en) * 2019-05-29 2019-08-30 合肥工业大学 It is a kind of for improving the detection method of orthogonal coding rotary angle transmitter counting precision
CN112924716A (en) * 2021-01-25 2021-06-08 武汉先同科技有限公司 Digital direction discrimination method for improved two-phase encoder
CN113919472A (en) * 2021-09-30 2022-01-11 广州思拓力测绘科技有限公司 Counting mode based on incremental encoder and counting device thereof
CN113919472B (en) * 2021-09-30 2022-05-17 广州思拓力测绘科技有限公司 Counting method and counting device based on incremental encoder

Also Published As

Publication number Publication date
CN101825481B (en) 2011-10-12

Similar Documents

Publication Publication Date Title
CN101825481B (en) Method and device for applying encoder to count
CN100547354C (en) The absolute type circle capacitor grid transducer measurement mechanism that is used for Absolute position measurement
CN106643827B (en) A kind of encoder output processing method
CN111197954B (en) Absolute position measuring method and device of machine, storage medium and machine
SE519816C2 (en) Phase digitization with accumulator
US10451647B2 (en) Method and device for measuring speed of permanent magnet synchronous motor
CN103558407A (en) Real-time low speed detection device and method based on DSP quadrature encoding
CN103940398B (en) Angle of revolution measuring method, device, system and engineering machinery
CN102843118A (en) Quadrupling and sensing method and device for quadrature encoder
US11061839B2 (en) Input/output control unit, programmable logic controller, and inspection system
CN105842473B (en) A kind of rotary encoder speed-measuring method and its system
CN101930013B (en) Steering detection method and steering detection circuit
CN2938035Y (en) Pulse detection device of incremental photoelectric coder
CN104679639A (en) Method and device for monitoring clock oscillator frequency
CN108106647A (en) A kind of code-disc building method of monorail absolute optical encoder
CN104133407A (en) Counting device and method for incremental encoder
CN203479256U (en) Micro-distance electronic meter
CN114518782A (en) Micro control unit, motor rotating speed measuring method and system and storage medium
CN203587606U (en) Real-time low speed detection device based on DSP quadrature encoding
US20190137302A1 (en) Device for determining the movement of a rotary element, particularly for readings of water and/or gas meters
CN1157589C (en) Absolute encoding measuremnt method using circular grating
EP2660565B1 (en) Digital logic circuit and method for detecting a relative shaft position on geared shafts
CN205317180U (en) Angle code appearance test system
CN217738289U (en) Testing device of incremental encoder
CN218411219U (en) Code disc type encoder

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20111012

Termination date: 20190129