Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

We are using WaveSculptor22 for motor controller, see TritiumWaveSculptor22_Manual.pdf (tritiumcharging.com) for docs.

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.

...

(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, and the other communicate communicates to the rest of the car referred to as CAN. MC-CAN is through CAN FD, which has 5x the speed of regular CAN! This is needed to keep up with wave-sculptor timing requirements.

Task

  1. CAN rx, MC-CAN rx

  2. process msgs sent by CAN rx, update any states

  3. process msgs sent by MC-CAN, update any states

  4. build messages for MC-CAN and CAN

  5. CAN tx, MC-CAN tx

Can Messages

WaveSculptor’s broadcast messages can be found TritiumWaveSculptor22_Manual.pdf (tritiumcharging.com) section 18.4

...

Code Block
1:
- velocity left: int16 (mmcm/s)
- velocity right: int16 (mmcm/s)
2:
- voltage left: uint16 (mVcV)
- current left: uint16 (mAcA)
- voltage right: uint16 (mVcV)
- current right: uint16 (mAcA)
3:
- limit_bitset left: uint8_t
- error_bitset left: uint8_t
- limit_bitset right: uint8_t
- error_bitset right: uint8_t
- board_fault bitset: uint8_t
- overtemp bitset: uint8_t
- precharge_state: uint8_t
4:
- motor_temp left: uint16_t (C/100)
- heatsink_temp left: uint16_t (C/100)
- motor_temp right: uint16_t (C/100)
- heatsink_temp right: uint16_t (C/100)
5:
- dsp_temp left: uint32uint16_t (C/100)
- dsp_temp right: uint32uint16_t (C/100)

Precharge:

In the firmware precharge is a monitor pin which gets toggled LOW when precharge is complete. We use a falling_edge interrupt to verify that precharge has occurred. Once it has happened we toggle the MCI_RELAY, closing the connection with the motor controller and the pack.

Precharge Monitor (FALLING EDGE) → Close MCI_RELAY

Electrically (IMPORTANT TO KNOW!), the precharge circuit charges up all capacitors in the wavesculptor22. Initially, all capacitors act as short circuits, meaning a large in-rush current will flow in once connected to the pack. This can severely damage our motor controllers. We can limit inrush current by having a 5W resistor in series with MOTOR_GND and ISO_GND.

During start-up, precharge equalizes MOTOR_GND and ISO_GND, achieving 0 potential difference. Initially, the current will flow between MOTOR_GND and ISO_GND, holding our monitor pin HIGH (Optocoupler). When precharge is complete no more current will flow, and our monitor pin will be LOW.