Merge pull request #59 from noisymime/master

update with josh 29062018
This commit is contained in:
Autohome2 2018-06-29 23:15:31 +01:00 committed by GitHub
commit 757256bbb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 298 additions and 115 deletions

View File

@ -54,6 +54,7 @@
;algorithmUnits = bits, U08, [0:2], $loadSourceUnits
algorithmUnits = bits, U08, [0:2], "kPa", "% TPS", "%", "% TPS", "INVALID", "INVALID", "INVALID", "INVALID"
algorithmLimits= array, U16, [8], "", 1.0, 0, 0, 511, 0, noMsqSave
#define all_IO_Pins = "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
boostTableLabels = bits, U08, [0:1], "Duty Cycle %", "kPa"
@ -240,7 +241,7 @@ page = 2
; Config2
algorithm = bits, U08, 37, [0:2], $loadSourceNames ;Has to be called algorithm for the req fuel calculator to work :(
unused2_37d = bits, U08, 37, [3:3], "Off", "On"
fixAngEnable = bits, U08, 37, [3:3], "Off", "On"
nInjectors = bits, U08, 37, [4:7], "INVALID","1","2","3","4","5","6","INVALID","8","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID"
; Config3
@ -826,7 +827,37 @@ page = 10
flexAdvBins = array, U08, 63, [6], "%", 1.0, 0.0, 0.0, 250.0, 0
flexAdvAdj = array, U08, 69, [6], "Deg", 1.0, 0.0, 0.0, 250.0, 0
unused11_75_191 = array, U08, 75,[116],"RPM", 100.0, 0.0, 100, 25500, 0
n2o_enable = bits , U08, 75, [0:1], "Off","1 Stage","2 stage", "INVALID"
n2o_arming_pin = bits , U08, 75, [2:7], $all_IO_Pins
#if CELSIUS
n2o_minCLT = scalar, U08, 76, "C", 1.0, -40, -40, 215, 0
#else
n2o_minCLT = scalar, U08, 76, "F", 1.8, -22.23, -40, 215, 0
#endif
n2o_maxMAP = scalar, U08, 77, "kPa", 2.0, 0.0, 0.0, 511.0, 0
n2o_minTPS = scalar, U08, 78, "%TPS", 1.0, 0.0, 0.0, 100, 0
n2o_maxAFR = scalar, U08, 79, "kPa", 0.1, 0.0, 0.0, 25.5, 1
n2o_stage1_pin = bits , U08, 80, [0:5], $all_IO_Pins
n2o_pin_polarity = bits , U08, 80, [6:6], "HIGH", "LOW"
n2o_unused = bits , U08, 80, [7:7], "INVALID", "INVALID"
n2o_stage1_minRPM = scalar, U08, 81, "RPM", 100, 0.0, 1000, 10000, 0
n2o_stage1_maxRPM = scalar, U08, 82, "RPM", 100, 0.0, 1000, 10000, 0
n2o_stage1_adderMin = scalar, U08, 83, "ms", 0.1, 0, 0, 25.5, 1
n2o_stage1_adderMax = scalar, U08, 84, "ms", 0.1, 0, 0, 25.5, 1
n2o_stage1_retard = scalar, U08, 85, "Deg", 1.0, 0.0, 0.0, 250.0, 0
n2o_stage2_pin = bits , U08, 86, [0:5], $all_IO_Pins
n2o_stage2_unused = bits , U08, 86, [6:7], "INVALID", "INVALID", "INVALID", "INVALID"
n2o_stage2_minRPM = scalar, U08, 87, "RPM", 100, 0.0, 1000, 10000, 0
n2o_stage2_maxRPM = scalar, U08, 88, "RPM", 100, 0.0, 1000, 10000, 0
n2o_stage2_adderMin = scalar, U08, 89, "ms", 0.1, 0, 0, 32, 1
n2o_stage2_adderMax = scalar, U08, 90, "ms", 0.1, 0, 0, 32, 1
n2o_stage2_retard = scalar, U08, 91, "Deg", 1.0, 0.0, 0.0, 250.0, 0
unused11_75_191 = array, U08, 92,[99],"RPM", 100.0, 0.0, 100, 25500, 0
;-------------------------------------------------------------------------------
@ -866,6 +897,8 @@ page = 10
requiresPowerCycle = stagingEnabled
requiresPowerCycle = resetControl
requiresPowerCycle = resetControlPin
requiresPowerCycle = n2o_enable
requiresPowerCycle = n2o_arming_pin
defaultValue = pinLayout, 1
defaultValue = TrigPattern, 0
@ -907,6 +940,8 @@ page = 10
defaultValue = boostSens, 2000
defaultValue = boostIntv, 30
defaultValue = sparkDur, 1.0
defaultValue = fixAngEnable,0
defaultValue = n2o_enable, 0
defaultValue = speeduino_tsCanId, 0
defaultValue = true_address, 256
defaultValue = realtime_base_address, 336
@ -1016,6 +1051,7 @@ menuDialog = main
subMenu = fanSettings, "Thermo Fan"
subMenu = LaunchControl, "Launch Control / Flat Shift"
subMenu = fuelpump, "Fuel Pump"
subMenu = NitrousControl, "Nitrous"
subMenu = std_separator
subMenu = boostSettings, "Boost Control"
subMenu = boostLoad, "Boost Targets/Load", 8, { boostEnabled }
@ -1089,6 +1125,8 @@ menuDialog = main
sparkMode = "Wasted Spark: Ignition outputs are on the channels <= half the number of cylinders. Eg 4 cylinder outputs on IGN1 and IGN2.\nSingle Channel: All ignition pulses are output on IGN1.\nWasted COP: Ignition pulses are output on all ignition channels up to the number of cylinders. Eg 4 cylinder outputs on all ignition channels. No valid for >4 cylinders"
IgInv = "Whether the spark fires when the ignition signal goes high or goes low. Nearly all ignition systems use 'Going Low' but please verify this as damage to coils can result from the incorrect selection. (NOTE: THIS IS NOT MEGASQUIRT. THIS SETTING IS USUALLY THE OPPOSITE OF WHAT THEY USE!)"
sparkDur = "The duration of the spark at full dwell. Typically around 1ms"
fixAngEnable= "If enabled, timing will be locked/fixed and the ignition map will be ignored"
FixAng = "Timing will be locked at this value if the above is enabled"
crankRPM = "The cranking RPM threshold. When RPM is lower than this value (and above 0) the system will be considered to be cranking"
@ -1134,6 +1172,8 @@ menuDialog = main
flexAdvAdj = "Additional advance (in degrees) for the current ethanol % (Typically 0 @ 0%, 10-20 @ 100%)"
flexBoostAdj = "Adjustment, in kPa, to the boost target for the current ethanol %. Negative values are allowed to lower boost at lower ethanol % if necessary."
n2o_arming_pin = "Pin that the nitrous arming/enagement switch is on."
flatSArm = "The RPM switch point that determines whether an eganged clutch is for launch control or flat shift. Below this figure, an engaged clutch is considered to be for launch, above this figure an active clutch input will be considered a flat shift. This should be set at least several hundred RPM above idle"
flatSSoftWin= "The number of RPM below the flat shift point where the softlimit will be applied (aka Soft limit window). Recommended values are 200-1000"
flatSRetard = "The absolute timing (BTDC) that will be used when within the soft limit window"
@ -1469,7 +1509,6 @@ menuDialog = main
field = "Primary base teeth", numTeeth, { TrigPattern == 0 || TrigPattern == 2 || TrigPattern == 11 }
field = "Primary trigger speed", TrigSpeed, { TrigPattern == 0 }
field = "Missing teeth", missingTeeth, { TrigPattern == 0 }
field = "Secondary teeth", missingTeeth, { TrigPattern == 2 }
field = "Trigger angle multiplier", TrigAngMul, { TrigPattern == 11 }
field = "Trigger Angle ", TrigAng
field = "This number represents the angle ATDC when "
@ -1479,8 +1518,8 @@ menuDialog = main
field = "Note: This is the number of revolutions that will be skipped during"
field = "cranking before the injectors and coils are fired"
field = "Trigger edge", TrigEdge { TrigPattern != 4 } ;4G63 uses both edges
field = "Secondary trigger edge", TrigEdgeSec, { TrigPattern == 0 || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 } ;Missing tooth, dual wheel and Miata 9905
field = "Missing Tooth Secondary type" trigPatternSec, { TrigPattern == 0 }
field = "Secondary trigger edge", TrigEdgeSec, { (TrigPattern == 0 && TrigSpeed == 0) || TrigPattern == 2 || TrigPattern == 9 || TrigPattern == 12 } ;Missing tooth, dual wheel and Miata 9905
field = "Missing Tooth Secondary type" trigPatternSec, { (TrigPattern == 0&& TrigSpeed == 0) }
field = "Trigger Filter", TrigFilter
field = "Re-sync every cycle", useResync, { TrigPattern == 2 || TrigPattern == 4 || TrigPattern == 7 || TrigPattern == 12 || TrigPattern == 9 } ;Dual wheel, 4G63, Audi 135, Nissan 360, Miata 99-05
field = ""
@ -1493,7 +1532,8 @@ menuDialog = main
field = "Cranking advance Angle", CrankAng
field = "Spark Outputs triggers", IgInv
field = ""
field = "Fixed Angle (0 = use map)", FixAng
field = "Enabled Fixed/Locked timing", fixAngEnable
field = "Fixed Angle", FixAng, { fixAngEnable }
dialog = dwellSettings, "Dwell Settings", 4
topicHelp = "http://speeduino.com/wiki/index.php/Dwell"
@ -1560,6 +1600,35 @@ menuDialog = main
field = "Soft rev window", flatSSoftWin, { flatSEnable }
field = "Soft limit absolute timing", flatSRetard, { flatSEnable }
dialog = NitrousStage1, "Stage 1"
field = "Nitrous Output Pin", n2o_stage1_pin
field = "Minimum Engage RPM", n2o_stage1_minRPM
field = "Maximum Engage RPM", n2o_stage1_maxRPM
field = "Fuel adder @ Min RPM", n2o_stage1_adderMin
field = "Fuel adder @ Max RPM", n2o_stage1_adderMax
field = "Ignition retard when active", n2o_stage1_retard
dialog = NitrousStage2, "Stage 2"
field = "Nitrous Output Pin", n2o_stage2_pin
field = "Minimum Engage RPM", n2o_stage2_minRPM
field = "Maximum Engage RPM", n2o_stage2_maxRPM
field = "Fuel adder @ Min RPM", n2o_stage2_adderMin
field = "Fuel adder @ Max RPM", n2o_stage2_adderMax
field = "Ignition retard when active", n2o_stage2_retard
dialog = NitrousMain, "Settings"
field = "Nitrous Mode", n2o_enable
field = "Arming Pin", n2o_arming_pin, { n2o_enable > 0 }
field = "Nitrous is armed when pin is", n2o_pin_polarity,{ n2o_enable > 0 }
field = "Minimum CLT", n2o_minCLT, { n2o_enable > 0 }
field = "Minimum TPS", n2o_minTPS, { n2o_enable > 0 }
field = "Maximum MAP", n2o_maxMAP, { n2o_enable > 0 }
dialog = NitrousControl, "Nitrous"
panel = NitrousMain, North
panel = NitrousStage1, West, { n2o_enable > 0 }
panel = NitrousStage2, East, { n2o_enable > 1 }
dialog = OLED, "OLED Display", 2
field = "Display Type", display
@ -2551,6 +2620,7 @@ cmdtestspk450dc = "E\x03\x0C"
indicator = { sync }, "No Sync", "Sync", white, black, green, black
indicator = { resetLockOn }, "Reset Lock OFF","Reset Lock ON", red, black, green, black
indicator = { bootloaderCaps > 0 }, "Std. Boot", "Custom Boot", white, black, white, black
indicator = { nitrousOn }, "Nitrous Off", "Nitrous On", white, black, red, black
;-------------------------------------------------------------------------------
@ -2650,7 +2720,8 @@ cmdtestspk450dc = "E\x03\x0C"
pulseWidth4 = scalar, U16, 79, "ms", 0.001, 0.000
status3 = scalar, U08, 81, "bits", 1.000, 0.000
resetLockOn = bits, U08, 81, [0:0]
unused81_1-4 = bits, U08, 81, [1:4]
nitrousOn = bits, U08, 81, [1:1]
unused81_2-4 = bits, U08, 81, [2:4]
nSquirts = bits, U08, 81, [5:7]
flexBoostCor = scalar, S16, 82, "kPa", 1.000, 0.000
nChannels = scalar, U08, 84, "bits", 1.000, 0.000
@ -2758,6 +2829,7 @@ cmdtestspk450dc = "E\x03\x0C"
entry = hardLimitOn , "Hard Limiter", int, "%d"
entry = idleLoad, "IAC value", int, "%d"
entry = baro, "Baro Pressure",int, "%d"
entry = nitrousOn, "Nitrous On", int, "%d", { n2o_enable > 0 }
#if CAN_COMMANDS
entry = canin_gauge0, "CanIn CH0", int, "%d"

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -5,6 +5,7 @@ void initialiseAuxPWM();
void boostControl();
void vvtControl();
void initialiseFan();
void nitrousControl();
#if defined(CORE_AVR)
#define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A)

View File

@ -121,7 +121,7 @@ void boostControl()
else if (configPage4.boostType == CLOSED_LOOP_BOOST)
{
if( (boostCounter & 7) == 1) { currentStatus.boostTarget = get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM) * 2; } //Boost target table is in kpa and divided by 2
if(currentStatus.MAP >= (currentStatus.boostTarget - BOOST_HYSTER) )
if(currentStatus.MAP >= 100 ) //Only engage boost control above 100kpa.
{
//If flex fuel is enabled, there can be an adder to the boost target based on ethanol content
if( configPage2.flexEnabled == 1 )
@ -207,6 +207,45 @@ void vvtControl()
else { DISABLE_VVT_TIMER(); } // Disable timer channel
}
void nitrousControl()
{
if(configPage10.n2o_enable > 0)
{
bool isArmed = digitalRead(configPage10.n2o_arming_pin);
if (configPage10.n2o_pin_polarity == 1) { isArmed = !isArmed; } //If nirtrous is active when pin is low, flip the reading (n2o_pin_polarity = 0 = active when High)
//Perform the main checks to see if nitrous is ready
if( (isArmed == true) && (currentStatus.coolant > (configPage10.n2o_minCLT - CALIBRATION_TEMPERATURE_OFFSET)) && (currentStatus.TPS > configPage10.n2o_minTPS) && (currentStatus.O2 < configPage10.n2o_maxAFR) && (currentStatus.MAP < configPage10.n2o_maxMAP) )
{
uint16_t realStage1MinRPM = configPage10.n2o_stage1_minRPM * 100;
uint16_t realStage1MaxRPM = configPage10.n2o_stage1_maxRPM * 100;
uint16_t realStage2MinRPM = configPage10.n2o_stage2_minRPM * 100;
uint16_t realStage2MaxRPM = configPage10.n2o_stage2_maxRPM * 100;
if( (currentStatus.RPM > realStage1MinRPM) && (currentStatus.RPM < realStage1MaxRPM) )
{
currentStatus.nitrous_status = NITROUS_STAGE1;
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
digitalWrite(configPage10.n2o_stage1_pin, HIGH);
}
if( (currentStatus.RPM > realStage2MinRPM) && (currentStatus.RPM < realStage2MaxRPM) )
{
currentStatus.nitrous_status = NITROUS_STAGE2;
BIT_SET(currentStatus.status3, BIT_STATUS3_NITROUS);
digitalWrite(configPage10.n2o_stage2_pin, HIGH);
}
}
else
{
currentStatus.nitrous_status = NITROUS_OFF;
BIT_CLEAR(currentStatus.status3, BIT_STATUS3_NITROUS);
digitalWrite(configPage10.n2o_stage1_pin, LOW);
digitalWrite(configPage10.n2o_stage2_pin, LOW);
}
}
}
void boostDisable()
{
boostPID.Initialize(); //This resets the ITerm value to prevent rubber banding

View File

@ -26,6 +26,7 @@ static inline int8_t correctionCrankingFixedTiming(int8_t);
static inline int8_t correctionFlexTiming(int8_t);
static inline int8_t correctionIATretard(int8_t);
static inline int8_t correctionSoftRevLimit(int8_t);
static inline int8_t correctionNitrous(int8_t);
static inline int8_t correctionSoftLaunch(int8_t);
static inline int8_t correctionSoftFlatShift(int8_t);

View File

@ -393,6 +393,7 @@ int8_t correctionsIgn(int8_t base_advance)
advance = correctionFlexTiming(base_advance);
advance = correctionIATretard(advance);
advance = correctionSoftRevLimit(advance);
advance = correctionNitrous(advance);
advance = correctionSoftLaunch(advance);
advance = correctionSoftFlatShift(advance);
@ -406,7 +407,7 @@ int8_t correctionsIgn(int8_t base_advance)
static inline int8_t correctionFixedTiming(int8_t advance)
{
int8_t ignFixValue = advance;
if (configPage4.FixAng != 0) { ignFixValue = configPage4.FixAng; } //Check whether the user has set a fixed timing angle
if (configPage2.fixAngEnable == 1) { ignFixValue = configPage4.FixAng; } //Check whether the user has set a fixed timing angle
return ignFixValue;
}
@ -449,6 +450,26 @@ static inline int8_t correctionSoftRevLimit(int8_t advance)
return ignSoftRevValue;
}
static inline int8_t correctionNitrous(int8_t advance)
{
byte ignNitrous = advance;
//Check if nitrous is currently active
if(configPage10.n2o_enable > 0)
{
//Check which stage is running (if any)
if( currentStatus.nitrous_status == NITROUS_STAGE1 )
{
ignNitrous -= configPage10.n2o_stage1_retard;
}
if( currentStatus.nitrous_status == NITROUS_STAGE2 )
{
ignNitrous -= configPage10.n2o_stage2_retard;
}
}
return ignNitrous;
}
static inline int8_t correctionSoftLaunch(int8_t advance)
{
byte ignSoftLaunchValue = advance;

View File

@ -81,4 +81,7 @@ int16_t toothAngles[24]; //An array for storing fixed tooth angles. Currently si
#define LONG 0;
#define SHORT 1;
#define CRANK_SPEED 0
#define CAM_SPEED 1
#endif

View File

@ -125,7 +125,7 @@ Note: This does not currently support dual wheel (ie missing tooth + single toot
void triggerSetup_missingTooth()
{
triggerToothAngle = 360 / configPage4.triggerTeeth; //The number of degrees that passes from tooth to tooth
if(configPage4.TrigSpeed == 1) { triggerToothAngle = 720 / configPage4.triggerTeeth; } //Account for cam speed missing tooth
if(configPage4.TrigSpeed == CAM_SPEED) { triggerToothAngle = 720 / configPage4.triggerTeeth; } //Account for cam speed missing tooth
triggerActualTeeth = configPage4.triggerTeeth - configPage4.triggerMissingTeeth; //The number of physical teeth on the wheel. Doing this here saves us a calculation each time in the interrupt
triggerFilterTime = (int)(1000000 / (MAX_RPM / 60 * configPage4.triggerTeeth)); //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise
triggerSecFilterTime = (int)((configPage4.trigPatternSec == SEC_TRIGGER_4_1 ) ? 1000000 * 60 / MAX_RPM / 4 / 2 : 1000000 * 60 / MAX_RPM / 2 / 2); //For 4-1 came wheel. Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
@ -171,6 +171,7 @@ void triggerPri_missingTooth()
toothOneTime = curTime;
currentStatus.hasSync = true;
currentStatus.startRevolutions++; //Counter
if ( configPage4.TrigSpeed == CAM_SPEED ) { currentStatus.startRevolutions++; } //Add an extra revolution count if we're running at cam speed
triggerFilterTime = 0; //This is used to prevent a condition where serious intermitent signals (Eg someone furiously plugging the sensor wire in and out) can leave the filter in an unrecoverable state
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
@ -238,14 +239,14 @@ uint16_t getRPM_missingTooth()
{
if(toothCurrentCount != 1)
{
if(configPage4.TrigSpeed == 1) { tempRPM = crankingGetRPM(configPage4.triggerTeeth/2); } //Account for cam speed
if(configPage4.TrigSpeed == CAM_SPEED) { tempRPM = crankingGetRPM(configPage4.triggerTeeth/2); } //Account for cam speed
else { tempRPM = crankingGetRPM(configPage4.triggerTeeth); }
}
else { tempRPM = currentStatus.RPM; } //Can't do per tooth RPM if we're at tooth #1 as the missing tooth messes the calculation
}
else
{
if(configPage4.TrigSpeed == 1) { tempRPM = (stdGetRPM() * 2); } //Account for cam speed
if(configPage4.TrigSpeed == CAM_SPEED) { tempRPM = stdGetRPM(720); } //Account for cam speed
else { tempRPM = stdGetRPM(); }
}
return tempRPM;
@ -275,7 +276,7 @@ int getCrankAngle_missingTooth(int timePerDegree)
//crankAngle += uSToDegrees(elapsedTime);
//Sequential check (simply sets whether we're on the first or 2nd revoltuion of the cycle)
if (tempRevolutionOne) { crankAngle += 360; }
if ( (tempRevolutionOne == true) && (configPage4.TrigSpeed == 0) ) { crankAngle += 360; }
if (crankAngle >= 720) { crankAngle -= 720; }
else if (crankAngle > CRANK_ANGLE_MAX) { crankAngle -= CRANK_ANGLE_MAX; }
@ -694,14 +695,6 @@ void triggerSetup_4G63()
//Note that these angles are for every rising and falling edge
if(configPage2.nCylinders == 6)
{
// 70 / 50 for 6 cylinder applications (50 high, 70 low)
toothAngles[0] = 185; //
toothAngles[1] = 235; //
toothAngles[2] = 305; //
toothAngles[3] = 355; //
toothAngles[4] = 65; //
toothAngles[5] = 115; //
//New values below
toothAngles[0] = 715; //Rising edge of tooth #1
toothAngles[1] = 45; //Falling edge of tooth #1
@ -775,7 +768,6 @@ void triggerPri_4G63()
toothCurrentCount = 1; //Reset the counter
toothOneMinusOneTime = toothOneTime;
toothOneTime = curTime;
//currentStatus.hasSync = true;
currentStatus.startRevolutions++; //Counter
}
@ -791,9 +783,9 @@ void triggerPri_4G63()
}
else if(configPage2.nCylinders == 6)
{
if( toothCurrentCount == 1 || (toothCurrentCount == 7) ) { endCoil1Charge(); }
else if( toothCurrentCount == 3 || (toothCurrentCount == 9) ) { endCoil2Charge(); }
else if( toothCurrentCount == 5 || (toothCurrentCount == 11) ) { endCoil3Charge(); }
if( (toothCurrentCount == 1) || (toothCurrentCount == 7) ) { endCoil1Charge(); }
else if( (toothCurrentCount == 3) || (toothCurrentCount == 9) ) { endCoil2Charge(); }
else if( (toothCurrentCount == 5) || (toothCurrentCount == 11) ) { endCoil3Charge(); }
}
}
@ -802,22 +794,29 @@ void triggerPri_4G63()
{
//Lite filter
if( (toothCurrentCount == 1) || (toothCurrentCount == 3) || (toothCurrentCount == 5) || (toothCurrentCount == 7) || (toothCurrentCount == 9) || (toothCurrentCount == 11) )
{
if(configPage2.nCylinders == 4)
{
triggerToothAngle = 70;
triggerFilterTime = curGap; //Trigger filter is set to whatever time it took to do 70 degrees (Next trigger is 110 degrees away)
if(configPage2.nCylinders == 6)
}
else if(configPage2.nCylinders == 6)
{
triggerToothAngle = 70;
triggerFilterTime = (curGap >> 2); //Trigger filter is set to (70/4)=17.5=17 degrees (Next trigger is 50 degrees away).
}
}
else
{
if(configPage2.nCylinders == 4)
{
triggerToothAngle = 110;
triggerFilterTime = (curGap * 3) >> 3; //Trigger filter is set to (110*3)/8=41.25=41 degrees (Next trigger is 70 degrees away).
if(configPage2.nCylinders == 6)
}
else if(configPage2.nCylinders == 6)
{
triggerToothAngle = 50;
triggerFilterTime = (curGap * 3) >> 2; //Trigger filter is set to (50*3)/4=37.5=37 degrees (Next trigger is 70 degrees away).
triggerFilterTime = curGap >> 1; //Trigger filter is set to 25 degrees (Next trigger is 70 degrees away).
}
}
}
@ -846,7 +845,7 @@ void triggerPri_4G63()
else
{
triggerToothAngle = 50;
triggerFilterTime = curGap; //50 degrees with a target of 70
triggerFilterTime = (curGap * 3) >> 2; //Trigger filter is set to (50*3)/4=37.5=37 degrees (Next trigger is 70 degrees away).
}
}
}
@ -897,10 +896,13 @@ void triggerPri_4G63()
//EXPERIMENTAL!
if(configPage2.perToothIgn == true)
{
if(configPage2.nCylinders == 4)
{
uint16_t crankAngle = toothAngles[(toothCurrentCount-1)];
doPerToothTiming(crankAngle);
}
}
} //Has sync
else
{
@ -917,14 +919,14 @@ void triggerPri_4G63()
{
//Crank is low, cam is low and the crank pulse STARTED when the cam was high.
if(configPage2.nCylinders == 4) { toothCurrentCount = 1; } //Means we're at 5* BTDC on a 4G63 4 cylinder
else if(configPage2.nCylinders == 6) { toothCurrentCount = 8; }
//else if(configPage2.nCylinders == 6) { toothCurrentCount = 8; }
}
//If sequential is ever enabled, the below toothCurrentCount will need to change:
else if( (READ_SEC_TRIGGER() == true) && (revolutionOne == true) )
{
//Crank is low, cam is high and the crank pulse STARTED when the cam was high.
if(configPage2.nCylinders == 4) { toothCurrentCount = 1; } //Means we're at 5* BTDC on a 4G63 4 cylinder
else if(configPage2.nCylinders == 6) { toothCurrentCount = 2; } //Means we're at 45* ATDC on 6G72 6 cylinder
else if(configPage2.nCylinders == 6) { toothCurrentCount = 2; currentStatus.hasSync = true; } //Means we're at 45* ATDC on 6G72 6 cylinder
}
}
}
@ -986,7 +988,7 @@ void triggerSec_4G63()
}
//if ( (micros() - secondaryLastToothTime1) < triggerSecFilterTime_duration && configPage2.useResync )
if ( (configPage4.useResync == 1) && (currentStatus.hasSync == true) && (toothCurrentCount == 4) )
if ( (configPage4.useResync == 1) && (currentStatus.hasSync == true) && (configPage2.nCylinders == 4) )
{
triggerSecFilterTime_duration = (micros() - secondaryLastToothTime1) >> 1;
if(READ_PRI_TRIGGER() == true)// && (crankState == digitalRead(pinTrigger)))
@ -1708,7 +1710,7 @@ int getCrankAngle_Miata9905(int timePerDegree)
crankAngle = toothAngles[(tempToothCurrentCount - 1)] + configPage4.triggerAngle; //Perform a lookup of the fixed toothAngles array to find what the angle of the last tooth passed was.
//Estimate the number of degrees travelled since the last tooth}
crankAngle += uSToDegrees(elapsedTime);
crankAngle += timeToAngle(elapsedTime);
if (crankAngle >= 720) { crankAngle -= 720; }
if (crankAngle > CRANK_ANGLE_MAX) { crankAngle -= CRANK_ANGLE_MAX; }

View File

@ -115,7 +115,7 @@
#define BIT_TIMER_30HZ 4
#define BIT_STATUS3_RESET_PREVENT 0 //Indicates whether reset prevention is enabled
#define BIT_STATUS3_UNUSED1 1
#define BIT_STATUS3_NITROUS 1
#define BIT_STATUS3_UNUSED2 2
#define BIT_STATUS3_UNUSED3 3
#define BIT_STATUS3_UNUSED4 4
@ -165,6 +165,10 @@
#define STAGING_MODE_TABLE 0
#define STAGING_MODE_AUTO 1
#define NITROUS_OFF 0
#define NITROUS_STAGE1 1
#define NITROUS_STAGE2 2
#define RESET_CONTROL_DISABLED 0
#define RESET_CONTROL_PREVENT_WHEN_RUNNING 1
#define RESET_CONTROL_PREVENT_ALWAYS 2
@ -368,6 +372,7 @@ struct statuses {
uint16_t crankRPM = 400; //The actual cranking RPM limit. Saves us multiplying it everytime from the config page
volatile byte status3;
int16_t flexBoostCorrection; //Amount of boost added based on flex
byte nitrous_status;
byte nSquirts;
byte nChannels; //Number of fuel and ignition channels
int16_t fuelLoad;
@ -434,7 +439,7 @@ struct config2 {
//config2 in ini
byte fuelAlgorithm : 3;
byte unused2_37d : 1;
byte fixAngEnable : 1; //Whether fixed/locked timing is enabled
byte nInjectors : 4; //Number of injectors
@ -783,7 +788,31 @@ struct config10 {
uint8_t flexAdvAdj[6]; //Additional advance (in degrees) @ current ethanol (typically 0 @ 0%, 10-20 @ 100%)
//And another three corn rows die.
byte unused11_75_191[117];
byte n2o_enable : 2;
byte n2o_arming_pin : 6;
byte n2o_minCLT;
byte n2o_maxMAP;
byte n2o_minTPS;
byte n2o_maxAFR;
byte n2o_stage1_pin : 6;
byte n2o_pin_polarity : 1;
byte n2o_stage1_unused : 1;
byte n2o_stage1_minRPM;
byte n2o_stage1_maxRPM;
byte n2o_stage1_adderMin;
byte n2o_stage1_adderMax;
byte n2o_stage1_retard;
byte n2o_stage2_pin : 6;
byte n2o_stage2_unused : 2;
byte n2o_stage2_minRPM;
byte n2o_stage2_maxRPM;
byte n2o_stage2_adderMin;
byte n2o_stage2_adderMax;
byte n2o_stage2_retard;
byte unused11_75_191[99];
#if defined(CORE_AVR)
};

View File

@ -41,6 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "errors.h"
#include "storage.h"
#include "scheduledIO.h"
#include "crankMaths.h"
#include <EEPROM.h>
#if defined (CORE_TEENSY)
#include <FlexCAN.h>
@ -948,7 +949,7 @@ void loop()
//Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough
//currentStatus.RPM = 3000;
boostControl();
nitrousControl();
}
//The IAT and CLT readings can be done less frequently (4 times per second)
if (BIT_CHECK(LOOP_TIMER, BIT_TIMER_4HZ))
@ -1069,6 +1070,20 @@ void loop()
currentStatus.advance = getAdvance();
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
if(currentStatus.nitrous_status == NITROUS_STAGE1)
{
int16_t adderRange = configPage10.n2o_stage1_maxRPM - configPage10.n2o_stage1_minRPM;
int16_t adderPercent = ((currentStatus.RPM - configPage10.n2o_stage1_minRPM) * 100) / adderRange; //The percentage of the way through the RPM range
currentStatus.PW1 = currentStatus.PW1 + configPage10.n2o_stage1_adderMax + percentage(adderPercent, (configPage10.n2o_stage1_adderMin - configPage10.n2o_stage1_adderMax)); //Calculate the above percentage of the calculated ms value.
}
if(currentStatus.nitrous_status == NITROUS_STAGE2)
{
int16_t adderRange = configPage10.n2o_stage2_maxRPM - configPage10.n2o_stage2_minRPM;
int16_t adderPercent = ((currentStatus.RPM - configPage10.n2o_stage2_minRPM) * 100) / adderRange; //The percentage of the way through the RPM range
currentStatus.PW1 = currentStatus.PW1 + configPage10.n2o_stage2_adderMax + percentage(adderPercent, (configPage10.n2o_stage2_adderMin - configPage10.n2o_stage2_adderMax)); //Calculate the above percentage of the calculated ms value.
}
int injector1StartAngle = 0;
int injector2StartAngle = 0;
int injector3StartAngle = 0;
@ -1332,7 +1347,7 @@ void loop()
else { currentStatus.dwell = (configPage4.dwellRun * 100); }
currentStatus.dwell = correctionsDwell(currentStatus.dwell);
int dwellAngle = uSToDegrees(currentStatus.dwell); //Convert the dwell time to dwell angle based on the current engine speed
int dwellAngle = timeToAngle(currentStatus.dwell); //Convert the dwell time to dwell angle based on the current engine speed
//Calculate start angle for each channel
//1 cylinder (Everyone gets this)
@ -1685,7 +1700,7 @@ void loop()
{
setIgnitionSchedule1(ign1StartFunction,
//((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree),
degreesToUS((ignition1StartAngle - crankAngle)),
angleToTime((ignition1StartAngle - crankAngle)),
currentStatus.dwell + fixedCrankingOverride, //((unsigned long)((unsigned long)currentStatus.dwell* currentStatus.RPM) / newRPM) + fixedCrankingOverride,
ign1EndFunction
);
@ -1717,7 +1732,7 @@ void loop()
if ( tempStartAngle < 0) { tempStartAngle += CRANK_ANGLE_MAX_IGN; }
{
unsigned long ignition2StartTime = 0;
if(tempStartAngle > tempCrankAngle) { ignition2StartTime = degreesToUS((tempStartAngle - tempCrankAngle)); }
if(tempStartAngle > tempCrankAngle) { ignition2StartTime = angleToTime((tempStartAngle - tempCrankAngle)); }
//else if (tempStartAngle < tempCrankAngle) { ignition2StartTime = ((long)(360 - tempCrankAngle + tempStartAngle) * (long)timePerDegree); }
else { ignition2StartTime = 0; }
@ -1740,7 +1755,7 @@ void loop()
//if (tempStartAngle > tempCrankAngle)
{
long ignition3StartTime = 0;
if(tempStartAngle > tempCrankAngle) { ignition3StartTime = degreesToUS((tempStartAngle - tempCrankAngle)); }
if(tempStartAngle > tempCrankAngle) { ignition3StartTime = angleToTime((tempStartAngle - tempCrankAngle)); }
//else if (tempStartAngle < tempCrankAngle) { ignition4StartTime = ((long)(360 - tempCrankAngle + tempStartAngle) * (long)timePerDegree); }
else { ignition3StartTime = 0; }
@ -1764,7 +1779,7 @@ void loop()
{
long ignition4StartTime = 0;
if(tempStartAngle > tempCrankAngle) { ignition4StartTime = degreesToUS((tempStartAngle - tempCrankAngle)); }
if(tempStartAngle > tempCrankAngle) { ignition4StartTime = angleToTime((tempStartAngle - tempCrankAngle)); }
//else if (tempStartAngle < tempCrankAngle) { ignition4StartTime = ((long)(360 - tempCrankAngle + tempStartAngle) * (long)timePerDegree); }
else { ignition4StartTime = 0; }
@ -1788,7 +1803,7 @@ void loop()
{
long ignition5StartTime = 0;
if(tempStartAngle > tempCrankAngle) { ignition5StartTime = degreesToUS((tempStartAngle - tempCrankAngle)); }
if(tempStartAngle > tempCrankAngle) { ignition5StartTime = angleToTime((tempStartAngle - tempCrankAngle)); }
//else if (tempStartAngle < tempCrankAngle) { ignition4StartTime = ((long)(360 - tempCrankAngle + tempStartAngle) * (long)timePerDegree); }
else { ignition5StartTime = 0; }
@ -1809,7 +1824,7 @@ void loop()
if ( tempStartAngle < 0) { tempStartAngle += CRANK_ANGLE_MAX_IGN; }
{
unsigned long ignition6StartTime = 0;
if(tempStartAngle > tempCrankAngle) { ignition6StartTime = degreesToUS((tempStartAngle - tempCrankAngle)); }
if(tempStartAngle > tempCrankAngle) { ignition6StartTime = angleToTime((tempStartAngle - tempCrankAngle)); }
else { ignition6StartTime = 0; }
if( (ignition6StartTime > 0) && (curRollingCut != 2) )