Pages: [1]   Go Down
Author Topic: Arduino motor shield vs. encoder on interrupt inputs D2 & D3  (Read 969 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an Arduino Uno and an Arduino motor shield. I want to use interrupt pins D2 and D3 to bring in a quadrature encoder. Do I need to cut the motor shield trace to D3 in order for this to work? I understand this will disable motor channel A, but I only plan to use channel B.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an Arduino Uno and an Arduino motor shield. I want to use interrupt pins D2 and D3 to bring in a quadrature encoder. Do I need to cut the motor shield trace to D3 in order for this to work? I understand this will disable motor channel A, but I only plan to use channel B.

Well cutting the trace will certainly work, but I don't think it's actually required as long as you won't be using that motor channel and have no motor wired to that channel. The fact that the motor channel uses D3 as an output pin would not effect you using it as an input pin to generate user interrupts. The signal being wired to D3 will just also be going to the motor shield but will have no effect as you will have no motor wired to that channel to be effected.

 If I was going to cut the trace, I would go ahead and wire that motor control signal to a different unused digital pin so that if the future I might be able to use both motor channels. Might take some software editing to adjust for the new pin usage but that's no big deal I would think?

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Aren't pins D2 & D3 the only interrupt pins?  I thought I'd need to use the interrupts to make sure I don't miss any encoder pulses. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh! I see what you mean.  Connect the motor shield trace that now goes to D3 to a different, unused PWM output.  Interesting idea, though I'd still need to cut the trace, no?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Aren't pins D2 & D3 the only interrupt pins?  I thought I'd need to use the interrupts to make sure I don't miss any encoder pulses.  

On a Uno board D2 and D3 are the only user interrupt pins, the mega board has 5 I believe. However if you look into pinchange interrupts, you will see that any pin can be used to generate a interrupt but it takes a few extra steps as you get one interrupt per 8 bit port and then you have to actually read the port data bits to determine which bit(s) changed to generate the interrupt, so a little harder to use.

 But more importantly in using a quadrature encoder you do not have to wire both quad channels to interrupt pins to still be able to use it. Just wiring one channel to an interrupt pin and the other to a non interrupt pin will still function. It gets back to how many encoder channel transitions per step you want to process. That is if the encoder is rated as say a 100 'steps' per revolution encoder you have the option to interface it as a 100 counts per rev, or 200 counts per rev, or finally 400 counts per rev. If you wanted to use just one channel as a interrupt source you would be limited to reading it as a 100 step encoder or as a 200 step encoder as you can only get 400 steps if both channels interrupt on change mode.

Lefty
« Last Edit: February 28, 2013, 10:34:33 pm by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome info.  Thanks!
Logged

Pages: [1]   Go Up
Jump to: