- CAN Library
- 1 Overview
- 2 Usage
- 3 CAN Message Documentation
Branches:
main
: Stores all files and latest changes.stm32
: StoresFEB_CAN_ID.h
file. This branch is a shared submodule for all STM32 projects.
STM32 Files:
FEB_CAN_ID.h
: A header file that stores all CAN Message IDs.FEB_CAN.c
: A file that handles CAN library initialization and received message handling. Additional CAN files will build of this one. File contains template code for writing additional CAN files.FEB_CAN.h
: Header file forFEB_CAN.c
.
Other files:
FEB_CAN_ID.csv
: A CSV file that stores names of CAN messages without assigned CAN IDs. This file is used to generate dynamic CAN IDs.FEB_CAN_Static_ID.csv
: A CSV file that sores names of CAN messages and their assigned CAN ID.generate.py
: This file uses data fromFEB_CAN_ID.csv
andFEB_CAN_Static_ID.csv
to generateFEB_CAN_ID.h
.feb_can_id.py
: A Python file that stores all CAN Message IDs.README.md
: Documentation for the CAN Library.
-
Add: Install submodule into STM32 project, in Core/Inc/FEB_CAN_Library. Example command for BMS project is provided below.
git submodule add -b stm32 [email protected]:Formula-Electric-Berkeley/FEB_CAN_Library_SN3.git BMS/Core/Inc/FEB_CAN_Library
Command template.
git submodule add -b stm32 <CAN Library GitHub URL> project_name/Core/Inc/FEB_CAN_Library
-
Update: Run this command periodically to update the CAN library for STM32 projects.
git submodule update --init --remote --recursive
Updating the library is a 2 step process, across branches main
and stm32
.
Git Branch: main
- Add CAN Message: To add a CAN message with a static CAN ID, update
FEB_CAN_Static_ID.csv
file. To add a CAN message without a static CAN ID, update theFEB_CAN_ID.csv
file. - Generate: Run
generate.py
script. This will update theFEB_CAN_ID.h
header file. - Documentation: Document the new CAN message in this readme file.
- GitHub: Commit and push changes to GitHub.
Git Branch: stm32
-
Update: Fetch changes from main branch.
git checkout main -- FEB_CAN_ID.h
-
GitHub: Commit and push changes to GitHub.
Note: Bytes and bits are 0-indexed. Multi-byte data is stored in Big-Endian format.
Byte | Value | Datatype |
---|---|---|
0 | BMS State | uint8_t |
1 | Relay State | - |
2 | GPIO Sense | - |
BMS State Value | BMS State |
---|---|
0 | Startup |
1 | Standby |
2 | Balance |
3 | Charge |
4 | Precharge |
5 | Drive-Standby |
6 | Drive |
7 | Drive-Regen |
8 | Fault |
Relay State Bit | Value |
---|---|
0 | BMS Shutdown |
1 | AIR+ |
2 | Precharge |
GPIO Sense Bit | Value |
---|---|
0 | AIR- Sense |
1 | AIR+ Sense |
2 | BMS Shutdown Sense |
3 | IMD Shutdown Sense |
4 | Charge Sense |
Byte | Bit | Value | Unit | Datatype |
---|---|---|---|---|
0 | 7-5 | Bank | - | uint8_t |
0 | 4-0 | Cell | - | uint8_t |
1-2 | - | Voltage | mV | uint16_t |
3-4 | - | Temperature | dC | int16_t |
5 | - | Flags | - | - |
Bit | Flags |
---|---|
0 | Under/Over Voltage |
1 | Under/Over Temperature |
2 | Balance |
3 | Disabled Temperature |
Byte | Value | Unit | Datatype |
---|---|---|---|
0-1 | Total Pack Voltage | mV | uint16_t |
2-3 | Min Cell Voltage | mV | uint16_t |
4-5 | Max Cell Voltage | mV | uint16_t |
Byte | Value | Unit | Datatype |
---|---|---|---|
0-1 | Average Cell Temperature | dC | int16_t |
2-3 | Min Cell Temperature | dC | int16_t |
4-5 | Max Cell Temperature | dC | int16_t |
Byte | Value | Datatype |
---|---|---|
0-4 | Normalized Brake | float |
Byte | Value | Datatype |
---|---|---|
0 | addr | uint8_t |
2 | r/w command | boolean |
3 | NA | - |
4-5 | data | uint8_t |
6-7 | NA | - |
R/W Command Value | State |
---|---|
0 | Read |
1 | Write |
Addr Value | State |
---|---|
20 | Fault Clear |
148 | CAN Active Messages Lo Wor |
Byte | Value | Datatype |
---|---|---|
0-1 | Torque Command | Torque |
2-3 | Speed Command | Angular Velocity |
4 | Direction | boolean |
5.0 | Inverter Enable | boolean |
5.1 | Inverter Discharge | boolean |
5.2 | Speedmode Enabled | boolean |
6-7 | Command Torque Limited | Torque |
Byte | Value | Datatype |
---|---|---|
0 | BSPD State | uint8_t |
BSPD State Value | BSPD State |
---|---|
0 | False / Not Triggered |
1 | True / Triggered |
Byte | Value | Datatype |
---|---|---|
0-4 | TPS Current | float |
The LVPDB transmits 1 byte messages that correspond to the voltage and currents on the main bus, coolant pump, accumulator fans, or radiator fans.
Bus current should be measured to the second decimal place. Intended to be measured in mA</tr>
Byte | Value | Datatype |
---|---|---|
1-2 | Bus Current | int16_t |
The DASH_Breakout Board transmits a 1 byte message corresponding to status of the I/O on the I/O expander, the bits in the message are broken down in the table below:
Bit | Value | Datatype |
---|---|---|
0 | Buzzer State | bool |
1 | Button 1 (Ready-To-Drive) | bool |
2 | Button 2 | bool |
3 | Button 3 | bool |
4 | Button 4 | bool |
5 | Switch 1 (Coolant Pump) | bool |
6 | Switch 2 (Radiator Fans) | bool |
7 | Switch 3 (Accumulator Fans) | bool |
Byte | Value | Datatype |
---|---|---|
0 | Measured fan speed for fan 1, with 0 being fan off and 255 being fan at full speed | uint8_t |
1 | Equivalent for fan 2 | uint8_t |
2 | Equivalent for fan 3 | uint8_t |
3 | Equivalent for fan 4 | uint8_t |
4 | Equivalent for fan 5 | uint8_t |