BrainStem® NetworksIndex

A BrainStem module has an IIC bus connector that can connect it to other devices.  Several BrainStem modules may be connected via the IIC bus to create a network.

In a BrainStem network, one module is the router .  Each module must have a unique IIC address, but all modules must share the same router address.  The router handles the traffic between the host and all the other modules.  When the router receives a command, it checks the destination address and if it matches its own, then it executes the command.  If it does not match, then it transmits the command via the IIC bus to another module.  When a module has a command to send to the host, it checks to see if it is a router.  If so, it transmits the data via the serial connection up to the host.  If it is not the router, it wraps the command in a cmdROUTE packet and sends it to the router via the IIC bus.  When the router receives a cmdROUTE packet, it unwraps the command and sends it to the host.  A host computer can send commands to any module on the network.  The modules in the network can also send commands back and forth to each other.

Pull-Up Resistors

The IIC specification requires pull-up resistors on the SDA and SCL lines.  Each BrainStem module has 2.2K pull-up resistors on its SDA and SCL lines.  These pull-up resistors are useful when connecting other IIC devices that do not have their own pull-ups.  Connecting multiple modules via the IIC bus will put the pull-up resistors of each module in parallel.  This lowers the actual pull-up resistance on the SDA and SCL lines and limits the number of BrainStem modules that can be networked.  The actual limit depends on the baud rate.  Once the limit is reached, additional modules may be added after removing their pull-up resistors.

Networking Multiple GP Modules

The following example describes how to network two new BrainStem GP modules.  These steps also work when connecting more than two modules.  The example uses IIC addresses 2 and 4 though any even values in the range 2-254 may be used.

Each new BrainStem GP module has its IIC address set to 2 and its router address set to 2.  It is its own router.  Pick one module and make its IIC address 4.  To do that, connect it with the serial cable to the host computer, apply power, and run the Console program.  Then send this command:

That changes the IIC address to 4 with the cmdVAL_SET command.  Its router address will still be 2.  Since the router address and IIC address no longer match, the module will no longer send a heartbeat to the host.  Then enter:

That is the Magic Byte which makes the module send its IIC address.  The following lines should appear in the Console window:

That will verify that the ID has actually changed.  Then enter:

That writes the new IIC address to the EEPROM with the cmdVAL_SAV command.  That command starts with the address 4 because the IIC address was just changed.  This will be Stem 4.  The other will be Stem 2.  Stem 2 is the router.

Connect the SDA, SCL, Logic Power, and Ground lines of Stem 2 and Stem 4 at their 2x6-pin connectors as shown in the pinout diagram of the BrainStem GP 1.0 Module.  Then connect Stem 2 to the host machine with the serial cable.  Connect power to Stem 2.  The power will be distributed to the other module through the Logic Power connection at the 2x6-pin IIC bus connector.  Then run the Console again.  Use the cmdDEBUG command to check the network connection by entering:

The following lines should appear in the Console window:

If that test works, it means that Stem 2 is routing data back and forth successfully between the host and Stem 4.

Networking a GP and Moto Module

A new BrainStem Moto 1.0 board already has its IIC address set to 4 and its router address set to 4.  All that is required to configure a network with a GP and Moto module is to change the router address on one of the modules.  The following commands will configure the Moto board to route through the GP module:

Reset Messages

A module sends a reset message to the host when it is turned on.  In a network, the reset messages of each module go through the router.  Each module waits a moment before sending its reset message.  This delay is proportional to the module's IIC address.  If the Console is running when the network is first turned on, it will display reset messages from each module in the order of their IIC addresses.  This prevents IIC bus collisions at power-up.

The cmdRESET command can reset a single module in a network.  When this occurs, only the targeted module will send a reset message.  After the reset, there will be an initialization period when the module can not respond to incoming IIC packets.  If another module is trying to send a command to it, such as a heartbeat , the transmitting module may report an "iic no ack" error message back to the host.


version: 1.0, build n.a.
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado.  All rights reserved.