Groundwork idle control algorithms
This commit is contained in:
parent
406071d81f
commit
3c6a39a9af
|
@ -5,9 +5,8 @@ A full copy of the license may be found in the projects root directory
|
|||
*/
|
||||
|
||||
/*
|
||||
These functions control the auxillary outputs
|
||||
Fan control
|
||||
*/
|
||||
|
||||
void initialiseFan()
|
||||
{
|
||||
if(configPage4.fanInv == 1) {fanHIGH = LOW, fanLOW = HIGH; }
|
||||
|
@ -20,3 +19,7 @@ void fanControl()
|
|||
if (currentStatus.coolant >= (configPage4.fanSP - CALIBRATION_TEMPERATURE_OFFSET)) { digitalWrite(pinFan,fanHIGH); }
|
||||
else if (currentStatus.coolant <= (configPage4.fanSP - configPage4.fanHyster)) { digitalWrite(pinFan, fanLOW); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ struct config3 {
|
|||
};
|
||||
|
||||
//Page 4 of the config mostly deals with idle control
|
||||
//See ini file for further info
|
||||
//See ini file for further info (Config Page 7 in the ini)
|
||||
struct config4 {
|
||||
byte iacCLValues[10]; //Closed loop target RPM value
|
||||
byte iacOLStepVal[10]; //Open loop step values for stepper motors
|
||||
|
|
9
idle.h
9
idle.h
|
@ -1,5 +1,6 @@
|
|||
#define STEPPER_FORWARD 1
|
||||
#define STEPPER_BACKWARD 0
|
||||
#define IDLE_TABLE_SIZE 10
|
||||
|
||||
enum StepperStatus {SOFF, STEPPING}; //The 2 statuses that a stepper can have. STEPPING means that a high pulse is currently being sent and will need to be turned off at some point.
|
||||
|
||||
|
@ -11,5 +12,13 @@ struct StepperIdle
|
|||
volatile unsigned long stepStartTime; //The time the curren
|
||||
};
|
||||
|
||||
struct table2D iacClosedLoopTable;
|
||||
struct table2D iacPWMTable;
|
||||
struct table2D iacStepTable;
|
||||
//Open loop tables specifically for cranking
|
||||
struct table2D iacCrankStepsTable;
|
||||
struct table2D iacCrankDutyTable;
|
||||
|
||||
bool idleOn; //Simply tracks whether idle was on last time around
|
||||
|
||||
void initialiseIdle();
|
||||
|
|
122
idle.ino
122
idle.ino
|
@ -8,17 +8,125 @@ A full copy of the license may be found in the projects root directory
|
|||
These functions over the PWM and stepper idle control
|
||||
*/
|
||||
|
||||
/*
|
||||
Idle Control
|
||||
Currently limited to on/off control and open loop PWM and stepper drive
|
||||
*/
|
||||
void initialiseIdle()
|
||||
{
|
||||
//Initialising comprises of setting the 2D tables with the relevant values from the config pages
|
||||
switch(configPage4.iacAlgorithm)
|
||||
{
|
||||
case 0:
|
||||
//Case 0 is no idle control ('None')
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//Case 1 is on/off idle control
|
||||
if (currentStatus.coolant < configPage4.iacFastTemp)
|
||||
{
|
||||
digitalWrite(pinIdle1, HIGH);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//Case 2 is PWM open loop
|
||||
iacPWMTable.xSize = 10;
|
||||
iacPWMTable.values = configPage4.iacOLPWMVal;
|
||||
iacPWMTable.axisX = configPage4.iacBins;
|
||||
|
||||
iacCrankDutyTable.xSize = 4;
|
||||
iacCrankDutyTable.values = configPage4.iacCrankDuty;
|
||||
iacCrankDutyTable.axisX = configPage4.iacCrankBins;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//Case 3 is PWM closed loop
|
||||
iacClosedLoopTable.xSize = 10;
|
||||
iacClosedLoopTable.values = configPage4.iacCLValues;
|
||||
iacClosedLoopTable.axisX = configPage4.iacBins;
|
||||
|
||||
iacCrankDutyTable.xSize = 4;
|
||||
iacCrankDutyTable.values = configPage4.iacCrankDuty;
|
||||
iacCrankDutyTable.axisX = configPage4.iacCrankBins;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
//Case 2 is Stepper open loop
|
||||
iacStepTable.xSize = 10;
|
||||
iacStepTable.values = configPage4.iacOLStepVal;
|
||||
iacStepTable.axisX = configPage4.iacBins;
|
||||
|
||||
iacCrankStepsTable.xSize = 4;
|
||||
iacCrankStepsTable.values = configPage4.iacCrankSteps;
|
||||
iacCrankStepsTable.axisX = configPage4.iacCrankBins;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
//Case 5 is Stepper closed loop
|
||||
iacClosedLoopTable.xSize = 10;
|
||||
iacClosedLoopTable.values = configPage4.iacCLValues;
|
||||
iacClosedLoopTable.axisX = configPage4.iacBins;
|
||||
|
||||
iacCrankStepsTable.xSize = 4;
|
||||
iacCrankStepsTable.values = configPage4.iacCrankSteps;
|
||||
iacCrankStepsTable.axisX = configPage4.iacCrankBins;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void initialiseIdlePWM()
|
||||
void idleControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void initialiseIdleStepper()
|
||||
{
|
||||
|
||||
switch(configPage4.iacAlgorithm)
|
||||
{
|
||||
case 0: //Case 0 is no idle control ('None')
|
||||
break;
|
||||
|
||||
case 1: //Case 1 is on/off idle control
|
||||
if ( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < configPage4.iacFastTemp) //All temps are offset by 40 degrees
|
||||
{
|
||||
digitalWrite(pinIdle1, HIGH);
|
||||
idleOn = true;
|
||||
}
|
||||
else if (idleOn) { digitalWrite(pinIdle1, LOW); idleOn = false; }
|
||||
break;
|
||||
|
||||
case 2: //Case 2 is PWM open loop
|
||||
//Check for cranking pulsewidth
|
||||
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||
{
|
||||
//Currently cranking. Use the cranking table
|
||||
analogWrite(pinIdle1, table2D_getValue(&iacCrankDutyTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)); //All temps are offset by 40 degrees
|
||||
idleOn = true;
|
||||
}
|
||||
else if( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < iacPWMTable.values[IDLE_TABLE_SIZE-1])
|
||||
{
|
||||
//Standard running
|
||||
analogWrite(pinIdle1, table2D_getValue(&iacPWMTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)); //All temps are offset by 40 degrees
|
||||
idleOn = true;
|
||||
}
|
||||
else if (idleOn) { digitalWrite(pinIdle1, LOW); idleOn = false; }
|
||||
break;
|
||||
|
||||
case 3: //Case 3 is PWM closed loop (Not currently implemented)
|
||||
break;
|
||||
|
||||
case 4: //Case 4 is open loop stepper control
|
||||
//Check for cranking pulsewidth
|
||||
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) )
|
||||
{
|
||||
//Currently cranking. Use the cranking table
|
||||
analogWrite(pinIdle1, table2D_getValue(&iacCrankStepsTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)); //All temps are offset by 40 degrees
|
||||
idleOn = true;
|
||||
}
|
||||
else if( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < iacStepTable.values[IDLE_TABLE_SIZE-1])
|
||||
{
|
||||
//Standard running
|
||||
analogWrite(pinIdle1, table2D_getValue(&iacStepTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)); //All temps are offset by 40 degrees
|
||||
idleOn = true;
|
||||
}
|
||||
else if (idleOn) { digitalWrite(pinIdle1, LOW); idleOn = false; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue