Serial electrical spec
Serial data will be transmitted by the computer and output either via RS-232 (DB9) and converted to TTL (5V) levels by a MAX232, or via USB and converted to TTL by an FTDI chip. The TTL-level serial will be fed into the input of a MAX485 which drives balanced RS-485 data lines capable of long distances and multi-drop connections. The chosen connector and cable for the serial data is RJ45 (Cat5).
Each panel will have a single MAX485 connected to the balanced data lines, whose output pin (TTL-level serial) connects to the Rx pin of both ATMega chips.
For information regarding the MAX485 + ATMega168, see this blog post
Purchasing note: We should actually use the SN75176B as an alternative to the MAX485 (it's $0.88 rather than $3.12). See this blog post for anecdotal evidence that it works just fine. Maxim has a comparison of these two ICs
Serial communication occurs at 38400kbps, with 1 stop bit and even parity.
Serial Protocol Revision 1.0 Draft
There will be two different firmware versions: RGB and UV. Through efficient use of preprocessor magic, it should be easy to design a single set of code that will easily compile to both firmwares.
Packet Format: [SYNC] [ACTION] [ARG1] [ARG2] ... [ARGn]
where the number of args (n) is determined by the ACTION.
[SYNC] is fixed to 170 (0xAA); no other byte can have this value. The following table describes the actions and their arguments. RGB Panels are "front" if their address is in [0,7] and "rear" if in [8,15]. The address is set with the DIP switches at system startup.
If an RGB panel is not in emergency mode and fails to receive any serial data (valid for that controller or not) in 5 seconds, it switches to standalone mode, where it randomly cycles through colors at varying speeds until it starts getting data again. The UV/white lights turn off if they are still on after 5 seconds, again, unless they are in emergency mode.
Arguments to commands (such as RGB values) can range from 0-255, but MUST SKIP 170 (0xAA) since that's the sync byte value.
|Value||Action||Action Name||Affects||# Args||Arg Fmt||Description|
|254||EMGCY||Emergency Lighting||RGB, Wht||0||Turns RGB panels to white, turns the white LEDs on, and turns the UVs off|
|253||EVOFF||Everything off||RGB, UV, Wht||0||Shuts everything off|
|252||FPANL||Front RGB LEDs Set All||RGB||3||[RED] [GRN] [BLU]||Sets the values of all front panel LEDs|
|251||RPANL||Rear RGB LEDs Set All||RGB||3||[RED] [GRN] [BLU]||Sets the values of all rear panel LEDs|
|250||UVSET||UV LEDs Set All||UV||1||[UV]||Sets the value of all UV LEDs|
|249||WHSET||White LEDs Set All||Wht||1||[WHT]||Sets the value of all white LEDs|
|248||STRBE||Pulse Strobe||Wht||0||Pulses all whites on for a short period of time (probably 1ms), after which they automatically shut off|
|247||FDISP||Front Panel Set All||RGB||12||[RED0] [GRN0] [BLU0] [RED1] [GRN1] [BLU1] [RED2] [GRN2] [BLU2] [RED3] [GRN3] [BLU3]||Sets the 4 RGB LED's for all of the front panels|
|246||RDISP||Rear Panel Set All||RGB||12||[RED0] [GRN0] [BLU0] [RED1] [GRN1] [BLU1] [RED2] [GRN2] [BLU2] [RED3] [GRN3] [BLU3]||Sets the 4 RGB LED's for all of the rear panels|
|245||UVSTB||Pulse UV Strobe||UV||0||Pulses all UV on for a short period of time (probably 1ms), after which they automatically shut off|
|16-24||UVWAD||UV/White Address||UV, Wht||2||[UV] [WHT]||Sets the UV and white values for a single light|
|0-15||RGBAD||RGB Address||RGB||12||[RED0] [GRN0] [BLU0] [RED1] [GRN1] [BLU1] [RED2] [GRN2] [BLU2] [RED3] [GRN3] [BLU3]||Sets the individual red, green, and blue values for all lights on a given panel|