diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 9b58b7d4..0a5893d3 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -377,18 +377,23 @@ page = 1 ;vssPullup = bits, U08, 102, [1:1], "Off", "On" vssPin = bits, U08, 102, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" vssPulsesPerKm= scalar, U16, 103, "pulses" 1.0, 0.0, 0.0, 25500, 0 - vssSmoothing = scalar, U08, 105, "%", 1.0, 0, 0, 120, 0 - vssRatio1 = scalar, U16, 106, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 - vssRatio2 = scalar, U16, 108, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 - vssRatio3 = scalar, U16, 110, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 - vssRatio4 = scalar, U16, 112, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 - vssRatio5 = scalar, U16, 114, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 - vssRatio6 = scalar, U16, 116, "km/h per 1000rpm", 0.1, 0, 0, 299.9, 1 + vssSmoothing = scalar, U08, 105, "%", 1.0, 0, 0, 255, 0 + vssRatio1 = scalar, U16, 106, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + vssRatio2 = scalar, U16, 108, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + vssRatio3 = scalar, U16, 110, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + vssRatio4 = scalar, U16, 112, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + vssRatio5 = scalar, U16, 114, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + vssRatio6 = scalar, U16, 116, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + + ;Idle up output (AC Fan) seettings + idleUpOutputEnabled = bits, U08, 118, [0:0], "Off", "On" + idleUpOutputInv = bits, U08, 118, [1:1], "No", "Yes" + idleUpOutputPin = bits, U08, 118, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" + + tachoSweepMaxRPM = scalar, U08, 119, "RPM", 100, 0.0, 100, 10000, 0 + primingDelay = scalar, U08, 120, "S", 0.1, 0.0, 0.0, 25.5, 1 - tachoSweepMaxRPM = scalar, U08, 118, "RPM", 100, 0.0, 100, 10000, 0 - - unused2-95 = array, U08, 119, [8], "%", 1.0, 0.0, 0.0, 255, 0 - primingDelay = scalar, U08, 127, "S", 0.1, 0.0, 0.0, 25.5, 1 + unused2-95 = array, U08, 121, [7], "%", 1.0, 0.0, 0.0, 255, 0 ;Page 2 is the fuel map and axis bins only page = 2 @@ -1259,6 +1264,7 @@ page = 14 requiresPowerCycle = knock_trigger requiresPowerCycle = knock_pullup requiresPowerCycle = idleUpEnabled + requiresPowerCycle = idleUpOutputEnabled requiresPowerCycle = CTPSEnabled requiresPowerCycle = CTPSPin requiresPowerCycle = CTPSPolarity @@ -1840,7 +1846,6 @@ menuDialog = main iacChannels = "The number of output channels used for PWM valves. Select 1 for 2-wire valves or 2 for 3-wire valves." iacStepTime = "Duration of each stepping pulse. Values that are too low can cause the motor to behave erratically or not at all. See the manual for suggested step times" iacCoolTime = "Cool time between each step. Set to zero if you don't want any cooling at all" - iacStepHome = "Homing steps to perform on startup. Must be greater than the fully open steps value" iacMaxSteps = "Maximum number of steps the IAC can be moved away from the home position. Should always be less than Homing steps." iacStepHyster = "The minimum number of steps to move in any one go." @@ -1850,6 +1855,8 @@ menuDialog = main 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" 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." + idleUpOutputInv = "No = When the idle up pin is high the output is active (grounding), when the idle up pin is low the output is inactive. Yes = When the idle up pin is high the output is inactive, when the idle up pin is low the output is active (grounding)." CTPSPolarity = "Normal polarity is a ground switch where an earthed signal activates the closed throttle position. The internal pullup will be enabled with Normal polarity. \n Inverted may be used if a 5v signal is used to enable the closed throttle position." idleUpAdder = "The amount (In either Duty Cycle % or Steps (Depending on the idle control method in use), that the idle control will increase by when Idle Up is active" idleAdvEnabled = "Added setting adds curve values to current spark table values when user defined idle is active. \n Switched setting overrides spark table values and uses curve values for idle ignition timing." @@ -2385,11 +2392,20 @@ menuDialog = main panel = stepper_idle panel = closedloop_idle + dialog = idleUpInputSettingsPanel, "Idle Up Input Settings", yAxis + field = "Idle Up Enabled", idleUpEnabled + field = "Idle Up Pin", idleUpPin, { idleUpEnabled } + field = "Idle Up Pin Polarity", idleUpPolarity, { idleUpEnabled } + field = "Idle Up Amount", idleUpAdder, { idleUpEnabled } + + dialog = idleUpOutputSettingsPanel, "Idle Up Output Settings", yAxis + field = "Idle Up Output Enabled", idleUpOutputEnabled, { idleUpEnabled } + field = "Idle Up Output Inverted", idleUpOutputInv, { idleUpEnabled && idleUpOutputEnabled + field = "Idle Up Output Pin", idleUpOutputPin, { idleUpEnabled && idleUpOutputEnabled } + dialog = idleUpSettings, "Idle Up Settings" - field = "Idle Up Enabled", idleUpEnabled - field = "Idle Up Pin", idleUpPin, { idleUpEnabled } - field = "Idle Up Pin Polarity", idleUpPolarity, { idleUpEnabled } - field = "Idle Up Amount", idleUpAdder, { idleUpEnabled } + panel = idleUpInputSettingsPanel + panel = idleUpOutputSettingsPanel dialog = fuelpump, "Fuel pump" field = "Fuel pump pin", fuelPumpPin @@ -3480,6 +3496,7 @@ menuDialog = main displayOnlyField = "fanPin", fanPin, {fanEnable} displayOnlyField = "tachoPin", tachoPin, {tachoDuration} displayOnlyField = "idleUpPin", idleUpPin, {idleUpEnabled} + displayOnlyField = "idleUpOutputPin", idleUpOutputPin, {idleUpEnabled && idleUpOutputEnabled} displayOnlyField = "launchPin", launchPin, {launchEnable} displayOnlyField = "vvt1Pin", vvt1Pin, {vvtEnabled} displayOnlyField = "vssPin", vssPin, {vssMode > 1} diff --git a/speeduino/globals.h b/speeduino/globals.h index 2e3a5995..c7bba8d1 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -620,6 +620,7 @@ struct statuses { uint16_t injAngle; byte ASEValue; uint16_t vss; /**< Current speed reading. Natively stored in kph and converted to mph in TS if required */ + bool idleUpOutputActive; /**< Whether the idle up output is currently active */ byte gear; /**< Current gear (Calculated from vss) */ byte fuelPressure; /**< Fuel pressure in PSI */ byte oilPressure; /**< Oil pressure in PSI */ @@ -777,8 +778,14 @@ struct config2 { uint16_t vssRatio5; uint16_t vssRatio6; - byte unused2_95[9]; + byte idleUpOutputEnabled : 1; + byte idleUpOutputInv : 1; + byte idleUpOutputPin : 6; + + byte tachoSweepMaxRPM; byte primingDelay; + + byte unused2_95[7]; #if defined(CORE_AVR) }; @@ -1303,6 +1310,7 @@ extern byte pinFuelPump; //Fuel pump on/off extern byte pinIdle1; //Single wire idle control extern byte pinIdle2; //2 wire idle control (Not currently used) extern byte pinIdleUp; //Input for triggering Idle Up +extern byte pinIdleUpOutput; //Output that follows (normal or inverted) the idle up pin extern byte pinCTPS; //Input for triggering closed throttle state extern byte pinFuel2Input; //Input for switching to the 2nd fuel table extern byte pinSpark2Input; //Input for switching to the 2nd ignition table diff --git a/speeduino/globals.ino b/speeduino/globals.ino index ce22ba0f..5f684806 100644 --- a/speeduino/globals.ino +++ b/speeduino/globals.ino @@ -185,6 +185,7 @@ byte pinFuelPump; //Fuel pump on/off byte pinIdle1; //Single wire idle control byte pinIdle2; //2 wire idle control (Not currently used) byte pinIdleUp; //Input for triggering Idle Up +byte pinIdleUpOutput; //Output that follows (normal or inverted) the idle up pin byte pinCTPS; //Input for triggering closed throttle state byte pinFuel2Input; //Input for switching to the 2nd fuel table byte pinSpark2Input; //Input for switching to the 2nd ignition table diff --git a/speeduino/idle.h b/speeduino/idle.h index 3b531aad..878d12a6 100644 --- a/speeduino/idle.h +++ b/speeduino/idle.h @@ -46,6 +46,8 @@ volatile PORT_TYPE *idle_pin_port; volatile PINMASK_TYPE idle_pin_mask; volatile PORT_TYPE *idle2_pin_port; volatile PINMASK_TYPE idle2_pin_mask; +volatile PORT_TYPE *idleUpOutput_pin_port; +volatile PINMASK_TYPE idleUpOutput_pin_mask; volatile bool idle_pwm_state; unsigned int idle_pwm_max_count; //Used for variable PWM frequency @@ -55,7 +57,11 @@ unsigned long idle_pwm_target_value; long idle_cl_target_rpm; byte idleCounter; //Used for tracking the number of calls to the idle control function +byte idleUpOutputHIGH = HIGH; // Used to invert the idle Up Output +byte idleUpOutputLOW = LOW; // Used to invert the idle Up Output + void initialiseIdle(); +void initialiseIdleUpOutput(); static inline void disableIdle(); static inline void enableIdle(); static inline byte isStepperHomed(); diff --git a/speeduino/idle.ino b/speeduino/idle.ino index 08980ce2..04dcf5ad 100644 --- a/speeduino/idle.ino +++ b/speeduino/idle.ino @@ -172,20 +172,49 @@ void initialiseIdle() //Well this just shouldn't happen break; } + + initialiseIdleUpOutput(); + idleInitComplete = configPage6.iacAlgorithm; //Sets which idle method was initialised currentStatus.idleLoad = 0; } +void initialiseIdleUpOutput() +{ + if (configPage2.idleUpOutputInv == 1) { idleUpOutputHIGH = LOW; idleUpOutputLOW = HIGH; } + else { idleUpOutputHIGH = HIGH; idleUpOutputLOW = LOW; } + + digitalWrite(pinIdleUpOutput, idleUpOutputLOW); //Initiallise program with the idle up output in the off state + currentStatus.idleUpOutputActive = false; + + idleUpOutput_pin_port = portOutputRegister(digitalPinToPort(pinIdleUpOutput)); + idleUpOutput_pin_mask = digitalPinToBitMask(pinIdleUpOutput); +} + void idleControl() { - if(idleInitComplete != configPage6.iacAlgorithm) { initialiseIdle(); } - if(currentStatus.RPM > 0) { enableIdle(); } + if (idleInitComplete != configPage6.iacAlgorithm) { initialiseIdle(); } + if (currentStatus.RPM > 0) { enableIdle(); } //Check whether the idleUp is active - if(configPage2.idleUpEnabled == true) + if (configPage2.idleUpEnabled == true) { - if(configPage2.idleUpPolarity == 0) { currentStatus.idleUpActive = !digitalRead(pinIdleUp); } //Normal mode (ground switched) + if (configPage2.idleUpPolarity == 0) { currentStatus.idleUpActive = !digitalRead(pinIdleUp); } //Normal mode (ground switched) else { currentStatus.idleUpActive = digitalRead(pinIdleUp); } //Inverted mode (5v activates idleUp) + + if (configPage2.idleUpOutputEnabled == true) + { + if (currentStatus.idleUpActive == true) + { + digitalWrite(pinIdleUpOutput, idleUpOutputHIGH); + currentStatus.idleUpOutputActive = true; + } + else + { + digitalWrite(pinIdleUpOutput, idleUpOutputLOW); + currentStatus.idleUpOutputActive = false; + } + } } else { currentStatus.idleUpActive = false; } diff --git a/speeduino/init.ino b/speeduino/init.ino index 6de42676..729e33f4 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -2350,6 +2350,9 @@ void setPinMapping(byte boardID) //Currently there's no default pin for Idle Up pinIdleUp = pinTranslate(configPage2.idleUpPin); + //Currently there's no default pin for Idle Up Output + pinIdleUpOutput = pinTranslate(configPage2.idleUpOutputPin); + //Currently there's no default pin for closed throttle position sensor pinCTPS = pinTranslate(configPage2.CTPSPin); @@ -2368,6 +2371,7 @@ void setPinMapping(byte boardID) pinMode(pinTachOut, OUTPUT); pinMode(pinIdle1, OUTPUT); pinMode(pinIdle2, OUTPUT); + pinMode(pinIdleUpOutput, OUTPUT); pinMode(pinFuelPump, OUTPUT); pinMode(pinIgnBypass, OUTPUT); pinMode(pinFan, OUTPUT);