communication

i want to communicate 9 arduino boards, 8 as a slaves and one as mater. i am unable to do the code for this communication. all the controllers will start sending the data at a time but they will transmit continuously, the master must receive the 8 controllers data and must save and compare. please give me the suggestions. Thanks in advance.

I have a system like that for controlling my model trains.

Each slave is given a different ID number when it is programmed.

The master sends a message for each slave in turn with the ID of the slave in the message. All the slaves hear all the messages.

When a slave receives a message with its ID it replies immediately. The message for the reply has already been prepared. (For my trains it is the locomotive battery voltage).

The master just waits a very short time for the reply and carries on to the next slave if no reply is received.

If I remember correctly my system can talk to 20 locomotives 5 times per second. The data to be sent to the slaves comes from my PC and the received battery voltages are sent back to the PC.

...R

can u send be the sample code for this communication, and can i know which type of communication u have been using in your project.

I have tried with I2C protocol but it is taking the values from any one of the device continuously and not switching to another device.

harshabollisetti:
i want to communicate 9 arduino boards, 8 as a slaves and one as mater. i am unable to do the code for this communication. all the controllers will start sending the data at a time but they will transmit continuously, the master must receive the 8 controllers data and must save and compare. please give me the suggestions. Thanks in advance.

You are going to have to define your protocol, decide an which type of shared databus to implement (I2C, RS485, RS422, SPI) each of these hardware definitions have a corresponding software protocol.

If your system is truly a Master -> Slave relationship, and they are physically near each other. (50cm max distance) you could use I2C, The master would poll each of the slave to read their values.
I2C is a 2 wire bus.

If your system is truly a Master -> Slave relationship, and they are physically near each other. (20cm max distance) you could use SPI, The master would poll each of the slave to read their values.
The SPI bus is a 3 wire bus, but it requires one additional wire for each slave, therefor with your 1+8 system, the master will use the 3 SPI pins plus 8 more pins for Slave selection. Each Slave will just need the 3 SPI pins and one SlaveSelect pin.
The Arduino environment does not have a 'good' slave SPI library. You will have to build one yourself.

RS485 is a 'party line' system. every device on the bus listens to all communications on the bus and responds only when it identifies a message that contains it's 'identifier'. The master initiates all communication request in the Master -> Slave relationship. It can also be used in a MULTI-Master configuration where each device is both a Master and a Slave. But this multi-master configuration adds collision detection and collision recovery complexity to the communication code.

RS422 can be configured as a loop with each device sending down stream and listening upstream. Basically the transmitter of one board is connected to the receiver of the next board inline until you wrap around to the first board. Each board receives packets, selects any that are addressed to itself these it removes from the stream while passing along any packets not address to it down stream. This loop will never have the collision problems a Multi-Master or shared bus, but if one of the device does not pass packets, the comunications loop will fail. Also, the data protocol must handle corrupt packets and lost packets.

Chuck.

Thank u chuck,
I am placing the each device at 3 feet from the master then can i use I2C or not. Some where i read that I2C can be communicated up to 5 feet

chucktodd:
You are going to have to define your protocol, decide an which type of shared databus to implement (I2C, RS485, RS422, SPI) each of these hardware definitions have a corresponding software protocol.

If your system is truly a Master -> Slave relationship, and they are physically near each other. (50cm max distance) you could use I2C, The master would poll each of the slave to read their values.
I2C is a 2 wire bus.

If your system is truly a Master -> Slave relationship, and they are physically near each other. (20cm max distance) you could use SPI, The master would poll each of the slave to read their values.
The SPI bus is a 3 wire bus, but it requires one additional wire for each slave, therefor with your 1+8 system, the master will use the 3 SPI pins plus 8 more pins for Slave selection. Each Slave will just need the 3 SPI pins and one SlaveSelect pin.
The Arduino environment does not have a 'good' slave SPI library. You will have to build one yourself.

RS485 is a 'party line' system. every device on the bus listens to all communications on the bus and responds only when it identifies a message that contains it's 'identifier'. The master initiates all communication request in the Master -> Slave relationship. It can also be used in a MULTI-Master configuration where each device is both a Master and a Slave. But this multi-master configuration adds collision detection and collision recovery complexity to the communication code.

RS422 can be configured as a loop with each device sending down stream and listening upstream. Basically the transmitter of one board is connected to the receiver of the next board inline until you wrap around to the first board. Each board receives packets, selects any that are addressed to itself these it removes from the stream while passing along any packets not address to it down stream. This loop will never have the collision problems a Multi-Master or shared bus, but if one of the device does not pass packets, the comunications loop will fail. Also, the data protocol must handle corrupt packets and lost packets.

Chuck.

harshabollisetti:
Thank u chuck,
I am placing the each device at 3 feet from the master then can i use I2C or not. Some where i read that I2C can be communicated up to 5 feet

I2C was designed as Intra IntegratedCircuit Communciations. It is designed to work on the same board. It may work at 5 feet but don't design your system to require error free communication. You may encounter random data corruption. Design you system for this contingency.

chuck.

chucktodd:
I2C was designed as Intra IntegratedCircuit Communciations. It is designed to work on the same board. It may work at 5 feet but don't design your system to require error free communication. You may encounter random data corruption. Design you system for this contingency.

chuck.

Yeah! I am facing the same problem. I am getting some garbage values by using any of communication(like SPI, I2C). If it is using one to one means it is showing the values properly but if it is increased slaves means it is connecting to any one of the devices only, that is the problem i am getting. I wanna receive the data from all the slaves. I am using the bread board connections.

harshabollisetti:
can u send be the sample code for this communication, and can i know which type of communication u have been using in your project.

I presume this question was addressed to me.

I don't have any sample code apart from what is in this old Thread. That system uses 2.4GHz transceivers for communication - but they are Cypress devices not the NRF24 that is more usual with Arduinos.

You could use the concept that I mentioned with any type of comms system that supports a master and multiple listeners.

...R