Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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

share|improve this question
    
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 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 at 17:47

1 Answer 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

share|improve this answer
    
How do you identify which motor in spinning? –  UserK Mar 31 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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