I am working on an autonomous robot in my summer vacations. I am currently working on running the motors of my robot in a closed loop. In order to do so, I have to interface two Quadrature encoders of the motors with the Arduino Due that I have. My motor encoder have 3200 Edges per Revolution. I have read the Atmel SAM3x8E datasheet and have successfully tested one encoder. It appears that TIOA0 and TIOBO are used to read PHA and PHB of of one Encoder which correspond to Pin 2 and 13 of Arduino Due. I am not using Index pin (TIOB1).
It seems that I can only interface 1 quadrature .Is their any way I can use Quadrature decoder to read 2 encoders instead of one. As I have stated earlier I am not using the index pin. So, maybe there might be a way to decode to encoders using the three available pins as shown in the above diagram. I don't want to use Interrupts to do this job.
Here's is the link of SAM3x Manual:
http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf
Link of Motor that i am using:
www.pololu.com/product/2824
Best Answer
If the encoder frequency is not too high it's just a matter of keeping track of the count using an up-down counter and two general purpose input pins.
simulate this circuit – Schematic created using CircuitLab
Figure 1. 2-bit rotary encoder waveforms.
The program logic is very simple.
You'll probably need to debounce the inputs to prevent spurious triggering. You then need to write some code to detect the rising edge of the 'A' pulse.