Multiple outputs to share a data line

Hey guys,

Been doing a little research and I'm a little new to the embedded area so I'm not exactly sure what to look for on this. I would like to have a master chip and some number of slave chips that all receive commands using a bus (I would like to have 1 master-controlled clock line, 1 mosi, and 1 miso, though I'm not using SPI). In some cases, I would like the master chip to be able to select which slave should be providing an active output as part of the command structure, and in other cases, I would like to be able to send a command and detect if one or more slaves are setting a bit (to show that one or more slaves had an error, as an example - but I wouldn't care which ones failed). Is this design something that can be achieved easily, or would I need to expand the design and have one data line per slave, and use a multiplexer or shift register to retrieve the values from the slaves? I would prefer to have just the three lines if possible because I don't know exactly how many slaves will be present, but I suppose I can set a cap if absolutely necessary. Do you guys have any ideas or suggestions on general approaches that I can use to achieve this goal?

Thanks - Harrison

If your master can control things so that only one slave talks at any one time and so that the master knows which slave is talking then you could easily transfer the data on a single line.

Why not use the built-in SPI or I2C systems? Or maybe even Serial?

If you describe your project fully it will be easier to give useful advice.

...R

Keep in mind that SPI/I2C/Serial only work over short distances without extra hardware.

For a project of mine I need to control 5 slaves over a longer distance. Say around 50 meter in total. That's why I bought MAX485 modules for every Arduino to communicate over serial.

Robin2: If you describe your project fully it will be easier to give useful advice.

So to give some more details, let me try and explain what I am trying to create here.

  • I will have 1 master chip, which controls synchronization across slaves, controls high level state, etc
  • I will have at least one slave chips in a 2D matrix (probably close to 20 when its all said and done). These chips may be wired to their neighbors, and they connect to various peripherals using SPI (they act as masters to their own peripherals in this situation)
  • Commands will be executed in parallel and generally affect all slaves (except for some specific commands). Sometimes slaves will need to transmit and receive data between their neighbors in order to complete the command, and this data transmission will be synchronized with the same master clock (e.g. in bit 7 of the command, slave 1,2 sends a bit to 2,2)
  • Some commands, notably a mode selection command, will cause some slaves to enter an invalid state. In this case, I need to know if at least one slave has an error, so that I can recover and move back to the last valid mode.

Robin2: If your master can control things so that only one slave talks at any one time and so that the master knows which slave is talking then you could easily transfer the data on a single line.

I think this might be possible, but it might dramatically slow down the rate at which I can send commands. In most of the scenarios, a command will simply be telling each slave to perform some action with no response. In some cases, the master will send a command and specify which slave should respond (just by sending bits over the standard mosi line), and then that slave could respond over miso. However, there are a few commands which will need to know if one of the slaves has failed it, but it doesn't really matter which one or how many failed. Theoretically I think I could run the command, then request from each slave the result, though this is pretty slow.

Robin2: Why not use the built-in SPI or I2C systems? Or maybe even Serial?

I am not using SPI because each slave is already using the built-in SPI pins in order to interact with other SPI peripherals that are attached (each device controls some other SPI devices - like SD card, TFT display, etc).

I was looking into I2C but I'm not sure if it will meet my needs. One issue is that the commands need to be send to all slaves at the same time as they need to be synchronized and execute in parallel.

Additionally, using my own method here lets me send commands that are not multiples of 8, which is nice, but not 100% necessary.

I’m still not clear about the level of synchronization you are hoping to achieve?

Are you trying to ensure that (for example) 20 Arduinos can make an I/O pin transition from LOW to HIGH in the same clock cycle?

Or something else entirely?

…R

Robin2: Are you trying to ensure that (for example) 20 Arduinos can make an I/O pin transition from LOW to HIGH in the same clock cycle?

Yeah, or that we might want them to all set to differing values, but their transitions should be timed together.

Use your system to setup latches, thern distribute a latch signal seperately.

Allan

monodop: Yeah, or that we might want them to all set to differing values, but their transitions should be timed together.

That's not going to be easy to achieve. I wonder if @allanhurst means that you should use latch chips rather then slave Arduinos?

Why do you need that level of accuracy?

You have still not told us what your project is all about.

...R