pin code for Quadrature Motor Encoder
Kris Cardoen
Posts: 46
Hi,
I have a robot with the following type of encoder
Quadrature Motor Encoder
Encoder = 100 cycles per revolution
Encoder = 400 quadrature counts per revolution
Frequency = up to 30khz
two questions:
1. I guess the specs mean that 100 cycles are equal to one complete rotation of the wheel. And that the pulses changes for one rotation are 400, is that correct?
2. I guess I will have to count the state changes on the encoders outputs. I was thinking on using
if pin.In(5) == 1
Is that the right way to do this? How do I have to set my frequency to check the state change?
Any help would be much appreciated
I have a robot with the following type of encoder
Quadrature Motor Encoder
Encoder = 100 cycles per revolution
Encoder = 400 quadrature counts per revolution
Frequency = up to 30khz
two questions:
1. I guess the specs mean that 100 cycles are equal to one complete rotation of the wheel. And that the pulses changes for one rotation are 400, is that correct?
2. I guess I will have to count the state changes on the encoders outputs. I was thinking on using
if pin.In(5) == 1
Is that the right way to do this? How do I have to set my frequency to check the state change?
Any help would be much appreciated
Comments
Quadrature Encoder
Object in the object exchange will give you the encoder count when ever you ask for it.
Hook the encoder up to lines 0 and 1
Turn the motor
Read the position in encoder counts
It is painless.
If you need more , ask.
True, there are quad-decode objects available in the OBEX but their function is not very straight-forward to me at least.
The logic is VERY simple and I decided to create my own quad-decoder using PropBASIC. Just working simply with the very transitions that we are concerned with.
This is actual functioning code. However, the counter value WILL need to be written to HUB memory which slows things down a bit but on the whole, this code executes faster than any pure PASM that I have found in the OBEX...albeit limited to one encoder (easily expandable but I require > 1.5M quadrature counts/sec).
P.S. My application is not battery powered and so this approach is not at all power efficient. The code could easily be modified to include the waitpne function to reduce the power consumption when no encoder transitions happen to be occurring.
Mickster
One more question :-)
When I make a full rotation I get value 20.000 reverse -20.000.
Where does this number come from?