pin code for Quadrature Motor Encoder
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).
DEVICE P8X32A, XTAL1, PLL16X FREQ 80_000_000 Chan_A PIN 18 INPUT Chan_B PIN 17 INPUT Chan_Z PIN 16 INPUT Counter VAR LONG = 0 PROGRAM Start Start: 'Decide where to start If Chan_A = 1 And Chan_B = 1 Then Goto A1B1 Endif If Chan_A = 0 And Chan_B = 0 Then Goto A0B0 Endif If Chan_A = 1 And Chan_B = 0 Then Goto A1B0 Endif If Chan_A = 0 And Chan_B = 1 Then Goto A0B1 Endif 'This is the main loop 'The only possible conditions are clearly spelled-out...no masking, no shifting, no rotating A1B1: If Chan_A = 0 Then Dec Counter Goto A0B1 Elseif Chan_B = 0 Then Inc Counter Goto A1B0 Endif Goto A1B1 A0B0: If Chan_A = 1 Then Dec Counter Goto A1B0 Elseif Chan_B = 1 Then Inc Counter Goto A0B1 Endif Goto A0B0 A1B0: If Chan_A = 0 Then Inc Counter Goto A0B0 Elseif Chan_B = 1 Then Dec Counter Goto A1B1 Endif Goto A1B0 A0B1: If Chan_A = 1 Then Inc Counter Goto A1B1 Elseif Chan_B = 0 Then Dec Counter Goto A0B0 Endif Goto A0B1 EndP.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?