mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Merge pull request #1094 from dalathegreat/feature/SMA-enable-event
SMA: Add Event for missing enable line
This commit is contained in:
commit
948e6d8c1b
5 changed files with 46 additions and 0 deletions
|
@ -81,6 +81,7 @@ void init_events(void) {
|
|||
events.entries[EVENT_INVERTER_OPEN_CONTACTOR].level = EVENT_LEVEL_INFO;
|
||||
events.entries[EVENT_INTERFACE_MISSING].level = EVENT_LEVEL_INFO;
|
||||
events.entries[EVENT_MODBUS_INVERTER_MISSING].level = EVENT_LEVEL_INFO;
|
||||
events.entries[EVENT_NO_ENABLE_DETECTED].level = EVENT_LEVEL_INFO;
|
||||
events.entries[EVENT_ERROR_OPEN_CONTACTOR].level = EVENT_LEVEL_INFO;
|
||||
events.entries[EVENT_CELL_CRITICAL_UNDER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
||||
events.entries[EVENT_CELL_CRITICAL_OVER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
||||
|
@ -269,6 +270,8 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
|
|||
"Check other error code for reason!";
|
||||
case EVENT_MODBUS_INVERTER_MISSING:
|
||||
return "Modbus inverter has not sent any data. Inspect communication wiring!";
|
||||
case EVENT_NO_ENABLE_DETECTED:
|
||||
return "Inverter Enable line has not been active for a long time. Check Wiring!";
|
||||
case EVENT_CELL_CRITICAL_UNDER_VOLTAGE:
|
||||
return "CELL VOLTAGE CRITICALLY LOW! Not possible to continue. Inspect battery!";
|
||||
case EVENT_CELL_UNDER_VOLTAGE:
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
XX(EVENT_INVERTER_OPEN_CONTACTOR) \
|
||||
XX(EVENT_INTERFACE_MISSING) \
|
||||
XX(EVENT_MODBUS_INVERTER_MISSING) \
|
||||
XX(EVENT_NO_ENABLE_DETECTED) \
|
||||
XX(EVENT_ERROR_OPEN_CONTACTOR) \
|
||||
XX(EVENT_CELL_CRITICAL_UNDER_VOLTAGE) \
|
||||
XX(EVENT_CELL_CRITICAL_OVER_VOLTAGE) \
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../include.h"
|
||||
#ifdef SMA_BYD_H_CAN
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "SMA-BYD-H-CAN.h"
|
||||
|
||||
/* TODO: Map error bits in 0x158 */
|
||||
|
@ -11,6 +12,8 @@ static unsigned long previousMillis100ms = 0;
|
|||
static uint32_t inverter_time = 0;
|
||||
static uint16_t inverter_voltage = 0;
|
||||
static int16_t inverter_current = 0;
|
||||
static uint16_t timeWithoutInverterAllowsContactorClosing = 0;
|
||||
#define THIRTY_MINUTES 1200
|
||||
|
||||
//Actual content messages
|
||||
CAN_frame SMA_158 = {.FD = false,
|
||||
|
@ -145,6 +148,17 @@ void update_values_can_inverter() { //This function maps all the values fetched
|
|||
#endif // INVERTER_CONTACTOR_ENABLE_LED_PIN
|
||||
}
|
||||
|
||||
// Check if Enable line is working. If we go too long without any input, raise an event
|
||||
if (!datalayer.system.status.inverter_allows_contactor_closing) {
|
||||
timeWithoutInverterAllowsContactorClosing++;
|
||||
|
||||
if (timeWithoutInverterAllowsContactorClosing > THIRTY_MINUTES) {
|
||||
set_event(EVENT_NO_ENABLE_DETECTED, 0);
|
||||
}
|
||||
} else {
|
||||
timeWithoutInverterAllowsContactorClosing = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
//SMA_158.data.u8[0] = //bit12 Fault high temperature, bit34Battery cellundervoltage, bit56 Battery cell overvoltage, bit78 batterysystemdefect
|
||||
//TODO: add all error bits. Sending message with all 0xAA until that.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../include.h"
|
||||
#ifdef SMA_BYD_HVS_CAN
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "SMA-BYD-HVS-CAN.h"
|
||||
|
||||
/* TODO: Map error bits in 0x158 */
|
||||
|
@ -11,6 +12,8 @@ static unsigned long previousMillis100ms = 0;
|
|||
static uint32_t inverter_time = 0;
|
||||
static uint16_t inverter_voltage = 0;
|
||||
static int16_t inverter_current = 0;
|
||||
static uint16_t timeWithoutInverterAllowsContactorClosing = 0;
|
||||
#define THIRTY_MINUTES 1200
|
||||
|
||||
//Actual content messages
|
||||
CAN_frame SMA_158 = {.FD = false,
|
||||
|
@ -149,6 +152,17 @@ void update_values_can_inverter() { //This function maps all the values fetched
|
|||
#endif // INVERTER_CONTACTOR_ENABLE_LED_PIN
|
||||
}
|
||||
|
||||
// Check if Enable line is working. If we go too long without any input, raise an event
|
||||
if (!datalayer.system.status.inverter_allows_contactor_closing) {
|
||||
timeWithoutInverterAllowsContactorClosing++;
|
||||
|
||||
if (timeWithoutInverterAllowsContactorClosing > THIRTY_MINUTES) {
|
||||
set_event(EVENT_NO_ENABLE_DETECTED, 0);
|
||||
}
|
||||
} else {
|
||||
timeWithoutInverterAllowsContactorClosing = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
//SMA_158.data.u8[0] = //bit12 Fault high temperature, bit34Battery cellundervoltage, bit56 Battery cell overvoltage, bit78 batterysystemdefect
|
||||
//TODO: add all error bits. Sending message with all 0xAA until that.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../include.h"
|
||||
#ifdef SMA_TRIPOWER_CAN
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "SMA-TRIPOWER-CAN.h"
|
||||
|
||||
/* TODO:
|
||||
|
@ -32,6 +33,8 @@ static int16_t inverter_current = 0;
|
|||
static bool pairing_completed = false;
|
||||
static int16_t temperature_average = 0;
|
||||
static uint16_t ampere_hours_remaining = 0;
|
||||
static uint16_t timeWithoutInverterAllowsContactorClosing = 0;
|
||||
#define THIRTY_MINUTES 1200
|
||||
|
||||
//Actual content messages
|
||||
CAN_frame SMA_358 = {.FD = false,
|
||||
|
@ -146,6 +149,17 @@ void update_values_can_inverter() { //This function maps all the values fetched
|
|||
} else {
|
||||
SMA_4D8.data.u8[6] = READY_STATE;
|
||||
}
|
||||
|
||||
// Check if Enable line is working. If we go too long without any input, raise an event
|
||||
if (!datalayer.system.status.inverter_allows_contactor_closing) {
|
||||
timeWithoutInverterAllowsContactorClosing++;
|
||||
|
||||
if (timeWithoutInverterAllowsContactorClosing > THIRTY_MINUTES) {
|
||||
set_event(EVENT_NO_ENABLE_DETECTED, 0);
|
||||
}
|
||||
} else {
|
||||
timeWithoutInverterAllowsContactorClosing = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void map_can_frame_to_variable_inverter(CAN_frame rx_frame) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue