From 1797020481b8db91aa9a6092b9db52043695d514 Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Mon, 30 Nov 2020 19:42:36 -0800 Subject: ocpc: Center hysteresis around target We add a bit of hysteresis when determining our error for the OCPC PID loop equivalent to charger IC's "step" in regulating current. We had set the band above and below the target for the full step. In order to reduce overshoot, this commit centers the band around the current target. BUG=b:174167890 BRANCH=dedede TEST=Build and flash drawlat; verify that steady state now settles around a shorter band and overshoot is reduced. Signed-off-by: Aseda Aboagye Change-Id: I8f8c7305c3973fb5cedecdd14e5466f11a0e85a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2567035 Commit-Queue: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Diana Z --- common/ocpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/ocpc.c b/common/ocpc.c index ff42d679a1..04a9fa9855 100644 --- a/common/ocpc.c +++ b/common/ocpc.c @@ -321,7 +321,7 @@ int ocpc_config_secondary_charger(int *desired_input_current, if (ocpc->last_vsys != OCPC_UNINIT) { error = i_ma - batt.current; /* Add some hysteresis. */ - if (ABS(error) < i_step) + if (ABS(error) < (i_step / 2)) error = 0; /* Make a note if we're significantly over target. */ -- cgit v1.2.1