Serial Protocol - Page Under Construction

The protocol is essentially what makes the robot work. I have taken considerable time to work out the necessities and arrived at the below set of commands and responses. Within the robot modules are hardware overrides (HO) which will override the software commands, they are used to keep the robot safe from dangers (driving off the stairs etc.) The reason for HO is simple, they arefaster to execute without associated command/response delays associated with protocol control. These overrides are similar to instinctive responses in all living things. In humans for example, if your finger gets burned by unexpected heat source you move your hand away without debating if it is getting too hot and weather you should keep it there or not. After a HO has been raised the module which executed the override broadcasts it's address and why it raised HO, the CPU (also monitoring the HO line) interrogates the module for a reason and takes appropriate action (reverse the robot if hanging on the edge of stairs for example).

The commands described below are requests and responses to and from different modules. Most of the command/response pairs depend on timing so I will also include the timing information in the description.

All modules incorporate an "Initialized" hardware LED to quickly asses if the module will function. When this LED is lit on the given module then the module has received a RESET from CPU and acknowledged it with a configuration response. If this LED is off the module is not initialized and will ignore all commands (even if the commands are addressed to it), it will only listen for a RESET command from CPU. The only "command" that will override this state is HO line. If a HO line is raised then the device will RESET and remain in "not initialized" state. A good example is the Motor Controller, let's assume that for some strange reason the Motor Controller module had become "not initialized" but last set of commands were to proceed forward %50 speed. Motor Controller module has two hardware PWM pins which are used to run the motors in the background and independent of firmware. The module will not listen to any commands from CPU unless it is a RESET command. When the HO line is raised (by a sonar module or a bumper switch module for example) the motor controller will stop all motors and wait for a RESET command from CPU. Problem solved, the CPU will asses the situation and act accordingly.

The first section covers the module discovery on CPU initialization, the Plug and Play functionality. After power reset or when the robot is turned on the CPU loops through 20 addresses starting from 1 through to 20 and sends a Module Reset (MR) command to which it expects a Reset Response (RR) reply. The RR message has two functions, to acknowledge there's a valid module on the address and to send it's configuration data back (Type and number of devices) so the CPU can use it.

Command colour Legend

Green - ASCII character
Red - Hex byte value
Comma - "," Is not actually sent/received, it is only used as a delimiter in the command/response for documentation purposes only and should be ignored.

Each variable between two commas is byte in length, this means it is 1 character only weather it is Binary, Hex or ASCII.

NOTE: CPU address on the serial bus is 000, this is programmed in to the CPU. This address can not be changed.

CPU - RESET Command

Syntax:
<->,Address,R,x,x

Description:
CPU sends this command on the bus to discover attached modules on power up or to reset a particular module after a hardware override. Response must be within 100ms.

Variables:
<-> - String (3 ASCII characters in length) always sent to indicate command/response follows.
Address - Hex byte value. Module address. Valid 0 to 255.
R - Preset ASCII Character.
x - Hex byte value. Don't care.

Responce

Syntax:
<->,Address,R,ModuleType,NumberOfDevices

Description:
Reply to CPU RESET command.

Variables:
<-> - String (3 ASCII characters in length) always sent to indicate command/response follows.
Address - Hex byte value. Module address. Valid 0 to 255.
R - Preset ASCII Character.
ModuleType - ASCII Character. The module type (Motor controller, Sonar, Radar etc.). Valid values are: M = Motor Controller, S = Sonar, I = Infra Red, B = Bumper Switch, R = Radio Telematry, E = Ethernet, P = Passive Infra Red Motion Detector, L = Light Detector, A = Sound detector (Audio), L = Laser Scan, V = Video Camera, G = GPS Receiver
NumberOfDevices - Hex byte value. Number of devices of ModuleType present on the module.

Motor Controller - Commands

Syntax:
<->,Address,Motor,MotorDir,MotorSpeed/Degrees

Description:
CPU sends this command on the bus to Motor Controller. This command determines Motor/Direction and Speed. This command in SINGLE mode can be used to control a single motor or in COMBINED mode it can be used to control multiple motors to perform a task. There is no associated response to this command.

Variables:
<-> - String (3 ASCII characters in length) always sent to indicate command/response follows.
Address - Hex byte value. Module address.Valid 0 to 255.
Motor - Hex byte value. Motor Number. Valid values for SINGLE mode are: 1 - Motor 1, 2 - Motor 2, 3 - Auxilary Motor 1, 4 - Auxilary Motor 2. NOTE: Auxilary motors are controlled through software PWM not hardware.
Motor - ASCII character. Motor command. Valid values for COMBINED mode are: A - All (Motor 1 and 2), L - Turn LEFT Degrees degrees, R - Turn RIGHT Degrees degrees. NOTE: Auxilary motors are not controlled in COMBINED mode.
MotorDir - ASCII character. Motor Direction for SINGLE and COMBINED modes. Valid values are: F - Forward, R - Reverse
MotorSpeed/Degrees - Hex byte value. Percent of Maximum Motor Speed in SINGLE mode or Number of Degrees in COMBINED mode. Valid values for SINGLE mode are: 0 to 100. Valid values for COMBINED mode are: 0 to 255. NOTE: To turn more than 255 degrees in COMBINED mode you need to issue a second command. In SINGLE mode a value of 0 denotes a STOP command and a value of 1 denotes Minimum Speed command.

 

Website hosted by WWW.EazySiteHost.Com