Skip to content

Create BmsFault header and c++ file #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bms/src/BmsFault.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "BmsFault.h"

void throwBmsFault(uint8_t FaultState) {
// store which fault(s) have occurred
// say what type of fault happened
// disable specific pins

if (FaultState == FaultVoltageThresholdHigh) {
serial->printf("***** BMS HIGH VOLTAGE FAULT *****"); // we would have to find the temp first to include the rest of this: \nTemp at %d\n\n", temp);
}

if (FaultState == FaultVoltageThresholdLow) {
serial->printf("***** BMS LOW VOLTAGE FAULT *****");
}

if (FaultState == FaultTempThresholdHigh) {
serial->printf("***** BMS HIGH TEMP FAULT *****");
}

if (FaultState == FaultTempThresholdLow) {
serial->printf("***** BMS LOW TEMP FAULT *****");
}
}

15 changes: 15 additions & 0 deletions bms/src/BmsFault.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "BmsConfig.h"
#include "mbed.h"
#include <time.h>


class BmsFaultStates {
public:
enum class BmsFaultState : uint8_t {
FaultVoltageThresholdHigh,
FaultVoltageThresholdLow,
FaultTempThresholdHigh,
FaultTempThresholdLow
}
}

4 changes: 2 additions & 2 deletions bms/src/BmsThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ class BMSThread {

if (voltage >= BMS_FAULT_VOLTAGE_THRESHOLD_HIGH) {
// Set fault line
serial->printf("***** BMS LOW VOLTAGE FAULT *****\nVoltage at %d\n\n", voltage);
serial->printf("***** BMS HIGH VOLTAGE FAULT *****\nVoltage at %d\n\n", voltage);
throwBmsFault();
}
if (voltage <= BMS_FAULT_VOLTAGE_THRESHOLD_LOW) {
// Set fault line
serial->printf("***** BMS HIGH VOLTAGE FAULT *****\nVoltage at %d\n\n", voltage);
serial->printf("***** BMS LOW VOLTAGE FAULT *****\nVoltage at %d\n\n", voltage);
throwBmsFault();
}

Expand Down