API Reference Hull controller - SergeGit/rc-tank-platform GitHub Wiki
Hull Controller API Reference
1. Overview
The Hull Controller is an Arduino Nano-based subsystem that operates as an I2C slave at address 0x08. It provides low-level control over the RC tankβs hardware components β including tracks, turret motors, lights, weapons, and battery monitoring.
Communication with the controller is handled via a command-response protocol over I2C. The Raspberry Pi (Turret Controller) acts as the master.
2. Command Format
Each command consists of two bytes:
Byte
Description
1
Command code (defines the operation)
2
Data byte (parameter or value)
Data values are often scaled where 100 = neutral / zero point. For example:
0β99 β Negative range (-100% to 0%)
101β200 β Positive range (0% to +100%)
3. Command List
3.1 Motion Commands
Command
Code (Hex)
Description
Data Range
Tracks Move
0x20
Forward/Backward movement
0β200 β -100% to +100%
Tracks Turn
0x21
Turning control (left/right)
0β200 β -100% to +100%
3.2 Turret Commands
Command
Code (Hex)
Description
Data Range
Turret Rotate
0x10
Rotate turret
0β200 β -100% to +100%
Turret Elevate
0x11
Elevate/depress cannon
0β200 β -100% to +100%
3.3 Weapon Commands
Command
Code (Hex)
Description
Data
Laser Toggle
0x30
Laser sight ON/OFF
0=OFF, 1=ON
IR Toggle
0x31
Infrared emitter ON/OFF
0=OFF, 1=ON
Cannon Fire
0x32
Fire cannon (pulse)
Duration (0β255)
3.4 Light Commands
Command
Code (Hex)
Description
Data
Front Lights
0x40
Front light control
0=OFF, 1=ON, 2=BLINK
Rear Lights
0x41
Rear light control
0=OFF, 1=ON, 2=BLINK
3.5 System & Sensor Commands
Command
Code (Hex)
Description
Data
Get Battery
0xE0
Request battery data
N/A
Get Position
0xE1
Request position
N/A
Get Cannon Status
0xE2
Check if cannon ready
N/A
Get GPS
0xE3
Request GPS data
N/A
Get All Sensors
0xEF
Combined telemetry
N/A
Get Status
0xF0
System status flags
N/A
Emergency Stop
0xFF
Stop/resume all systems
0=STOP, 1=RESUME
4. Response Format
Responses depend on the request command. Data is transmitted back to the I2C master when it issues a read request.