Add support for BMS2 power (#741)

This commit is contained in:
Daniel Öster 2025-01-03 16:52:58 +03:00 committed by GitHub
parent e0d72b71aa
commit c8efe2ff63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -87,13 +87,21 @@ void init_contactors() {
set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF); set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF);
#endif // CONTACTOR_CONTROL_DOUBLE_BATTERY #endif // CONTACTOR_CONTROL_DOUBLE_BATTERY
// Init BMS contactor // Init BMS contactor
#ifdef HW_STARK // This hardware has dedicated pin, always enable on start #if defined HW_STARK || defined HW_3LB // This hardware has dedicated pin, always enable on start
pinMode(BMS_POWER, OUTPUT); pinMode(BMS_POWER, OUTPUT); //LilyGo is omitted from this, only enabled if user selects PERIODIC_BMS_RESET
digitalWrite(BMS_POWER, HIGH); digitalWrite(BMS_POWER, HIGH);
#endif // HW_STARK #ifdef BMS_2_POWER //Hardware supports 2x BMS
pinMode(BMS_2_POWER, OUTPUT);
digitalWrite(BMS_2_POWER, HIGH);
#endif BMS_2_POWER
#endif // HW with dedicated BMS pins
#ifdef PERIODIC_BMS_RESET // User has enabled BMS reset, turn on output on start #ifdef PERIODIC_BMS_RESET // User has enabled BMS reset, turn on output on start
pinMode(BMS_POWER, OUTPUT); pinMode(BMS_POWER, OUTPUT);
digitalWrite(BMS_POWER, HIGH); digitalWrite(BMS_POWER, HIGH);
#ifdef BMS_2_POWER //Hardware supports 2x BMS
pinMode(BMS_2_POWER, OUTPUT);
digitalWrite(BMS_2_POWER, HIGH);
#endif BMS_2_POWER
#endif //PERIODIC_BMS_RESET #endif //PERIODIC_BMS_RESET
} }
@ -233,6 +241,9 @@ void handle_BMSpower() {
setBatteryPause(true, true, false, false); setBatteryPause(true, true, false, false);
digitalWrite(BMS_POWER, LOW); // Remove power by setting the BMS power pin to LOW digitalWrite(BMS_POWER, LOW); // Remove power by setting the BMS power pin to LOW
#ifdef BMS_2_POWER
digitalWrite(BMS_2_POWER, LOW); // Same for battery 2
#endif
isBMSResetActive = true; // Set a flag to indicate power removal is active isBMSResetActive = true; // Set a flag to indicate power removal is active
} }
@ -241,6 +252,9 @@ void handle_BMSpower() {
if (isBMSResetActive && currentTime - lastPowerRemovalTime >= powerRemovalDuration) { if (isBMSResetActive && currentTime - lastPowerRemovalTime >= powerRemovalDuration) {
// Reapply power to the BMS // Reapply power to the BMS
digitalWrite(BMS_POWER, HIGH); digitalWrite(BMS_POWER, HIGH);
#ifdef BMS_2_POWER
digitalWrite(BMS_2_POWER, HIGH); // Same for battery 2
#endif
//Resume the battery pause and CAN communication //Resume the battery pause and CAN communication
setBatteryPause(false, false, false, false); setBatteryPause(false, false, false, false);

View file

@ -51,10 +51,12 @@
#define POSITIVE_CONTACTOR_PIN 32 #define POSITIVE_CONTACTOR_PIN 32
#define NEGATIVE_CONTACTOR_PIN 33 #define NEGATIVE_CONTACTOR_PIN 33
#define PRECHARGE_PIN 25 #define PRECHARGE_PIN 25
#define BMS_POWER 2
#define SECOND_POSITIVE_CONTACTOR_PIN 13 #define SECOND_POSITIVE_CONTACTOR_PIN 13
#define SECOND_NEGATIVE_CONTACTOR_PIN 16 #define SECOND_NEGATIVE_CONTACTOR_PIN 16
#define SECOND_PRECHARGE_PIN 18 #define SECOND_PRECHARGE_PIN 18
#define BMS_2_POWER 12
// SMA CAN contactor pins // SMA CAN contactor pins
#define INVERTER_CONTACTOR_ENABLE_PIN 36 #define INVERTER_CONTACTOR_ENABLE_PIN 36