Hi Tej,
Typically encoders are connected and read by counters which have
built-in functionality to determine the direction of movement based
upon the state of the 2 or 3 quadrature encoder signals (Channels A, B
and Z).
First of all, a little background on quadrature encoders:
Quadrature encoders generally have 2 or 3 signals, A&B which are
square waves +/-90 degrees out of phase and optionally Z which pulses
to zero the position. When the encoder moves, a pulse is created on
both A&B. Depending on the direction of movement, pulse A will
either lead or lag pulse B by 90 degrees.
I see you are working with a digital board which does not have onboard
counters, however with a little extra work you may still be able to use
your 6533 for encoder measurement. To be able to perform counter
measurments on your digital lines you will want to sample the lines as
fast as possible to make sure that you do not miss any high or low
transitions. You will then need to create a software algorithm to
determine which way the encoder is turning.
I have not tried this before, but I would suggest using a
state machine
type of architecture. For example, monitor both lines until a change
occurs - this would be the initial state. You would then transition
to a "prepare to increment" or "prepare to decrement count" state
(depending on whether the A or B signal was the one that changed). In
this state you would wait for the opposite line to pulse and then
increment or decrement the count accordingly. Next you would want to
wait for both lines to return to idle. This process would then repeat.
You will need to know some information about your encoder to verify
that the pulse width will be wide enough to ensure you are able to
accurately detect which line (A or B) pulses first. If you are using a
Z signal you would want to add code to reset the count back to zero
when this line pulses.
Hope this helps,
Jennifer O.
Applications Engineer
National Instruments