Boost by gear (Open loop) (#729)

* Boost by Gear

* Minor changes to PR

- Changed *2 into bitwise operator
- Reserved 1 extra bit for boostByGearEnabled for 2 additional boost by gear modes in the future

* Added mode to set percentage of boost target table

* Boost by Gear (Open loop)

Added Boost by Gear to open loop boost control
This commit is contained in:
DylanRooijakkers 2021-12-18 23:43:14 +01:00 committed by GitHub
parent db8722e3d0
commit 0a71d0972b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 153 additions and 74 deletions

View File

@ -94,7 +94,7 @@
#define fullStatus_def = $fullStatus_def_1, $fullStatus_def_2, $fullStatus_def_3, $fullStatus_def_4, $fullStatus_def_5, $fullStatus_def_6, $fullStatus_def_7, $fullStatus_def_8
boostTableLabels = bits, U08, [0:1], "Duty Cycle %", "kPa"
boostByGearLabels = bits, U08, [0:1], "", "%", "kPa", ""
boostByGearLabels = bits, U08, [0:1], "", "%", "Limit", ""
prgm_out_selection = bits, U08, [0:2], "1", "2", "3", "4", "5", "6", "7", "8"
fuelLoadMax = scalar, U08, "", 1, 0, 0, 511, 0
@ -1011,12 +1011,12 @@ page = 9
iacMaxSteps = scalar, U08, 154, "Steps", 3, 0, 0, {iacStepHome-3}, 0
idleAdvStartDelay = scalar, U08, 155, "S", 0.1, 0.0, 0.0, 25.5, 1
boostByGear1 = scalar, U08, 156, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear2 = scalar, U08, 157, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear3 = scalar, U08, 158, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear4 = scalar, U08, 159, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear5 = scalar, U08, 160, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear6 = scalar, U08, 161, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, 511.0, 0
boostByGear1 = scalar, U08, 156, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
boostByGear2 = scalar, U08, 157, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
boostByGear3 = scalar, U08, 158, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
boostByGear4 = scalar, U08, 159, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
boostByGear5 = scalar, U08, 160, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
boostByGear6 = scalar, U08, 161, { bitStringValue(boostByGearLabels , boostByGearEnabled) }, 2.0, 0.0, 0.0, {boostTableLimit}, 0
PWMFanDuty = array, U08, 162, [4], "%", 0.5, 0, 0, 100, 1
unused10_160 = array, U08, 166, [26], "", 1, 0, 0, 255, 0
@ -2141,6 +2141,7 @@ menuDialog = main
FILTER_FLEX = "Higher values provide more filtering, but slower Eth% and fuel temp response"
boostIntv = "The closed loop control interval will run every this many ms. Generally values between 50% and 100% of the valve frequency work best"
boostByGearEnabled = "Open loop -> Constant limit in Duty cycle %\nClosed Loop -> Constant limit in kPa\nIn both cases the multiplied option simply takes a percentage of the values in the boost table"
vvtMode = "Selects method of VVT control.\nOn/Off = No PWM control and output is only on or off.\nOpen Loop = PWM control where duty is taken directly from VVT table.\nClosed Loop = PWM control where VVT table is Cam angle target map and output duty is PID controlled."
vvt2Enabled = "Secondary VVT output. Uses same frequency and control algorithm as primary VVT output."
vvtPWMdir = "This is used to invert VVT closed loop PID direction if needed."
@ -2922,7 +2923,7 @@ menuDialog = main
field = "Valve minimum duty cycle", boostMinDuty, { boostEnabled && boostType == 1 }
field = "Valve maximum duty cycle", boostMaxDuty, { boostEnabled && boostType == 1 }
panel = boostCut
panel = boostByGear, { boostEnabled && boostType == 1 && vssMode > 1 }
panel = boostByGear, { boostEnabled && vssMode > 1 }
field = "Closed Loop settings"
field = "Control mode", boostMode, { boostEnabled && boostType == 1 }
slider = "Sensitivity", boostSens, horizontal, { boostEnabled && boostType == 1 }

View File

@ -6,6 +6,7 @@
void initialiseAuxPWM();
void boostControl();
void boostDisable();
void boostByGear();
void idleControl();
void vvtControl();
void initialiseFan();

View File

@ -228,6 +228,146 @@ void initialiseAuxPWM()
}
void boostByGear()
{
if(configPage4.boostType == OPEN_LOOP_BOOST)
{
if( configPage9.boostByGearEnabled == 1 )
{
uint16_t combinedBoost = 0;
switch (currentStatus.gear)
{
case 1:
combinedBoost = ( ((uint16_t)configPage9.boostByGear1 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
case 2:
combinedBoost = ( ((uint16_t)configPage9.boostByGear2 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
case 3:
combinedBoost = ( ((uint16_t)configPage9.boostByGear3 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
case 4:
combinedBoost = ( ((uint16_t)configPage9.boostByGear4 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
case 5:
combinedBoost = ( ((uint16_t)configPage9.boostByGear5 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
case 6:
combinedBoost = ( ((uint16_t)configPage9.boostByGear6 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) ) << 2;
if( combinedBoost <= 10000 ){ currentStatus.boostDuty = combinedBoost; }
else{ currentStatus.boostDuty = 10000; }
break;
default:
break;
}
}
else if( configPage9.boostByGearEnabled == 2 )
{
switch (currentStatus.gear)
{
case 1:
currentStatus.boostDuty = configPage9.boostByGear1 * 2 * 100;
break;
case 2:
currentStatus.boostDuty = configPage9.boostByGear2 * 2 * 100;
break;
case 3:
currentStatus.boostDuty = configPage9.boostByGear3 * 2 * 100;
break;
case 4:
currentStatus.boostDuty = configPage9.boostByGear4 * 2 * 100;
break;
case 5:
currentStatus.boostDuty = configPage9.boostByGear5 * 2 * 100;
break;
case 6:
currentStatus.boostDuty = configPage9.boostByGear6 * 2 * 100;
break;
default:
break;
}
}
}
else if (configPage4.boostType == CLOSED_LOOP_BOOST)
{
if( configPage9.boostByGearEnabled == 1 )
{
uint16_t combinedBoost = 0;
switch (currentStatus.gear)
{
case 1:
combinedBoost = ( ((uint16_t)configPage9.boostByGear1 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 2:
combinedBoost = ( ((uint16_t)configPage9.boostByGear2 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 3:
combinedBoost = ( ((uint16_t)configPage9.boostByGear3 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 4:
combinedBoost = ( ((uint16_t)configPage9.boostByGear4 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 5:
combinedBoost = ( ((uint16_t)configPage9.boostByGear5 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 6:
combinedBoost = ( ((uint16_t)configPage9.boostByGear6 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
default:
break;
}
}
else if( configPage9.boostByGearEnabled == 2 )
{
switch (currentStatus.gear)
{
case 1:
currentStatus.boostTarget = (configPage9.boostByGear1 << 1);
break;
case 2:
currentStatus.boostTarget = (configPage9.boostByGear2 << 1);
break;
case 3:
currentStatus.boostTarget = (configPage9.boostByGear3 << 1);
break;
case 4:
currentStatus.boostTarget = (configPage9.boostByGear4 << 1);
break;
case 5:
currentStatus.boostTarget = (configPage9.boostByGear5 << 1);
break;
case 6:
currentStatus.boostTarget = (configPage9.boostByGear6 << 1);
break;
default:
break;
}
}
}
}
#define BOOST_HYSTER 40
void boostControl()
{
@ -236,7 +376,8 @@ void boostControl()
if(configPage4.boostType == OPEN_LOOP_BOOST)
{
//Open loop
currentStatus.boostDuty = get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM) * 2 * 100;
if ( (configPage9.boostByGearEnabled > 0) && (configPage2.vssMode > 1) ){ boostByGear(); }
else{ currentStatus.boostDuty = get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM) * 2 * 100; }
if(currentStatus.boostDuty > 10000) { currentStatus.boostDuty = 10000; } //Safety check
if(currentStatus.boostDuty == 0) { DISABLE_BOOST_TIMER(); BOOST_PIN_LOW(); } //If boost duty is 0, shut everything down
@ -250,71 +391,7 @@ void boostControl()
{
if( (boostCounter & 7) == 1)
{
if( (configPage9.boostByGearEnabled == 1) && (configPage2.vssMode > 1) )
{
uint16_t combinedBoost = 0;
switch (currentStatus.gear)
{
case 1:
combinedBoost = ( ((uint16_t)configPage9.boostByGear1 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 2:
combinedBoost = ( ((uint16_t)configPage9.boostByGear2 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 3:
combinedBoost = ( ((uint16_t)configPage9.boostByGear3 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 4:
combinedBoost = ( ((uint16_t)configPage9.boostByGear4 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 5:
combinedBoost = ( ((uint16_t)configPage9.boostByGear5 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
case 6:
combinedBoost = ( ((uint16_t)configPage9.boostByGear6 * (uint16_t)get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM)) / 100 ) << 2;
if( combinedBoost <= 511 ){ currentStatus.boostTarget = combinedBoost; }
else{ currentStatus.boostTarget = 511; }
break;
default:
break;
}
}
else if( (configPage9.boostByGearEnabled == 2) && (configPage2.vssMode > 1) )
{
switch (currentStatus.gear)
{
case 1:
currentStatus.boostTarget = (configPage9.boostByGear1 << 1);
break;
case 2:
currentStatus.boostTarget = (configPage9.boostByGear2 << 1);
break;
case 3:
currentStatus.boostTarget = (configPage9.boostByGear3 << 1);
break;
case 4:
currentStatus.boostTarget = (configPage9.boostByGear4 << 1);
break;
case 5:
currentStatus.boostTarget = (configPage9.boostByGear5 << 1);
break;
case 6:
currentStatus.boostTarget = (configPage9.boostByGear6 << 1);
break;
default:
break;
}
}
if ( (configPage9.boostByGearEnabled > 0) && (configPage2.vssMode > 1) ){ boostByGear(); }
else{ currentStatus.boostTarget = get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM) << 1; } //Boost target table is in kpa and divided by 2
}
if(currentStatus.MAP >= currentStatus.baro ) //Only engage boost control above baro pressure