From 8e2fb0b36e29b0550afa8c7ad245fc279f09e79a Mon Sep 17 00:00:00 2001 From: "Vitor Moreno B. Sales" Date: Sun, 6 Nov 2022 23:52:04 -0300 Subject: [PATCH] Added possibility to configure Steper bounds (#930) Previous bounding worked only for PWM --- reference/speeduino.ini | 27 +++++++++++++++------------ speeduino/globals.h | 4 ++-- speeduino/idle.ino | 8 ++++---- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index b68bc1d5..925f2699 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -372,8 +372,8 @@ page = 1 aeTaperMin = scalar, U08, 59, "RPM", 100, 0.0, 1000, 10000, 0 aeTaperMax = scalar, U08, 60, "RPM", 100, 0.0, 2000, 10000, 0 - iacCLminDuty = scalar, U08, 61, "%", 1.0, 0.0, 0.0, 100.0, 0 ; Minimum and maximum duty cycles when using closed loop idle - iacCLmaxDuty = scalar, U08, 62, "%", 1.0, 0.0, 0.0, 100.0, 0 + iacCLminValue = scalar, U08, 61, "% / Steps", idleRes, 0.0, 0.0, idleResMax, 0 ; Minimum and maximum duty cycles when using closed loop idle + iacCLmaxValue = scalar, U08, 62, "% / Steps", idleRes, 0.0, 0.0, idleResMax, 0 boostMinDuty = scalar, U08, 63, "%", 1.0, 0.0, 0.0, 100.0, 0 ; Minimum and maximum duty cycles for boost control baroMin = scalar, S08, 64, "kpa", 1.0, 0.0, -100, 127.0, 0 @@ -1469,8 +1469,8 @@ page = 15 requiresPowerCycle = oddfire2 requiresPowerCycle = oddfire3 requiresPowerCycle = oddfire4 - requiresPowerCycle = iacCLminDuty - requiresPowerCycle = iacCLmaxDuty + requiresPowerCycle = iacCLminValue + requiresPowerCycle = iacCLmaxValue requiresPowerCycle = useExtBaro requiresPowerCycle = useEMAP requiresPowerCycle = baroPin @@ -1580,8 +1580,8 @@ page = 15 defaultValue = flexFreqHigh,150 defaultValue = fuelPumpPin, 0 defaultValue = fanPin, 0 - defaultValue = iacCLminDuty,0 - defaultValue = iacCLmaxDuty,100 + defaultValue = iacCLminValue,0 + defaultValue = iacCLmaxValue,100 defaultValue = iacTPSlimit, 5 defaultValue = iacRPMlimitHysteresis, 200 defaultValue = boostMinDuty,0 @@ -2057,8 +2057,8 @@ menuDialog = main iacAlgorithm = "Selects method of idle control.\nNone = no idle control valve.\nOn/Off valve.\nPWM valve (2,3 wire).\nStepper Valve (4,6,8 wire)." iacPWMdir = "Normal PWM valves increase RPM with higher duty. If RPM decreases with higher duty then select Reverse" iacPWMrun = "Determines if the idle valve runs before engine is cranked over. This can help starting the engine by letting more air in before the RPM sync is achieved." - iacCLminDuty = "When using closed loop idle control, this is the minimum duty cycle that the PID loop will allow. Combined with the maximum value, this specifies the working range of your idle valve" - iacCLmaxDuty = "When using closed loop idle control, this is the maximum duty cycle that the PID loop will allow. Combined with the minimum value, this specifies the working range of your idle valve" + iacCLminValue = "When using closed loop idle control, this is the minimum position value that the PID loop will allow. Combined with the maximum value, this specifies the working range of your idle valve" + iacCLmaxValue = "When using closed loop idle control, this is the maximum position value that the PID loop will allow. Combined with the minimum value, this specifies the working range of your idle valve" iacTPSlimit = "When using OL+CL idle control, if the TPS is higher than this value closed loop idle resets the integral of the PID (To prevent RPM dips coming back to idle)" iacRPMlimitHysteresis = "When using closed loop idle control, if the closed loop Target RPM + this value is higher than the actual RPM, closed loop idle resets the integral of the PID (To prevent RPM dips coming back to idle)" iacFastTemp = "Below this temperature, the idle output will be high (On). Above this temperature, it will turn off." @@ -2158,8 +2158,8 @@ menuDialog = main iacStepHyster = "The minimum number of steps to move in any one go." iacAlgorithm = "Selects method of idle control.\nNone = no idle control valve.\nOn/Off valve.\nPWM valve (2,3 wire).\nStepper Valve (4,6,8 wire)." iacPWMdir = "Normal PWM valves increase RPM with higher duty. If RPM decreases with higher duty then select Reverse" - iacCLminDuty = "When using closed loop idle control, this is the minimum duty cycle that the PID loop will allow. Combined with the maximum value, this specifies the working range of your idle valve" - iacCLmaxDuty = "When using closed loop idle control, this is the maximum duty cycle that the PID loop will allow. Combined with the minimum value, this specifies the working range of your idle valve" + iacCLminValue = "When using closed loop idle control, this is the minimum duty cycle that the PID loop will allow. Combined with the maximum value, this specifies the working range of your idle valve" + iacCLmaxValue = "When using closed loop idle control, this is the maximum duty cycle that the PID loop will allow. Combined with the minimum value, this specifies the working range of your idle valve" iacFastTemp = "Below this temperature, the idle output will be high (On). Above this temperature, it will turn off." idleUpPolarity = "Normal polarity is a ground switch where an earthed signal activates the Idle Up. The internal pullup will be enabled with Normal polarity. \n Inverted may be used if a 5v signal is used to enable the Idle Up." idleUpOutputEnabled = "Enable an output that is toggled by the idle up input pin. An example use is driving an AC fan relay." @@ -2788,8 +2788,8 @@ menuDialog = main field = "P", idleKP, { iacAlgorithm == 3 || iacAlgorithm == 5 || iacAlgorithm == 6 || iacAlgorithm == 7 } field = "I", idleKI, { iacAlgorithm == 3 || iacAlgorithm == 5 || iacAlgorithm == 6 || iacAlgorithm == 7 } field = "D", idleKD, { iacAlgorithm == 3 || iacAlgorithm == 5 || iacAlgorithm == 6 || iacAlgorithm == 7 } - field = "Minimum valve duty", iacCLminDuty, { iacAlgorithm == 3 || iacAlgorithm == 6 } - field = "Maximum valve duty", iacCLmaxDuty, { iacAlgorithm == 3 || iacAlgorithm == 6 } + field = "Minimum valve value", iacCLminValue, { iacAlgorithm == 3 || iacAlgorithm == 5 || iacAlgorithm == 6 || iacAlgorithm == 7 } + field = "Maximum valve value", iacCLmaxValue, { iacAlgorithm == 3 || iacAlgorithm == 5 || iacAlgorithm == 6 || iacAlgorithm == 7 } field = "Integral reset above TPS", iacTPSlimit, { iacAlgorithm == 6 || iacAlgorithm == 7 } field = "Integral reset RPM Hysteresis", iacRPMlimitHysteresis, { iacAlgorithm == 6 || iacAlgorithm == 7 } @@ -5359,6 +5359,9 @@ cmdVSSratio6 = "E\x99\x06" wmiLoadMax = { (wmiMode == 2) ? 100.0 : 255 } ;Select data resolution and scale based on algorithm used + idleRes = { (iacAlgorithm == 5 || iacAlgorithm == 7) ? 3.0 : 1.0 } + idleResMax = { (iacAlgorithm == 5 || iacAlgorithm == 7) ? (iacStepHome-3) : 100.0 } + vvtLoadRes = { (vvtLoadSource == 0) ? 2.000 : 0.500 } fuelLoadRes = { ((algorithm == 0) || (algorithm == 2)) ? 2.000 : 0.500 } diff --git a/speeduino/globals.h b/speeduino/globals.h index fdc10481..173980e7 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -852,8 +852,8 @@ struct config2 { byte aeTaperMin; byte aeTaperMax; - byte iacCLminDuty; - byte iacCLmaxDuty; + byte iacCLminValue; + byte iacCLmaxValue; byte boostMinDuty; int8_t baroMin; //Must be signed diff --git a/speeduino/idle.ino b/speeduino/idle.ino index e815e2da..b06b9c56 100644 --- a/speeduino/idle.ino +++ b/speeduino/idle.ino @@ -105,7 +105,7 @@ void initialiseIdle(bool forcehoming) #elif defined(CORE_TEENSY41) idle_pwm_max_count = 1000000L / (2 * configPage6.idleFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz #endif - idlePID.SetOutputLimits(percentage(configPage2.iacCLminDuty, idle_pwm_max_count<<2), percentage(configPage2.iacCLmaxDuty, idle_pwm_max_count<<2)); + idlePID.SetOutputLimits(percentage(configPage2.iacCLminValue, idle_pwm_max_count<<2), percentage(configPage2.iacCLmaxValue, idle_pwm_max_count<<2)); idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on idle_pid_target_value = 0; @@ -129,7 +129,7 @@ void initialiseIdle(bool forcehoming) #elif defined(CORE_TEENSY41) idle_pwm_max_count = 1000000L / (2 * configPage6.idleFreq * 2); //Converts the frequency in Hz to the number of ticks (at 2uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz #endif - idlePID.SetOutputLimits(percentage(configPage2.iacCLminDuty, idle_pwm_max_count<<2), percentage(configPage2.iacCLmaxDuty, idle_pwm_max_count<<2)); + idlePID.SetOutputLimits(percentage(configPage2.iacCLminValue, idle_pwm_max_count<<2), percentage(configPage2.iacCLmaxValue, idle_pwm_max_count<<2)); idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on idle_pid_target_value = table2D_getValue(&iacCrankDutyTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); @@ -205,7 +205,7 @@ void initialiseIdle(bool forcehoming) } idlePID.SetSampleTime(250); //4Hz means 250ms - idlePID.SetOutputLimits((configPage6.iacOLStepVal[9]*3)<<1, (configPage9.iacMaxSteps * 3)<<2); //Maximum number of steps; always less than home steps count. + idlePID.SetOutputLimits((configPage2.iacCLminValue * 3)<<2, (configPage2.iacCLmaxValue * 3)<<2); //Maximum number of steps; always less than home steps count. idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on configPage6.iacPWMrun = false; // just in case. This needs to be false with stepper idle @@ -249,7 +249,7 @@ void initialiseIdle(bool forcehoming) } idlePID.SetSampleTime(250); //4Hz means 250ms - idlePID.SetOutputLimits((configPage6.iacOLStepVal[9]*3)<<1, (configPage9.iacMaxSteps * 3)<<2); //Maximum number of steps; always less than home steps count. + idlePID.SetOutputLimits((configPage2.iacCLminValue * 3)<<2, (configPage2.iacCLmaxValue * 3)<<2); //Maximum number of steps; always less than home steps count. idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on configPage6.iacPWMrun = false; // just in case. This needs to be false with stepper idle