Quote:
Originally Posted by FalconFour
Ah, it does look like it's hardwired to 4 and 5. That'd work fine if MPGuino just went "straight down the lines" and went 0-1-2-3 for VSS-L-Center-R inputs... I swear, none of the pin mapping on MPGuino makes any sense at all (look at the jungle in the LCD wiring).
|
Well, the significance of the injector signal location is that pins 2 and 3 can have interrupt routines assigned to them. For those not familiar with them, an interrupt routine is a piece of code that gets called and executed when some signal is triggered, no matter what the normal running loop says should be happening at that point in time. The triggering signal can be internal to the microcontroller such as a timer that triggers at regular intervals, or can come from an external source in the case of pins 2 and 3. Interrupts are key to time-sensitive tasks such as measuring the pulse width of the injector signal. What
doesn't make sense about the assignment is that pins 2 and 3 can be assigned to two different interrupt routines... There's no reason to use both of them for the single injector signal.
The button signals are obviously digital in nature, so it would make sense to put them on digital inputs. Unfortunately, there's only one free digital input that doesn't have some special function. We really just need more digital ports.
Here's two birds with one stone: The
$1.71 PCA9554 8-bit I2C I/O port in a 16-pin DIP package (it comes in others, but DIP is solder-friendly). Move the button signals over to the PCA9554, and use the two Arduino pins it frees up to run the I2C bus.
I2C is like USB in that you can communicate with many devices which share a single 2-wire bus. Each device has a unique address on the bus (generally selected by a jumper or combination of resistors on a pin of the particular device), so selecting which device you want to communicate with is just a matter of using its address when you start a particular bit of serial communication.
So tacking on that sub-$2 part would let us set up an I2C bus (with the substantial expansion options it provides), free up one analog I/O pin and provide 5 new digital I/O pins.
I'm kind of curious if the LCD could be driven off one of these expanders as well.
Quote:
Originally Posted by mluckham
I'm looking at interfacing to two I2C devices ... the MPGuino would be I2C Master to the EEPROM, and I2C Slave to the external, intelligent LCD module.
|
Unfortunately, I don't think I2C has provisions for a hierarchy like that. There's one master and all the other devices on the bus are slaves. I guess you could get around that by using two busses, but the Arduino uses specific pins for I2C because of hardware provisions in the ATmega controller. There's only hardware for one bus.