Most of the base logic for the conditional and input based table switching

This commit is contained in:
Josh Stewart 2019-08-20 09:44:18 +10:00
parent 50ab4f9548
commit f088c72c96
6 changed files with 88 additions and 21 deletions

View File

@ -949,16 +949,19 @@ page = 10
fuel2Mode = bits, U08, 122, [3:5], "Off", "Multiplied %", "Added", "Switched - Conditional", "Switched - Input based","INVALID","INVALID","INVALID"
fuel2SwitchVariable = bits, U08, 122, [6:7], "RPM", "MAP", "TPS", "ETH%"
fuel2SwitchValue = scalar, U16, 123, { bitStringValue(algorithmUnits, fuel2SwitchVariable) }, 1.0, 0.0, 0.0, 9000, 0
fuel2InputPin = bits , U08, 125, [0:5], $IO_Pins_no_def
fuel2InputPolarity = bits , U08, 125, [6:6], "LOW", "HIGH"
fuel2InputPullup = bits , U08, 125, [7:7], "No", "Yes"
;All related to the closed loop VVT control
vvtCLholdDuty = scalar, U08, 125, "%", 1.0, 0.0, 0.0, 100.0, 0
vvtCLKP = scalar, U08, 126, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLKI = scalar, U08, 127, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLKD = scalar, U08, 128, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLMinAng = scalar, U16, 129, "deg", 1.0, 0.0, 0.0, 360.0, 0 ; * ( 1 bytes)
vvtCLMaxAng = scalar, U16, 131, "deg", 1.0, 0.0, 0.0, 360.0, 0 ; * ( 1 bytes)
vvtCLholdDuty = scalar, U08, 126, "%", 1.0, 0.0, 0.0, 100.0, 0
vvtCLKP = scalar, U08, 127, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLKI = scalar, U08, 128, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLKD = scalar, U08, 129, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
vvtCLMinAng = scalar, U16, 130, "deg", 1.0, 0.0, 0.0, 360.0, 0 ; * ( 1 bytes)
vvtCLMaxAng = scalar, U16, 132, "deg", 1.0, 0.0, 0.0, 360.0, 0 ; * ( 1 bytes)
unused11_122_191 = array, U08, 126, [58], "RPM", 100.0, 0.0, 100, 25500, 0
unused11_122_191 = array, U08, 134, [57], "RPM", 100.0, 0.0, 100, 25500, 0
;Page 11 is the fuel map and axis bins only
page = 11
@ -1676,9 +1679,20 @@ menuDialog = main
panel = veTableDialog_north, North
panel = veTableDialog_south, South
dialog = fuelTable2Dialog_switch, "Switch Conditions", xAxis
field = "Use secondary table when:", fuel2SwitchVariable
field = "is greater than:", fuel2SwitchValue
dialog = fuelTable2Dialog_input, "Input Options", yAxis
field = "Use secondary table when pin", fuel2InputPin
field = "Is", fuel2InputPolarity
field = "Use internal pullup on pin", fuel2InputPullup, { fuel2InputPolarity == 0 }
dialog = fuelTable2Dialog_north, ""
field = "Secondary fuel table mode", fuel2Mode
field = "Load source", fuel2Algorithm, { fuel2Mode }
panel = fuelTable2Dialog_switch, { fuel2Mode == 3 }
panel = fuelTable2Dialog_input, { fuel2Mode == 4 }
dialog = fuelTable2Dialog_south, ""
panel = fuelTable2Tbl
@ -3197,7 +3211,7 @@ cmdtestspk450dc = "E\x03\x0C"
; you change it.
ochGetCommand = "r\$tsCanId\x30%2o%2c"
ochBlockSize = 94
ochBlockSize = 96
secl = scalar, U08, 0, "sec", 1.000, 0.000
status1 = scalar, U08, 1, "bits", 1.000, 0.000
@ -3298,7 +3312,9 @@ cmdtestspk450dc = "E\x03\x0C"
dwell = scalar, U16, 89, "ms", 0.001, 0.000
CLIdleTarget = scalar, U08, 91, "RPM", 10.00, 0.000
MAPdot = scalar, U08, 92, "kPa/s", 10.00, 0.000
vvtAngle = scalar, U08, 93, "deg", 1.00, 0.000
vvtAngle = scalar, S08, 93, "deg", 1.00, 0.000
vvtTarget = scalar, U08, 94, "deg", 1.00, 0.000
vvtDuty = scalar, U08, 95, "%", 1.00, 0.000
#if CELSIUS
coolant = { coolantRaw - 40 } ; Temperature readings are offset by 40 to allow for negatives
@ -3414,6 +3430,8 @@ cmdtestspk450dc = "E\x03\x0C"
entry = nitrousOn, "Nitrous", int, "onOff", { n2o_enable > 0 }
entry = syncLossCounter, "Sync Loss #", int, "%d"
entry = vvtAngle, "VVT Angle", int, "%d", { vvtMode == 2 } ;;Only show when using close loop vvt
entry = vvtTarget, "VVT Target Angle", int,"%d", { vvtMode == 2 } ;;Only show when using close loop vvt
entry = vvtDuty, "VVT Duty", int, "%d", { vvtEnabled > 0 }
entry = auxin_gauge0, "AuxIn CH0", int, "%d"
entry = auxin_gauge1, "AuxIn CH1", int, "%d"

View File

@ -22,7 +22,7 @@
#define warmupPage 10 //Config Page 10
#define fuelMap2Page 11
#define SERIAL_PACKET_SIZE 94 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
#define SERIAL_PACKET_SIZE 96 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
byte currentPage = 1;//Not the same as the speeduino config page numbers
bool isMap = true; /**< Whether or not the currentPage contains only a 3D map that would require translation */

View File

@ -608,7 +608,9 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
fullStatus[90] = highByte(currentStatus.dwell);
fullStatus[91] = currentStatus.CLIdleTarget;
fullStatus[92] = currentStatus.mapDOT;
fullStatus[93] = currentStatus.vvtAngle;
fullStatus[93] = (int8_t)currentStatus.vvtAngle;
fullStatus[94] = currentStatus.vvtTargetAngle;
fullStatus[95] = currentStatus.vvtDuty;
for(byte x=0; x<packetLength; x++)
{

View File

@ -225,8 +225,8 @@
#define VVT_MODE_ONOFF 0
#define VVT_MODE_OPEN_LOOP 1
#define VVT_MODE_CLOSED_LOOP 2
#define VVTCL_LOAD_MAP 0
#define VVTCL_LOAD_TPS 1
#define VVT_LOAD_MAP 0
#define VVT_LOAD_TPS 1
#define FOUR_STROKE 0
#define TWO_STROKE 1
@ -464,8 +464,10 @@ struct statuses {
bool knockActive;
bool toothLogEnabled;
bool compositeLogEnabled;
byte vvtAngle;
byte targetVVTAngle;
//int8_t vvtAngle;
long vvtAngle;
byte vvtTargetAngle;
byte vvtDuty;
};
struct statuses currentStatus; //The global status object
@ -940,6 +942,11 @@ struct config10 {
byte fuel2SwitchVariable : 2;
uint16_t fuel2SwitchValue;
//Byte 123
byte fuel2InputPin : 6;
byte fuel2InputPolarity : 1;
byte fuel2InputPullup : 1;
byte vvtCLholdDuty;
byte vvtCLKP;
byte vvtCLKI;
@ -947,7 +954,7 @@ struct config10 {
uint16_t vvtCLMinAng;
uint16_t vvtCLMaxAng;
byte unused11_123_191[59];
byte unused11_123_191[58];
#if defined(CORE_AVR)
};
@ -989,6 +996,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 pinFuel2Input; //Input for switching to the 2nd fuel table
byte pinSpareTemp1; // Future use only
byte pinSpareTemp2; // Future use only
byte pinSpareOut1; //Generic output

View File

@ -1648,6 +1648,7 @@ void setPinMapping(byte boardID)
if ( (configPage6.vvtPin != 0) && (configPage6.vvtPin < BOARD_NR_GPIO_PINS) ) { pinVVT_1 = pinTranslate(configPage6.vvtPin); }
if ( (configPage6.useExtBaro != 0) && (configPage6.baroPin < BOARD_NR_GPIO_PINS) ) { pinBaro = configPage6.baroPin + A0; }
if ( (configPage6.useEMAP != 0) && (configPage10.EMAPPin < BOARD_NR_GPIO_PINS) ) { pinEMAP = configPage10.EMAPPin + A0; }
if ( (configPage10.fuel2InputPin != 0) && (configPage10.fuel2InputPin < BOARD_NR_GPIO_PINS) ) { pinFuel2Input = pinTranslate(configPage10.fuel2InputPin); }
//Currently there's no default pin for Idle Up
pinIdleUp = pinTranslate(configPage2.idleUpPin);
@ -1769,6 +1770,11 @@ void setPinMapping(byte boardID)
if (configPage2.idleUpPolarity == 0) { pinMode(pinIdleUp, INPUT_PULLUP); } //Normal setting
else { pinMode(pinIdleUp, INPUT); } //inverted setting
}
if(configPage10.fuel2Mode == FUEL2_MODE_INPUT_SWITCH)
{
if (configPage10.fuel2InputPullup == 1) { pinMode(pinfuel2Input, INPUT_PULLUP); } //Normal setting
else { pinMode(pinFuel2Input, INPUT); } //inverted setting
}
//These must come after the above pinMode statements

View File

@ -200,6 +200,8 @@ void loop()
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
boostControl();
//VVT may eventually need to be synced with the cam readings (ie run once per cam rev) but for now run at 30Hz
vvtControl();
}
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_4HZ))
{
@ -271,7 +273,6 @@ void loop()
} //For loop going through each channel
} //aux channels are enabled
vvtControl();
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
} //4Hz timer
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_1HZ)) //Once per second)
@ -290,10 +291,9 @@ void loop()
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Clear the bit indicating that the 2nd fuel table is in use.
if(configPage10.fuel2Mode > 0)
{
currentStatus.VE2 = getVE2();
if(configPage10.fuel2Mode == FUEL2_MODE_MULTIPLY)
{
currentStatus.VE2 = getVE2();
//Fuel 2 table is treated as a % value. Table 1 and 2 are multiplied together and divded by 100
uint16_t combinedVE = ((uint16_t)currentStatus.VE * (uint16_t)currentStatus.VE2) / 100;
if(combinedVE <= 255) { totalVE = combinedVE; }
@ -301,6 +301,7 @@ void loop()
}
else if(configPage10.fuel2Mode == FUEL2_MODE_ADD)
{
currentStatus.VE2 = getVE2();
//Fuel tables are added together, but a check is made to make sure this won't overflow the 8-bit totalVE value
uint16_t combinedVE = (uint16_t)currentStatus.VE + (uint16_t)currentStatus.VE2;
if(combinedVE <= 255) { totalVE = combinedVE; }
@ -310,12 +311,44 @@ void loop()
{
if(configPage10.fuel2SwitchVariable == FUEL2_CONDITION_RPM)
{
if(currentStatus.RPM > configPage10.fuel2SwitchValue)
{
BIT_SET(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Set the bit indicating that the 2nd fuel table is in use.
currentStatus.VE2 = getVE2();
}
}
else if(configPage10.fuel2SwitchVariable == FUEL2_CONDITION_MAP)
{
if(currentStatus.MAP > configPage10.fuel2SwitchValue)
{
BIT_SET(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Set the bit indicating that the 2nd fuel table is in use.
currentStatus.VE2 = getVE2();
}
}
else if(configPage10.fuel2SwitchVariable == FUEL2_CONDITION_TPS)
{
if(currentStatus.TPS > configPage10.fuel2SwitchValue)
{
BIT_SET(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Set the bit indicating that the 2nd fuel table is in use.
currentStatus.VE2 = getVE2();
}
}
else if(configPage10.fuel2SwitchVariable == FUEL2_CONDITION_ETH)
{
if(currentStatus.ethanolPct > configPage10.fuel2SwitchValue)
{
BIT_SET(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Set the bit indicating that the 2nd fuel table is in use.
currentStatus.VE2 = getVE2();
}
}
}
else if(configPage10.fuel2Mode == FUEL2_MODE_INPUT_SWITCH)
{
if(digitalRead(configPage10.fuel2InputPin) == configPage10.fuel2InputPolarity)
{
BIT_SET(currentStatus.status3, BIT_STATUS3_FUEL2_ACTIVE); //Set the bit indicating that the 2nd fuel table is in use.
currentStatus.VE2 = getVE2();
}
}
}
else { totalVE = currentStatus.VE; }