Some default pin mappings for VVT and Boost

This commit is contained in:
Josh Stewart 2017-01-19 15:02:10 +11:00
parent 770da8b43e
commit dfab13631a
1 changed files with 72 additions and 38 deletions

View File

@ -118,7 +118,9 @@ void setPinMapping(byte boardID)
pinDisplayReset = 48; // OLED reset pin
pinTachOut = 49; //Tacho output pin
pinIdle1 = 5; //Single wire idle control
pinIdle2 = 7; //2 wire idle control
pinIdle2 = 6; //2 wire idle control
pinBoost = 7; //Boost control
pinVVT = 4; //Default VVT output
pinFuelPump = 4; //Fuel pump output
pinStepperDir = 16; //Direction pin for DRV8825 driver
pinStepperStep = 17; //Step pin for DRV8825 driver
@ -150,7 +152,9 @@ void setPinMapping(byte boardID)
pinDisplayReset = 48; // OLED reset pin
pinTachOut = 49; //Tacho output pin (Goes to ULN2803)
pinIdle1 = 5; //Single wire idle control
pinIdle2 = 7; //2 wire idle control (Note this is shared with boost!!!)
pinIdle2 = 6; //2 wire idle control
pinBoost = 7; //Boost control
pinVVT = 4; //Default VVT output
pinFuelPump = 45; //Fuel pump output (Goes to ULN2803)
pinStepperDir = 16; //Direction pin for DRV8825 driver
pinStepperStep = 17; //Step pin for DRV8825 driver
@ -326,13 +330,27 @@ void setPinMapping(byte boardID)
}
//Setup any devices that are using selectable pins
if(configPage3.launchPin != 0) { pinLaunch = configPage3.launchPin; }
if(configPage2.ignBypassPin != 0) { pinIgnBypass = configPage2.ignBypassPin; }
if(configPage1.tachoPin != 0) { pinTachOut = configPage1.tachoPin; }
if(configPage2.fuelPumpPin != 0) { pinFuelPump = configPage2.fuelPumpPin; }
if(configPage4.fanPin != 0) { pinFan = configPage4.fanPin; }
if(configPage3.boostPin != 0) { pinBoost = configPage3.boostPin; }
if(configPage3.vvtPin != 0) { pinVVT_1 = configPage3.vvtPin; }
if (configPage3.launchPin != 0) {
pinLaunch = configPage3.launchPin;
}
if (configPage2.ignBypassPin != 0) {
pinIgnBypass = configPage2.ignBypassPin;
}
if (configPage1.tachoPin != 0) {
pinTachOut = configPage1.tachoPin;
}
if (configPage2.fuelPumpPin != 0) {
pinFuelPump = configPage2.fuelPumpPin;
}
if (configPage4.fanPin != 0) {
pinFan = configPage4.fanPin;
}
if (configPage3.boostPin != 0) {
pinBoost = configPage3.boostPin;
}
if (configPage3.vvtPin != 0) {
pinVVT_1 = configPage3.vvtPin;
}
//Finally, set the relevant pin modes for outputs
pinMode(pinCoil1, OUTPUT);
@ -392,8 +410,12 @@ void setPinMapping(byte boardID)
pinMode(pinTrigger3, INPUT);
pinMode(pinFlex, INPUT_PULLUP); //Standard GM / Continental flex sensor requires pullup
// pinMode(pinLaunch, INPUT_PULLUP); //This should work for both NO and NC grounding switches
if (configPage3.lnchPullRes) { pinMode(pinLaunch, INPUT_PULLUP); }
else { pinMode(pinLaunch, INPUT); } //If Launch Pull Resistor is not set make input float.
if (configPage3.lnchPullRes) {
pinMode(pinLaunch, INPUT_PULLUP);
}
else {
pinMode(pinLaunch, INPUT); //If Launch Pull Resistor is not set make input float.
}
//Set default values
digitalWrite(pinMAP, HIGH);
@ -421,16 +443,26 @@ unsigned int PW(int REQ_FUEL, byte VE, byte MAP, int corrections, int injOpen)
//100% float free version, does sacrifice a little bit of accuracy, but not much.
iVE = ((unsigned int)VE << 7) / 100;
if( configPage1.multiplyMAP ) { iMAP = ((unsigned int)MAP << 7) / currentStatus.baro; } //Include multiply MAP (vs baro) if enabled
if( configPage1.includeAFR && (configPage3.egoType == 2)) { iAFR = ((unsigned int)currentStatus.O2 << 7) / currentStatus.afrTarget; } //Include AFR (vs target) if enabled
if ( configPage1.multiplyMAP ) {
iMAP = ((unsigned int)MAP << 7) / currentStatus.baro; //Include multiply MAP (vs baro) if enabled
}
if ( configPage1.includeAFR && (configPage3.egoType == 2)) {
iAFR = ((unsigned int)currentStatus.O2 << 7) / currentStatus.afrTarget; //Include AFR (vs target) if enabled
}
iCorrections = (corrections << 7) / 100;
unsigned long intermediate = ((long)REQ_FUEL * (long)iVE) >> 7; //Need to use an intermediate value to avoid overflowing the long
if( configPage1.multiplyMAP ) { intermediate = (intermediate * iMAP) >> 7; }
if( configPage1.includeAFR && (configPage3.egoType == 2)) { intermediate = (intermediate * iAFR) >> 7; } //EGO type must be set to wideband for this to be used
if ( configPage1.multiplyMAP ) {
intermediate = (intermediate * iMAP) >> 7;
}
if ( configPage1.includeAFR && (configPage3.egoType == 2)) {
intermediate = (intermediate * iAFR) >> 7; //EGO type must be set to wideband for this to be used
}
intermediate = (intermediate * iCorrections) >> 7;
if(intermediate == 0) { return 0; } //If the pulsewidth is 0, we return here before the opening time gets added
if (intermediate == 0) {
return 0; //If the pulsewidth is 0, we return here before the opening time gets added
}
intermediate += injOpen; //Add the injector opening time
if ( intermediate > 65535) {
@ -450,6 +482,8 @@ unsigned int PW_SD(int REQ_FUEL, byte VE, byte MAP, int corrections, int injOpen
unsigned int PW_AN(int REQ_FUEL, byte VE, byte TPS, int corrections, int injOpen)
{
//Sanity check
if(TPS > 100) { TPS = 100; }
if (TPS > 100) {
TPS = 100;
}
return PW(REQ_FUEL, VE, currentStatus.MAP, corrections, injOpen);
}