diff --git a/Software/src/devboard/config.h b/Software/src/devboard/config.h index 25ee3743..7dc1c348 100644 --- a/Software/src/devboard/config.h +++ b/Software/src/devboard/config.h @@ -65,6 +65,7 @@ #define INTERVAL_500_MS 500 #define INTERVAL_640_MS 640 #define INTERVAL_1_S 1000 +#define INTERVAL_2_S 2000 #define INTERVAL_5_S 5000 #define INTERVAL_10_S 10000 #define INTERVAL_60_S 60000 diff --git a/Software/src/inverter/BYD-CAN.cpp b/Software/src/inverter/BYD-CAN.cpp index 890dfe04..52cfb962 100644 --- a/Software/src/inverter/BYD-CAN.cpp +++ b/Software/src/inverter/BYD-CAN.cpp @@ -6,9 +6,6 @@ static unsigned long previousMillis2s = 0; // will store last time a 2s CAN Message was send static unsigned long previousMillis10s = 0; // will store last time a 10s CAN Message was send static unsigned long previousMillis60s = 0; // will store last time a 60s CAN Message was send -static const int interval2s = 2000; // interval (ms) at which send CAN Messages -static const int interval10s = 10000; // interval (ms) at which send CAN Messages -static const int interval60s = 60000; // interval (ms) at which send CAN Messages static uint8_t char1_151 = 0; static uint8_t char2_151 = 0; static uint8_t char3_151 = 0; @@ -232,13 +229,13 @@ void send_can_byd() { } // Send 2s CAN Message - if (currentMillis - previousMillis2s >= interval2s) { + if (currentMillis - previousMillis2s >= INTERVAL_2_S) { previousMillis2s = currentMillis; ESP32Can.CANWriteFrame(&BYD_110); } // Send 10s CAN Message - if (currentMillis - previousMillis10s >= interval10s) { + if (currentMillis - previousMillis10s >= INTERVAL_10_S) { previousMillis10s = currentMillis; ESP32Can.CANWriteFrame(&BYD_150); @@ -246,7 +243,7 @@ void send_can_byd() { ESP32Can.CANWriteFrame(&BYD_210); } //Send 60s message - if (currentMillis - previousMillis60s >= interval60s) { + if (currentMillis - previousMillis60s >= INTERVAL_60_S) { previousMillis60s = currentMillis; ESP32Can.CANWriteFrame(&BYD_190); diff --git a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp index f673783b..e93d7637 100644 --- a/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp +++ b/Software/src/inverter/SERIAL-LINK-TRANSMITTER-INVERTER.cpp @@ -49,13 +49,12 @@ void manageSerialLinkTransmitter() { } #endif - if (currentTime - updateTime > 100) { + if (currentTime - updateTime > INTERVAL_100_MS) { updateTime = currentTime; if (!initLink) { initLink = true; transmitGoodSince = currentTime; - // sends variables every 5000mS even if no change - dataLinkTransmit.setUpdateInterval(10000); + dataLinkTransmit.setUpdateInterval(INTERVAL_10_S); } bool sendError = dataLinkTransmit.checkTransmissionError(true); if (sendError) { @@ -86,7 +85,7 @@ void manageSerialLinkTransmitter() { } //--- reporting every 60 seconds that transmission is good - if (currentTime - transmitGoodSince > 60000) { + if (currentTime - transmitGoodSince > INTERVAL_60_S) { transmitGoodSince = currentTime; Serial.print(currentTime); Serial.println(" - Transmit Good"); @@ -97,8 +96,7 @@ void manageSerialLinkTransmitter() { } //--- report that Errors been ocurring for > 60 seconds - if (currentTime - lastGood > 60000) // 60 seconds - { + if (currentTime - lastGood > INTERVAL_60_S) { lastGood = currentTime; Serial.print(currentTime); Serial.println(" - Transmit Failed : 60 seconds"); @@ -127,7 +125,7 @@ void manageSerialLinkTransmitter() { static unsigned long updateDataTime = 0; - if (currentTime - updateDataTime > 999) { + if (currentTime - updateDataTime > INTERVAL_1_S) { updateDataTime = currentTime; dataLinkTransmit.updateData(0, system_real_SOC_pptt); dataLinkTransmit.updateData(1, system_SOH_pptt); diff --git a/Software/src/inverter/SMA-CAN.cpp b/Software/src/inverter/SMA-CAN.cpp index 1ade5a9c..8981d9c0 100644 --- a/Software/src/inverter/SMA-CAN.cpp +++ b/Software/src/inverter/SMA-CAN.cpp @@ -6,7 +6,6 @@ /* Do not change code below unless you are sure what you are doing */ static unsigned long previousMillis100ms = 0; // will store last time a 100ms CAN Message was send -static const int interval100ms = 100; // interval (ms) at which send CAN Messages //Actual content messages static const CAN_frame_t SMA_558 = { @@ -235,7 +234,7 @@ void send_can_sma() { unsigned long currentMillis = millis(); // Send CAN Message every 100ms - if (currentMillis - previousMillis100ms >= interval100ms) { + if (currentMillis - previousMillis100ms >= INTERVAL_100_MS) { previousMillis100ms = currentMillis; ESP32Can.CANWriteFrame(&SMA_558); diff --git a/Software/src/inverter/SMA-TRIPOWER-CAN.cpp b/Software/src/inverter/SMA-TRIPOWER-CAN.cpp index 14d170ca..370ad5d2 100644 --- a/Software/src/inverter/SMA-TRIPOWER-CAN.cpp +++ b/Software/src/inverter/SMA-TRIPOWER-CAN.cpp @@ -12,7 +12,6 @@ /* Do not change code below unless you are sure what you are doing */ static unsigned long previousMillis500ms = 0; // will store last time a 100ms CAN Message was send -static const int interval500ms = 100; // interval (ms) at which send CAN Messages //Actual content messages static CAN_frame_t SMA_00D = { // Battery Limits @@ -336,7 +335,7 @@ void send_can_sma_tripower() { unsigned long currentMillis = millis(); // Send CAN Message every 500ms - if (currentMillis - previousMillis500ms >= interval500ms) { + if (currentMillis - previousMillis500ms >= INTERVAL_500_MS) { previousMillis500ms = currentMillis; ESP32Can.CANWriteFrame(&SMA_00D); //Battery limits diff --git a/Software/src/inverter/SOFAR-CAN.cpp b/Software/src/inverter/SOFAR-CAN.cpp index b9afe7df..7e99797c 100644 --- a/Software/src/inverter/SOFAR-CAN.cpp +++ b/Software/src/inverter/SOFAR-CAN.cpp @@ -6,7 +6,6 @@ /* Do not change code below unless you are sure what you are doing */ static unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send -static const int interval100 = 100; // interval (ms) at which send CAN Messages //Actual content messages //Note that these are technically extended frames. If more batteries are put in parallel,the first battery sends 0x351 the next battery sends 0x1351 etc. 16 batteries in parallel supported @@ -324,7 +323,7 @@ void receive_can_sofar(CAN_frame_t rx_frame) { void send_can_sofar() { unsigned long currentMillis = millis(); // Send 100ms CAN Message - if (currentMillis - previousMillis100 >= interval100) { + if (currentMillis - previousMillis100 >= INTERVAL_100_MS) { previousMillis100 = currentMillis; //Frames actively reported by BMS ESP32Can.CANWriteFrame(&SOFAR_351);