John Fields wrote:> On Sun, 6 Apr 2008 14:25:23 -0700 (PDT), kronecker@yahoo.co.uk wrote: > >> I have an encoder for a servo that gives out two quadrature sets of >> pulses and a clock. How do I use this to detect position? Do I need >> the clock or do I just read both outputs and watch one edge wrt the >> other? I thought maybe an exclusive OR may tell me direction? > > --- > > Assuming that your encoder output looks like this: (View in Courier) > > ______ ______ > CHA ______| |______| > > __ ______ ___ > CHB |______| |______| > > __ > CHI_________________| |_______ > > > Then your decoder could look like this: > > +--------+ > CHI>---------------|> QD| > | QC| > +-----+ | _ QB| > CHA>-----|D Q|---|U/D QA| > | _| +--------+ > CHB>-----|> Q| UP/DOWN > +-----+ COUNTER > DFLOP > > Where the dflop could be part of an XX74 or a 4013 and the counter > could be something like an XX190 or 191. > > Rotation of the encoder shaft in one direction will cause the dflop's > output to be high, while in the other direction it will cause it to be > low. This will cause the counter to either count up or down, and the > index pulse from your encoder will cause the count to increment or > decrement once per revolution of the encoder shaft.I must be missing something. CHI clocks the counter? That's a once-around signal for providing an absolute reference to what is basically an incremental system. I like your ASCII artwork. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →
Quadrature encoder question
Started by ●April 6, 2008
Reply by ●April 7, 20082008-04-07
Reply by ●April 7, 20082008-04-07
On Mon, 07 Apr 2008 11:31:58 -0400, Jerry Avins <jya@ieee.org> wrote:>John Fields wrote: >> On Sun, 6 Apr 2008 14:25:23 -0700 (PDT), kronecker@yahoo.co.uk wrote: >> >>> I have an encoder for a servo that gives out two quadrature sets of >>> pulses and a clock. How do I use this to detect position? Do I need >>> the clock or do I just read both outputs and watch one edge wrt the >>> other? I thought maybe an exclusive OR may tell me direction? >> >> --- >> >> Assuming that your encoder output looks like this: (View in Courier) >> >> ______ ______ >> CHA ______| |______| >> >> __ ______ ___ >> CHB |______| |______| >> >> __ >> CHI_________________| |_______ >> >> >> Then your decoder could look like this: >> >> +--------+ >> CHI>---------------|> QD| >> | QC| >> +-----+ | _ QB| >> CHA>-----|D Q|---|U/D QA| >> | _| +--------+ >> CHB>-----|> Q| UP/DOWN >> +-----+ COUNTER >> DFLOP >> >> Where the dflop could be part of an XX74 or a 4013 and the counter >> could be something like an XX190 or 191. >> >> Rotation of the encoder shaft in one direction will cause the dflop's >> output to be high, while in the other direction it will cause it to be >> low. This will cause the counter to either count up or down, and the >> index pulse from your encoder will cause the count to increment or >> decrement once per revolution of the encoder shaft. > >I must be missing something. CHI clocks the counter? That's a >once-around signal for providing an absolute reference to what is >basically an incremental system.--- Depends. If you're only counting incremental revolutions and missing up to one doesn't matter, then that'll work. If you need more than that then Moosefet's way will work better. --->I like your ASCII artwork.--- Thanks. :-) JF
Reply by ●April 7, 20082008-04-07
John Fields wrote:> On Mon, 07 Apr 2008 11:31:58 -0400, Jerry Avins <jya@ieee.org> wrote: > >> John Fields wrote: >>> On Sun, 6 Apr 2008 14:25:23 -0700 (PDT), kronecker@yahoo.co.uk wrote: >>> >>>> I have an encoder for a servo that gives out two quadrature sets of >>>> pulses and a clock. How do I use this to detect position? Do I need >>>> the clock or do I just read both outputs and watch one edge wrt the >>>> other? I thought maybe an exclusive OR may tell me direction? >>> --- >>> >>> Assuming that your encoder output looks like this: (View in Courier) >>> >>> ______ ______ >>> CHA ______| |______| >>> >>> __ ______ ___ >>> CHB |______| |______| >>> >>> __ >>> CHI_________________| |_______ >>> >>> >>> Then your decoder could look like this: >>> >>> +--------+ >>> CHI>---------------|> QD| >>> | QC| >>> +-----+ | _ QB| >>> CHA>-----|D Q|---|U/D QA| >>> | _| +--------+ >>> CHB>-----|> Q| UP/DOWN >>> +-----+ COUNTER >>> DFLOP >>> >>> Where the dflop could be part of an XX74 or a 4013 and the counter >>> could be something like an XX190 or 191. >>> >>> Rotation of the encoder shaft in one direction will cause the dflop's >>> output to be high, while in the other direction it will cause it to be >>> low. This will cause the counter to either count up or down, and the >>> index pulse from your encoder will cause the count to increment or >>> decrement once per revolution of the encoder shaft. >> I must be missing something. CHI clocks the counter? That's a >> once-around signal for providing an absolute reference to what is >> basically an incremental system. > > --- > Depends. If you're only counting incremental revolutions and missing > up to one doesn't matter, then that'll work. > > If you need more than that then Moosefet's way will work better. > --- > >> I like your ASCII artwork. > > --- > Thanks. :-)Most people who use incremental encoders want position a bit finer than whole revolutions. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●April 7, 20082008-04-07
On 6 Apr., 23:25, kronec...@yahoo.co.uk wrote:> I have an encoder for a servo that gives out two quadrature sets of > pulses and a clock. How do I use this to detect position? Do I need > the clock or do I just read both outputs and watch one edge wrt the > other? I thought maybe an exclusive OR may tell me direction? > > K.http://groups.google.dk/group/sci.electronics.design/tree/browse_frm/thread/3981e9f38e97b307/b74b1601be9a39a9?hl=da&rnum=1&q=+Quadrature+Decoder+Circuit+Wanted+++&_done=%2Fgroup%2Fsci.electronics.design%2Fbrowse_frm%2Fthread%2F3981e9f38e97b307%2F2c87f3ae06fdd487%3Fhl%3Dda%26lnk%3Dgst%26q%3D%2BQuadrature%2BDecoder%2BCircuit%2BWanted%2B%2B%2B%26#doc_b74b1601be9a39a9 -Lasse
Reply by ●April 7, 20082008-04-07
On Apr 6, 10:25�pm, kronec...@yahoo.co.uk wrote:> I have an encoder for a servo that gives out two quadrature sets of > pulses and a clock. How do I use this to detect position? Do I need > the clock or do I just read both outputs and watch one edge wrt the > other? I thought maybe an exclusive OR may tell me direction? > > K.It sounds like a standard encoder, the "clock" is not a clock but a zero marker, 1 pulse per rev, you use that to reset the counter for absolute position. You need a 2 phase counter, they are common in microcontrollers made for the motor control market. You could also use a state machine in a pld to produce clock, up/down pulses or some gating and one shot monostables for a conventional counter.
Reply by ●April 7, 20082008-04-07
On Mon, 07 Apr 2008 12:54:01 -0400, Jerry Avins <jya@ieee.org> wrote:>John Fields wrote: >> On Mon, 07 Apr 2008 11:31:58 -0400, Jerry Avins <jya@ieee.org> wrote: >> >>> John Fields wrote: >>>> On Sun, 6 Apr 2008 14:25:23 -0700 (PDT), kronecker@yahoo.co.uk wrote: >>>> >>>>> I have an encoder for a servo that gives out two quadrature sets of >>>>> pulses and a clock. How do I use this to detect position? Do I need >>>>> the clock or do I just read both outputs and watch one edge wrt the >>>>> other? I thought maybe an exclusive OR may tell me direction? >>>> --- >>>> >>>> Assuming that your encoder output looks like this: (View in Courier) >>>> >>>> ______ ______ >>>> CHA ______| |______| >>>> >>>> __ ______ ___ >>>> CHB |______| |______| >>>> >>>> __ >>>> CHI_________________| |_______ >>>> >>>> >>>> Then your decoder could look like this: >>>> >>>> +--------+ >>>> CHI>---------------|> QD| >>>> | QC| >>>> +-----+ | _ QB| >>>> CHA>-----|D Q|---|U/D QA| >>>> | _| +--------+ >>>> CHB>-----|> Q| UP/DOWN >>>> +-----+ COUNTER >>>> DFLOP >>>> >>>> Where the dflop could be part of an XX74 or a 4013 and the counter >>>> could be something like an XX190 or 191. >>>> >>>> Rotation of the encoder shaft in one direction will cause the dflop's >>>> output to be high, while in the other direction it will cause it to be >>>> low. This will cause the counter to either count up or down, and the >>>> index pulse from your encoder will cause the count to increment or >>>> decrement once per revolution of the encoder shaft. >>> I must be missing something. CHI clocks the counter? That's a >>> once-around signal for providing an absolute reference to what is >>> basically an incremental system. >> >> --- >> Depends. If you're only counting incremental revolutions and missing >> up to one doesn't matter, then that'll work. >> >> If you need more than that then Moosefet's way will work better. >> --- >> >>> I like your ASCII artwork. >> >> --- >> Thanks. :-) > >Most people who use incremental encoders want position a bit finer than >whole revolutions.--- Of course they do. What _was_ I thinking about??? :-( JF
Reply by ●April 7, 20082008-04-07
Jerry Avins wrote:> kronecker@yahoo.co.uk wrote: > >> On Apr 7, 12:35 pm, Jerry Avins <j...@ieee.org> wrote: >> >>> kronec...@yahoo.co.uk wrote: >>> >>>> I have an encoder for a servo that gives out two quadrature sets of >>>> pulses and a clock. How do I use this to detect position? Do I need >>>> the clock or do I just read both outputs and watch one edge wrt the >>>> other? I thought maybe an exclusive OR may tell me direction? >>> >>> Two sets of quadrature pulses? Four tracks? what do you do with them? >>> >>> Jerry >>> -- >>> Engineering is the art of making what you want from things you can get. >>> ����������������������������������������������������������������������� >> >> >> Oops - two only of course not two sets. > > > Good. There must be chips that do this, but It is easily done with > hardware or with interrupt-driven software. Do you want a display, an > updated variable in a computer, or both? Whatever you do, there can be > mis-counts unless the shaft locations are exactly the same when counting > up and counting down. The up- and down-count angles differ In > excessively simple implementations, and that leads to trouble. > "Solutions should be as simple as possible, but not simpler." > > JerryEmail me, I'll give you a PDF file that shows the use of 2 D-Ff with a clear Function that can generate the up/down pulse just from the A and B outputs only. I don't have ASCII text options here to post something so I'll wing it. Assume 2 D-FF's, 1FF and 2FF On each FF, the Data input and CLR function pin are tied together. (A) encoder signal is connected to the Clk(clock) of 1FF as well to the Data/CLR pin function of 2FF. (B) encoder signal is connected to the CLK(clock) of 2FF as well to the Data/CLR pin function of 1FF. The Q output of each D-ff forms the Pulse. Q of 1FF will Pulse going CW. Q of 2FF will Pulse going CCW. These Pulses can be used to inc/dec a counter somewhere to indicate position. We use this circuit via a A/B encoder to determine the direction and speed with a large accumulator system to govern forward speed and direction of detection. The decoded signal then gets past into a simple F/V converter to generate an analog signal proportional to the speed of movement only on the forward direction for a drive using analog biasing. Happy benching. http://webpages.charter.net/jamie_5"
Reply by ●April 7, 20082008-04-07
kronecker@yahoo.co.uk wrote in news:076db4f6-3c70-4926-bbe8- 0fed798cbefb@n1g2000prb.googlegroups.com:> I have an encoder for a servo that gives out two quadrature sets of > pulses and a clock. How do I use this to detect position? Do I need > the clock or do I just read both outputs and watch one edge wrt the > other? I thought maybe an exclusive OR may tell me direction? > > K. >Theres a great circuit for quad decoding in Horowitz and Hill, The Art of Electronics. I believe it uses two D flip flops and a bidirectional counter. -- Scott Reverse name to reply
Reply by ●April 7, 20082008-04-07
In article <Xns9A79CEBAEF3EDscottseidmanmindspri@130.133.1.4>, Scott Seidman <namdiesttocs@mindspring.com> wrote:>> I have an encoder for a servo that gives out two quadrature sets of >> pulses and a clock. How do I use this to detect position? Do I need >> the clock or do I just read both outputs and watch one edge wrt the >> other? I thought maybe an exclusive OR may tell me direction?>Theres a great circuit for quad decoding in Horowitz and Hill, The Art of >Electronics. I believe it uses two D flip flops and a bidirectional >counter.Depending on the speed required, one can also use a small microcontroller. A simple lookup-table design (previous two quadrature bits, current two quadrature bits) yields a +1/0/-1 counter increment. -- Dave Platt <dplatt@radagast.org> AE6EO Friends of Jade Warrior home page: http://www.radagast.org/jade-warrior I do _not_ wish to receive unsolicited commercial email, and I will boycott any company which has the gall to send me such ads!
Reply by ●April 7, 20082008-04-07
dplatt@radagast.org (Dave Platt) wrote in news:4hsqc5-t61.ln1@radagast.org:> In article <Xns9A79CEBAEF3EDscottseidmanmindspri@130.133.1.4>, > Scott Seidman <namdiesttocs@mindspring.com> wrote: > >>> I have an encoder for a servo that gives out two quadrature sets of >>> pulses and a clock. How do I use this to detect position? Do I need >>> the clock or do I just read both outputs and watch one edge wrt the >>> other? I thought maybe an exclusive OR may tell me direction? > >>Theres a great circuit for quad decoding in Horowitz and Hill, The Art >>of Electronics. I believe it uses two D flip flops and a >>bidirectional counter. > > Depending on the speed required, one can also use a small > microcontroller. A simple lookup-table design (previous two > quadrature bits, current two quadrature bits) yields a +1/0/-1 counter > increment. >My experience with quad encoders and ucontrollers is that if you're in for a penny, you're in for a pound, and it really helps to use a unit designed around quad encoders, like the Pic 18F4331. Otherwise, if your encoder is going real fast, even a very basic interrupt driven lookup can fall behind. The extra cost is negligible, and many features that help you tweak out your system are at your fingertips. -- Scott Reverse name to reply







