diff --git a/reference/speeduino.ini b/reference/speeduino.ini index db4cb556..2126e5bf 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -1361,8 +1361,8 @@ menuDialog = main subMenu = iacClosedLoop_curve, "Idle - RPM targets", 7, { iacAlgorithm == 3 || iacAlgorithm == 5 || idleAdvEnabled >= 1 } subMenu = iacPwm_curve, "Idle - PWM Duty Cycle", 7, { iacAlgorithm == 2 } subMenu = iacPwmCrank_curve, "Idle - PWM Cranking Duty Cycle", 7, { iacAlgorithm == 2 } - subMenu = iacStep_curve, "Idle - Stepper Motor", 7, { iacAlgorithm == 4 } - subMenu = iacStepCrank_curve, "Idle - Stepper Motor Cranking", 7, { iacAlgorithm == 4 } + subMenu = iacStep_curve, "Idle - Stepper Motor", 7, { iacAlgorithm == 4 } + subMenu = iacStepCrank_curve, "Idle - Stepper Motor Cranking", 7, { iacAlgorithm == 4 || iacAlgorithm == 5 } subMenu = std_separator subMenu = idleUpSettings, "Idle Up Settings", { iacAlgorithm == 2 || iacAlgorithm == 3 || iacAlgorithm == 4 || iacAlgorithm == 5 } subMenu = std_separator diff --git a/speeduino/idle.ino b/speeduino/idle.ino index 21efeacb..8cb34e6a 100644 --- a/speeduino/idle.ino +++ b/speeduino/idle.ino @@ -321,6 +321,24 @@ void idleControl() //First thing to check is whether there is currently a step going on and if so, whether it needs to be turned off if( (checkForStepping() == false) && (isStepperHomed() == true) ) //Check that homing is complete and that there's not currently a step already taking place. MUST BE IN THIS ORDER! { + if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK )/* ||currentStatus.rpmDOT>=500||currentStatus.rpmDOT<=-500*/) + { + //Currently cranking. Use the cranking table + idleStepper.targetIdleStep = table2D_getValue(&iacCrankStepsTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here + if(currentStatus.idleUpActive == true) { idleStepper.targetIdleStep += configPage2.idleUpAdder; } //Add Idle Up amount if active + + //limit to the configured max steps. This must include any idle up adder, to prevent over-opening. + if (idleStepper.targetIdleStep > (configPage9.iacMaxSteps * 3) ) + { + idleStepper.targetIdleStep = configPage9.iacMaxSteps * 3; + } + + doStep(); + + } + + else + { if( (idleCounter & 31) == 1) { //This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second @@ -342,9 +360,11 @@ void idleControl() } doStep(); - currentStatus.idleLoad = idleStepper.curIdleStep / 2; //Current step count (Divided by 2 for byte) + idleCounter++; } + currentStatus.idleLoad = idleStepper.curIdleStep / 2; //Current step count (Divided by 2 for byte) + } //Set or clear the idle active flag if(idleStepper.targetIdleStep != idleStepper.curIdleStep) { BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); } else { BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); }