Quadrature encoder question

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.

Reply to
kronecker
Loading thread data ...

Google is your friend.

formatting link

Reply to
donald

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF

Oops - two only of course not two sets.

K.

Reply to
kronecker

A, B outputs leads or lags depending on what direction your moving.

For example. lets say the rotor is turning CW, A output comes on before B output does, and if it was CCW, B output comes on before A output.

You can use a dual Data RS flip flop to gate the pulses where only one output will pulse depending on the direction or, you can do it in software via a micro.

formatting link
"

Reply to
Jamie

--
Assuming that your encoder output looks like this: (View in Courier)

           ______        ______
 Click to see the full signature
Reply to
John Fields

I think that you want to bring the other section of the DFLOP into the circuit. CHI sets it. CHA clears it and its Q clocks the counter. This way bobbling of the CHI edge won't cause multiple counts and reversing back past the CHI pulse won't count the wrong way on the first time by. This would also mean changing to a CD4013 flip-flop to get the right polarity set and clear.

I have, in the past, decoded just the CHA and CHB to get 4 counts per cycle. I was using a counter with an up-clock and a down-clock. The decoder was logic in a 22V10. Basically it was like this:

CHA_DELAYED = CHA;

CHA_RISE = CHA & !CHA_DELAYED; CHA_FALL = !CHA & CHA_DELAYED;

CHB_DELAYED = CHB;

CHB_RISE = CHB & !CHB_DELAYED; CHB_FALL = !CHB & CHB_DELAYED;

UP_CLOCK = CHA_RISE & !CHB # CHB_RISE & CHA # CHA_FALL & CHB # CHB_FALL & !CHA;

DOWN_CLOCK = CHA_FALL & !CHB # CHB_FALL & CHA # CHA_RISE & CHB # CHB_RISE & !CHA;

Reply to
MooseFET

--
OK. :-)

JF
Reply to
John Fields

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."

Jerry

--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

Can you offer a schematic? What happens when the encoder shaft vibrates just a little, causing repeated transitions on one track and none on the other?

Jerry

--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

--
Depends.  If you\'re only counting incremental revolutions and missing
up to one doesn\'t matter, then that\'ll work.
 Click to see the full signature
Reply to
John Fields

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 to
Jerry Avins

formatting link

-Lasse

Reply to
langwadt

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 to
cbarn24050

--
Of course they do.  What _was_ I thinking about??? :-(

JF
Reply to
John Fields

Email 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.

formatting link
"

Reply to
Jamie

snipped-for-privacy@yahoo.co.uk wrote in news:076db4f6-3c70-4926-bbe8- snipped-for-privacy@n1g2000prb.googlegroups.com:

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 to
Scott Seidman

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                                    AE6EO
Friends of Jade Warrior home page:  http://www.radagast.org/jade-warrior
 Click to see the full signature
Reply to
Dave Platt

snipped-for-privacy@radagast.org (Dave Platt) wrote in news: snipped-for-privacy@radagast.org:

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
Reply to
Scott Seidman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.