From 71b2dc762a760d5fcef4006221896f2dbedaacc8 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 14 Jan 2022 21:18:51 -0500 Subject: [PATCH] https://en.wikipedia.org/wiki/Pi --- firmware/controllers/actuators/electronic_throttle.cpp | 2 +- firmware/controllers/algo/rusefi_types.h | 2 ++ firmware/controllers/math/pid_auto_tune.h | 1 - firmware/hw_layer/sensors/hip9011_logic.cpp | 2 +- firmware/hw_layer/sensors/hip9011_logic.h | 3 +-- firmware/util/math/biquad.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index f3d56f2b17..f5b5afa04c 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -394,7 +394,7 @@ expected EtbController::getClosedLoopAutotune(percent_t target, perce float b = 2 * autotuneAmplitude; // Ultimate gain per A-H relay tuning rule - float ku = 4 * b / (3.14159f * m_a); + float ku = 4 * b / (CONST_PI * m_a); // The multipliers below are somewhere near the "no overshoot" // and "some overshoot" flavors of the Ziegler-Nichols method diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index 0ddc459e79..23afea7af5 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -35,6 +35,8 @@ typedef unsigned int time_t; // gasoline E0 #define STOICH_RATIO 14.7f +#define CONST_PI 3.14159265358979323846 + // time in seconds typedef time_t efitimesec_t; diff --git a/firmware/controllers/math/pid_auto_tune.h b/firmware/controllers/math/pid_auto_tune.h index 1016b4237a..976d20766c 100644 --- a/firmware/controllers/math/pid_auto_tune.h +++ b/firmware/controllers/math/pid_auto_tune.h @@ -20,7 +20,6 @@ typedef unsigned char byte; #endif // irrational constants -#define CONST_PI 3.14159265358979323846 #define CONST_SQRT2_DIV_2 0.70710678118654752440 diff --git a/firmware/hw_layer/sensors/hip9011_logic.cpp b/firmware/hw_layer/sensors/hip9011_logic.cpp index 2a1b5d25a0..5d65161abe 100644 --- a/firmware/hw_layer/sensors/hip9011_logic.cpp +++ b/firmware/hw_layer/sensors/hip9011_logic.cpp @@ -110,7 +110,7 @@ float HIP9011::getRpmByAngleWindowAndTimeUs(int timeUs, float angleWindowWidth) /** * TINT = TC * 2 * PI * VOUT */ - float integrationTimeUs = timeUs * 2 * PIF * HIP9011_DESIRED_OUTPUT_VALUE; + float integrationTimeUs = timeUs * 2 * CONST_PI * HIP9011_DESIRED_OUTPUT_VALUE; /** * rpm = 60 seconds / time * '60000000' because revolutions per MINUTE in uS conversion diff --git a/firmware/hw_layer/sensors/hip9011_logic.h b/firmware/hw_layer/sensors/hip9011_logic.h index 9beebc9df3..445d454cd1 100644 --- a/firmware/hw_layer/sensors/hip9011_logic.h +++ b/firmware/hw_layer/sensors/hip9011_logic.h @@ -15,8 +15,7 @@ #define EFI_HIP_9011_DEBUG EFI_HIP_9011 #endif -#define PIF 3.14159f -#define HIP9011_BAND(bore) (900 / (PIF * (bore) / 2)) +#define HIP9011_BAND(bore) (900 / (CONST_PI * (bore) / 2)) #define HIP9011_DESIRED_OUTPUT_VALUE 5.0f #define HIP9011_DIGITAL_OUTPUT_MAX 0x03ff /* 10 bit max value */ #define HIP_INPUT_CHANNELS 2 diff --git a/firmware/util/math/biquad.cpp b/firmware/util/math/biquad.cpp index 3ae911329f..4dff895059 100644 --- a/firmware/util/math/biquad.cpp +++ b/firmware/util/math/biquad.cpp @@ -22,7 +22,7 @@ void Biquad::reset() { } static float getK(float samplingFrequency, float cutoff) { - return tanf_taylor(3.14159f * cutoff / samplingFrequency); + return tanf_taylor(CONST_PI * cutoff / samplingFrequency); } static float getNorm(float K, float Q) {