Update KIA-HYUNDAI-64-BATTERY.cpp

- Expand the time of parameterID polling to increase the ID-counter every other time instead of every 100ms cycle.
- Sometimes the cell voltages are corrupted if polled to fast.
This commit is contained in:
LevinSwe 2025-01-02 15:05:33 +01:00 committed by GitHub
parent 3d1f535b09
commit 884ed718d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,7 @@ static int16_t batteryAmps = 0;
static int16_t temperatureMax = 0;
static int16_t temperatureMin = 0;
static int16_t poll_data_pid = 0;
static bool holdPidCounter = false;
static uint8_t CellVmaxNo = 0;
static uint8_t CellVminNo = 0;
static uint8_t batteryManagementMode = 0;
@ -262,11 +263,16 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
case 0x5D8:
startedUp = true;
//PID data is polled after last message sent from battery:
if (poll_data_pid >= 10) { //polling one of ten PIDs at 100ms, resolution = 1s
//PID data is polled after last message sent from battery every other time:
if (poll_data_pid >= 10) { //polling one of ten PIDs at 100ms*2, resolution = 2s
poll_data_pid = 0;
}
poll_data_pid++;
if (holdPidCounter == false) {
poll_data_pid++;
holdPidCounter = true;
} else {
holdPidCounter = false;
}
if (poll_data_pid == 1) {
transmit_can_frame(&KIA64_7E4_id1, can_config.battery);
} else if (poll_data_pid == 2) {