Automatic board addressing

Discussion in 'General Electronics Chat' started by kubeek, Dec 10, 2011.

  1. kubeek

    Thread Starter AAC Fanatic!

    Sep 20, 2005
    4,669
    804
    Hi guys,
    once again I am in need of your opinions. I am supposed to build a set of stackable boards - i.e. each boards clicks into the last one through some kind of connector, the pin count doesn´t really matter.

    Now, all the boards will have a common I2C bus and on each board there will be a slave chip, each with different address. My goal is to somehow set the connection in a way that each board gets it´s address based on where it is positioned in the stack, so that boards can be swapped randomly and you don´t need to set the address by jumpers which is prone to errors.

    Any elegant suggestions on how to achieve this?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Interesting concept. I have systems with many stacked daughter boards in a multi-processor system, each one is a complete computer in its own right. Each board communicates with a master CPU using interrupts and parallel data transfers.

    The normal practice is use DIP switches on each board. In my system, each MCU is assigned a unique address. Hence the addressing is not dependent on the position of the board.

    I have to give your request some more thoughts.
     
    Last edited: Dec 10, 2011
  3. kubeek

    Thread Starter AAC Fanatic!

    Sep 20, 2005
    4,669
    804
    First I was thinking about shifting the address by one bit and then using 1ofN decoder to decode it, but that would be too many wires. So I decided to simply add 1 to the received address using a 4008 4-bit adder and send it to the next board, which should give me nice and easy addressing.
     
    Last edited: Dec 10, 2011
  4. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348

    Back in the dark ages (1980's) we had a multi zone hot press that used the scheme of all the individual zone controllers being daisy chained and each subtracting 1 from the address it received before sending it on to the next zone control. Of course that doesn't address (pun intended) the OP desire of having each board automatically recognize its position in the stack and know what address to respond to. Maybe a voltage divider scheme where the position in the stack is read by reading the voltage from the divider.
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    I have given this some thoughts and I cannot come up with a solution. The problem is I assume that there is a master controller in your system and it needs to know which module it is communicating with, especially if each module has a different function, such as, ADC, DAC, I/O, relays etc.

    1) As I mentioned, one solution is to use DIP switches on each board and each has to have a unique switch setting.

    2) The solution I use is each board is programmed with a unique address in firmware.

    3) A more complicated solution is for the master to negotiate with all boards on power up and to assign a unique address to each board. This is entirely a software solution.

    You could use a hardware daisy chain where on each board a signal is input to the MCU and the MCU relays the signal to the next board. On first power up, all MCUs will relay a logic LOW = DISABLE to the next board.The master sends a HIGH = SELECT signal to the first board and assigns an address to it. When the first board has been assigned, it relays a logic HIGH to the next board. This board will get negotiated next with the master MCU... and so on.

    (Normally, I would reverse the logic, using NEGATIVE LOGIC. I have used POSITIVE LOGIC in the example above just to make it easier to follow.)

    For this to work, each board will have to identify the type or function of the board back to the master.
     
    Last edited: Dec 10, 2011
  6. kubeek

    Thread Starter AAC Fanatic!

    Sep 20, 2005
    4,669
    804
    Well, I don´t need the boards to report where in the stack they are, as all the boards will be the same. This is a part of a large (~160 port) USB data switch and I need to be able to simply call port #19 on board #6 and be sure that it is allways the same port, even after someone changes the board, for example if one stops working properly.
     
  7. crutschow

    Expert

    Mar 14, 2008
    12,972
    3,219
    The only solution I can see offhand is to plug the boards into a mother-board rather than into each other. That way the mother-board connector can assign the address.
     
  8. kubeek

    Thread Starter AAC Fanatic!

    Sep 20, 2005
    4,669
    804
    The solution is ready, each board will add 1 to the address received from the last board and send it to the next board. This way all the boards will have increasing addresses starting from 0. The number of boards will be limited by the bus width, so if you stack 17 boards with 4bit bus you will have a collision.
     
  9. Kermit2

    AAC Fanatic!

    Feb 5, 2010
    3,761
    924
    Have each board generate an address bus voltage of all ones with pull down resistors on each line, and include a connector for those resistors which is plugged in when a board is placed in that position. Exactly the same as a dip switch except the switched portion is in the wiring harness. Each wiring harness has a different configuration of grounding wires creating a unique address for any board plugged into that harness.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Here is another solution that uses your existing I2C interface and requires no additional hardware nor interconnects.

    On power up, each slave device generates a random unit code, like a MAC address.
    Also using a random delay time, each device reports to the master and identifies itself - using ethernet style CDMA (collision detection multiple access).
     
    Last edited: Dec 11, 2011
  11. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Are they hot-swappable?

    If so, start adding boards to the bare CPU/bottom board while it is on.

    It sends an address to be saved to EEPROM to a board as soon as it is added, then the board figures out how react to that address, or the CPU just keeps track of addresses as they are added.
    Minimum of 1 second between boards to be stacked, so the CPU has plenty of time to figure out config.

    Adding two boards at once, or changing boards around while powered off would hork the concept though, just as moving drives around in a powered down RAID Storage system would hork it.
     
  12. kubeek

    Thread Starter AAC Fanatic!

    Sep 20, 2005
    4,669
    804
    Unfortunately there is no way teaching that an I/O expander, which will control the data paths.
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Would the boards always need to be in a certain order?


    Say you have 16 choices, and any 10 of those can be used, but they need to be in the same order (1-16, with numbers missing).

    You could use physical keying for that, to ensure a higher numbered board can only go on top of a lower numbered board.

    My other idea is to have 2 pins to make a resistor chain to the top board, then measure voltage drops to match addresses.
     
Loading...