CAN Bus Sensor Framing
📌 What is this for? (Quick Summary for New Interns)​
In Simple Words:
A hyperloop pod has dozens of microcontrollers: one reading battery cells, another measuring motor temperatures, another measuring wheel speed.They all talk over a shared pair of twisted copper wires called a CAN bus (the same standard used in modern electric cars).
Instead of sending long English sentences, CAN sends tiny 8-byte binary packets for extreme speed and noise resistance.This page is the decoder ring that explains which packet ID contains which numbers.
1. How a CAN Message Looks​
Every message has an ID (identifying what kind of data it is) and an 8-byte payload:
+-------------------+---------------+------------------------------------+
| CAN ID (2 Bytes) | Length (1 Byte)| Payload (8 Bytes) |
+-------------------+---------------+------------------------------------+
| e.g. 0x00 0x16 | 0x08 | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 |
+-------------------+---------------+------------------------------------+
2. The CAN Message Table​
| CAN ID | Hex Name | What Numbers Are Packed Inside? |
|---|---|---|
0x16 | Velocity & Accel | • Bytes 0-3: Forward Speed (float32, meters per second) • Bytes 4-7: Acceleration (float32, m/s²) |
0x17 | Battery Voltages | • Bytes 0-3: Internal Battery Pack Voltage (float32, Volts) • Bytes 4-7: Output Voltage after main switch (Must be > 48V to launch) |
0x18 | Battery Temps 1 & 2 | • Bytes 0-3: Cell Module 1 Temp (°C) • Bytes 4-7: Cell Module 2 Temp (°C) |
0x19 | Battery Temps 3 & 4 | • Bytes 0-3: Cell Module 3 Temp (°C) • Bytes 4-7: Cell Module 4 Temp (°C) |
0x1A | Inverter Temps A & B | • Bytes 0-3: Phase A Motor Drive Temp (°C) • Bytes 4-7: Phase B Motor Drive Temp (°C) |
0x1B | Inverter C & Battery % | • Bytes 0-3: Phase C Motor Drive Temp (°C) • Bytes 4-7: Battery State of Charge (0.0 to 100.0%) |
0x1F | Safety & Drive Status | • Byte 0-2: Gate A/B/C fault flags (1 = healthy, 0 = fault) • Byte 3: Emergency line (1 = OK, 0 = trip) • Byte 4: Drive active (1 = driving, 0 = stopped) |
0x21 | LIM Motor Temp | • Bytes 0-3: Linear Induction Motor core stator temperature (°C) |
3. How to Pack These Bytes in Python​
If you are writing simulation scripts, Python's built-in struct module lets you pack numbers into exact CAN bytes:
import struct
def make_can_frame(can_id, num1, num2):
# '>H' = 2 bytes ID, 'B' = 1 byte length (8), '>ff' = two 32-bit floating point numbers
return struct.pack('>HB', can_id, 8) + struct.pack('>ff', float(num1), float(num2))
# Example: Send Speed = 16.67 m/s (60 km/h) and Accel = 2.0 m/s^2 on CAN 0x16
packet = make_can_frame(0x16, 16.67, 2.0)
socket_client.sendall(packet)