Underwater Robot Control System



ROVotron has two microcontrollers: one in the transmitter to convert the PlayStation2 controller data into tether data, and one in the receiver to convert tether data into motor controller commands.

The software is written in the C18 variant of C for the Microchip PIC18F series of microcontrollers.

April 23 - The software is now nearly fully operational. It has been used to drive Babs, our ROV, in a swimming pool. The telemetry display has been made to work. The configuration system works well. The only things left to do are activate the switch control code and provide commands to permit backing up the configuration to the ROV's non-volatile memory.

See the source files here:

rtxa.c Transmitter main source file

config.c Transmitter configuration source file

rtxa.h Transmitter header file

rrxa.c Receiver source file

Command format

The serial interface up and down the tether is human-readable data sent as hexadecimal characters. The advantage of human-readable data is ease of debugging control problems. It is possible to connect the tether serial data line to a PC COM port to observe the data stream if needed.

The ROVotron command format is shown in detail below.

Command message:


There are 10 motor channels and 4 PWM servo channels. Data are 8 bits per channel. The data values are: full backwards or left is 0x01, neutral is 0x80, full forward or right is 0xff. Motors 1 and 2 are in slot 1, motors 3 and 4 in slot 2, etc.

Switch commands each have one byte of data: 0 for off and A for active. There are 10 switches, two per ESC2. Switch 1 is NO, switch 2 is NC. Switches 1 and 2 are in slot 1, switches 3 and 4 in slot 2, etc.

Reply message:


We can display the commands on the LCD screen for diagnostic purposes as below.

Run Sw: 0AAA000000
M0: 80 C5 80 72 95
M5: 62 80 80 80 80
P0: 45 80 80 9F

A related task is to receive a stream of telemetry data and and display this on the LCD screen.

Depth: 1023 mm
TorpV: 35.4 VDC
Temp1: 34.5 DegC

Transmitter software

PS2 controller input

There is PS2 controller code available at CuriousInventor, written in the MPLAB C18 variant of C. We have modified this code to handle two controllers and to place the data into arrays for use by the translation software.

Command translation

The primary task of the transmitter microcontroller is to translate the PS2 controller's control encoding into a form suitable for transmission down the tether cable. The PS2 controller provides analog position for each button and joystick, as well as a pair of bytes with single-bit status of each button. This must be translated into ROV command information consisting of a speed/direction value for each motor and an on/off byte for each switch.

To ensure that the ROV can actually be controlled with one PS2 controller, an example mapping of PS2 axes to ROV axes is given below.

ROV axisControl
Move fore-aftRt joy up-dn
SteerRt joy side-side
Move side-sideL joy side-side
Move up-downL joy up-dn
Tilt up-downL trigger
Manip closeL button up-dn
Manip rotateL button side-side
Camera tiltR trigger

This leaves the R button diamond unused.


The microcontroller allows the operator to assign joysticks and buttons to ROV control channels as desired to produce the most natural control arrangement. A 4 line by 20 character LCD displays configuration menus.

Configuration mode is entered by pressing the SELECT button. The START button goes back to run mode after asking to save the updated configuration in non-volatile memory.

Each item has a label and some parameters. The labels are in a list which is compiled into the program. So to add a label to the list, the code needs to be recompiled. The parameters are described in detail in each screen description below.

The motor configuration screen is shown below. The items in brackets are fields. Only the selected field will actually be shown in brackets, to let the user know which field is currently being modified.

[Motor ][3A ][Speed]
[Rt Front Up/Down  ]
Pri:[L Joy X ][+68%]
Sec:[L Joy Y ][-31%]

The upper-left corner of the configuration screen shows which type of item is being configured. Top center is the number of the spicific item being configured. The upper-right corner displays the operating mode of the item, speed or rate of change of speed.

The second line is a text label that identifies the function of the item. It's selected from a long list stored in the software. Adding new labels requires recompiling the RTXA code after editing the header file labels.h.

The third line contains the primary axis control name, selected from a list. This is the name of the PlayStation controller button pair or joystick axis used to operate this function. At the right is the gain of the control, variable from -99% to +99%.

The fourth line is the secondary control axis. A secondary control name and gain is set for paired motors driven in coupled mode, for example a left/right thruster motor pair that is steered with the X axis of a joytstick and driven forward/reverse by the X axis of that joystick. In that case, the left secondary gain would be negative for the right motor and positive for the left motor. When not used, the secondary axis feature may be disabled.

The servo screen is identical to the motor screen.

[Servo ][ 1 ][Speed]
[Camera up/down    ]
Pri:[R Trig  ][+57%]
Sec:[--off-- ][ +0%]

The switch configuration screen is similar, but without the gain fields. The modes are On-Off or Momentary.

[Aux Light         ]
On: [Triangle]
Off:[Cross   ]

[Switch][1NO][Mom. ]
[Torpedo 2 Launch  ]
On: [Box Sw 2]

Configuration is done one ROV channel at a time. First, the user sets the function name (e.g., Left fore-aft motor). Then the user scrolls through a list of control axes and selects one. Then the user sets the gain of the channel. Range is -100% to +100%.

The telemetry display format may be configured in the setup menu. The parameters for each channel are decimal places, units and label, zero and gain.

[Telem.][ 1 ][ 0.00]
[m Depth           ]
Zero:[ +0.00]
Gain:[ +3.43]

The Zero field is set to a reference point such as icewater for temperature or atmospheric for depth. The value in the field is adjusted to match the measured parameter using another measuring device.

The Gain field is set the same way, but at a specific water temperature or water depth, for example. The value displayed is adjusted to match the measured parameter using another measuring device.

The computer is now able to scale the telemetry data to display it in the user-specified units.


The PS2 controller navigates the menus. The proposed navigation is thus:

One field on the screen is always selected. It is highlighted by surrounding the field in square brackets.

The left button diamond moves around on the screen, selecting another field when pressed. The navigation may be simply that left moves to the next field and right moves to the previous field, or it may be geographical. Experiment.

The right diamond modifies the selected value. It has upper and lower limits (it doesn't wrap the value). Button pressure determines the value changing rate, from one per push to ~40 per second with hard pressing. Experiment.

There are two types of fields: text and numeric. Numeric would like variable-rate selection. Text might as well.

Saving Data

Configuration parameters are stored in EEDATA memory in the microcontroller. This allows the box to retain its configuration between power cycles. The configuration is saved when configuration mode is exited.

PS2 Controller information

The PlayStation2 controller is well documented on sites such as the Curious Inventor.

There are four joystick axes:

There are six control button pairs:

Left Cross XLR - LL
Left Cross YLU - LD
Left TriggerL1 - L2
Right Cross XRR - RL
Right Cross YRU - RD
Right TriggerR1 - R2