I2C: slave to slaves. all slaves listen to all other slave writes

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to make an I2C bus where after a master requests information from a slave, the response from the slave is listened by all the other slaves. I tried to take the arduino Wire library and tweak it to achieve this; but soon learned that most of the Wire interface is implemented in the AVR hardware (AtMega2560, and I think Atmega 328). What would be the best strategy to achieve this? My sense tells me that there should be no conflicts with the current I2C protocol, because there is no additional writings to the bus than how it currently is.

I have been reading the data-sheets and protocol specifications, but it remains obscure to me because of ignorance around the subject.

  •  can it be done using the TWAMR register? In that case, I think that I would need to recognize by software the read requests, so not all the nodes in the bus answer to read calls. The question is whether a 0xFF TWAMR mask would make all slaves to listen to the other slave's response
  • If a slave answers a read request with a general call (0x00), would all the other slaves recognize the slave general call? My intuition says that they wouldn't
  • Should I think instead about switching the roles of the slaves into master writers during runtime, to enable them to generate general calls? How bad of an overhead could result from this?

In parallel I developed a token ring based protocol, that is built upon RS232, which works well; but I expect that TWI will allow a higher bitrate than RS232; and also take less processing power. (I can poll 14 times a second a network of three nodes that answer with 6 byte payload each) Are these assumptions right? or I should stay with the made-up protocol?

 

Last Edited: Mon. Jun 19, 2017 - 06:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that does conflict with I2C. The master starts out with a "hey you, listen", then sends some control information. The addressed slave responds with a "here the data is", which all other slaves ignore. If you want a "slaves listen to traffic" system, RS422/485 gives you total control over the protocol. There, you can do anything you want. RS232 is not it, because it is designed for a 1:1 pair, only.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Mon. Jun 19, 2017 - 06:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So basically I should keep it RS232/485

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The I2C spec is designed for one Master talking to one Slave. The two devices ACK each other to confirm that they are communicating correctly.
.
It also has a promiscuous mode (address =0).
Multiple Slaves of easy virtue can respond. The Master only knows that at least one Slave has acknowledged. All the Slaves can obey the Master's command but obviously replies are not possible.
.
The General Call Address is normally used to reset all the Slaves. Nothing more.
Multiple Slaves can listen. If a Master wants to find out which Slaves are "available", it should scan through all addresses.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, indeed, that would work.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"but I expect that TWI will allow a higher bitrate than RS232; and also take less processing power"

 

Well, I usually have 115200 bauds (more bits / second than I2C standard mode...)  on an Arduino I connect to a nanopi: I know "I" cannot go fasterer because the nanopi serial port, like the RPi, is limited to 115200 bauds. But is bitrate the only relevent criterium?

for example, I2C is a multipoint link : the adress of the slave needs to be transmitted before transmitting/receiving data. This eats average bit rate. OTOH, serial does not need to send an adress (point to point; would be redundant)...

I2C was designed for short wires, or the same PCB (but PCB could be big in the 1980s) I never tested the maximum cable length for 115200 bauds, but http://www.tldp.org/HOWTO/Remote... , when extrapolated, lead to 1.5 meter with "good" cables... (I am afraid it refers to +/-12 v RS232 )...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want a master to get data from a slave, and have all the other slaves receive that data, then do the process one slave at a time. 

Say that you are getting a block of 8 bytes from a slave. The master gets this block of 8 bytes and ends the transmission.  The master then connects to each of the other slaves, one by one, transmits this block of 8 bytes to each of them in a separate message for each slave.  

How many slaves are you referring to?  I2C allows 127.  400KHz I2C allows @ 40,000 byte transfers per second.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to all!

I consider the question more than ansered. I think that the most sensical option is to make a half duplex based on RS232 or RS485. Perhaps If I was an expert on electronics or data transmission, I would experiment with more advanced drivers. I am combining it with a token based protocol for maximum use of the bandwidth. The expected length is short, and the amount of modules should vary between 1 to 10.

Many thanks to all!