For 3 address a three post jumper with a resistor divider would work. Shorting out a resistor would give 0 or VCC and no jumpers would be the voltage from the divider.
Any ideas on how to get all 8 addresses? A simple trimpot seems a little inaccurate IMHO.
Nine equal resistors would work. Each tap would be a different voltage. Note that 0V and Vcc are not among the 8 voltages you can choose from. That's why you use 9 resistors.
It is possible that an R/2R ladder D/A driven by three jumpers would also produce the right outputs. I think that would be 6 or 7 resistors.
You could substitute the MC2309 with a small AVR and program the I2C address to any value you like without requiring additional in-circuit parts whatsoever.
I understand this is not quite what you asked and that it involves programing, but it may be useful to keep in mind that microcontrollers are general purpose IC’s.
The way I read the datasheet
"The ADDR pin is used to set the slave address of the MCP23009 (I2C only) to allow up to eight devices on
the bus using only a single pin. Typically, this would require three pins."
you are only setting the I2C address the part responds to, and not changing on the fly to select which GPIO is being accessed - that is via registers.
So setting the voltage once via trimpot and multimeter would be sufficient.
Why not go even simpler, faster, and use the SPI interface instead?
I wish Microchip would have used a couple of extra pins on the device and allowed address setting the old fashioned way.
seems VCC & GND are valid voltages so 7 equal resistors say 1K @ 3.3V should be possible.
trimpot just seems so sloppy, else it would be a obvious choice and cheap too.
SPI is great & fast but I2C makes it easy to add more slave devices e.g. relay / opto boards, RTCC & EEPROM without adding a CS or CE line for each peripheral. I am open to suggestions though...
johnwasser:
Nine equal resistors would work. Each tap would be a different voltage. Note that 0V and Vcc are not among the 8 voltages you can choose from. That's why you use 9 resistors.
No, 7 resistors and 0V and Vcc are among the valid 8 voltages. Fig 1-3 in datasheet. Unless you want to run more than one IO expander just wire ADDR pin to ground.
This is easy. The intent is to ensure that the flash ADC decodes the correct address for each input voltage. Intuitively, that happens most securely when each input voltage is smack in the middle of the range that yields the corresponding code, except at the endpoints - a 0V input will give a 0 reading from the flash ADC, and VDD will always give a reading of 7, without any concerns about voltage errors.
The bottom of the range for each code is ADDR * VDD / 8, the top is (ADDR + 1) * VDD / 8, so the middle is (2 * ADDR + 1) * VDD / 16. Those values match Figure 1-3 perfectly. It takes 7 resistors: one with a value of 3R, followed by five at 2R, and another at 3R, where R is some convenient value, to get 0V at one end, VDD at the other, and an exact match with Figure 1-3 at the junctions in between.
As crossroads says, have we established that you are going to use 8 of these chips on the I2C bus at the same time.
You should not change the address once it is fixed in your circuit so a simple potential divider with each chip you use is sufficient.
MarkT:
No, 7 resistors and 0V and Vcc are among the valid 8 voltages. Fig 1-3 in datasheet.
Yes they are, but the allowed range for the first/last rows in the table is bigger.
Think though: With 7 resistors the first voltage in your chain would be 1/7 VDD.
At VDD=5.5 that's 0.7857V - nowhere near any of the target voltages in figure 1.3 (column V2).
Ah yes, that's odd, I'd have thought they would choose the on-chip resistors appropriate to allow equal external resistors (chip designers usually think carefully about the parts count on external circuit). So you need the two end resistors to be 3/2 the size of the other 5. Or use 9, make the end ones 1/2 the value of the others, and ignore the first and last taps.
Still with 1% resistors 7 equal value ones would actually work I think, on-chip resistors have very good matching.
MarkT:
Ah yes, that's odd, I'd have thought they would choose the on-chip resistors appropriate to allow equal external resistors (chip designers usually think carefully about the parts count on external circuit). So you need the two end resistors to be 3/2 the size of the other 5. Or use 9, make the end ones 1/2 the value of the others, and ignore the first and last taps.
Still with 1% resistors 7 equal value ones would actually work I think, on-chip resistors have very good matching.
I think the chip engineers were expecting people to use two resistors per chip (that's why the datasheet uses "R1" and "R2" in the tables). It's what I'd do...
MarkT:
Well then they weren't thinking about external parts count... Odd.
Huh?
They're probably thinking that attaching eight of these to something is silly, that sensible people would prefer the 16-channel version of the chip if they want that many outputs. A 16 bit chip will save you a hell of a lot more than just a resistor or two.