Flow Chart




The embedded software was written in Atmel's assembly language. A high level language and cross compiler wasn't used because of the high amount of overhead needed in the program memory space.

Communications Protocol

Communication Settings

The communication is set to 9600 baud. This was selected because of its reliability and that it is still fast enough to appear instantaneous to a human. There is one start bit, eight data bits, one address bit and one stop bit.

The Address bit is instead of a more standard parity bit. Its use is to allow the receiving microprocessor to know if the byte received is actually an address. This was further exploited to indicate a new command to the microprocessor from an external microprocessor. When the address bit is reset, the associated byte is data. The loss of use of the parity bit is not a problem for error detection and will be further discussed below.


There are only two sizes of packets in this system. Single byte packets are used to grant and refuse access to the communication lines. Four byte packets consist of a command byte, two Data bytes and a Check Sum. These four byte packets are used for the Slave and Master Broadcasts. The command byte consists of 3 opcode bits followed by 5 address bits indicating the target address of the command if necessary. The first of the two data bytes is the current state byte. This byte indicates which LEDs are not off. Following this is the current flash byte that indicates which of the LEDs are flashing. For an LED to flash, the respective bit in the current state and current flash bytes must be high. The checksum byte is the least significant byte of the sum of the first two data bytes.


In order to negate the possibility of two nodes communicating simultaneously, a Master/Slave relationship was developed between the nodes. The Master Node maintains full control of all communication. It dictates which slave is permitted to take control of the communication lines. Any new information from a Slave is reviewed by the Master. The Master will only allow itself to be updated with a new state when it decides that the new data would be consistent with the press of only a single button.

A further reason to use a Master/Slave system is to ensure that a node does not have incorrect data prior to communicating. The check for the single button press eliminates errors due to  a Slave being not synchronized with the master. Also, a periodic update from the Master all Slaves further reduces the possibility of synchronization errors.


In order for the Master to know how many Slaves are under its command, it is always set at the highest address. For example, in a 3 node system, one Slave would be address 1, another would be address 2, and the Master would be address 3. Rather than set these addresses via additional dipswitches or at the programming stage, a button was added that would put the node into “Address Mode”. The address is displayed on the LEDs and the respective switches can manipulate the address. The binary representation of the address is displayed on LEDs 0 to 4. LED 6 is set high if the node is the Master, and Low for Slaves. LED 5 serves as a space between the address bits and the Master/Slave bit and is always low. LED 7 is high to signify that the node is currently in address mode. Once the address mode button is pressed again, the address is overwritten in EEPROM and the node is reset.

 Watch Dog Timer

To guarantee that the system will not hang if the Master Node Address is set too high, or when a Slave Node fails to respond, a Watch Dog Timer was implemented. The watchdog was set at 16ms. If the watchdog timer expires, the master will grant permission to the next node in the system.

Master Error Checking

The Master keeps close watch over the responses from the Slaves. First, the data must pass the check sum test. The data will only be accepted if it represents a single state change from the current master state. These state changes include a single LED to going from off to flashing, flashing to solid or solid to off. Therefore, there are only 8 combinations of the received command that will result in a change of the Master data. Each byte corresponds to 9 bits including the Address bit, this makes the possible number of combinations 236. This results in a probability of random data being accepted 1 in 8,589,934,592

Slave Error Checking

The Slave stores data from Slave broadcasts and Master broadcasts separately. Once the Master broadcast is complete, the Slave performs 5 tests on the 6 received bytes to ensure that flawless communication occurred. If it detects that too many consecutive errors have occurred, it will enter an error state by flashing all of its LEDs at 4Hz until communication is re-established.



Every 32ms, the keypad buttons are polled. Once a low to high transition is detected, the button press is buffered. The node accepts the input data only if one button is being pressed. This is to add to the stability of the individual node even though the master would not accept such data. 

The Address Mode button is connected to interrupt pin IRQ0. Having the button cause an interrupt ensures that priority is given to the user configuring the system.

Output LEDs

The output LEDs have 3 states: off, on and flashing. The flashing state was implemented as a distinct method of indicating a new message. Solid on is an acknowledgement of a message and a reminder that it still needs to be dealt with. The off state removes the message indication from the display.

Smooth display updating

If new data is directly written to the display, noticeable glitches would be observed. These glitches are disruptions in the 4Hz flash. Code was written to update the display at the instant when the flashing lights are in an on state.



Home ] Up ] Flow Chart ]

Last modified: August 01, 2001