diff --git a/Software/Software.ino b/Software/Software.ino index cd09171a..5374625a 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -545,10 +545,6 @@ void init_contactors() { pinMode(BMS_POWER, OUTPUT); digitalWrite(BMS_POWER, HIGH); #endif //HW_STARK -#ifdef SMA_TRIPOWER_CAN - //pinMode(INVERTER_CONTACTOR_ENABLE_PIN, OUTPUT); //Incase this is an output - //digitalWrite(INVERTER_CONTACTOR_ENABLE_PIN, LOW); //Incase this is an output -#endif //SMA_TRIPOWER_CAN } void init_rs485() { @@ -743,14 +739,9 @@ void check_interconnect_available() { #endif //DOUBLE_BATTERY void handle_contactors() { -#ifdef BYD_SMA +#if defined(BYD_SMA) || defined(SMA_TRIPOWER_CAN) datalayer.system.status.inverter_allows_contactor_closing = digitalRead(INVERTER_CONTACTOR_ENABLE_PIN); #endif -#ifdef SMA_TRIPOWER_CAN - //set(INVERTER_CONTACTOR_ENABLE_PIN, ON); //TODO: is this an input, or an output? Figure out and make logic - datalayer.system.status.inverter_allows_contactor_closing = - digitalRead(INVERTER_CONTACTOR_ENABLE_PIN); //Incase it is input -#endif #ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY handle_contactors_battery2(); diff --git a/Software/src/inverter/SMA-TRIPOWER-CAN.cpp b/Software/src/inverter/SMA-TRIPOWER-CAN.cpp index 777f1f3e..1296cbe7 100644 --- a/Software/src/inverter/SMA-TRIPOWER-CAN.cpp +++ b/Software/src/inverter/SMA-TRIPOWER-CAN.cpp @@ -171,7 +171,10 @@ void receive_can_inverter(CAN_frame rx_frame) { void send_can_inverter() { unsigned long currentMillis = millis(); - //TODO, should we break before pairing_completed? Or rely on Enable line? + // Send CAN Message only if we're enabled by inverter + if (!datalayer.system.status.inverter_allows_contactor_closing) { + return; + } // Send CAN Message every 2s if (currentMillis - previousMillis2s >= INTERVAL_2_S) {