mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Add best guesses
This commit is contained in:
parent
5a35403b92
commit
9667c263df
1 changed files with 7 additions and 5 deletions
|
@ -10,9 +10,7 @@
|
||||||
static unsigned long previousMillis10 = 0; // will store last time a 10ms CAN Message was send
|
static unsigned long previousMillis10 = 0; // will store last time a 10ms CAN Message was send
|
||||||
static unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
static unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
||||||
|
|
||||||
static int SOC_1 = 0;
|
static uint16_t SOC = 0;
|
||||||
static int SOC_2 = 0;
|
|
||||||
static int SOC_3 = 0;
|
|
||||||
static bool interlock_missing = false;
|
static bool interlock_missing = false;
|
||||||
static uint16_t battery_current = 0;
|
static uint16_t battery_current = 0;
|
||||||
static uint16_t voltage = 0;
|
static uint16_t voltage = 0;
|
||||||
|
@ -27,9 +25,9 @@ CAN_frame_t HYBRID_200 = {.FIR = {.B =
|
||||||
|
|
||||||
void update_values_battery() { //This function maps all the values fetched via CAN to the correct parameters used for modbus
|
void update_values_battery() { //This function maps all the values fetched via CAN to the correct parameters used for modbus
|
||||||
|
|
||||||
datalayer.battery.status.real_soc;
|
datalayer.battery.status.real_soc = SOC * 100;
|
||||||
|
|
||||||
datalayer.battery.status.voltage_dV;
|
datalayer.battery.status.voltage_dV = voltage * 10;
|
||||||
|
|
||||||
datalayer.battery.status.current_dA = battery_current;
|
datalayer.battery.status.current_dA = battery_current;
|
||||||
|
|
||||||
|
@ -62,12 +60,16 @@ void receive_can_battery(CAN_frame_t rx_frame) {
|
||||||
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
|
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
|
||||||
switch (rx_frame.MsgID) {
|
switch (rx_frame.MsgID) {
|
||||||
case 0x5F1:
|
case 0x5F1:
|
||||||
|
SOC = rx_frame.data.u8[2]; //Best guess so far, could be very wrong
|
||||||
break;
|
break;
|
||||||
case 0x51E:
|
case 0x51E:
|
||||||
break;
|
break;
|
||||||
case 0x588:
|
case 0x588:
|
||||||
break;
|
break;
|
||||||
case 0x5AE:
|
case 0x5AE:
|
||||||
|
if (rx_frame.data.u8[0] > 100) {
|
||||||
|
voltage = rx_frame.data.u8[0];
|
||||||
|
}
|
||||||
interlock_missing = (bool)(rx_frame.data.u8[1] & 0x02) >> 1;
|
interlock_missing = (bool)(rx_frame.data.u8[1] & 0x02) >> 1;
|
||||||
temperature = rx_frame.data.u8[3]; // Is this correct byte? Or is it 5AD 4/5? The one there is 1deg higher
|
temperature = rx_frame.data.u8[3]; // Is this correct byte? Or is it 5AD 4/5? The one there is 1deg higher
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue