Option to allow reverse direction for PWM valve

This commit is contained in:
Josh Stewart 2016-05-15 19:29:52 +10:00
parent 9742f831ad
commit 366f75c38b
3 changed files with 8 additions and 5 deletions

View File

@ -354,7 +354,7 @@ struct config4 {
byte iacAlgorithm : 3; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop"
byte iacStepTime : 3; //How long to pulse the stepper for to ensure the step completes (ms)
byte iacChannels : 1; //How many outputs to use in PWM mode (0 = 1 channel, 1 = 2 channels)
byte unused52 : 1;
byte iacPWMdir : 1; //Directino of the PWM valve. 0 = Normal = Higher RPM with more duty. 1 = Reverse = Lower RPM with more duty
byte iacFastTemp; //Fast idle temp when using a simple on/off valve

View File

@ -152,7 +152,6 @@ void idleControl()
//No cranking specific value for closed loop (yet?)
idle_cl_target_rpm = table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) * 10; //All temps are offset by 40 degrees
longRPM = currentStatus.RPM; //The PID object needs a long as the RPM input. A separate variable is used for this
idlePID.SetOutputLimits(0, idle_pwm_max_count);
idlePID.SetTunings(configPage3.idleKP, configPage3.idleKI, configPage3.idleKD);
idlePID.Compute();
@ -249,7 +248,8 @@ ISR(TIMER4_COMPC_vect)
*idle_pin_port &= ~(idle_pin_mask); // Switch pin to low (1 pin mode)
if(configPage4.iacChannels) { *idle2_pin_port |= (idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1
OCR4C = TCNT4 + (idle_pwm_max_count - idle_pwm_cur_value);
idle_pwm_state = false;
if (configPage4.iacPWMdir == 0) { idle_pwm_state = false; }
else { idle_pwm_state = true; }
}
else
{
@ -257,7 +257,8 @@ ISR(TIMER4_COMPC_vect)
if(configPage4.iacChannels) { *idle2_pin_port &= ~(idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1
OCR4C = TCNT4 + idle_pwm_target_value;
idle_pwm_cur_value = idle_pwm_target_value;
idle_pwm_state = true;
if (configPage4.iacPWMdir == 0) { idle_pwm_state = true; }
else { idle_pwm_state = false; }
}
}

View File

@ -371,7 +371,7 @@ page = 7
iacAlgorithm = bits , U08, 52, [0:2], "None", "On/Off", "PWM Open loop", "PWM Closed loop", "Stepper", "INVALID", "INVALID", "INVALID"
iacStepTime = bits , U08, 52, [3:5], "1", "2", "3", "4", "5", "6"
iacChannels = bits, U08, 52, [6:6], "1", "2"
unused7-52f = bits , U08, 52, [7:7], "One", "INVALID"
iacPWMdir = bits , U08, 52, [7:7], "Normal", "Reverse"
#if CELSIUS
iacFastTemp = scalar, U08, 53, "C", 1.0, -40, -40, 215, 0
@ -582,6 +582,7 @@ page = 8
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
dfcoRPM = "The RPM above which DFCO will be active. Typically set a few hundred RPM above maximum idle speed"
dfcoHyster = "Hysteresis for DFCO RPM. 200-300 RPM is typical for this, however a higher value may be needed if the RPM is fluctuating around the cutout speed"
@ -688,6 +689,7 @@ page = 8
dialog = pwm_idle, "PWM Idle"
field = "Number of outputs", iacChannels, { iacAlgorithm == 2 || iacAlgorithm == 3 }
field = "Idle valve frequency", idleFreq, { iacAlgorithm == 2 || iacAlgorithm == 3 }
field = "Idle valve direction", iacPWMdir, { iacAlgorithm == 2 || iacAlgorithm == 3 }
dialog = closedloop_idle, "Closed loop Idle"
field = "P", idleKP, { iacAlgorithm == 3 }