Initial work on MAP sampling options
This commit is contained in:
parent
9dd0908d45
commit
fda74b22cc
|
@ -142,7 +142,7 @@ struct config1 {
|
|||
unsigned int inj4Ang;
|
||||
|
||||
//config1 in ini
|
||||
byte mapType : 2;
|
||||
byte mapSample : 2;
|
||||
byte strokes : 1;
|
||||
byte injType : 1;
|
||||
byte nCylinders : 4; //Number of cylinders
|
||||
|
|
|
@ -128,7 +128,7 @@ page = 2
|
|||
inj4Ang = scalar, U16, 34, "deg", 1.0, 0.0, 0.0, 360, 0
|
||||
|
||||
; Config1
|
||||
mapType = bits, U08, 36, [0:1], "115 kPa", "250 kPa", "INVALID", "INVALID"
|
||||
mapSample = bits, U08, 36, [0:1], "Instantaneous", "Cycle Average", "Cycle Minimum", "INVALID"
|
||||
twoStroke = bits, U08, 36, [2:2], "Four-stroke", "Two-stroke"
|
||||
injType = bits, U08, 36, [3:3], "Port", "Throttle Body"
|
||||
nCylinders = bits, U08, 36, [4:8], "INVALID","1","2","3","4","INVALID","6","INVALID","8","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID"
|
||||
|
@ -525,6 +525,7 @@ page = 8
|
|||
dialog = engine_constants_south
|
||||
field = "Injector Timing", injTiming, { nCylinders <= 4 }
|
||||
field = "Board Layout", pinLayout
|
||||
field = "MAP Sample method", mapSample
|
||||
|
||||
dialog = engine_constants, ""
|
||||
panel = std_injection, North
|
||||
|
|
|
@ -83,8 +83,11 @@ byte o2CalibrationTable[CALIBRATION_TABLE_SIZE];
|
|||
unsigned long counter;
|
||||
unsigned long currentLoopTime; //The time the current loop started (uS)
|
||||
unsigned long previousLoopTime; //The time the previous loop started (uS)
|
||||
unsigned long scheduleStart;
|
||||
unsigned long scheduleEnd;
|
||||
|
||||
unsigned long MAPrunningValue; //Used for tracking either the total of all MAP readings in this cycle (Event average) or the lowest value detected in this cycle (event minimum)
|
||||
unsigned int MAPcount; //Number of samples taken in the current MAP cycle
|
||||
byte MAPcurRev = 0; //Tracks which revolution we're sampling on
|
||||
|
||||
|
||||
byte coilHIGH = HIGH;
|
||||
byte coilLOW = LOW;
|
||||
|
@ -493,9 +496,51 @@ void loop()
|
|||
//***SET STATUSES***
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//currentStatus.MAP = map(analogRead(pinMAP), 0, 1023, 10, 255); //Get the current MAP value
|
||||
currentStatus.mapADC = analogRead(pinMAP);
|
||||
currentStatus.MAP = map(currentStatus.mapADC, 0, 1023, configPage1.mapMin, configPage1.mapMax); //Get the current MAP value
|
||||
//MAP Sampling system
|
||||
switch(configPage1.mapSample)
|
||||
{
|
||||
case 0:
|
||||
//Instantaneous MAP readings
|
||||
currentStatus.mapADC = analogRead(pinMAP);
|
||||
currentStatus.MAP = map(currentStatus.mapADC, 0, 1023, configPage1.mapMin, configPage1.mapMax); //Get the current MAP value
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//Average of a cycle
|
||||
if( (MAPcurRev == startRevolutions) || (MAPcurRev == startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
{
|
||||
MAPrunningValue = MAPrunningValue + analogRead(pinMAP); //Add the current reading onto the total
|
||||
MAPcount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reaching here means that the last cylce has completed and the MAP value should be calculated
|
||||
currentStatus.mapADC = ldiv(MAPrunningValue, MAPcount).quot;
|
||||
currentStatus.MAP = map(currentStatus.mapADC, 0, 1023, configPage1.mapMin, configPage1.mapMax); //Get the current MAP value
|
||||
MAPcurRev = startRevolutions; //Reset the current rev count
|
||||
MAPrunningValue = 0;
|
||||
MAPcount = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//Minimum reading in a cycle
|
||||
if( (MAPcurRev == startRevolutions) || (MAPcurRev == startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
{
|
||||
int tempValue = analogRead(pinMAP);
|
||||
if( tempValue < MAPrunningValue) { MAPrunningValue = tempValue; } //Check whether the current reading is lower than the running minimum
|
||||
MAPcount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Reaching here means that the last cylce has completed and the MAP value should be calculated
|
||||
currentStatus.mapADC = MAPrunningValue;
|
||||
currentStatus.MAP = map(currentStatus.mapADC, 0, 1023, configPage1.mapMin, configPage1.mapMax); //Get the current MAP value
|
||||
MAPcurRev = startRevolutions; //Reset the current rev count
|
||||
MAPrunningValue = 1023; //Reset the latest value so the next reading will always be lower
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//TPS setting to be performed every 32 loops (any faster and it can upset the TPSdot sampling time)
|
||||
if ((mainLoopCount & 31) == 1)
|
||||
|
|
Loading…
Reference in New Issue