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

asked Mar 31, 2015 at 13:15
2
  • 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. Commented Mar 31, 2015 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. Commented Mar 31, 2015 at 17:47

1 Answer 1

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

answered Mar 31, 2015 at 15:23
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.