Add Automatic Precharge Control for modified HIA4V1 boards

This commit is contained in:
mvgalen 2024-12-21 20:33:20 +01:00
parent f138f97905
commit dccfca17ea
6 changed files with 302 additions and 27 deletions

View file

@ -12,6 +12,7 @@
#include "src/communication/contactorcontrol/comm_contactorcontrol.h"
#include "src/communication/equipmentstopbutton/comm_equipmentstopbutton.h"
#include "src/communication/nvm/comm_nvm.h"
#include "src/communication/precharge_control/precharge_control.h"
#include "src/communication/rs485/comm_rs485.h"
#include "src/communication/seriallink/comm_seriallink.h"
#include "src/datalayer/datalayer.h"
@ -115,6 +116,10 @@ void setup() {
init_contactors();
#ifdef PRECHARGE_CONTROL
init_precharge_control();
#endif // PRECHARGE_CONTROL
init_rs485();
init_serialDataLink();
@ -242,6 +247,9 @@ void core_loop(void* task_time_us) {
previousMillis10ms = millis();
led_exe();
handle_contactors(); // Take care of startup precharge/contactor closing
#ifdef PRECHARGE_CONTROL
handle_precharge_control();
#endif // PRECHARGE_CONTROL
}
END_TIME_MEASUREMENT_MAX(time_10ms, datalayer.system.status.time_10ms_us);
@ -293,6 +301,30 @@ void core_loop(void* task_time_us) {
if (check_pause_2s.elapsed()) {
emulator_pause_state_transmit_can_battery();
}
static bms_status_enum previous_state = FAULT;
if (previous_state != datalayer.battery.status.bms_status) {
switch (datalayer.battery.status.bms_status) {
case ACTIVE:
logging.printf("BMS state changed to: OK\n");
break;
case UPDATING:
logging.printf("BMS state changed to: UPDATING\n");
break;
case FAULT:
logging.printf("BMS state changed to: FAULT\n");
break;
case INACTIVE:
logging.printf("BMS state changed to: INACTIVE\n");
break;
case STANDBY:
logging.printf("BMS state changed to: STANDBY\n");
break;
default:
logging.printf("BMS state changed to: ??\n");
break;
}
previous_state = datalayer.battery.status.bms_status;
}
vTaskDelayUntil(&xLastWakeTime, xFrequency);
}