See answers in-line. I'll walk you through the code when you are
ready to try out your parts. It will power up in input mode so
basically you could just try reading the part but you'll want to set
the pullups first with a write command.
Dave
--- In
ComputerVoltageSources@yahoogroups.com, "Andrew Scheidler"
<xpandrew@...> wrote:
> [voltage source] --> toggle switch --> input pin of MCP23008
> a) What should I use for the [voltage source], ie. what voltage ?
Make it easier - inpu pin to switch to ground. The part has internal
pullups so you can have the no switch closure read a 1 and the switch
closure will read a 0. A write of $ff to the GPPU register will turn
on the pullups. You can also write to the IPOL register to invert the
inputs so a switch closure would read as a 1 (wouldn't bother).
> (Is there somewhere on the PSIM I can pull this from?)
You'll need a minimal amount of +5 volts for the MCP23008. Pin 3 of
J5 is +5 but you are using that for your midi interface. You could
tap into the connector for your midi interface to connect to that pin.
The part only needs 1 mA which is no big deal.
> MCP23008 --> P6
> MCP23008 --> P7
> b) Which pins on the MCP go to P6/P7?
You can wire either P6 or P7 to SCL (pin 1) and SDA (pin 2). I
connected mine as P6 to SDA pin 2 and P7 to SCL pin 1. These are
defined in the I2C commands.
> c) Do I need a resistor in between them? (you mentioned a pullup
> resistor)
No, but you need a 4K7 resistor from pin 1 to +5 volts and another
from pin 2 to +5 volts. These lines are open drain so they have no
active pullup. The resistors are needed for logical 1's.
> Power/ground/other connections to the MCP23008
> d) What other connections (minimal!) do I need to make?
To make it easy, don't wire up the address (let them float) and you'll
need to use address $27 instead of $20. Note this has to be shifted
left to become $4E. I let the compiler do this for me. A better
solution would be to ground them all (floating is susceptable to
noise). This would be grounding pins 3,4,5. Pin 9 is ground, pin 18
is +5. I would wire reset pin 6 directly to the reset switch. Make
sure you get the non-grounded side of the switch or wire it directly
to J10 (you'll have a wire there for the switch).