Skip to content

Formula-Electric-Berkeley/SN3_CAN_Library

Repository files navigation

CAN Library

1 Overview

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 for FEB_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 from FEB_CAN_ID.csv and FEB_CAN_Static_ID.csv to generate FEB_CAN_ID.h.
  • FEB_CAN_ID.py: This file storse all CAN Message IDs. Used for the CAN Monitor.

2 Update Instructions

  1. 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 the FEB_CAN_ID.csv file.
  2. Generate: Run generate.py script. This will update the FEB_CAN_ID.h header file.
  3. Documentation: Document the new CAN message in this readme file.
  4. GitHub: Push all changes to GitHub to ensure the CAN Library is up to date for everyone.

3 CAN Message Documentation

3.1 BMS

3.1.1 Voltage

Byte Value Factor Offset Datatype Unit
0 Bank [1, 7] 1 0 uint8_t -
1 Cell [1, 20] 1 0 uint8_t -
2-3 Voltage 10-4 0 uint16_t V

3.1.2 Temperature

Byte Value Factor Offset Datatype Unit
0 Bank [1, 7] 1 0 uint8_t -
1 Cell [1, 20] 1 0 uint8_t -
2-3 Temperature 10-1 0 int16_t oC

3.1.3 State

Byte Value Datatype
0 BMS State uint8_t
1 Relay State uint8_t
BMS State Value BMS State
0 Pre-charge
1 Charge
2 Balance
3 Drive
4 Shutdown
Relay State Bit Relay State
2 Shutdown 0 if closed else 1
1 AIR+ 0 if closed else 1
0 Pre-charge 0 if closed else 1

3.1.4 Balance

Byte Value Factor Offset Datatype Unit
0 Bank [1, 7] 1 0 uint8_t -
1-3 Cell balance state 1 0 - -
4-5 Target voltage 10-4 0 uint16_t V
Cell balance state bit Value
24-20 0
19-0 1 if cell balance else 0. Bit i for cell (i + 1).

3.1.5 Enabled Temperature Sensors

Byte Value Datatype
0 Bank [1, 7] uint8_t
1-3 Temperature Sensor -
Temperature sensor state bit Value
24-20 0
19-0 1 if enabled else 0. Bit i for cell (i + 1).

3.1.6 Desired Fan Speeds (Both DART1 and DART2)

Byte Value Datatype
0 Desired 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

3.2 APPS

3.2.1 Normalized Brake

Byte Value Datatype
0-4 Normalized Brake float

3.2.2 RMS Param Msg

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

3.2.3 RMS Command Msg

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

3.2.4 BSPD

Byte Value Datatype
0 BSPD State uint8_t
BSPD State Value BSPD State
0 False / Not Triggered
1 True / Triggered

3.2.5 Current

Byte Value Datatype
0-4 TPS Current float

3.3 LVPDB

3.4 DCU

3.5 ICS

3.5.1 Buttons & Swtiches

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

3.6 DART

3.6.1 Measured Fan Speeds (Both DART1 and DART2)

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published