The 4E network is a low bandwidth network that allows the many embedded devices on Slugfest to communicate with servers. It uses half duplex RS485 wired in a bus configuration. Each device (including the server) has a tristate RS485 driver connected to a common pair of wires. RS485 is simply a variation on the traditional serial port, making it extremely easy to generate the signals from both a $3 microcontroller and a computer.
Since all the devices are wired together, a simple protocol is imposed to allow individual devices to be addressed. A simple mechanism for collision avoidence is also implemented, but is likely unnecessary because of the extremely light traffic.
The 4E network is built around the DS751768N IC from National. It is a half-duplex tristate RS485 driver that takes CMOS input.
The server is a 30 port Portmaster 2e serial port server located in the Goodale lounge. Several of the serial port connect to the 4E network through RS485 drivers. A MAX232 IC converts the 5V signal from the RS485 driver to/from the higher voltage levels used by the serial port. An RC circuit is used to control the tristate from the transmit line.
There is nothing that makes this node special other than the fact that it is the only bridge between the 4E network and the Internet.
Each device contains a 16f series PIC microcontroller with a built in USART (serial port). The serial port is simply connected to an RS485 driver with a thrid IO pin on the PIC controlling the tristate.
The 4E network requires one twisted pairs. Becuase the 4E network is a bus, adding a new node is as easy as tapping off the closes existing node. Currently, Shallow Walcott, Bemis, and Shallow Goodale bathrooms as well as both lounges have 4E network wiring.
Each bathroom recieves 2 cat 3 cables for Bemix, one for signal and one for power. The signal cable is pinned as shown below
|Green with white||Tx/Rx+|
|White with green||Tx/Rx-|
|Orange with white||unused|
|White with orange||unused|
|Blue with white||Left audio|
|White with blue||Audio ground|
|Brown with white||Right audio|
|White with brown||Audio ground|
For the power cable, all colored wires are +12V and all white wires are ground.
Connecting to the 4E Network
The portmaster serial port server is accessed through telnet:
- administrative - port 23
- 4E network, debug - port 6020
- 4E network, primary - port 6025
- 4E network, Rx only-port 6026
All data sent over the 4E network is encapsulated in packets. The packet format is outlined below:
- header code (2 bytes) = escape character + header character
- header (3 bytes)
- data (variable length)
- end code (2 bytes) = escape character + end character
- escape character = '\'
- header character = 'H'
- end character = 'E'
The header contains three 1 byte fields:
- destination address: This allows the server to route packets from one client to another.
- source address: This allows one client to respond to a request made by another client.
- port: This tells the device what type of data to expect and how to processes it.
Note: If the escape character needs to be transmitted in the data block, two should be transmitted instead.
Each device, including the server, is a assigned a unique address.
- 0 = unused
- 1 = server
- 66 (B) = Bemis
- 67 (C) = control panel
- 71 (G) = shallow goodale
- 87 (W) = shallow walcott
- 92 (\) unused
- 255 = broadcast, all devices listen (not yet implemented)
Ports can include:
- 31 - debug
- 32 - ping
- 64 - Bemix
- 65 - control panel
Other possible ports include:
- EEPROM - for storing data that is currently hardcoded but shouldn't be
- programming - so the PICs can download their own software
How to control Bemix
When a Bemix client is booted, it sends a packet to the server containing "Bemix v3.0" over the debug port.
Touch Switch Output
The Bemix clients will send an ASCII number 1 through 5, corresponding to the 5 touch switches. The PIC can be programmed to send a single packet when a switch is touched or a continuous stream (at adjustable repeat rate) when it is touched.
Example: touch switches 1 and 5 are touched on device 70 which is programmed to tell device 1 (the server)
'\' 'H' 01 70 64 1 '\' 'E' '\' 'H' 01 70 64 5 '\' 'E'
Touch Switch Recalibration
The touch switch may be recalibrated by disabling it then reenabling it. This is done by sending a packet containing "D" followed by "E" over the Bemix port:
'\' 'H' 70 01 64 'D' '\' 'E' '\' 'H' 70 01 64 'E' '\' 'E'
Bemix clients will respond to a packet over the pinging port with an empty packet over the same port.
Example: server pinging device 70 and its response
'\' 'H' 70 01 32 '\' 'E' '\' 'H' 01 70 32 '\' 'E'
One possible use of pinging is to build a routing table by sending a pinging each serial port to map serial port numbers to device addresses.
- Make it so that messages not addressed to the PIC don't overwrite the recieve buffer
- Make code modular
- Fix bugs with reception
- Store PIC's address in EEPROM, be able to send an address and data pair and have PIC write it to EEPROM
- Make devices listen to address 255
See Bemix PIC code.