![]() |
Serial Wombat 18AB Firmware
|
Ascii Commands
Wombat commands are all eight bytes long, and Wombat responses are eight bytes long. The first byte is a command byte. The meaning of following bytes varies depending on the command byte. In some cases padding bytes are added to the end of simple messages to achieve eight bytes. Padding bytes are set to 0x55 (see resyncing, below). Some functionality may require multiple messages to invoke. Multi-byte values are transmitted most-significant byte first.
The most important compromise of the Wombat serial protocol is its susceptability to loss of synchronization with the host. This can occur if the host sends a partial message or if environmental conditions cause communication problems or a Wombat reset. If the Wombat interprets the second or later byte of a message to be the command (first) byte, then it will act on that byte when eight total bytes have been received.
When a loss of synchronization is suspected the host should send 0x55 (ASCII 'U' ) eight times. 0x55 is a special value which is discarded when received as a command byte. After this sequence is received the Wombat will always be ready to receive a command.
There are a number of steps the user can take to detect and prevent loss of synchronization:
For example, suppose the host intends to send two commands. After four bytes of the first message are sent an electrostatic event causes the Wombat to reset. The fifth byte is missed all together during the reset. The Wombat comes out of reset and receives the 6th, 7th, and 8th byte of the first message, which it interprets as the command, 2nd and 3rd byte of a new message. The host waits for a response, which never comes. The Wombat recieve timeout occurs because a 4th byte never comes, and the message is discarded. The Wombat is now ready to receive a new message, and the host is prepared to send one because no response came. In following the resyncing recommendations above, the host will send 0x55 eight times, then send a new message. Note that in the above example the Wombat must be configured to enable receive timeout when coming up from reset. See the section on EEPROM for more information. |
The Serial Wombat has the ability to add an additional 9th byte to the beginning of each command packet. This allows more than one Wombat to share a serial connection. This is achieved by connecting all of the RX pins on the various Wombats together and to the TX from the host or RS232 voltage converter chip logic output. The Wombats' TX pins are connected to the input of a "logic AND" chip. The output of the "logic AND" is fed to the host, or to the RS232 voltage converter chip logic input.
This scheme is possible in the PC to Wombat direction because the transmissions from the PC go to all Wombats. However, if the 8 byte packet is not preceeded by the proper 8-bit address, then the Wombat will ignore the message. Note that one can enable addressing with only one Wombat in order to improve the reliability of communication. If the host and Wombat get out of sync then any packet which appears to start with the wrong address will be ignored.
This scheme is possible in the Wombat to PC direction because a Wombat will only speak immediately after spoken to. This prevents the possibility of a bus collision, assuming that only one Wombat assumes it's being spoken to at a time (due to addressing). In order to prevent a physical voltage conflict, the transmit outputs of all Wombats are fed into a logical AND chip. The output of the AND is fed to the host, usually by means of a voltage converter. An AND chip is used because the natural idle state of a logic-level UART is high. Therefore, a "speaking" Wombat will occasionally pull the line low, while idle Wombats will remain high. Therefore, the desired output from the "speaking" Wombat will propogate through the AND chip. Should more than one Wombat attempt to speak at a time, the result will likely be garbled.
In order to talk to multiple Wombats in an addressed manner it is necessary for each Wombat to have a different address, and for the host to know that address. A Wombat can be assigned an address in a number of ways.
Sometimes it may be desirable to send one command to all of the Wombats on a bus. Any packet sent with an address of 0xFF will be processed by all Wombats, but no Wombat will send a response (because simultaneous responses would cause conflict on the bus).
The character 'U' (0x55) will be discarded if received as the address byte.
Serial Wombat commands fall into two broad categories: