diff --git a/bms/src/BmsFault.cpp b/bms/src/BmsFault.cpp new file mode 100644 index 0000000..b87bd0e --- /dev/null +++ b/bms/src/BmsFault.cpp @@ -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 *****"); + } +} + diff --git a/bms/src/BmsFault.h b/bms/src/BmsFault.h new file mode 100644 index 0000000..ea7a87d --- /dev/null +++ b/bms/src/BmsFault.h @@ -0,0 +1,15 @@ +#include "BmsConfig.h" +#include "mbed.h" +#include + + +class BmsFaultStates { + public: + enum class BmsFaultState : uint8_t { + FaultVoltageThresholdHigh, + FaultVoltageThresholdLow, + FaultTempThresholdHigh, + FaultTempThresholdLow + } +} + diff --git a/bms/src/BmsThread.h b/bms/src/BmsThread.h index f8f88eb..64d5870 100644 --- a/bms/src/BmsThread.h +++ b/bms/src/BmsThread.h @@ -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(); }