mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Add min/max cellvoltage mapping
This commit is contained in:
parent
92d327f039
commit
eac1f3e2cb
1 changed files with 8 additions and 2 deletions
|
@ -19,6 +19,8 @@ static int8_t battery_module_max_temperature = 0;
|
|||
static int8_t battery_module_min_temperature = 0;
|
||||
static uint8_t poll_data_pid = 0;
|
||||
static uint16_t cellvoltages_mv[59];
|
||||
static uint16_t min_cell_voltage_mv = 3700;
|
||||
static uint16_t max_cell_voltage_mv = 3700;
|
||||
|
||||
CAN_frame_t KIA_7E4_id1 = {.FIR = {.B =
|
||||
{
|
||||
|
@ -79,6 +81,10 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
|
||||
datalayer.battery.status.temperature_max_dC = (int16_t)(battery_module_max_temperature * 10);
|
||||
|
||||
datalayer.battery.status.cell_max_voltage_mV = max_cell_voltage_mv;
|
||||
|
||||
datalayer.battery.status.cell_min_voltage_mV = min_cell_voltage_mv;
|
||||
|
||||
if (interlock_missing) {
|
||||
set_event(EVENT_HVIL_FAILURE, 0);
|
||||
} else {
|
||||
|
@ -161,7 +167,7 @@ void receive_can_battery(CAN_frame_t rx_frame) {
|
|||
break;
|
||||
case 0x23: //Third datarow in PID group
|
||||
if (poll_data_pid == 1) {
|
||||
max_cell_voltage = rx_frame.data.u8[6] * 20;
|
||||
max_cell_voltage_mv = rx_frame.data.u8[6] * 20;
|
||||
} else if (poll_data_pid == 2) {
|
||||
cellvoltages_mv[13] = (rx_frame.data.u8[1] * 20);
|
||||
cellvoltages_mv[14] = (rx_frame.data.u8[2] * 20);
|
||||
|
@ -182,7 +188,7 @@ void receive_can_battery(CAN_frame_t rx_frame) {
|
|||
break;
|
||||
case 0x24: //Fourth datarow in PID group
|
||||
if (poll_data_pid == 1) {
|
||||
min_cell_voltage = rx_frame.data.u8[1] * 20;
|
||||
min_cell_voltage_mv = rx_frame.data.u8[1] * 20;
|
||||
} else if (poll_data_pid == 2) {
|
||||
cellvoltages_mv[20] = (rx_frame.data.u8[1] * 20);
|
||||
cellvoltages_mv[21] = (rx_frame.data.u8[2] * 20);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue