1

I would like to control 2 motors with the Arduino Uno board, which provides only two interrupt pins on digital 2 and 3.

I've set one encoder using these pins, and it works. What do you think about the following approaches:

  • Timer Interrupt:

Create a Timer Interrupt. Connect the seconder encoder to an analog pin. Set an analog read function in the interrupt service routine. Change the prescaler of the ADC and increase the acquisition time.

  • PinChangeInt

Use PinChangeInt to capture the pin change interrupt rather than an external interrupt.

This should allow you to use almost any I/O pins on the Uno for the encoder.

as Ignacio Vazquez-Abrams suggested here

  • Just go with the PinChangeInterrupts solution. There are some libraries for it if you want. I don't get the timer or analog read solution. – Gerben Mar 31 '15 at 17:40
  • Just to check the state of the pin as fast and precise as possible but they suggested to check it with a normal digital pin. – UserK Mar 31 '15 at 17:47
1

It is very possible. use a separate interrupt pin for Phase A of both motors, then read phase B from a non interrupt pin in the interrupt handler. http://www.spiked3.com/?p=5501

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.