Multiple node network communication over I²C
Multiple node network communication over I²C
I am working on a project where I want to send data from and to different Arduinos on a network. At the moment IC seems the best option for my needs since I can specify where to send the data. But using this method I have a bit of an issue I cant seem to find a solution for :. I will try to explain my problem using the following image: In the backend all the nodes are connected like in the first image above the example network. But the nodes may be connected in a different sequence by a user. See the example network. In this example network, the node with ID 1 needs to send data to ID 10 and not to any other node on the network. Node ID 12 also needs to send data to node ID 10, but no other nodes. Etc. Etc. Etc. But the node that needs to send data to the next node doesnt know the id of the node it needs to send to. So at first the nodes need to find out what nodes they are connected to and where they need to send their data. I thought of doing this by connecting a wire between each node blue wire in possible solution and when a node gets added to the network the nodes send a high signal over the blue wire and sends its ID to all nodes on the network and then all nodes on the network check if they receive a high signal and an ID. If this is true they will send its id to the node that has been added. This works fine if you add a node one by one to the network. But it fails when you replace a node in the middle of the network or disconnect power from the network. What would be the best way to do this I am also open to use different data transfer protocols
It sounds after discussion like what you are after is actually a mesh of multiple peer to peer devices. That is, lots of devices, each one has multiple dedicated communication links each directly going to another device. If you had enough UART ports you could create individual UART links between nodes. The bets Arduinos only have a handful of those, and the UNO only one. So thats not really practical. You could possibly do it with SPI if you wanted to put a lot of work in to developing a decent control protocol to go along with it. Something along the lines of BUSRQBUSACK signalling: BUSRQ: Signalling line pulled HIGH by resistor. All nodes INPUT. BUSACK: Signalling line pulled HIGH by resistor. All nodes OPEN-DRAIN LOW. SS: Direct 1:1 GPIO links between nodes - all pulled HIGH. All nodes INPUT. Node 1 Node 2 Node X RELEASE BUSACK DRIVE BUSRQ OD Low Sees BUSRQ fall Sees BUSRQ fall RELEASE BUSACK could be busy... RELEASE BUSACK Sees BUSACK rise DRIVE BUSACK SS Node 2 LOW Sees SS go LOW Send SPI data Receives SPI data SS Node 2 INPUT Sees SS go HIGH RELEASE BUSRQ Sees BUSRQ rise Sees BUSRQ rise Drive BUSACK Drive BUSACK Only once all nodes have released BUSACK will the requesting node be able to send any data, and once a node has released BUSACK it knows that it must never send any data. The requesting node has basically locked the bus from other nodes accessing it. Its not perfect, and doesnt handle multiple devices requesting the bus at the same moment, but it does prevent one device trying to send while another is actively sending.
Комментарии
Отправить комментарий