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).

enter image description here

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


1 Answer 1


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.

  • Track the current state of 'A'. If the state changes to 'high' then:
  • Look at input 'B'. If 'B' is low then count up. If 'B' is high then count down.

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.

  • \$\begingroup\$ My motor encoder have 3200 Edges per Revolution which is quite fast. Arduino Due misses the ticks if i use this method. \$\endgroup\$ Aug 11, 2016 at 18:55
  • 1
    \$\begingroup\$ Why didn't you state that in your question then so that I wouldn't waste my time? It's still not in your question. \$\endgroup\$
    – Transistor
    Aug 11, 2016 at 18:58
  • \$\begingroup\$ I have got to know that Sam3x8e has 2 QDEC Decoder. According to Quadrature Decoder QDEC for SAM3/4 Devices_ApplicationNote_AT11483 Pg 16 I have to first configure the iopins. How can i configure TIOA6 and TIOB6 as QDEC input pins? Link of file showing QDEC channel in Atmel ICs.atmel.force.com/support/servlet/fileField?id=0BEG0000000HRvP \$\endgroup\$ Aug 11, 2016 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.