Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature Encoder Resetting

Hello - I am trying to generate a one shot pulse based on a quadrature encoder input. I am wondering why I need to know the phase of A and B relative to the encoder reset signal (often Z is used)? I do not have the luxery of using Z since I need to generate many pulses per one single revolution. Constraining the A & B phase makes it hard to generate a reset pulse if the speed of the system changes. Any way to work around this constraint?

John
0 Kudos
Message 1 of 2
(3,752 Views)
rammer,

Oops, just noticed I may have answered the wrong question. I was talking about using an input Z-index pulse to reset an encoder counter to 0. I think you're asking how to generate a pulse based on encoder position? Let me address you first but leave the first stuff at the bottom since I spent several minutes typing it up.

Generate Pulse based on encoder position
----------------------------------------
Are the pulse positions spaced equally or arbitrarily? If equally and if your motion is unidirectional, there may be a couple ways.

1. Use one of the encoder phases as a source signal when defining another counter's pulse generation parameters. You can then define the number of encoder cycles to act as pulse high and pulse low times.

2. Configure your encoder counter to "pulse on terminal count." Also set it up to use Z-indexing with a (specific) non-zero Z-index reload value. Finally wire its output pin to its gate pin.
Suppose you are moving in the - direction and you have a Z-index reload value of 40. When the counter decrements down to 0, it will issue a short output pulse. That output pulse will also cause the z-index reloading to reset the counter's value to 40. And so on. You'll just have to config the right A,B phase for the z-index, and you'll need to use a reload value that's a multiple of 4 to be sure everything works.

On the other hand if the pulse positions are spaced unevenly, I'm afraid I don't have a good suggestion.


Using Z-index input pulse to reset encoder counter to 0
---------------------------------------------------------
Unfortunately, AFAIK there isn't any "ignore A,B phase" option when resetting a count on a Z pulse. Annoying, isn't it? There is a good reason that one should usually care about A,B phase though. It helps to make sure that the 0 position registers within the same quadrature state regardless of whether one approaches CW or CCW.

Some encoders produce an index pulse that lasts for one full quadrature cycle, i.e., 4 quadrature states. An edge-sensitive z-index interface would then mark slightly offset 0 positions depending on CW vs CCW. Now it's more common for the encoder electronics to take care of that internally, producing a pulse that lasts for only a quarter-cycle, i.e., 1 single state.

However the counter/timer board still wants to be able to deal with the 4-state index pulse, so the solution is to have the programmer specify which single quadrature state the reset to 0 should occur within -- the A,B phase. Also, I *think* that the reset is level-driven rather than edge-driven. I seem to recall putting a constant 5V into the index pulse input while rotating an encoder, and it counted 0,1,2,3,0,1,2,3,0,1...


Anyway, I really would like to see NI add the following capability into their counter hw and driver:
----------------------------------------------------------------------------------------------------
1. Allow reset of counter value that is edge sensitive to the z-index pulse. Allow a choice of rising or falling edge. Also allow a quadrature phase option similar to "A-any, B-any".

2. Allow reset of counter in modes other than position counting / encoder measurement. The first most useful would be edge counting mode.
Time and time again I've had apps that interface to a stepper motor controller and a quadrature encoder. The stepper contoller issues pulse and direction signals and must be measured in an edge-counting mode with hw control of count direction. The trouble is, that mode doesn't allow for a hw z-index reset. So then I can't synchronize a z-index reset of the stepper counter with the z-index reset of the encoder counter.
It would also be useful in pulse generation mode. One could turn a counter into a hw watchdog timer where toggling a DIO bit keeps resetting the count value, preventing it from counting down to TC and making a pulse. If ever it pulses, the output could shut off a relay supplying power to key equipment.

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 2
(3,736 Views)