mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
Add interval defines for inverters
This commit is contained in:
parent
25afbd82f9
commit
c9fe3168e1
6 changed files with 12 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue