diff --git a/firmware/controllers/algo/can_header.h b/firmware/controllers/algo/can_header.h deleted file mode 100644 index b5b78870c5..0000000000 --- a/firmware/controllers/algo/can_header.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @file can_header.h - * - * @date Dec 21, 2013 - * @author Andrey Belomutskiy, (c) 2012-2016 - */ - -#ifndef CAN_HEADER_H_ -#define CAN_HEADER_H_ - -#include "rusefi_enums.h" - -/** - * Net Body Computer types - */ -typedef enum { - CAN_BUS_NBC_BMW = 0, - CAN_BUS_NBC_FIAT = 1, - CAN_BUS_NBC_VAG = 2, - CAN_BUS_MAZDA_RX8 = 3, - - Internal_ForceMyEnumIntSize_can_nbc = ENUM_32_BITS, -} can_nbc_e; - -#endif /* CAN_HEADER_H_ */ diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index d1e5b81b4f..81c0d2bdb2 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -11,7 +11,6 @@ #include "efifeatures.h" #include "crc.h" -#include "can_header.h" #include "rusefi_enums.h" #include "global.h" #include "rusefi_types.h" diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 11377b39dd..4bddc7a4cc 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,5 +1,9 @@ // this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jan 14 23:21:45 EST 2016 // begin + +#ifndef ENGINE_CONFIGURATION_GENERATED_H_ +#define ENGINE_CONFIGURATION_GENERATED_H_ + #include "rusefi_types.h" typedef struct { /** @@ -1607,5 +1611,6 @@ typedef struct { /** total size 16088*/ } persistent_config_s; +#endif // end // this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jan 14 23:21:45 EST 2016 diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 5f452eb49c..18dcfcf709 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -640,5 +640,16 @@ typedef enum { Internal_ForceMyEnumIntSize_chamber_stype = ENUM_32_BITS, } chamber_style_e; +/** + * Net Body Computer types + */ +typedef enum { + CAN_BUS_NBC_BMW = 0, + CAN_BUS_NBC_FIAT = 1, + CAN_BUS_NBC_VAG = 2, + CAN_BUS_MAZDA_RX8 = 3, + + Internal_ForceMyEnumIntSize_can_nbc = ENUM_32_BITS, +} can_nbc_e; #endif /* RUSEFI_ENUMS_H_ */ diff --git a/firmware/controllers/alternatorController.cpp b/firmware/controllers/alternatorController.cpp index a6227ba939..63128883b2 100644 --- a/firmware/controllers/alternatorController.cpp +++ b/firmware/controllers/alternatorController.cpp @@ -16,6 +16,9 @@ #include "voltage.h" #include "pid.h" +#if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__) + + EXTERN_ENGINE ; @@ -25,7 +28,8 @@ static Logging *logger; static SimplePwm alternatorControl; static OutputPin alternatorPin; -static Pid altPid(10, 0, 0, 1, 90); +static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl; +static Pid altPid(altPidS, 1, 90); static THD_WORKING_AREA(alternatorControlThreadStack, UTILITY_THREAD_STACK_SIZE); @@ -108,3 +112,5 @@ void initAlternatorCtrl(Logging *sharedLogger) { applySettings(); } + +#endif /* EFI_ALTERNATOR_CONTROL */ diff --git a/firmware/controllers/electronic_throttle.cpp b/firmware/controllers/electronic_throttle.cpp index cff37e8496..d4ae39d52f 100644 --- a/firmware/controllers/electronic_throttle.cpp +++ b/firmware/controllers/electronic_throttle.cpp @@ -54,7 +54,8 @@ static OutputPin output2 CCM_OPTIONAL; static OutputPin outputDirectionOpen CCM_OPTIONAL; static OutputPin outputDirectionClose CCM_OPTIONAL; -static Pid pid(1, 0, 0, 0, 100); +static pid_s etbS; +static Pid pid(&etbS, 0, 100); static float prevTps; diff --git a/firmware/controllers/math/pid.cpp b/firmware/controllers/math/pid.cpp index 8de187bbf8..19d1b98e1d 100644 --- a/firmware/controllers/math/pid.cpp +++ b/firmware/controllers/math/pid.cpp @@ -9,10 +9,8 @@ #include "pid.h" -Pid::Pid(float pFactor, float iFactor, float dFactor, float minResult, float maxResult) { - this->pFactor = pFactor; - this->iFactor = iFactor; - this->dFactor = dFactor; +Pid::Pid(pid_s *pid, float minResult, float maxResult) { + this->pid = pid; this->minResult = minResult; this->maxResult = maxResult; @@ -23,9 +21,9 @@ Pid::Pid(float pFactor, float iFactor, float dFactor, float minResult, float max float Pid::getValue(float target, float input, float dTime) { float error = target - input; - float pTerm = pFactor * error; - iTerm += iFactor * dTime * error; - float dTerm = dFactor / dTime * (error - prevError); + float pTerm = pid->pFactor * error; + iTerm += pid->iFactor * dTime * error; + float dTerm = pid->dFactor / dTime * (error - prevError); prevError = error; @@ -41,9 +39,9 @@ float Pid::getValue(float target, float input, float dTime) { } void Pid::updateFactors(float pFactor, float iFactor, float dFactor) { - this->pFactor = pFactor; - this->iFactor = iFactor; - this->dFactor = dFactor; + pid->pFactor = pFactor; + pid->iFactor = iFactor; + pid->dFactor = dFactor; reset(); } @@ -53,11 +51,11 @@ void Pid::reset(void) { } float Pid::getP(void) { - return pFactor; + return pid->pFactor; } float Pid::getI(void) { - return iFactor; + return pid->iFactor; } float Pid::getIntegration(void) { @@ -65,7 +63,7 @@ float Pid::getIntegration(void) { } float Pid::getD(void) { - return dFactor; + return pid->dFactor; } diff --git a/firmware/controllers/math/pid.h b/firmware/controllers/math/pid.h index b35cde241b..6859f7cdcb 100644 --- a/firmware/controllers/math/pid.h +++ b/firmware/controllers/math/pid.h @@ -8,10 +8,12 @@ #ifndef PID_H_ #define PID_H_ +#include "engine_configuration_generated_structures.h" + class Pid { public: - Pid(float pFactor, float iFactor, float dFactor, float minResult, float maxResult); + Pid(pid_s *pid, float minResult, float maxResult); float getValue(float target, float input, float dTime); void updateFactors(float pFactor, float iFactor, float dFactor); void reset(void); @@ -20,15 +22,12 @@ public: float getIntegration(void); float getD(void); private: - float pFactor; - float iFactor; - float dFactor; + pid_s *pid; float minResult; float maxResult; float iTerm; float prevError; - }; #endif /* PID_H_ */ diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index 7005861ce2..0496216e65 100644 --- a/firmware/hw_layer/can_hw.cpp +++ b/firmware/hw_layer/can_hw.cpp @@ -18,7 +18,6 @@ #include "pin_repository.h" #include "engine_state.h" -#include "can_header.h" #include "engine_configuration.h" #include "vehicle_speed.h" #endif /* EFI_PROD_CODE */ diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 81f38d5796..20163c8a30 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -946,7 +946,7 @@ fileVersion = { 20151201 } gauge3 = throttleGauge gauge4 = mafGaugeVolts gauge5 = afr1Gauge - gauge6 = tpsADCGauge + gauge6 = VBattGauge gauge7 = dwellGauge gauge8 = ignadvGauge @@ -985,29 +985,29 @@ fileVersion = { 20151201 } ; Channel Label Type Format entry = time, "Time", float, "%.3f" entry = rpm, "RPM", int, "%d" - entry = coolant, "CLT", float, "%.1f" - entry = intake, "IAT", float, "%.1f" + entry = coolant, "CLT", float, "%.2f" + entry = intake, "IAT", float, "%.2f" entry = TPS, "TPS", float, "%d" entry = MAF, "MAF", float, "%.2f" - entry = MAPValue, "MAP", float, "%d" + entry = MAPValue, "MAP", float, "%.1f" entry = AFRactual, "AFR", float, "%.2f" entry = VBatt, "vBatt", float, "%.2f" - entry = engineLoad, "Load", float, "%d" + entry = engineLoad, "Load", float, "%.1f" entry = ign_adv, "ignAdv", float, "%.2f" entry = knockLevel, "Knock", float, "%.2f" entry = vehicleSpeedKph, "speed", float, "%.2f" entry = rpmAcceleration, "dRPM", float, "%.3f" - entry = massAirFlowValue,"airMass", float, "%.3f" + entry = massAirFlowValue,"airMass", float, "%.3f" entry = pedalPosition, "pedal", float, "%.3f" entry = triggerErrorsCounter, "trg err",int, "%d" entry = pulseWidth, "injPulse", float, "%.3f" - entry = baseFuel, "fuel: base", float, "%.2f" - entry = veValue, "fuel: VE", float, "%.3f" + entry = baseFuel, "fuel: base", float, "%.2f" + entry = veValue, "fuel: VE", float, "%.3f" entry = engineLoadAccelDelta, "fuel: EL accel",float, "%.3f" entry = tpsAccelFuel, "fuel: tpsAccel", float, "%.3f" - entry = iatCorrection, "fuel: IAT corr", float, "%.3f" - entry = wallFuelCorrection, "fuel: wall corr ms", float, "%.3f" + entry = iatCorrection, "fuel: IAT corr", float, "%.3f" + entry = wallFuelCorrection,"fuel: wall corr ms", float, "%.3f" entry = wallFuelAmount, "fuel: wall amout", float, "%.3f" entry = baroCorrection "baroCorrection",float,"%.3f" diff --git a/unit_tests/test_idle_controller.cpp b/unit_tests/test_idle_controller.cpp index 5ad8663933..e733023f31 100644 --- a/unit_tests/test_idle_controller.cpp +++ b/unit_tests/test_idle_controller.cpp @@ -39,7 +39,12 @@ void testIdleController(void) { void testPidController(void) { print("******************************************* testPidController\r\n"); - Pid pid(50, 0.5, 0, 10, 90); + pid_s pidS; + pidS.pFactor = 50; + pidS.iFactor = 0.5; + pidS.dFactor = 0; + + Pid pid(&pidS, 10, 90); assertEquals(90, pid.getValue(14, 12, 0.1));