Connecting a Rover 5 controller, need 1 more interrupt

Awhile ago I got a basic POC of a Core controlling a Rover 5 unit via the Rover 5 Controller board. I want to pick up the project and interface all the I/Os into the Core (and do fancy things like PID control and Path Planning.)

My setup requires:

  • 4 digitalWrite pins to enable the motors
  • 4 analogWrite pins to use PWM signals to control speed
  • 4 digital interrupts to measure the quadrature encoders
  • 4 analogRead to measure current

I’m also using I2C to talk to other boards, like an IMU.

The problem is that I need 4 interrupts for the encoders and while the Core has 12 interrupts, I need to use 9 pins for other tasks, leaving only 3 available pins that can be attached as interrupts. Here is a diagram of my planned layout:

Also, another thread suggests the docs might lacking when it comes to interrupts. I could use another board like a Mega or not use Current Sensing (which is what I believe others have done.) Any other ideas?

I’m not sure if it’s applicable here, but have you considered a GPIO expander? There’s one in the maker kit. There should be plenty of guides available too.

A good suggestion but shift registers only expand Output (AFAIK) and also add latency. I need more inputs, or a way to enable more pins as interrupts.

Could you mux the current sensing part? I imagine you don’t need super high speed current sensing? That way you could use some of the analog ports as interrupts

1 Like

@jonathanberi, a good expander you may want to consider is the MCP23017 or 23008. Both use I2C and have libraries available :smile:

1 Like

@harrisonhjones were you thinking of something like a 4051?

@peekay123 I like that idea. I’ll see if any local (Bay area) suppliers have one for pickup or I’ll have to wait for shipment :cry:

Sure, that would work

I think you can make this work without the I/O expander:

Move Motor Enable from D6 to D5
Move PWM from A6 to D6
Move Encoder Interrupt 4 from D5 to A6.

You still may have some trouble though because of this:

// D0-D3 were initially chosen, but because 
// individual control of dis/en'abling their
// interrupt handlers was not available, A6, A7
// D3 and D4 were chosen instead.  D0, D1, D2
// A0, A1, A3, A4 are all tied to one interrupt
// handler

So, because you really need A7 as well... you'd have to find another PWM from the Analog pins, because you are using the I2C/PWM pins already for I2C. Perhaps you could get a I2C to PWM chip to generate your PWM, like this one: Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Are the TX and RX pins reversed on this diagram? Or am I just confused?

@Jack, TX and RX can be used as GPIO pins but at the cost of losing the UART functionality. :smile:

Sorry if I my question was not clear. Let me ask it this way.
I thought (think) that the TX is next to the Ground pin, not the RX. The pinout of the Core in this thread seems to say otherwise.

@Jack, then yes, I believe you are correct!