UART Protocol


UART Protocol

This document defines how to communicate with the robot on the lowest level. This protocol is used by our native ROS, Python, C++ and C# drivers to abstract this communication away. 

 

Communication Settings

Baud Rate: 57600

Parity: None

 

TX message format

Length: 7 bytes (56 bits)

start byte + left motor + right motor + flipper + parameter 1 + parameter 2 + checksum

start byte: 253

motors speeds: 0 - 250

0 is full speed reverse

125 is stop

250 is full speed forward

parameter 1: see appendix

parameter 2: see appendix

checksum:  255-( Left motor + right motor + flipper + parameter 1 + parameter 2)%255

 

RX message format

Length: 5 bytes (40 bits)

start byte + Data NO + data 1 + data 2 + checksum

start byte: 253

DataNO: Same as parameter 2 of TX message

data1: high byte of the data

data2: low byte of the data

checksum: 255-( Data NO + data 1 + data 2)%255

 

 

Appendix

Table 1 - TX Parameter 1
Parameter 1 Description
10  Request data with param 2
20  Send fan speed with param 2

 

Table 2 - TX Parameter 2
 Param 2 Description Allowable data Comments
0 REG_PWR_TOTAL_CURRENT 0-2048, decimal,
Actual unit to be tested,
Theoretical value: a reading of 34 = 1A
Total current from battery
2 REG_MOTOR_FB_RPM.left N/A Work in progress
4 REG_MOTOR_FB_RPM.right N/A Work in progress
6 REG_FLIPPER_FB_POSITION.pot1 0-1023, decimal, relative position of 15 - 330 degrees of one sensor Flipper position sensor 1
8 REG_FLIPPER_FB_POSITION.pot2 0-1023, decimal, relative position of 15 - 330 degrees of one sensor Flipper position sensor 2
10 REG_MOTOR_FB_CURRENT_left

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 34 = 1A

Left motor current
12 REG_MOTOR_FB_CURRENT_right

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 34 = 1A

Right motor current
14 REG_MOTOR_ENCODER_COUNT.left

Unsigned 16 bit integer 0 - UINT16_MAX.

May overflow or underflow. Increments when motor driven forward, decrements backward

Left motor encoder count.
16 REG_MOTOR_ENCODER_COUNT.right

Unsigned 16 bit integer 0 - UINT16_MAX.

May overflow or underflow. Increments when motor driven forward, decrements backward

Right motor encoder count
18 REG_MOTOR_FAULT_FLAG.left

WIP

Motor fault (work in progress, WIP)
20 REG_MOTOR_TEMP.left

Decimal, celsius

Left motor temperature
22 REG_MOTOR_TEMP.right

Decimal, celsius

Right motor temperature
24 REG_PWR_BAT_VOLTAGE.a

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 58 = 1V

Voltage, battery side a
26 REG_PWR_BAT_VOLTAGE.b

 

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 58 = 1V

Voltage, battery side a
28 EncoderInterval[0]

Number of ticks between two adjacent rising edge signal from motor encoder

Left motor, About 45 us/ Tick, for example, if a value of 100 is returned (100 ticks), then the time it takes to complete a full cycle is 4500 us = 45* 100.
30 EncoderInterval[1]

Number of ticks between two adjacent rising edge signal from motor encoder

Right motor, About 45 us/ Tick
32 EncoderInterval[2]

Number of ticks between two adjacent rising edge signal from motor encoder

Flipper motor, reserved for the future, not in use right now, About 45 us/ Tick
34 REG_ROBOT_REL_SOC_A

%

Battery relative state of charge, 0-100%, data range 0-100 decimal (WIP)
36 REG_ROBOT_REL_SOC_B

%

Battery relative state of charge, 0-100%, data range 0-100 decimal
38 REG_MOTOR_CHARGER_STATE

See comments

0xDADA meaning charging, otherwise, no

battery charger state: 56026

40 BuildNO

See comments

A + mon + date

A= last digit of a year /2

mon=0x

date=0x

For example, a build on 05-09-2018

A=8/2=4

mon=05

date=09

Build=40509

42 REG_PWR_A_CURRENT

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 34 = 1A

Battery a current
44 REG_PWR_B_CURRENT

 

0-1023, decimal,

Actual unit to be tested,

Theoretical value: a reading of 34 = 1A

Battery b current
46 REG_MOTOR_FLIPPER_ANGLE

 0-360, degrees (actual data range needs to be tested)

Flipper angle
48 to_computer_REG_MOTOR_SIDE_FAN_SPEED 0-240, relative fan speed Fan speed (feedback)
50 to_computer_REG_MOTOR_SLOW_SPEED

0 or 1

0 - high speed (low speed off)

1 - low speed

Low speed mode status (feedback)
52 BATTERY_STATUS_A Bit flags

Alarm bits:

0x8000 OVER_CHARGED_ALARM

0x4000 TERMINATE_CHARGE_ALARM

0x1000 OVER_TEMP_ALARM

0x0800 TERMINATE_DISCHARGE_ALARM

0x0200 REMAINING_CAPACITY_ALARM

0x0100 REMAINING_TIME_ALARM


Status bits:

0x0080 INITIALIZED

0x0040 DISCHARGING

0x0020 FULLY_CHARGED

0x0010 FULLY_DISCHARGED

54 BATTERY_STATUS_B Bit flags

Alarm bits:

0x8000 OVER_CHARGED_ALARM

0x4000 TERMINATE_CHARGE_ALARM

0x1000 OVER_TEMP_ALARM

0x0800 TERMINATE_DISCHARGE_ALARM

0x0200 REMAINING_CAPACITY_ALARM

0x0100 REMAINING_TIME_ALARM


Status bits:

0x0080 INITIALIZED

0x0040 DISCHARGING

0x0020 FULLY_CHARGED

0x0010 FULLY_DISCHARGED

56 BATTERY_MODE_A Bit flags Bit 7 (value & 0x80) gives whether battery needs a condition cycle. Other values probably useless
58 BATTERY_MODE_B Bit flags Bit 7 (value & 0x80) gives whether battery needs a condition cycle. Other values probably useless
60 BATTERY_TEMP_A Temperature of battery above absolute 0 in deciKelvins
62 BATTERY_TEMP_B Temperature of battery above absolute 0 in deciKelvins
64 BATTERY_VOLTAGE_A Voltage of battery in mV These are sampled from the SmartBattery itself, compare with PWR_BAT_VOLTAGE, which is estimated from a signal from the motor
66 BATTERY_VOLTAGE_B Voltage of battery in mV These are sampled from the SmartBattery itself, compare with PWR_BAT_VOLTAGE, which is estimated from a signal from the motor
68 BATTERY_CURRENT_A Current of battery in mA These are sampled from the SmartBattery itself,
70 BATTERY_CURRENT_B Current of battery in mA These are sampled from the SmartBattery itself,