Go Down

Topic: Devices addressing  (Read 183 times) previous topic - next topic

Gbouna

Aug 19, 2019, 06:32 pm Last Edit: Aug 19, 2019, 06:33 pm by Gbouna

I'd like to have one master Arduino ( Arduino MEGA) node and many (say 100 or more) Arduino's (Arduino nano) connected to that master via an Arduino supported communication protocol (say I2C, SPI, CAN etc). They all would be running the exact same software.

The question I have is simple: How do I allocate each slave Arduino with a unique address if they are all running the same program code?

If each slave was running different software, I would hardcode the address of each slave in each project and all would work ok, but this simple problem is stumping me.

A few other ways to pose the same question:

how can I get each slave to retrieve a unique address from the master node?

how can I get each slave to self-allocate a unique address?

how can I send each slave a unique address from the master node before it has a address allocated to it?


Maybe the protocols themselves may not necessary support this which im not sure, is there any algorithm that can be used to achieve this which is supported by Arduino?

Robin2

One option is to give the slaves an initial address (perhaps just 0) and when a slave calls the master and the master sees that address the master will send it a new unique address which the slave can store in its EEPROM memory.

Another way to think of the same general idea is that the slave checks its own address and if it is 0 it goes into a special process for contacting the master and asking for a unique address.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

GolamMostafa

#2
Aug 19, 2019, 08:03 pm Last Edit: Aug 20, 2019, 01:17 pm by GolamMostafa
I2C Bus allows connecting 128 slave devices with a single Master where each slave is assigned a unique 7-bit address.  In I2C Protocol, the Master keeps polling the slaves one after another for data collection. The slave(s) has no ability to ask the Master to read its data unless you use an interrupt line which is very unusual.

raymw

Quote
how can I get each slave to self-allocate a unique address?
If you need an individual identity of each slave, then maybe get them to read some i/o ports which have been grounded. Seven ports can give 128 identities.

Quote
how can I send each slave a unique address from the master node before it has a address allocated to it?
If you have a number of slaves running identical code, and you allocate an address from a master, how do you know which slave has a particular address? 

Go Up