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
runsubcommand tellsprobe-rsto flash the board and attach to the output.- The
--chipflag tellsprobe-rswhat the microcontroller is.- The
--preverifyflag tellsprobe-rsto not write if the firmware is identical.- The
--verifyflag tellsprobe-rsto 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 Pin | Transceiver Pin | Line Description |
|---|---|---|
| D2 (PA12) | TXD | CAN TX Line |
| D10 (PA11) | RXD | CAN RX Line |
| +3V3 | VDD | 3.3V Power Supply |
| GND (choose any one) | VSS | Ground |
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 Pin | DB9 Connector |
|---|---|
| CANH | Pin 7 (CAN_H) |
| CANL | Pin 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.