From f6095b833982d1532833918c6e24ba74268ed013 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sun, 25 Jul 2021 17:42:26 -0700 Subject: [PATCH] fix nonlinear correction threshold (#3060) * s * macro * test has to do the inverse --- firmware/controllers/algo/fuel/injector_model.cpp | 2 +- firmware/util/efitime.h | 2 ++ unit_tests/tests/ignition_injection/test_injector_model.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/algo/fuel/injector_model.cpp b/firmware/controllers/algo/fuel/injector_model.cpp index 412c4abe56..465e71dc1d 100644 --- a/firmware/controllers/algo/fuel/injector_model.cpp +++ b/firmware/controllers/algo/fuel/injector_model.cpp @@ -128,7 +128,7 @@ float InjectorModel::correctShortPulse(float baseDuration) const { } float InjectorModel::correctInjectionPolynomial(float baseDuration) const { - if (baseDuration > CONFIG(applyNonlinearBelowPulse)) { + if (baseDuration > USF2MS(CONFIG(applyNonlinearBelowPulse))) { // Large pulse, skip correction. return baseDuration; } diff --git a/firmware/util/efitime.h b/firmware/util/efitime.h index e20fe35742..a42bade031 100644 --- a/firmware/util/efitime.h +++ b/firmware/util/efitime.h @@ -29,6 +29,8 @@ // the expensive conversions from int64 <-> float #define USF2NT(us_float) ((us_float) * US_TO_NT_MULTIPLIER) +#define USF2MS(us_float) (0.001f * (us_float)) + // And back #define NT2US(x) ((x) / US_TO_NT_MULTIPLIER) diff --git a/unit_tests/tests/ignition_injection/test_injector_model.cpp b/unit_tests/tests/ignition_injection/test_injector_model.cpp index 701ecb7319..3a65f96e53 100644 --- a/unit_tests/tests/ignition_injection/test_injector_model.cpp +++ b/unit_tests/tests/ignition_injection/test_injector_model.cpp @@ -67,7 +67,7 @@ TEST(InjectorModel, nonlinearPolynomial) { InjectorModel dut; INJECT_ENGINE_REFERENCE(&dut); - CONFIG(applyNonlinearBelowPulse) = 10; + CONFIG(applyNonlinearBelowPulse) = MS2US(10); for (int i = 0; i < 8; i++) { CONFIG(injectorCorrectionPolynomial)[i] = i + 1;