Quadrature encoder question

Apr 06, 2008 27 Replies

Jamie,

Thanks for the offer. The email address in this post (and all my posts) is valid and I'd like to see your circuit. (I have several patents for encoder circuits, so I'm not a newbie in the field.) If one of the inputs to your counter circuit is held steady and the other excited with a steady square wave, what will the counter do? The combination of inputs I described is possible in service in the presence of vibration.

If it is of interest to anyone, I'll work up and post a description of a vibration-proof counter. any algorithm that counts down and up at the same phase transition works.

Jerry

Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

The simplest circuit I know -- my patent has expired -- is an up/down counter and two XOR gates.

Jerry

Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Jerry Avins wrote: (snip)

That only gets half the transitions, though, doesn't it?

Last time I looked there is a design that uses a clock signal faster than the fastest transition (but slower than the counter) that can get all transitions.

-- glen

The output of the XOR xonnected to the direction input is the real LSB if you want all the transitions. With it, you get 200 counts with a

50-line wheel. Without it, you get 100. Many circuits would give you only 50. (When the raw photocell output is available, an extra pair of comparators can get you 400 counts.)

Jerry

Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

t.

=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD= =EF=BF=BD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BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF= =BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD- Hide quoted text -

(snip)

Being too used to synchronous logic I didn't think about that one.

The last one I worked on, in verilog below, takes the two phase inputs and clocks them into a register with a fast clock, and into another register after that. If there are an odd number of ones in the two registers, a transition occurred. An exclusive or between one bit of the first register and the other bit of the second gives the direction. The enable and direction signals go into a synchronous counter with the same clock.

As long as the clock is faster than the time between real transitions it should get them all. I think one should zero the counter on the first pulse of the third signal line and not on any later pulse, but I was never sure about that.

I didn't invent this one, I got it off the web and wrote the verilog for it. linem1 is the number of lines on the encoder wheel.

Not being good at ASCII logic, here is the verilog.

module quadrature(clk, reset, in, out, linem1);

input clk, reset; input [1:0] in; output [17:0] out; input [15:0] linem1;

reg [17:0] out;

// shift register with extra stage for metastability reg [1:0] in0, in1, in2;

wire enable, up;

always @(posedge clk) begin in2

...

Way back when, I was aware of one company that went bankrupt because they couldn't solve the problem at MHz fringe rates. The state-machine solution took a 3x5" circuit board and cost $175. The parts cost for my

35MHz version was about $6.00. I don't think that the schematic posted earlier in this thread or the verbal descriptions meet your standard.

Jerry

Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Most of the quad decoders we implement, we over sample the inputs (generally less than twice expected maximum speed) and use the current and previous samples to determine motion and direction. This approach is quite noise immune because edge effects are self correcting. This approach takes very little processing time and a limited number of external components.

In small micros used in the mice we sampled both axis at the same time and used a 16 way jump to routines that updated both x and y axis.

Regards,

-- Walter Banks Byte Craft Limited Tel. (519) 888-6911

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required