add minimum duration of 1 sec for precharge
This commit is contained in:
parent
aa85867083
commit
4be1355c40
@ -11,6 +11,8 @@
|
||||
// Time to wait after reaching 95% of battery voltage before exiting precharge
|
||||
// Set this to 1000 in scruti to demonstrate the voltage on the multimeter
|
||||
#define PRECHARGE_95_DURATION 0 // ms
|
||||
// Minimum precharge time
|
||||
#define PRECHARGE_MIN_DURATION 1000 // ms
|
||||
// Time to wait for discharge
|
||||
#define DISCHARGE_DURATION 5000 // ms
|
||||
// Time to wait after there is no more error condition before exiting TS_ERROR
|
||||
|
@ -12,6 +12,7 @@
|
||||
TSStateHandle ts_state;
|
||||
|
||||
static uint32_t precharge_95_reached_timestamp = 0;
|
||||
static uint32_t precharge_start_timestamp = 0;
|
||||
static uint32_t charging_check_timestamp = 0;
|
||||
static uint32_t discharge_begin_timestamp = 0;
|
||||
static uint32_t precharge_opened_timestamp = 0;
|
||||
@ -104,15 +105,20 @@ TSState ts_sm_update_precharge() {
|
||||
discharge_begin_timestamp = HAL_GetTick();
|
||||
return TS_DISCHARGE;
|
||||
}
|
||||
if (precharge_start_timestamp == 0) {
|
||||
precharge_start_timestamp = HAL_GetTick();
|
||||
}
|
||||
if (shunt_data.voltage_veh > MIN_VEHICLE_SIDE_VOLTAGE &&
|
||||
shunt_data.voltage_veh > 0.95 * shunt_data.voltage_bat) {
|
||||
const uint32_t now = HAL_GetTick();
|
||||
if (precharge_95_reached_timestamp == 0) {
|
||||
precharge_95_reached_timestamp = now;
|
||||
} else if ((now - precharge_95_reached_timestamp) >=
|
||||
PRECHARGE_95_DURATION) {
|
||||
PRECHARGE_95_DURATION &&
|
||||
(now - precharge_start_timestamp) >= PRECHARGE_MIN_DURATION) {
|
||||
precharge_95_reached_timestamp = 0;
|
||||
precharge_opened_timestamp = 0;
|
||||
precharge_start_timestamp = 0;
|
||||
//precharge_opened = 0;
|
||||
return TS_ACTIVE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user