diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index 1299310b..fc66177c 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -519,16 +519,18 @@ the first, for a few cycles, then stop all messages which causes the contactor if (currentMillis - previousMillis30 >= interval30) { previousMillis30 = currentMillis; - if (bms_status == ACTIVE) { - send221still = 50; - batteryAllowsContactorClosing = true; - ESP32Can.CANWriteFrame(&TESLA_221_1); - ESP32Can.CANWriteFrame(&TESLA_221_2); - } else { //bms_status == FAULT - if (send221still > 0) { - batteryAllowsContactorClosing = false; + if (inverterAllowsContactorClosing == 1) { + if (bms_status == ACTIVE) { + send221still = 50; + batteryAllowsContactorClosing = true; ESP32Can.CANWriteFrame(&TESLA_221_1); - send221still--; + ESP32Can.CANWriteFrame(&TESLA_221_2); + } else { //bms_status == FAULT or inverter requested opening contactors + if (send221still > 0) { + batteryAllowsContactorClosing = false; + ESP32Can.CANWriteFrame(&TESLA_221_1); + send221still--; + } } } } diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.h b/Software/src/battery/TESLA-MODEL-3-BATTERY.h index 9b689275..e6ba8625 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.h +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.h @@ -29,7 +29,8 @@ extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 funct extern uint16_t cell_max_voltage; //mV, 0-4350 extern uint16_t cell_min_voltage; //mV, 0-4350 extern uint8_t LEDcolor; //Enum, 0-10 -extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false // Definitions for BMS status #define STANDBY 0 #define INACTIVE 1