Correct behaviour for when both stages of nitrous are active
This commit is contained in:
parent
6396ee551d
commit
0db3806b60
|
@ -306,9 +306,15 @@ void nitrousControl()
|
||||||
uint16_t realStage2MinRPM = (uint16_t)configPage10.n2o_stage2_minRPM * 100;
|
uint16_t realStage2MinRPM = (uint16_t)configPage10.n2o_stage2_minRPM * 100;
|
||||||
uint16_t realStage2MaxRPM = (uint16_t)configPage10.n2o_stage2_maxRPM * 100;
|
uint16_t realStage2MaxRPM = (uint16_t)configPage10.n2o_stage2_maxRPM * 100;
|
||||||
|
|
||||||
|
//The nitrous state is set to 0 and then the subsequent stages are added
|
||||||
|
// OFF = 0
|
||||||
|
// STAGE1 = 1
|
||||||
|
// STAGE2 = 2
|
||||||
|
// BOTH = 3 (ie STAGE1 + STAGE2 = BOTH)
|
||||||
|
currentStatus.nitrous_status = NITROUS_OFF;
|
||||||
if( (currentStatus.RPM > realStage1MinRPM) && (currentStatus.RPM < realStage1MaxRPM) )
|
if( (currentStatus.RPM > realStage1MinRPM) && (currentStatus.RPM < realStage1MaxRPM) )
|
||||||
{
|
{
|
||||||
currentStatus.nitrous_status = NITROUS_STAGE1;
|
currentStatus.nitrous_status += NITROUS_STAGE1;
|
||||||
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
|
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
|
||||||
N2O_STAGE1_PIN_HIGH();
|
N2O_STAGE1_PIN_HIGH();
|
||||||
nitrousOn = true;
|
nitrousOn = true;
|
||||||
|
@ -317,7 +323,7 @@ void nitrousControl()
|
||||||
{
|
{
|
||||||
if( (currentStatus.RPM > realStage2MinRPM) && (currentStatus.RPM < realStage2MaxRPM) )
|
if( (currentStatus.RPM > realStage2MinRPM) && (currentStatus.RPM < realStage2MaxRPM) )
|
||||||
{
|
{
|
||||||
currentStatus.nitrous_status = NITROUS_STAGE2;
|
currentStatus.nitrous_status += NITROUS_STAGE2;
|
||||||
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
|
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
|
||||||
N2O_STAGE2_PIN_HIGH();
|
N2O_STAGE2_PIN_HIGH();
|
||||||
nitrousOn = true;
|
nitrousOn = true;
|
||||||
|
|
|
@ -629,11 +629,11 @@ int8_t correctionNitrous(int8_t advance)
|
||||||
if(configPage10.n2o_enable > 0)
|
if(configPage10.n2o_enable > 0)
|
||||||
{
|
{
|
||||||
//Check which stage is running (if any)
|
//Check which stage is running (if any)
|
||||||
if( currentStatus.nitrous_status == NITROUS_STAGE1 )
|
if( (currentStatus.nitrous_status == NITROUS_STAGE1) || (currentStatus.nitrous_status == NITROUS_BOTH) )
|
||||||
{
|
{
|
||||||
ignNitrous -= configPage10.n2o_stage1_retard;
|
ignNitrous -= configPage10.n2o_stage1_retard;
|
||||||
}
|
}
|
||||||
if( currentStatus.nitrous_status == NITROUS_STAGE2 )
|
if( (currentStatus.nitrous_status == NITROUS_STAGE2) || (currentStatus.nitrous_status == NITROUS_BOTH) )
|
||||||
{
|
{
|
||||||
ignNitrous -= configPage10.n2o_stage2_retard;
|
ignNitrous -= configPage10.n2o_stage2_retard;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,7 @@
|
||||||
#define NITROUS_OFF 0
|
#define NITROUS_OFF 0
|
||||||
#define NITROUS_STAGE1 1
|
#define NITROUS_STAGE1 1
|
||||||
#define NITROUS_STAGE2 2
|
#define NITROUS_STAGE2 2
|
||||||
|
#define NITROUS_BOTH 3
|
||||||
|
|
||||||
#define AE_MODE_TPS 0
|
#define AE_MODE_TPS 0
|
||||||
#define AE_MODE_MAP 1
|
#define AE_MODE_MAP 1
|
||||||
|
|
|
@ -19,21 +19,7 @@ byte getVE2();
|
||||||
byte getAdvance();
|
byte getAdvance();
|
||||||
|
|
||||||
uint16_t calculateInjectorStartAngle(uint16_t, int16_t);
|
uint16_t calculateInjectorStartAngle(uint16_t, int16_t);
|
||||||
/*
|
|
||||||
uint16_t calculateInjector2StartAngle(unsigned int);
|
|
||||||
uint16_t calculateInjector3StartAngle(unsigned int);
|
|
||||||
uint16_t calculateInjector4StartAngle(unsigned int);
|
|
||||||
uint16_t calculateInjector5StartAngle(unsigned int);
|
|
||||||
*/
|
|
||||||
|
|
||||||
void calculateIgnitionAngles(int);
|
void calculateIgnitionAngles(int);
|
||||||
/*
|
|
||||||
struct config2 configPage2;
|
|
||||||
struct config4 configPage4;
|
|
||||||
struct config6 configPage6;
|
|
||||||
struct config9 configPage9;
|
|
||||||
struct config10 configPage10;
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint16_t req_fuel_uS; /**< The required fuel variable (As calculated by TunerStudio) in uS */
|
uint16_t req_fuel_uS; /**< The required fuel variable (As calculated by TunerStudio) in uS */
|
||||||
uint16_t inj_opentime_uS; /**< The injector opening time. This is set within Tuner Studio, but stored here in uS rather than mS */
|
uint16_t inj_opentime_uS; /**< The injector opening time. This is set within Tuner Studio, but stored here in uS rather than mS */
|
||||||
|
@ -41,10 +27,6 @@ uint16_t inj_opentime_uS; /**< The injector opening time. This is set within Tun
|
||||||
bool ignitionOn = false; /**< The current state of the ignition system (on or off) */
|
bool ignitionOn = false; /**< The current state of the ignition system (on or off) */
|
||||||
bool fuelOn = false; /**< The current state of the fuel system (on or off) */
|
bool fuelOn = false; /**< The current state of the fuel system (on or off) */
|
||||||
|
|
||||||
//byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the coolant sensor calibration values */
|
|
||||||
//byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the inlet air temperature sensor calibration values */
|
|
||||||
//byte o2CalibrationTable[CALIBRATION_TABLE_SIZE]; /**< An array containing the O2 sensor calibration values */
|
|
||||||
|
|
||||||
byte maxIgnOutputs = 1; /**< Used for rolling rev limiter to indicate how many total ignition channels should currently be firing */
|
byte maxIgnOutputs = 1; /**< Used for rolling rev limiter to indicate how many total ignition channels should currently be firing */
|
||||||
byte curRollingCut = 0; /**< Rolling rev limiter, current ignition channel being cut */
|
byte curRollingCut = 0; /**< Rolling rev limiter, current ignition channel being cut */
|
||||||
byte rollingCutCounter = 0; /**< how many times (revolutions) the ignition has been cut in a row */
|
byte rollingCutCounter = 0; /**< how many times (revolutions) the ignition has been cut in a row */
|
||||||
|
|
|
@ -427,14 +427,14 @@ void loop()
|
||||||
currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
|
currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
|
||||||
|
|
||||||
//Manual adder for nitrous. These are not in correctionsFuel() because they are direct adders to the ms value, not % based
|
//Manual adder for nitrous. These are not in correctionsFuel() because they are direct adders to the ms value, not % based
|
||||||
if(currentStatus.nitrous_status == NITROUS_STAGE1)
|
if( (currentStatus.nitrous_status == NITROUS_STAGE1) || (currentStatus.nitrous_status == NITROUS_BOTH) )
|
||||||
{
|
{
|
||||||
int16_t adderRange = (configPage10.n2o_stage1_maxRPM - configPage10.n2o_stage1_minRPM) * 100;
|
int16_t adderRange = (configPage10.n2o_stage1_maxRPM - configPage10.n2o_stage1_minRPM) * 100;
|
||||||
int16_t adderPercent = ((currentStatus.RPM - (configPage10.n2o_stage1_minRPM * 100)) * 100) / adderRange; //The percentage of the way through the RPM range
|
int16_t adderPercent = ((currentStatus.RPM - (configPage10.n2o_stage1_minRPM * 100)) * 100) / adderRange; //The percentage of the way through the RPM range
|
||||||
adderPercent = 100 - adderPercent; //Flip the percentage as we go from a higher adder to a lower adder as the RPMs rise
|
adderPercent = 100 - adderPercent; //Flip the percentage as we go from a higher adder to a lower adder as the RPMs rise
|
||||||
currentStatus.PW1 = currentStatus.PW1 + (configPage10.n2o_stage1_adderMax + percentage(adderPercent, (configPage10.n2o_stage1_adderMin - configPage10.n2o_stage1_adderMax))) * 100; //Calculate the above percentage of the calculated ms value.
|
currentStatus.PW1 = currentStatus.PW1 + (configPage10.n2o_stage1_adderMax + percentage(adderPercent, (configPage10.n2o_stage1_adderMin - configPage10.n2o_stage1_adderMax))) * 100; //Calculate the above percentage of the calculated ms value.
|
||||||
}
|
}
|
||||||
if(currentStatus.nitrous_status == NITROUS_STAGE2)
|
if( (currentStatus.nitrous_status == NITROUS_STAGE2) || (currentStatus.nitrous_status == NITROUS_BOTH) )
|
||||||
{
|
{
|
||||||
int16_t adderRange = (configPage10.n2o_stage2_maxRPM - configPage10.n2o_stage2_minRPM) * 100;
|
int16_t adderRange = (configPage10.n2o_stage2_maxRPM - configPage10.n2o_stage2_minRPM) * 100;
|
||||||
int16_t adderPercent = ((currentStatus.RPM - (configPage10.n2o_stage2_minRPM * 100)) * 100) / adderRange; //The percentage of the way through the RPM range
|
int16_t adderPercent = ((currentStatus.RPM - (configPage10.n2o_stage2_minRPM * 100)) * 100) / adderRange; //The percentage of the way through the RPM range
|
||||||
|
|
Loading…
Reference in New Issue