Connect with us

Quadrature encoder question

Discussion in 'Electronic Design' started by [email protected], Apr 6, 2008.

Scroll to continue with content
  1. Guest

    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?

  2. Guest

    Oops - two only of course not two sets.

  3. Jamie

    Jamie Guest

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

    MooseFET Guest

    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:





    # CHB_RISE & CHA
    # CHA_FALL & CHB
    # CHB_FALL & !CHA;

    # CHB_FALL & CHA
    # CHA_RISE & CHB
    # CHB_RISE & !CHA;
  5. Guest

  6. Guest

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

    Jamie Guest

    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

    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

    Happy benching."
  8. wrote in :
    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
  9. (Dave Platt) wrote in
    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

    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.
  10. Guest

    I think thats pretty much a standard, not much use otherwise.
  11. Walter Banks

    Walter Banks Guest

    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.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day