diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 2c470ec4..16a8a7c6 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -547,6 +547,7 @@ page = 6 fanPWMBins = array, U08, 124, [4], "F", 1.8, -22.23, -40, 215, 0 #endif + ;-------------------------------------------------- ;Boost and vvt maps (Page 7) ;-------------------------------------------------- @@ -852,7 +853,9 @@ page = 9 ;unused10_150 = scalar, U08, 150, "", 1, 0, 0, 255, 0 ;unused10_151 = scalar, U08, 151, "", 1, 0, 0, 255, 0 ;unused10_152 = scalar, U08, 152, "", 1, 0, 0, 255, 0 - unused10_153 = scalar, U08, 153, "", 1, 0, 0, 255, 0 + ;unused10_153 = scalar, U08, 153, "", 1, 0, 0, 255, 0 + iacStepperInv = bits, U08, 153, [0:0], "No", "Yes" + unused10_154 = scalar, U08, 154, "", 1, 0, 0, 255, 0 unused10_155 = scalar, U08, 155, "", 1, 0, 0, 255, 0 unused10_156 = scalar, U08, 156, "", 1, 0, 0, 255, 0 @@ -1714,6 +1717,7 @@ menuDialog = main field = "Step time (ms)", iacStepTime, { iacAlgorithm == 4 || iacAlgorithm == 5 } field = "Home steps", iacStepHome, { iacAlgorithm == 4 || iacAlgorithm == 5 } field = "Minimum Steps", iacStepHyster, { iacAlgorithm == 4 || iacAlgorithm == 5 } + field = "Stepper Inverted", iacStepperInv, { iacAlgorithm == 4 || iacAlgorithm == 5 } dialog = pwm_idle, "PWM Idle" field = "Number of outputs", iacChannels, { iacAlgorithm == 2 || iacAlgorithm == 3 } @@ -1801,7 +1805,7 @@ menuDialog = main field = "Cranking advance Angle", CrankAng field = "Spark Outputs triggers", IgInv field = "" - field = "Enabled Fixed/Locked timing", fixAngEnable + field = "Enabled Fixed/Locked timing", fixAngEnable field = "Fixed Angle", FixAng, { fixAngEnable } field = "#Note: During cranking the fixed/locked timing angle is overriden by the Cranking advance angle value above" field = "" @@ -1895,8 +1899,8 @@ menuDialog = main field = "Nitrous is armed when pin is", n2o_pin_polarity,{ n2o_enable > 0 } field = "Minimum CLT", n2o_minCLT, { n2o_enable > 0 } field = "Minimum TPS", n2o_minTPS, { n2o_enable > 0 } - field = "Maximum MAP", n2o_maxMAP, { n2o_enable > 0 } - field = "Leanest AFR", n2o_maxAFR, { n2o_enable > 0 } + field = "Maximum MAP", n2o_maxMAP, { n2o_enable > 0 } + field = "Leanest AFR", n2o_maxAFR, { n2o_enable > 0 } dialog = NitrousControl, "Nitrous" panel = NitrousMain, North diff --git a/speeduino/globals.h b/speeduino/globals.h index 882ca70b..8ffea6ea 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -726,8 +726,9 @@ struct config9 { uint16_t obd_address; //speeduino OBD diagnostic address uint8_t Auxinpina[16]; //analog pin number when internal aux in use uint8_t Auxinpinb[16]; // digital pin number when internal aux in use - - byte unused10_152; + + byte iacStepperInv : 1; //stepper direction of travel to allow reversing. 0=normal, 1=inverted. + byte unused10_153; byte unused10_154; byte unused10_155; diff --git a/speeduino/idle.h b/speeduino/idle.h index ffa4f22c..53a89826 100644 --- a/speeduino/idle.h +++ b/speeduino/idle.h @@ -23,6 +23,8 @@ struct StepperIdle int targetIdleStep; //What the targetted step is volatile StepperStatus stepperStatus; volatile unsigned long stepStartTime; //The time the curren + byte lessAirDirection; + byte moreAirDirection; }; #if defined(CORE_AVR) diff --git a/speeduino/idle.ino b/speeduino/idle.ino index 1a156b8e..b0829bd8 100644 --- a/speeduino/idle.ino +++ b/speeduino/idle.ino @@ -183,6 +183,17 @@ void initialiseIdle() completedHomeSteps = 0; idleStepper.curIdleStep = 0; idleStepper.stepperStatus = SOFF; + if (! configPage9.iacStepperInv) + { + idleStepper.lessAirDirection = STEPPER_BACKWARD; + idleStepper.moreAirDirection = STEPPER_FORWARD; + } + else + { + idleStepper.lessAirDirection = STEPPER_FORWARD; + idleStepper.moreAirDirection = STEPPER_BACKWARD; + } + break; case IAC_ALGORITHM_STEP_CL: @@ -203,6 +214,17 @@ void initialiseIdle() idleStepper.curIdleStep = 0; idleStepper.stepperStatus = SOFF; + if (! configPage9.iacStepperInv) + { + idleStepper.lessAirDirection = STEPPER_BACKWARD; + idleStepper.moreAirDirection = STEPPER_FORWARD; + } + else + { + idleStepper.lessAirDirection = STEPPER_FORWARD; + idleStepper.moreAirDirection = STEPPER_BACKWARD; + } + idlePID.SetOutputLimits(0, (configPage6.iacStepHome * 3)); //Maximum number of steps probably needs its own setting idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on @@ -354,7 +376,7 @@ static inline byte isStepperHomed() bool isHomed = true; //As it's the most common scenario, default value is true if( completedHomeSteps < (configPage6.iacStepHome * 3) ) //Home steps are divided by 3 from TS { - digitalWrite(pinStepperDir, STEPPER_BACKWARD); //Sets stepper direction to backwards + digitalWrite(pinStepperDir, idleStepper.lessAirDirection); //homing the stepper closes off the air bleed digitalWrite(pinStepperEnable, LOW); //Enable the DRV8825 digitalWrite(pinStepperStep, HIGH); idleStepper.stepStartTime = micros_safe(); @@ -410,8 +432,20 @@ static inline void doStep() { if ( (idleStepper.targetIdleStep <= (idleStepper.curIdleStep - configPage6.iacStepHyster)) || (idleStepper.targetIdleStep >= (idleStepper.curIdleStep + configPage6.iacStepHyster)) ) //Hysteris check { - if(idleStepper.targetIdleStep < idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_BACKWARD); idleStepper.curIdleStep--; }//Sets stepper direction to backwards - else if (idleStepper.targetIdleStep > idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_FORWARD); idleStepper.curIdleStep++; }//Sets stepper direction to forwards + // the home position for a stepper is pintle fully seated, i.e. no airflow. + if(idleStepper.targetIdleStep < idleStepper.curIdleStep) + { + // we are moving toward the home position (reducing air) + digitalWrite(pinStepperDir, idleStepper.lessAirDirection); + idleStepper.curIdleStep--; + } + else + if (idleStepper.targetIdleStep > idleStepper.curIdleStep) + { + // we are moving away from the home position (adding air). + digitalWrite(pinStepperDir, idleStepper.moreAirDirection); + idleStepper.curIdleStep++; + } digitalWrite(pinStepperEnable, LOW); //Enable the DRV8825 digitalWrite(pinStepperStep, HIGH);