Complete but untested TAE implementation

This commit is contained in:
Josh Stewart 2015-01-28 10:01:12 +11:00
parent e00e29144d
commit 8040de56ce
3 changed files with 49 additions and 7 deletions

View File

@ -134,7 +134,7 @@ void sendValues(int length)
response[12] = 0x00; //Warmup enrichment (%)
response[13] = (byte)(div(currentStatus.RPM, 100).quot); //rpm / 100
response[14] = (byte)(currentStatus.PW / 200); //Pulsewidth 1 multiplied by 10 in ms. Have to convert from uS to mS.
response[15] = 0x00; //acceleration enrichment (ms)
response[15] = currentStatus.TAEamount; //acceleration enrichment (ms)
response[16] = 0x00; //Barometer correction (%)
response[17] = currentStatus.corrections; //Total GammaE (%)
response[18] = currentStatus.VE; //Current VE 1 (%)

View File

@ -1,5 +1,17 @@
/*
The corrections functions in this file affect the fuel pulsewidth (Either increasing or decreasing)
based on factors other than the VE lookup.
These factors include temperature (Warmup Enrichment and After Start Enrichment), Acceleration/Decelleration,
Flood clear mode etc.
*/
//************************************************************************************************************
/*
correctionsTotal() calls all the other corrections functions and combines their results.
This is the only function that should be called from anywhere outside the file
*/
byte correctionsTotal()
{
int sumCorrections = 100;
@ -18,6 +30,10 @@ byte correctionsTotal()
return (byte)sumCorrections;
}
/*
Warm Up Enrichment (WUE)
Uses a 2D enrichment table (WUETable) where the X axis is engine temp and the Y axis is the amount of extra fuel to add
*/
byte correctionWUE()
{
//Possibly reduce the frequency this runs at (Costs about 50 loops per second)
@ -25,6 +41,11 @@ byte correctionWUE()
return table2D_getValue(WUETable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET);
}
/*
After Start Enrichment
This is a short period (Usually <20 seconds) immediately after the engine first fires (But not when cranking)
where an additional amount of fuel is added (Over and above the WUE amount)
*/
byte correctionASE()
{
@ -43,19 +64,38 @@ byte correctionASE()
/*
TPS based acceleration enrichment
Calculates the % change of the throttle over time (%/second) and performs a lookup based on this
When the enrichment is turned on, it runs at that amount for a fixed period of time (taeTime)
*/
byte correctionAccel()
{
//First, check whether the accel. enrichment is already running
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_ACC) )
{
//If it is currently running, check whether it should still be running or whether it's reached it's end time
if( micros() >= currentStatus.TAEEndTime )
{
//Time to turn enrichment off
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_ACC);
currentStatus.TAEamount = 0;
return 100;
}
//Enrichment still needs to keep running. Simply return the total TAE amount
return 100 + currentStatus.TAEamount;
}
//If TAE isn't currently turned on, need to check whether it needs to be turned on
int rateOfChange = ldiv(1000000, (currentLoopTime - previousLoopTime)).quot * (currentStatus.TPS - currentStatus.TPSlast); //This is the % per second that the TPS has moved
//int rateOfChange = div( (1000000 * (currentStatus.TPS - currentStatus.TPSlast)), (currentLoopTime - previousLoopTime)).quot; //This is the % per second that the TPS has moved
currentStatus.tpsDOT = div(rateOfChange, 10).quot;
currentStatus.tpsDOT = div(rateOfChange, 10).quot; //The TAE bins are divided by 10 in order to allow them to be stored in a byte.
if (rateOfChange > configPage1.tpsThresh)
{
return 100 + table2D_getValue(taeTable, currentStatus.tpsDOT);
BIT_SET(currentStatus.engine, BIT_ENGINE_ACC); //Mark accleration enrichment as active.
currentStatus.TAEamount = table2D_getValue(taeTable, currentStatus.tpsDOT); //Lookup and store the amount of enrichment required
currentStatus.TAEEndTime = micros() + (configPage1.taeTime * 100); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS * 10, so multiply it by 100 to get it in uS
return 100 + currentStatus.TAEamount;
}
//If we reach here then TAE is neither on, nor does it need to be turned on.
return 100;
}

View File

@ -15,8 +15,8 @@ const byte page_size = 128;
#define BIT_ENGINE_CRANK 1 // Engine cranking
#define BIT_ENGINE_ASE 2 // after start enrichment (ASE)
#define BIT_ENGINE_WARMUP 3 // Engine in warmup
#define BIT_ENGINE_TPS 4 // in TPS acceleration mode
#define BIT_ENGINE_ACC 5 // in deceleration mode
#define BIT_ENGINE_ACC 4 // in TPS acceleration mode
#define BIT_ENGINE_DCC 5 // in deceleration mode
#define BIT_ENGINE_MAP 6 // in MAP acceleration mode
#define BIT_ENGINE_IDLE 7 // idle on
@ -59,6 +59,8 @@ struct statuses {
byte battery10; //The current BRV in volts (multiplied by 10. Eg 12.5V = 125)
byte advance;
byte corrections;
byte TAEamount; //The amount of accleration enrichment currently being applied
unsigned long TAEEndTime; //The target end time used whenever TAE is turned on
volatile byte squirt;
byte engine;
unsigned int PW; //In uS