Skip to content

Commit f5e6eaf

Browse files
committed
handle HLC charging without power and fix AC basic pause transitions
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
1 parent 86b97be commit f5e6eaf

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

modules/EVSE/EvseManager/Charger.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -627,14 +627,14 @@ void Charger::run_state_machine() {
627627
// In AC mode BASIC, iec_allow is sufficient. The same is true for HLC mode when nominal PWM is
628628
// used as the car can do BASIC and HLC charging any time. In AC HLC with 5 percent mode, we need to
629629
// wait for both iec_allow and hlc_allow.
630-
if (not power_available()) {
631-
// FIXME: For AC BC, it is ok to wait here. The behaviour we would like to have for AC ISO
632-
// when starting up with no power needs to be defined still. For DC it just continues here without
633-
// power.
630+
if (not power_available() and not hlc_use_5percent_current_session) {
631+
//For AC BC: it is ok to wait here.
632+
// For AC and DC ISO, continue in case we are in 5% mode. This allows us to go into
633+
// Charge loop and report 0A/0W to the EV
634634
break;
635635
}
636636

637-
// Power is available, PWM is already enabled. Check if we can go to charging
637+
// Power is available or we are in HLC, PWM is already enabled. Check if we can go to charging
638638
if ((shared_context.iec_allow_close_contactor and not hlc_use_5percent_current_session) or
639639
(shared_context.iec_allow_close_contactor and shared_context.hlc_allow_close_contactor and
640640
hlc_use_5percent_current_session)) {
@@ -703,18 +703,15 @@ void Charger::run_state_machine() {
703703
check_soft_over_current();
704704

705705
if (not power_available()) {
706-
707-
if (shared_context.hlc_charging_active) {
706+
if (shared_context.hlc_charging_active or hlc_use_5percent_current_session) {
707+
// We are in HLC and have no energy
708708
// TODO: start timer to stop charging
709-
// FIXME: hlc_charging_active is only set once PowerDelivery.req is received,
710-
// so currently an AC HLC session will stop immediately here if power is not
711-
// available
712709
} else {
713710
EVLOG_info << "HLC charging not active";
714711
// Stop immediately in basic AC mode
715-
shared_context.current_state = EvseState::ChargingPausedEVSE;
712+
set_state(EvseState::StoppingCharging); // Proxy state to ChargingPausedEVSE
713+
break;
716714
}
717-
break;
718715
}
719716

720717
if (initialize_state) {
@@ -800,6 +797,9 @@ void Charger::run_state_machine() {
800797
if (initialize_state) {
801798
if (shared_context.hlc_charging_active and shared_context.flag_transaction_active) {
802799
signal_hlc_pause_charging();
800+
} else {
801+
// Basic Charging: just turn off PWM
802+
pwm_off();
803803
}
804804
internal_context.last_charging_paused_evse_reasons = {};
805805
}
@@ -878,12 +878,7 @@ void Charger::run_state_machine() {
878878
}
879879
// Car is maybe not unplugged yet, so for HLC(AC/DC) wait in this state. We will go to Finished
880880
// once car is unplugged.
881-
} else {
882-
// For AC BASIC charging, we reached StoppingCharging because an unplug happend.
883-
pwm_off();
884-
shared_context.current_state = EvseState::Finished;
885881
}
886-
887882
bsp->allow_power_on(false, types::evse_board_support::Reason::PowerOff);
888883
}
889884

@@ -894,7 +889,7 @@ void Charger::run_state_machine() {
894889
break;
895890
}
896891

897-
if (shared_context.flag_paused_by_evse or stop_charging_on_fatal_error_internal()) {
892+
if (not power_available() or shared_context.flag_paused_by_evse or stop_charging_on_fatal_error_internal()) {
898893
// Paused was initiated by EVSE, continue to PausedEVSE
899894
set_state(EvseState::ChargingPausedEVSE);
900895
break;

modules/EVSE/EvseManager/Charger.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class Charger {
435435
// after the wake-up sequence.
436436
static constexpr int STAY_IN_X1_AFTER_TSTEP_EF_MS = 750;
437437
static constexpr int WAIT_FOR_ENERGY_IN_AUTHLOOP_TIMEOUT_MS = 5000;
438-
static constexpr int AC_X1_FALLBACK_TO_NOMINAL_TIMEOUT_MS = 3000;
438+
static constexpr int AC_X1_FALLBACK_TO_NOMINAL_TIMEOUT_MS = 10000; // TODO: is this reasonable?
439439

440440
types::evse_manager::EnableDisableSource active_enable_disable_source{
441441
types::evse_manager::Enable_source::Unspecified, types::evse_manager::Enable_state::Unassigned, 10000};

0 commit comments

Comments
 (0)