I'm fairly sure what I have designed here is right, but I want to ask before I commit to buying chips...
I want to create an extendible bus-based switch system for an Arduino, i.e. so I can switch dozens, maybe hundreds of devices on and off according to whatever programming I choose (OK, hundreds may be a stretch, but more than I can comfortably fit on a single circuit board anyway). Plus I think there may be some other devices on this bus...
Anyway, I want some way of being able to choose a specific card on the bus by its address. The card could be anywhere on the bus (it's a passive bus). I'll allow up to 16 cards in total, i.e. 4 address lines.
Please look at the attached diagram; here I use a quad 2-input XNOR chip, with each address line going into one side of one of the gates. On the other side, I have 4 dip switches, ON=HIGH; if off, a pull-down resistor (I only show one resistor on the diagram due to my lack of drawing skills - please assume each line has its own pull-down resistor) ensures its at logic zero. The output of the XNOR gates is then ANDed, and fed into the Output Enable of the tri-state buffer - which isolates the D1-4 (ahem, D0 went missing) data lines.
Am I on the right track here? I assume I'll need some decoupling caps; also, ignore the "use NAND if inverse OE" label... I'd have to use an inverter, a NAND would not give the correct result.
(1 XNOR 1) is 0, not 1. That's what Grumpy is trying to say.
Why run so many wires? It's much easier to use a serial bus. I2C is great for addressing although not great for running the wires long distances (more than 6 inches can cause problems in some installations.) MODBUS is good for inches up to miles.
MorganS:
Why run so many wires? It's much easier to use a serial bus. I2C is great for addressing although not great for running the wires long distances (more than 6 inches can cause problems in some installations.) MODBUS is good for inches up to miles.
The 4 address lines will be used to select a card on a backplane. The 4 data lines are those needed to run a '595 shift register (data, clock, latch, reset). I may implement reset in hardware. Two '595s can, between them, switch 16 MOSFETs, and the whole lot should fit comfortably on a home-made Eurocard PCB with edge fingers to plug into the bus.
With 4 address lines, assuming 15 plug-in cards (the "CPU" would also be a plug-in card), I can in theory therefore switch 240 devices... all from 7 or 8 Arduino pins.
[And before anyone jumps in... that's obviously theoretical, and would probably require magic power supplies, inch-thick copper traces etc. etc. Practically I'll probably end up with less than 8 cards plugged in in the final design]
AdeV:
The 4 address lines will be used to select a card on a backplane. The 4 data lines are those needed to run a '595 shift register (data, clock, latch, reset). I may implement reset in hardware. Two '595s can, between them, switch 16 MOSFETs, and the whole lot should fit comfortably on a home-made Eurocard PCB with edge fingers to plug into the bus.
With 4 address lines, assuming 15 plug-in cards (the "CPU" would also be a plug-in card), I can in theory therefore switch 240 devices... all from 7 or 8 Arduino pins.
You can consider off-the-shelf components like the 4 bit magnitude comparator 74HC85; there are also 8-bit versions (address comparator) if needed (74HC68x, not sure what the x is).
And 74HC244 or 74HC245 for the tri-state buffer.
I wasn't specifically... but now I am, thanks. I'll read up on them.
So, let's imagine that I use a port expander via SPI. I want to put 15 of them on my bus, so I assign 4 address lines. Obviously I don't want to etch 15 different PCBs, so I use DIP switches to set the "address" of each card. Would the logic circuit I proposed originally work? Or not?
sterretje:
...there are also 8-bit versions (address comparator) if needed (74HC68x, not sure what the x is).
Ahhh, thank you. The 74'688 is the very beastie I need - it'll even do 8 bits (woo! 256 devices on my bus! Crashtastic!) if I want it to.
And looky, the logic diagram's identical (bar the -OE override) to the one I drew.
sterretje:
Agreed, it takes the fun away
Well, yes and no... I find routing boards with ICs on them to be a complete nightmare, so the less chips on the board, the better IMO. LEDs bring the fun back anyway
AdeV:
So, let's imagine that I use a port expander via SPI. I want to put 15 of them on my bus, so I assign 4 address lines.
Firstly, the expanders only have a 3-bit address capability but the SPI version has a chip select line. So, with the mentioned 74LS138 as decoder, you could address eight 23S017s (128 bits) with only six lines - 3 SPI, 3 decoder. With another address line you could use a 74145 and select ten 23017s.