Because all Slaves are placed in parallel on the SB-Bus they can't help receiving all commands and data from the Master.
Therefore we need a way to address a particular Slave before sending commands.
Only the selected Slave is allowed to obey to the commands, all other Slaves have to ignore all incoming characters when they are not selected.
At the same time only the selected Slave is allowed to talk back to the Master. We cannot allow more than one Slave to talk at any given time, otherwise we will only receive garbage.
Communication on the SB-Bus is done with 8-bit characters, although we only use the standard 7-bit ASCII codes for normal communication. Bit 7 of normal characters is always "0". When bit 7 is "1" it is obviously not a normal ASCII character, and it will be interpreted as an address by all Slaves.
Address values range from 128 to 255 ($80 to $FF).
Considering 2 special cases this will give us a maximum of up to 126 addressable Slaves on one single SB-Bus.
The 2 special cases are addresses 128 and 255. Address 128 is the so called Idle address. No Slave is allowed to answer to this address. You can safely alter the physical bus configuration when the Idle address was last sent. This means that you can safely add or remove Slaves and rewire the bus if necessary.
Address 255 is the so called Broadcast address. All Slaves will listen to this address simultaneously. While selected by the Broadcast address Slaves will only listen to system commands (commands that start with an asterisk * ). Please note that Slaves are not allowed to respond to the Broadcast address, although they are required to listen to system commands. So when selected by the Broadcast address a Slave may not talk back in any way. For example the Broadcast address can be used to reset all devices on the SB-Bus, or to trigger commands that were put in *HOLD. Or you can change the unknown address of a strange or new Slave to a known address, provided this Slave is the only device on the bus at that time.
Whenever a Slave receives an address it must flush its input and output buffers and cancel all activities on the SB-Bus immediately.
This is even true if a selected Slave receives its own unique address again.
You may use this feature to reset a runaway Slave for instance.
The Slave that received its own unique address is now selected and must respond with an OK prompt => within 0.5 seconds.
After sending the OK prompt the Slave will wait for further instructions given by the Master.
At the same time all other Slaves are excluded from conversation.
If an address is not acknowledge by an OK prompt within 0.5 seconds, the Master may assume that the selected Slave is not present on the bus.
I have defined some address ranges for different types of equipment.
Please note that this is only a recommendation, made by myself to make it easier to remember addresses for all the devices that can be connected to the bus.
You are totally free to create your own address map.
The only two fixed addresses are 128 and 255, their purpose can not be redefined.
|Idle address. Slaves may never replay to this address!
|Reserved for an "intelligent" SB-Bus driver.
|Programmers and EPROM simulators.
|Power supplies and battery chargers/meters.
|Electronic measurement instruments.
|Data loggers in general.
|Environment instruments (clocks, thermometers, weather station, thermostat).
|New Slave. Address must be changed as soon as possible.
|Broadcast address. All Slaves must listen to this address, but may never talk.
One of the required properties of the SB-Bus is that it must be able to control it with a normal terminal program.
Therefore we need a way to send addresses to the bus using this terminal program.
We now know that addressing is done by sending ASCII character codes 128 to 255 over the SB-Bus. But how do we send such codes using a terminal program?
On Windows machines this can be done using the ALT key and the numeric keypad on your computer.
The trick is to type the ASCII code on the numeric keypad while holding down the ALT key.
You may have to experiment a little to get it going, because some systems require only the 3 digit code to be typed, while others need a 4 digit code.
In case your system requires you to type a 4 digit code, you must add a leading 0 before typing the 3 digit code.
Some systems also differentiate between the left and right ALT keys, so if you're in doubt try them both.
Examples: ALT-170, ALT-255, ALT-0130, ALT-0150
Most notebook computers don't have a dedicated numeric keypad. But they usually do have a NUM-LOCK key, which transforms part of the Alpha keyboard to a numeric keypad. In that case you should first engage the NUM-LOCK function, then type the ALT-code of the address you want to send. Don't forget to disengage the NUM-LOCK function after sending the address.
On Linux computers you can enter the required codes by holding Ctrl-Shift, while typing uxx, where xx is the hex value of the code you want to type. Unfortunately you'll have to convert the addresses from decimal to hexadecimal first.
If you're not able to send addresses in the above mentioned ways you may have one last option to send addresses with your terminal program.
You may save a file to your hard disk containing only a single byte, which is the address you want to send.
If for instance you want to select Slave 170, you prepare a file named 170.txt containing only one byte with the value of 170. Now each time you send this file you effectively select address 170.
A Slave must know its own address, otherwise it has no way of knowing when it is selected on the bus. I can think of 3 ways to tell the Slave what address it has. You can pick the appropriate method for your own Slaves, depending on its resources and the time you want to spend on writing the software.
By far the easiest way to let the Slave know its own address is to hard code it into the program memory.
The disadvantage of this method is that you'll have to re-compile the entire program if you want to change the address for whatever reason (for instance if you want to connect two identical devices to the same bus).
To overcome the need to re-compile the code whenever the address needs to be changed is by putting the text "@SLAVE=" directly before the byte that defines the Slave address in program memory. That way the Slave address is easy to locate and change with an HEX editor program. But anyway, it still does require you to re-burn the code into ROM memory somehow.
One way to overcome the difficulty of changing a Hard Coded address is to (Half) Hard Wire the Slave's address.
A Hard Wired address is entirely or partially wired through some I/O pins of the processor.
That way we overcome the difficulty to change the address in an easy way.
A totally Hard Wired address needs 7 jumpers or a 7-way DIP switch to setup the Slave address, whereas a Half Hard Wired address can do with less jumpers. A Half Hard Wired address needs part of the address to be defined by hard coding it into program memory. The missing bits can then be supplied by one or more jumpers or DIP switches. Obviously a Half Hard Wired address requires less I/O resources than a fully Hard Wired address.
Soft Coded addresses are obviously the most flexible solution.
A Soft Coded address is stored in the Slave in so called Non Volatile Memory.
This can be a RAM memory with battery backup, or it can be some kind of EEPROM device.
I²C EEPROMs are very cheap nowadays, and even more and more micro controllers come equipped with plenty of EEPROM memory inside.
You can change the address of Soft Coded Slaves by means of the System Command *SLAVE.