mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Add balancing status for Zoe Gen2
This commit is contained in:
parent
c9cbd16cf1
commit
fdb7e73567
2 changed files with 35 additions and 2 deletions
|
@ -108,8 +108,12 @@ void RenaultZoeGen2Battery::handle_incoming_can_frame(CAN_frame 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.ID) {
|
switch (rx_frame.ID) {
|
||||||
case 0x18DAF1DB: // LBC Reply from active polling
|
case 0x18DAF1DB: // LBC Reply from active polling
|
||||||
//frame 2 & 3 contains
|
|
||||||
reply_poll = (rx_frame.data.u8[2] << 8) | rx_frame.data.u8[3];
|
if (rx_frame.data.u8[0] == 0x10) { //First frame of a group
|
||||||
|
transmit_can_frame(&ZOE_POLL_FLOW_CONTROL, can_config.battery);
|
||||||
|
//frame 2 & 3 contains which PID is sent
|
||||||
|
reply_poll = (rx_frame.data.u8[2] << 8) | rx_frame.data.u8[3];
|
||||||
|
}
|
||||||
|
|
||||||
switch (reply_poll) {
|
switch (reply_poll) {
|
||||||
case POLL_SOC:
|
case POLL_SOC:
|
||||||
|
@ -200,6 +204,29 @@ void RenaultZoeGen2Battery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||||
battery_bms_state = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
battery_bms_state = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
||||||
break;
|
break;
|
||||||
case POLL_BALANCE_SWITCHES:
|
case POLL_BALANCE_SWITCHES:
|
||||||
|
if (rx_frame.data.u8[0] == 0x10) {
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
// Byte 4 - 7 (bits 0-31)
|
||||||
|
for (int byte_i = 0; byte_i < 4; byte_i++) {
|
||||||
|
battery_balancing_shunts[byte_i * 8 + i] = (rx_frame.data.u8[4 + byte_i] & (1 << i)) >> i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rx_frame.data.u8[0] == 0x21) {
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
// Byte 1 to 7 (bits 32-87)
|
||||||
|
for (int byte_i = 0; byte_i < 7; byte_i++) {
|
||||||
|
battery_balancing_shunts[32 + byte_i * 8 + i] = (rx_frame.data.u8[1 + byte_i] & (1 << i)) >> i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rx_frame.data.u8[0] == 0x22) {
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
// Byte 1 (bits 88-95)
|
||||||
|
battery_balancing_shunts[88 + i] = (rx_frame.data.u8[1] & (1 << i)) >> i;
|
||||||
|
}
|
||||||
|
memcpy(datalayer.battery.status.cell_balancing_status, battery_balancing_shunts, 96 * sizeof(bool));
|
||||||
|
}
|
||||||
battery_balance_switches = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
battery_balance_switches = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
||||||
break;
|
break;
|
||||||
case POLL_ENERGY_COMPLETE:
|
case POLL_ENERGY_COMPLETE:
|
||||||
|
|
|
@ -205,6 +205,7 @@ class RenaultZoeGen2Battery : public CanBattery {
|
||||||
uint32_t ZOE_376_time_now_s = 1745452800; // Initialized to make the battery think it is April 24, 2025
|
uint32_t ZOE_376_time_now_s = 1745452800; // Initialized to make the battery think it is April 24, 2025
|
||||||
unsigned long kProductionTimestamp_s =
|
unsigned long kProductionTimestamp_s =
|
||||||
1614454107; // Production timestamp in seconds since January 1, 1970. Production timestamp used: February 25, 2021 at 8:08:27 AM GMT
|
1614454107; // Production timestamp in seconds since January 1, 1970. Production timestamp used: February 25, 2021 at 8:08:27 AM GMT
|
||||||
|
bool battery_balancing_shunts[96];
|
||||||
|
|
||||||
CAN_frame ZOE_373 = {
|
CAN_frame ZOE_373 = {
|
||||||
.FD = false,
|
.FD = false,
|
||||||
|
@ -225,6 +226,11 @@ class RenaultZoeGen2Battery : public CanBattery {
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x18DADBF1,
|
.ID = 0x18DADBF1,
|
||||||
.data = {0x03, 0x22, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
.data = {0x03, 0x22, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||||
|
CAN_frame ZOE_POLL_FLOW_CONTROL = {.FD = false,
|
||||||
|
.ext_ID = true,
|
||||||
|
.DLC = 8,
|
||||||
|
.ID = 0x18DADBF1,
|
||||||
|
.data = {0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||||
//NVROL Reset
|
//NVROL Reset
|
||||||
CAN_frame ZOE_NVROL_1_18DADBF1 = {.FD = false,
|
CAN_frame ZOE_NVROL_1_18DADBF1 = {.FD = false,
|
||||||
.ext_ID = true,
|
.ext_ID = true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue