From fcb78b2e9f3746849411431e22e3fae00f1e5359 Mon Sep 17 00:00:00 2001 From: vaiski <68817622+vaizq@users.noreply.github.com> Date: Mon, 19 Jun 2023 11:33:26 +0300 Subject: [PATCH] Small fix so that vvt2PID get updated in a correct frequency. (#1060) --- speeduino/auxiliaries.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index 3ced81c6..7d39579e 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -793,7 +793,7 @@ void vvtControl(void) if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, (currentStatus.TPS * 2), currentStatus.RPM); } else { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, currentStatus.MAP, currentStatus.RPM); } - if( vvtCounter == 30) { vvt2PID.SetTunings(configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD); //This only needs to be run very infrequently, once every 32 calls to vvtControl(). This is approx. once per second + if( (vvtCounter & 31) == 1) { vvt2PID.SetTunings(configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD); //This only needs to be run very infrequently, once every 32 calls to vvtControl(). This is approx. once per second vvt2PID.SetControllerDirection(configPage4.vvt2PWMdir); } // safety check that the cam angles are ok. The engine will be totally undriveable if the cam sensor is faulty and giving wrong cam angles, so if that happens, default to 0 duty.