REVISED: I have a master controller PCB with four bus bars (+, -, and two signal lines), see image below. I have module PCBs A-C (or could be 10 or 15 of them), each with MCUs and unique identifiers, that plug into the sockets in an unknown order (and may or may not all be present). How could the module PCBs communicate with the master controller so that the master controller would know the ordering of the module PCBs. (In the digram it would be [C, A, B]
.) The two "signal" lines drawn could be reconfigured (or additional components/circuitry added).
ORIGINAL: I have a master controller PCB with sockets 0-5. I have module PCBs A-F (these are also the unique IDs, either through an MCU or other means) that plug into the sockets in an unknown order (and may or may not all be present). I am wondering if there is a simple way for the master controller to know the ordering of the module PCBs. (In the digram it would be [C, E, A, B, F, D]
.) There is one "signal" line drawn but additional ones could be added (or additional components/circuitry).
Best Answer
In the comments you say:-
If cards will not be inserted or removed when the controller is powered then it only needs to check their order on startup. This can be done with a signal line that is split at each slot, with each card passing the signal on to the next slot once it been identified. Slots that do not have cards in them must also pass the signal on.
Here's how it could be done with logic gates.
simulate this circuit – Schematic created using CircuitLab
Each slot has an AND gate on the backplane, with a pullup resistor on the 'Done' input so the 'ID' signal will be passed through to the next slot even if no card is present. When initially powered up all the boards pull their 'Done' outputs low, preventing the ID signal from getting to the next slot. Each board then waits for its 'ID in' signal to go high, which indicates that the controller wants to identify it.
The controller pulls the 'ID' signal up on the first slot, then talks to whichever card responds. Once the card has been identified it makes its 'Done' output go high and then ignores further ID requests, letting the next card respond. This continues until no card responds. Then the controller knows that all the cards are accounted for, and the order of the cards is the order that they were identified.
The 'ID' signal could also be one of the normal signal lines, so you might only need one extra pin per slot. If you have hundreds of cards then gate delays might be a problem, in which case you will need 2 extra pins per slot (which could perhaps be on opposite sides of the board). The AND gate could be a 74LVC1G08, which costs ~US$0.1 in 100 up quantities.