Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
BMS Class Reference

BMS class for managing the Accumulator (Kclear BMS) via CAN bus. More...

#include <BMS.hpp>

Collaboration diagram for BMS:

Public Member Functions

 BMS (MCP2515 &bms_can_, CarState &car_)
 Construct a new BMS object, initing car.pedal.status.bits.hv_ready to false.
 
bool hvReady () const
 Returns true if HV has been started.
 
void initFilter ()
 Initializes the CAN filters for reading BMS data. Call after constructing the BMS object and the MCP2515 object it references to ensure BMS data is being read correctly. This function will block until the filter is set correctly on the MCP2515. If it never succeed, the program will be stuck here. Consider that in the case that we can't even set the filter on the MCP2515, we probably can't communicate with the BMS at all, so being stuck here is acceptable since the car won't start without BMS communication anyway.
 
void checkHv ()
 Attempts to start HV. First check BMS is in standby(3) state, then send the HV start command. Keep sending the command until the BMS state changes to precharge(4). Sets car.pedal.status.bits.hv_ready to true when BMS state changes to run(5).
 

Private Attributes

MCP2515 & bms_can
 
can_frame rx_bms_msg
 
CarStatecar
 

Detailed Description

BMS class for managing the Accumulator (Kclear BMS) via CAN bus.

Definition at line 46 of file BMS.hpp.

Constructor & Destructor Documentation

◆ BMS()

BMS::BMS ( MCP2515 &  bms_can_,
CarState car_ 
)

Construct a new BMS object, initing car.pedal.status.bits.hv_ready to false.

Parameters
bms_can_Reference to MCP2515 for BMS CAN bus
car_Reference to CarState, for the status flags and setting BMS data

Definition at line 32 of file BMS.cpp.

References TelemetryFramePedal::StateByteStatus::bits, car, TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, and TelemetryFramePedal::status.

Member Function Documentation

◆ checkHv()

void BMS::checkHv ( )

Attempts to start HV. First check BMS is in standby(3) state, then send the HV start command. Keep sending the command until the BMS state changes to precharge(4). Sets car.pedal.status.bits.hv_ready to true when BMS state changes to run(5).

Definition at line 62 of file BMS.cpp.

References TelemetryFramePedal::StateByteStatus::bits, bms_can, TelemetryFramePedal::StateByteStatus::Bits::bms_no_msg, car, DBGLN_GENERAL(), TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, rx_bms_msg, start_hv_msg, and TelemetryFramePedal::status.

Referenced by scheduler_bms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hvReady()

bool BMS::hvReady ( ) const
inline

Returns true if HV has been started.

Returns
true if HV started, false otherwise

Definition at line 54 of file BMS.hpp.

References TelemetryFramePedal::StateByteStatus::bits, car, TelemetryFramePedal::StateByteStatus::Bits::hv_ready, CarState::pedal, and TelemetryFramePedal::status.

◆ initFilter()

void BMS::initFilter ( )

Initializes the CAN filters for reading BMS data. Call after constructing the BMS object and the MCP2515 object it references to ensure BMS data is being read correctly. This function will block until the filter is set correctly on the MCP2515. If it never succeed, the program will be stuck here. Consider that in the case that we can't even set the filter on the MCP2515, we probably can't communicate with the BMS at all, so being stuck here is acceptable since the car won't start without BMS communication anyway.

Definition at line 45 of file BMS.cpp.

References bms_can, and BMS_INFO_EXT.

Referenced by setup().

Here is the caller graph for this function:

Member Data Documentation

◆ bms_can

MCP2515& BMS::bms_can
private

Reference to MCP2515 for BMS CAN bus

Definition at line 59 of file BMS.hpp.

Referenced by checkHv(), and initFilter().

◆ car

CarState& BMS::car
private

Reference to CarState, for the status flags and setting BMS data

Definition at line 66 of file BMS.hpp.

Referenced by BMS(), checkHv(), and hvReady().

◆ rx_bms_msg

can_frame BMS::rx_bms_msg
private
Initial value:
= {
0,
0,
{0},
}

Local storage for received BMS CAN frame

Definition at line 61 of file BMS.hpp.

Referenced by checkHv().


The documentation for this class was generated from the following files: