Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Setup

This section will guide you through how to setup the AMS Controller with the BMS and test it to ensure that it works.

Hardware Items

  • STM32 Nucleo G431KB
  • CAN Transceiver (e.g. Microchip MCP2561)
  • Prohelion D1000 Gen 2 w/ Modules

Flashing the Firmware

Important

If the Nucleo has already been flashed with the correct firmware then this step isn’t needed.

If you’re building from source then see building from source, otherwise this section is assuming you’re flashing prebuilt firmware to the board.

To flash the prebuilt firmware, you can use any tool which supports flashing ELF binaries. This tutorial will use probe-rs as the tool to flash since it can automatically hook into the logging outputs. To install probe-rs, see their website.

Once you’ve downloaded the firmware into a directory, open up a terminal and flash the board by running:

probe-rs run --chip STM32G431KB --preverify --verify [[PATH TO FIRMWARE]]

Note

To quickly explain this command:

  • The run subcommand tells probe-rs to flash the board and attach to the output.
  • The --chip flag tells probe-rs what the microcontroller is.
  • The --preverify flag tells probe-rs to not write if the firmware is identical.
  • The --verify flag tells probe-rs to read back what was written and ensure it is correct.

Once you start getting logging output from the board which will be indicated by output which has INFO, you can then Ctrl+C to exit from probe-rs and disconnect.

Setting up the Hardware

Note

This assumes you’re using a breadboard and not a perf board.

On the breadboard, add both the Nucleo board and CAN transceiver and then grab some breadboard wires to connect them up. The wiring is as follows:

Nucleo PinTransceiver PinLine Description
D2 (PA12)TXDCAN TX Line
D10 (PA11)RXDCAN RX Line
+3V3VDD3.3V Power Supply
GND (choose any one)VSSGround

Additionally, the Nucleo board is connected to the ready to drive (R2D) line, which terminates at the A0 pin. For testing purposes, connecting this line to ground will set R2D to low (preventing engagement) and connecting it to power (i.e. floating) will set R2D to high.

Important

The firmware only cares whether the R2D line is driven low or not as it assumes the line will be floating when R2D is enabled.

Now that the board is setup, it can be connected up to the BMS and used.

Caution

Neither the BMS or the AMS Board should be powered during this process as the firmware will enable the accumulator if the R2D line is not pulled low.

The BMS provides a male DB9 connection for use by the AMS or other peripherals, to connect the CAN transceiver to the BMS, the wiring is as follows:

Transceiver PinDB9 Connector
CANHPin 7 (CAN_H)
CANLPin 2 (CAN_L)
GND (From Nucleo Board)Pin 3 (GND)

Once everything is connected, connect the R2D line to ground to prevent automatic engagement of the accumulator. After this, power up the BMS and the AMS board and then connect the R2D line to the +3V3 line on the Nucleo to allow it to engage the accumulator.