Rotation direction detection and counter
Don M
Posts: 1,652
I have a machine that has a pulley with 2 hall effect sensors. I want to be able to detect CW or CCW direction (to count up or down). Does anyone have any favorite objects that they use or recommend for this? I was looking in the OBEX and was not sure what I should use. Would I use a quadrature encoder object?
Thanks.
Don
Thanks.
Don
Comments
-Phil
With switch 1 on the right and switch 2 on the left. If switch 1 is read before switch 2, the direction is CCW. If switch 2 is read before switch 1, the direction is CW. For RPM, count the pulses and do the appropiate math.
On the other hand, you already have the hall effects.
Bruce
EDIT: You could also do the same with the hall effects
Ideally one signal has to stay on till the other one comes on to be 90 deg out of phase
Then signal one has to go off before signal two goes off.
If this is not true, it is hard to tell what the direction of motion is. ie which signal is leading.
Harprit
The requirement for only one bit to change at once forces an even number of states, incidentally. For more states the usual scheme is a reflected Gray code which can be used to give absolute position as well as step-counting.
There will be a difference in time between T1 and T2. I could do some sort of code logic to distinguish between which sensor is read before the other by virtue of the time differences.
For CW you would have 1, T1, 2, T2, 1, T1, 2, T2 and so on. For CCW you would have 1, T2, 2, T1, 1, T2, 2, T1, 1....
As long as the rotation speed is fairly constant, the relative timing method should work okay. In that case, the closer the two sensors are to each other, the better. It's only during speed changes and starting and stopping that there might be some directional ambiguity from your readings.
-Phil
This wheel runs a gearbox that raises or lowers a table. I did some distance measuring of the table while rotating the wheel. The wheel provides 284.48 pulses per inch of table travel or .0070303712 inches of travel per revolution.
I used my Salae Logic analyzer to record the pulse train in both forward and backward rotation from the sensors.
So now I'll have to dream up some "logic" code to decipher whether the wheel is turning forward or backward. I don't care about position just the direction and to keep track of the pulse count.
See attached.
-Phil