Motivation
The motor controllers (MC) are a third-party board with a custom CAN communication protocol. The MC must send and receive messages to the driver controls (DC), however because the MC protocol is strict and thorough it requires abstraction from the rest of the system. The motor controller interface (MCI) handles this abstraction.
Components
Moter Controller (MC)
MCI must transmit to MC every 250ms or else the MC will shut down. This will be a periodic (200ms) task.
MCI will receive updates on measurements of voltage and current, these will be transmitted to DC.
(Try to see if it’s possible to use can.h to control two can controllers simultaneously, if not, use mcp2515
needs to be migrated to fwxv)
Driver Controls (DC)
MCI will receive can msgs from DC requesting to set the car’s drive state. MCI then sends the message to MC.
MCI will transmit voltage and current updates to the main CAN line.
Can
There are two can lines, one communicates only to MC referred to as MC-CAN, the other communicate to the rest of the car referred to as CAN.
Task
CAN rx, MC-CAN rx
process msgs sent by CAN rx, update any states
process msgs sent by MC-CAN, update any states
build messages for MC-CAN and CAN
CAN tx, MC-CAN tx
Can Messages
WaveSculptor’s broadcast messages can be found TritiumWaveSculptor22_Manual.pdf (tritiumcharging.com) section 18.4
WaveScultpor drive command message can be found in section 18.2
Drive commands to the MCI:
id:
MCI status messages, groups by motor controller:
id: target: data: velocity: uint8_t (m/s) ? rpm: uint16_t or uint32_t depending on motor max rpm bus_voltage_v: uint32_t bus_current_a: uint32_t mc_limit_bitset: uint8_t mc_error_bitset: uint8_t motor_temp_c: int8_t ? heatsink_temp_c: int8_t ? dsp_temp_c: int8_t ?
FSM
There will be fsm to make sure state transitions are valid, valid transitions are
FSM starts in the off state