Guest
#1981794
Hi Folks I am thinking about making an I2C connected uC (atmega master, attiny slaves) cluster consisting of up to 10 participants. What I want is that you can connect or disconnect any number of "clients" if the power is down. The cluster will have one master, all the other are configured as slaves BUT: the master does not know how many slaves it has, because the user can add or remove slaves (not during operation though). Also the slaves do not know how many other slaves there are and what their addresses are. The addresses need to be random. To sum up: One master, up to 9 slaves. Unknown addresses of the slaves. Slaves need to be able to change address to have a unique address. Has anyone done something like this? Can it even be done? My approach would be something like this: The devices later to be slaves (attiny) start out as masters, the later master (atmega) starts as a slave. Each attiny does an analog read on a floating pin to get a random number and sets it as its address. It then starts transmitting this random address to the atmega, which has a fixed address. the winning master (the one with the highest address) gets through. It then goes to slave mode and stops transmitting. the remaining masters continue like this until all have transmitted their address. the atmega then switches to master mode and sends a init command to all detected slaves. If a slave (attiny) does not respond, a timeout needs to be triggered on the master and the slave, chaning the transmission direction and having the attiny re-transmit its address. The problems I see is in how to detect which attiny wins the master battle, especially if two have the same random address. I know that something similar is done in a bluetooth network to detect the devices. I do not need this to be very fast.