From 2f3995378e82c9684a03ab66fa3b974ce0ae3c58 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 8 Aug 2018 20:42:55 -0400 Subject: [PATCH] sorry more manual merge of #602 --- firmware/hw_layer/sensors/CJ125.cpp | 18 +++++++++++++----- firmware/hw_layer/sensors/CJ125.h | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/firmware/hw_layer/sensors/CJ125.cpp b/firmware/hw_layer/sensors/CJ125.cpp index 1e78c8a260..d206a46e02 100644 --- a/firmware/hw_layer/sensors/CJ125.cpp +++ b/firmware/hw_layer/sensors/CJ125.cpp @@ -361,9 +361,13 @@ static bool cjIsWorkingState(void) { } static void cjInitPid(void) { - // todo: these values are valid only for LSU 4.2 - heaterPidConfig.pFactor = CJ125_PID_LSU42_P; - heaterPidConfig.iFactor = CJ125_PID_LSU42_I; + if(engineConfiguration->cj125isLsu49) { + heaterPidConfig.pFactor = CJ125_PID_LSU49_P; + heaterPidConfig.iFactor = CJ125_PID_LSU49_I; + } else { + heaterPidConfig.pFactor = CJ125_PID_LSU42_P; + heaterPidConfig.iFactor = CJ125_PID_LSU42_I; + } heaterPidConfig.dFactor = 0.0f; heaterPidConfig.minValue = 0; heaterPidConfig.maxValue = 1; @@ -550,8 +554,12 @@ static void cjSetInit2(int v) { #endif /* CJ125_DEBUG */ float cjGetAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - // todo: make configurable sensor LSU type - cj125_sensor_type_e sensorType = CJ125_LSU_42; + cj125_sensor_type_e sensorType; + if (engineConfiguration->cj125isLsu49) { + sensorType = CJ125_LSU_49; + } else { + sensorType = CJ125_LSU_42; + } // See CJ125 datasheet, page 6 float pumpCurrent = (vUa - vUaCal) * amplCoeff * (CJ125_PUMP_CURRENT_FACTOR / CJ125_PUMP_SHUNT_RESISTOR); diff --git a/firmware/hw_layer/sensors/CJ125.h b/firmware/hw_layer/sensors/CJ125.h index f3a2a92107..cf757116fd 100644 --- a/firmware/hw_layer/sensors/CJ125.h +++ b/firmware/hw_layer/sensors/CJ125.h @@ -133,6 +133,9 @@ #define CJ125_PID_LSU42_P (80.0f / 16.0f * 5.0f / 1024.0f) #define CJ125_PID_LSU42_I (25.0f / 16.0f * 5.0f / 1024.0f) +#define CJ125_PID_LSU49_P (8.0f) +#define CJ125_PID_LSU49_I (0.003f) + // Returned if there's no valid measurement #define CJ125_AFR_NAN 0.0f