Merge branch 'master' of https://github.com/noisymime/speeduino into reset-lock

This commit is contained in:
Murray 2018-01-07 16:22:55 -06:00
commit 43f0d35839
10 changed files with 308 additions and 48 deletions

View File

@ -60,7 +60,8 @@ script:
- git clone --depth=20 https://github.com/noisymime/cppcheck.git noisymime/cppcheck
- cd noisymime/speeduino
- platformio update
- platformio run -e megaatmega2560 -e teensy35 -e bluepill_f103c8 -e genericSTM32F103RB
# - platformio run -e megaatmega2560 -e teensy35 -e bluepill_f103c8 -e genericSTM32F103RB
- platformio run -e megaatmega2560 -e teensy35 -e genericSTM32F103RB
- cd ..
- chmod +x speeduino/misra/check_misra.sh
- speeduino/misra/check_misra.sh

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<msq xmlns="http://www.msefi.com/:msq">
<bibliography author="TunerStudio MS(Beta) 3.0.50.17 - EFI Analytics, Inc." tuneComment="" writeDate="Sun Dec 10 17:18:48 AEDT 2017"/>
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.11" nPages="10" signature="speeduino 201711"/>
<bibliography author="TunerStudio MS(Beta) 3.0.50.23 - EFI Analytics, Inc." tuneComment="" writeDate="Wed Jan 03 21:37:23 AEDT 2018"/>
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.12" nPages="10" signature="speeduino 201712"/>
<page>
<pcVariable name="tsCanId">"CAN ID 0"</pcVariable>
</page>
@ -113,12 +113,14 @@
<constant name="twoStroke">"Four-stroke"</constant>
<constant name="injType">"Port"</constant>
<constant name="nCylinders">"4"</constant>
<constant name="unused2-37a">"None"</constant>
<constant name="unused2-37b">"None"</constant>
<constant name="nInjectors">"4"</constant>
<constant name="engineType">"Even fire"</constant>
<constant name="flexEnabled">"Off"</constant>
<constant name="algorithm">"Speed Density"</constant>
<constant name="baroCorr">"Off"</constant>
<constant name="injLayout">"Semi-Sequential"</constant>
<constant name="injLayout">"Paired"</constant>
<constant name="perToothIgn">"No"</constant>
<constant name="dfcoEnabled">"Off"</constant>
<constant digits="1" name="primePulse" units="ms">2.0</constant>
@ -207,7 +209,7 @@
77.0
</constant>
<constant digits="0" name="UNALLOCATED_TOP_1" units="RAW">
77.0
255.0
</constant>
</page>
<page number="2" size="288">
@ -274,7 +276,6 @@
<constant name="TrigEdge">"Leading"</constant>
<constant name="TrigSpeed">"Crank Speed"</constant>
<constant name="IgInv">"Going Low"</constant>
<constant name="unused4-5d">"Yes"</constant>
<constant name="TrigPattern">"4G63 / Miata / 3000GT"</constant>
<constant name="TrigEdgeSec">"Trailing"</constant>
<constant name="fuelPumpPin">"Board Default"</constant>
@ -420,7 +421,7 @@
1.0
</constant>
<constant digits="0" name="UNALLOCATED_TOP_3" units="RAW">
134.0
255.0
</constant>
</page>
<page number="4" size="288">
@ -526,8 +527,8 @@
20.0
35.0
50.0
60.0
90.0
62.0
91.0
120.0
</constant>
<constant cols="1" digits="0" name="airDenRates" rows="9" units="%">
@ -537,7 +538,7 @@
100.0
95.0
91.0
88.0
83.0
81.0
74.0
</constant>
@ -860,6 +861,22 @@
<constant name="caninput_sel13">"Off"</constant>
<constant name="caninput_sel14">"Off"</constant>
<constant name="caninput_sel15">"Off"</constant>
<constant name="caninput_source_can_address0">"0x100"</constant>
<constant name="caninput_source_can_address1">"0x100"</constant>
<constant name="caninput_source_can_address2">"0x100"</constant>
<constant name="caninput_source_can_address3">"0x100"</constant>
<constant name="caninput_source_can_address4">"0x100"</constant>
<constant name="caninput_source_can_address5">"0x100"</constant>
<constant name="caninput_source_can_address6">"0x100"</constant>
<constant name="caninput_source_can_address7">"0x100"</constant>
<constant name="caninput_source_can_address8">"0x100"</constant>
<constant name="caninput_source_can_address9">"0x100"</constant>
<constant name="caninput_source_can_address10">"0x100"</constant>
<constant name="caninput_source_can_address11">"0x100"</constant>
<constant name="caninput_source_can_address12">"0x100"</constant>
<constant name="caninput_source_can_address13">"0x100"</constant>
<constant name="caninput_source_can_address14">"0x100"</constant>
<constant name="caninput_source_can_address15">"0x100"</constant>
<constant name="caninput_source_start_byte0">"7"</constant>
<constant name="caninput_source_start_byte1">"1"</constant>
<constant name="caninput_source_start_byte2">"1"</constant>
@ -926,6 +943,9 @@
<constant digits="0" name="unused10_98">0.0</constant>
<constant digits="0" name="unused10_99">0.0</constant>
<constant name="speeduino_tsCanId">"CAN ID 0"</constant>
<constant name="true_address">"0x100"</constant>
<constant name="realtime_base_address">"0x100"</constant>
<constant name="obd_address">"0x100"</constant>
<constant digits="0" name="unused10_107">0.0</constant>
<constant digits="0" name="unused10_108">0.0</constant>
<constant digits="0" name="unused10_109">0.0</constant>
@ -946,7 +966,7 @@
<constant digits="0" name="unused10_124">0.0</constant>
<constant digits="0" name="unused10_125">0.0</constant>
<constant digits="0" name="unused10_126">0.0</constant>
<constant digits="0" name="unused10_127">132.0</constant>
<constant digits="0" name="unused10_127">1.0</constant>
</page>
<page number="9" size="192">
<constant cols="1" digits="0" name="crankingEnrichBins" rows="4" units="C">
@ -1154,7 +1174,7 @@
0.0
</constant>
<constant digits="0" name="UNALLOCATED_TOP_9" units="RAW">
0.0
255.0
</constant>
</page>
<settings Comment="These setting are only used if this msq is opened without a project.">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<msq xmlns="http://www.msefi.com/:msq">
<bibliography author="TunerStudio MS(Beta) 3.0.50.17 - EFI Analytics, Inc." tuneComment="" writeDate="Sun Dec 10 15:54:48 AEDT 2017"/>
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.10" nPages="10" signature="speeduino 201711"/>
<bibliography author="TunerStudio MS(Beta) 3.0.50.23 - EFI Analytics, Inc." tuneComment="" writeDate="Wed Jan 03 21:35:21 AEDT 2018"/>
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.12" nPages="10" signature="speeduino 201712"/>
<page>
<pcVariable name="tsCanId">"CAN ID 0"</pcVariable>
</page>
@ -144,6 +144,70 @@
<constant digits="0" name="iacCLminDuty" units="%">0.0</constant>
<constant digits="0" name="iacCLmaxDuty" units="%">0.0</constant>
<constant digits="0" name="boostMinDuty" units="%">20.0</constant>
<constant digits="0" name="baroMin" units="kpa">1.0</constant>
<constant digits="0" name="baroMax" units="kpa">315.0</constant>
<constant cols="1" digits="0" name="unused2-67" rows="60" units="%">
62.0
62.0
60.0
61.0
64.0
65.0
66.0
68.0
68.0
70.0
71.0
71.0
71.0
71.0
66.0
59.0
60.0
60.0
61.0
63.0
64.0
66.0
67.0
68.0
69.0
70.0
71.0
72.0
74.0
69.0
61.0
59.0
60.0
61.0
62.0
64.0
66.0
67.0
69.0
70.0
71.0
72.0
72.0
73.0
74.0
64.0
59.0
61.0
60.0
61.0
64.0
65.0
67.0
68.0
68.0
70.0
71.0
71.0
71.0
71.0
</constant>
<constant digits="0" name="UNALLOCATED_TOP_1" units="RAW">
255.0
</constant>
@ -212,7 +276,6 @@
<constant name="TrigEdge">"Leading"</constant>
<constant name="TrigSpeed">"Crank Speed"</constant>
<constant name="IgInv">"Going Low"</constant>
<constant name="unused4-5d">"No"</constant>
<constant name="TrigPattern">"Missing Tooth"</constant>
<constant name="TrigEdgeSec">"Leading"</constant>
<constant name="fuelPumpPin">"Board Default"</constant>
@ -621,8 +684,8 @@
100.0
</constant>
<constant cols="8" digits="0" name="vvtTable" rows="8" units="%">
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
11.0 10.0 6.0 6.0 6.0 6.0 7.0 7.0
175.0 0.0 0.0 27.0 4.0 4.0 0.0 0.0
99.0 8.0 6.0 0.0 6.0 6.0 0.0 1.0
24.0 22.0 20.0 18.0 18.0 18.0 19.0 20.0
32.0 30.0 29.0 28.0 27.0 27.0 27.0 29.0
39.0 39.0 38.0 38.0 37.0 37.0 36.0 36.0
@ -933,6 +996,167 @@
<constant digits="0" name="boostIntv" units="ms">20.0</constant>
<constant digits="0" name="stagedInjSizePri" units="cc/min">200.0</constant>
<constant digits="0" name="stagedInjSizeSec" units="cc/min">600.0</constant>
<constant cols="1" digits="0" name="unused11_32_192" rows="159" units="RPM">
700.0
25500.0
700.0
700.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
700.0
700.0
700.0
700.0
700.0
700.0
0.0
0.0
25500.0
25500.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
700.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
100.0
0.0
200.0
200.0
100.0
100.0
100.0
200.0
25500.0
25500.0
25500.0
25500.0
0.0
100.0
0.0
100.0
100.0
25500.0
100.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
25500.0
1000.0
5000.0
7500.0
11000.0
15000.0
12000.0
10900.0
9600.0
0.0
1200.0
1000.0
600.0
500.0
1000.0
1000.0
1300.0
1500.0
1500.0
2500.0
3800.0
4500.0
5000.0
6500.0
9000.0
12500.0
21600.0
100.0
3000.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
</constant>
<constant digits="0" name="UNALLOCATED_TOP_9" units="RAW">
255.0
</constant>

View File

@ -6,7 +6,7 @@
MTversion = 2.25
queryCommand = "Q"
signature = "speeduino 201712-dev"
signature = "speeduino 201712"
versionInfo = "S" ;This info is what is displayed to user
[TunerStudio]
@ -935,7 +935,7 @@ menuDialog = main
; constantName = "Help Text"
; These provide the context help in the dialog when these variables are used
nCylinders = "Cylinder count"
alternate = ""
alternate = "Whether or not the injectors should be fired at the same time. This setting is ignored when Sequential is selected below, however it will still affect the req_fuel value."
engineType = "Engines with an equal number of degrees between all firings (This is most engines) should select Even fire. Some 2 and 6 cylinder engines are Odd fire however."
twoStroke = "Four-Stroke (most engines), Two-stroke."
nInjectors = "Number of primary injectors."

View File

@ -132,7 +132,7 @@ void command()
break;
case 'Q': // send code version
Serial.print("speeduino 201712-dev");
Serial.print("speeduino 201712");
break;
case 'r': //New format for the optimised OutputChannels
@ -162,7 +162,7 @@ void command()
break;
case 'S': // send code version
Serial.print("Speeduino 2017.12-dev");
Serial.print("Speeduino 2017.12");
currentStatus.secl = 0; //This is required in TS3 due to its stricter timings
break;

View File

@ -58,8 +58,8 @@ volatile int triggerActualTeeth;
volatile unsigned long triggerFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
unsigned long triggerSecFilterTime; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) for the secondary input
unsigned int triggerSecFilterTime_duration; // The shortest valid time (in uS) pulse DURATION
volatile int triggerToothAngle; //The number of crank degrees that elapse per tooth
volatile bool triggerToothAngleIsCorrect = false; //Whether or not the triggerToothAngle variable is currently accurate. Some patterns have times when the triggerToothAngle variable cannot be accurately set.
volatile uint16_t triggerToothAngle; //The number of crank degrees that elapse per tooth
volatile bool triggerToothAngleIsCorrect = false; //Whether or not the triggerToothAngle variable is currently accurate. Some patterns have times when the triggerToothAngle variable cannot be accurately set.
bool secondDerivEnabled; //The use of the 2nd derivative calculation is limited to certain decoders. This is set to either true or false in each decoders setup routine
bool decoderIsSequential; //Whether or not the decoder supports sequential operation
bool decoderIsLowRes = false; //Is set true, certain extra calculations are performed for better timing accuracy

View File

@ -926,13 +926,12 @@ int getCrankAngle_4G63(int timePerDegree)
{
//This is the current angle ATDC the engine is at. This is the last known position based on what tooth was last 'seen'. It is only accurate to the resolution of the trigger wheel (Eg 36-1 is 10 degrees)
unsigned long tempToothLastToothTime, tempToothLastMinusOneToothTime;
int tempToothCurrentCount, tempToothAngle;
int tempToothCurrentCount;
//Grab some variables that are used in the trigger code and assign them to temp variables.
noInterrupts();
tempToothCurrentCount = toothCurrentCount;
tempToothLastToothTime = toothLastToothTime;
tempToothLastMinusOneToothTime = toothLastMinusOneToothTime;
tempToothAngle = triggerToothAngle;
interrupts();
crankAngle = toothAngles[(tempToothCurrentCount - 1)] + configPage2.triggerAngle; //Perform a lookup of the fixed toothAngles array to find what the angle of the last tooth passed was.
@ -941,7 +940,7 @@ int getCrankAngle_4G63(int timePerDegree)
unsigned long elapsedTime = micros() - tempToothLastToothTime;
//crankAngle += uSToDegrees(elapsedTime);
unsigned long toothTime = tempToothLastToothTime - tempToothLastMinusOneToothTime;
crankAngle += (elapsedTime * triggerToothAngle) / toothTime;
crankAngle += int((elapsedTime * triggerToothAngle) / toothTime);
//timePerDegree = toothTime / tempToothAngle;
if (crankAngle >= 720) { crankAngle -= 720; }
@ -2527,8 +2526,6 @@ void triggerPri_ThirtySixMinus222()
if ( (curGap > targetGap) )
{
//if(toothCurrentCount < (triggerActualTeeth) && (currentStatus.hasSync == true) ) { currentStatus.hasSync = false; } //This occurs when we're at tooth #1, but haven't seen all the other teeth. This indicates a signal issue so we flag lost sync so this will attempt to resync on the next revolution.
//else
{
if(toothSystemCount == 1)
{

View File

@ -725,21 +725,22 @@ static inline void ignitionSchedule1Interrupt() //Most ARM chips can simply call
ignitionSchedule1.Status = RUNNING; //Set the status to be in progress (ie The start callback has been called, but not the end callback)
ignitionSchedule1.startTime = micros();
IGN1_COMPARE = ignitionSchedule1.endCompare;
}
/*
This code is all to do with the staged ignition timing testing. That is, calling this interrupt slightly before the true ignition point and recalculating the end time for more accuracy
IGN1_COMPARE = ignitionSchedule1.endCompare - 20;
ignitionSchedule1.Status = STAGED;
}
//This code is all to do with the staged ignition timing testing. That is, calling this interrupt slightly before the true ignition point and recalculating the end time for more accuracy
//IGN1_COMPARE = ignitionSchedule1.endCompare - 50;
//ignitionSchedule1.Status = STAGED;
}
else if (ignitionSchedule1.Status == STAGED)
{
int16_t crankAngle = getCrankAngle(timePerDegree);
if(crankAngle > CRANK_ANGLE_MAX_IGN) { crankAngle -= CRANK_ANGLE_MAX_IGN; }
if(ignition1EndAngle > crankAngle)
{ IGN1_COMPARE = IGN1_COUNTER + uS_TO_TIMER_COMPARE( (ignition1EndAngle - crankAngle) * timePerDegree ); }
{
IGN1_COMPARE = IGN1_COUNTER + uS_TO_TIMER_COMPARE( fastDegreesToUS((ignition1EndAngle - crankAngle)) );
}
else { IGN1_COMPARE = ignitionSchedule1.endCompare; }
ignitionSchedule1.Status = RUNNING;
}*/
}
else if (ignitionSchedule1.Status == RUNNING)
{
ignitionSchedule1.EndCallback();

View File

@ -345,12 +345,21 @@ void setup()
else { channel2IgnDegrees = configPage1.oddfire2; }
//For alternating injection, the squirt occurs at different times for each channel
if(configPage1.injLayout == INJ_SEMISEQUENTIAL)
if(configPage1.injLayout == INJ_SEMISEQUENTIAL || configPage1.injLayout == INJ_PAIRED)
{
channel1InjDegrees = 0;
channel2InjDegrees = channel2IgnDegrees; //Set to the same as the ignition degrees (Means there's no need for another if to check for oddfire)
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
}
else if (configPage1.injLayout == INJ_SEQUENTIAL)
{
channel1InjDegrees = 0;
channel2InjDegrees = channel2IgnDegrees;
CRANK_ANGLE_MAX_INJ = 720;
req_fuel_uS = req_fuel_uS * 2;
}
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
channel1InjEnabled = true;
channel2InjEnabled = true;
@ -381,11 +390,13 @@ void setup()
}
//For alternatiing injection, the squirt occurs at different times for each channel
if(configPage1.injLayout == INJ_SEMISEQUENTIAL || configPage1.injLayout == INJ_PAIRED)
if(configPage1.injLayout == INJ_SEMISEQUENTIAL || configPage1.injLayout == INJ_PAIRED)
{
channel1InjDegrees = 0;
channel2InjDegrees = 120;
channel3InjDegrees = 240;
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = channel3InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
}
else if (configPage1.injLayout == INJ_SEQUENTIAL)
{
@ -395,7 +406,6 @@ void setup()
CRANK_ANGLE_MAX_INJ = 720;
req_fuel_uS = req_fuel_uS * 2;
}
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = channel3InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
channel1InjEnabled = true;
channel2InjEnabled = true;
@ -436,6 +446,8 @@ void setup()
{
channel1InjDegrees = 0;
channel2InjDegrees = 180;
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
}
else if (configPage1.injLayout == INJ_SEQUENTIAL)
{
@ -450,7 +462,6 @@ void setup()
CRANK_ANGLE_MAX_INJ = 720;
req_fuel_uS = req_fuel_uS * 2;
}
if (!configPage1.injTiming) { channel1InjDegrees = channel2InjDegrees = 0; } //For simultaneous, all squirts happen at the same time
//Check if injector staging is enabled
if(configPage11.stagingEnabled == true)
@ -549,6 +560,8 @@ void setup()
break;
}
if(CRANK_ANGLE_MAX_IGN == CRANK_ANGLE_MAX_INJ) { CRANK_ANGLE_MAX = CRANK_ANGLE_MAX_IGN; } //If both the injector max and ignition max angles are the same, make the overall system max this value
switch(configPage2.sparkMode)
{
case IGN_MODE_WASTED:
@ -1114,14 +1127,14 @@ void loop()
if (pw4percent != 100) { currentStatus.PW4 = (pw4percent * currentStatus.PW4) / 100; }
}
}
if(configPage11.stagingEnabled == true)
else if(configPage11.stagingEnabled == true)
{
PWdivTimerPerDegree = div(currentStatus.PW3, timePerDegree).quot; //Need to redo this for PW3 as it will be dramatically different to PW1 when staging
injector3StartAngle = configPage1.inj3Ang - ( PWdivTimerPerDegree ); //This is a little primitive, but is based on the idea that all fuel needs to be delivered before the inlet valve opens. See http://www.extraefi.co.uk/sequential_fuel.html for more detail
if(injector3StartAngle < 0) {injector3StartAngle += CRANK_ANGLE_MAX_INJ;}
if(injector3StartAngle > CRANK_ANGLE_MAX_INJ) {injector3StartAngle -= CRANK_ANGLE_MAX_INJ;}
injector4StartAngle = injector3StartAngle + (CRANK_ANGLE_MAX_INJ / 2);
injector4StartAngle = injector3StartAngle + (CRANK_ANGLE_MAX_INJ / 2); //Phase this either 180 or 360 degrees out from inj3 (In reality this will always be 180 as you can't have sequential and staged currently)
if(injector4StartAngle < 0) {injector4StartAngle += CRANK_ANGLE_MAX_INJ;}
if(injector4StartAngle > CRANK_ANGLE_MAX_INJ) {injector4StartAngle -= CRANK_ANGLE_MAX_INJ;}
}
@ -1440,10 +1453,14 @@ void loop()
if( (ignitionSchedule1.Status == RUNNING) && (ignition1EndAngle > crankAngle) && configPage2.StgCycles == 0)
{
unsigned long uSToEnd = 0;
//if(ignition1EndAngle > crankAngle) { uSToEnd = fastDegreesToUS( (ignition1EndAngle - crankAngle) ); }
//else { uSToEnd = fastDegreesToUS( (360 + ignition1EndAngle - crankAngle) ); }
uSToEnd = fastDegreesToUS( (ignition1EndAngle - crankAngle) );
//uSToEnd = ((ignition1EndAngle - crankAngle) * (toothLastToothTime - toothLastMinusOneToothTime)) / triggerToothAngle;
ONLY ONE OF THE BELOW SHOULD BE USED (PROBABLY THE FIRST):
*********
if(ignition1EndAngle > crankAngle) { uSToEnd = fastDegreesToUS( (ignition1EndAngle - crankAngle) ); }
else { uSToEnd = fastDegreesToUS( (360 + ignition1EndAngle - crankAngle) ); }
*********
uSToEnd = ((ignition1EndAngle - crankAngle) * (toothLastToothTime - toothLastMinusOneToothTime)) / triggerToothAngle;
*********
refreshIgnitionSchedule1( uSToEnd + fixedCrankingOverride );
}

View File

@ -346,7 +346,7 @@ void setPinMapping(byte boardID)
pinCoil2 = 24; //Done
pinCoil3 = 51; //Won't work (No mapping for pin 32)
pinCoil4 = 52; //Won't work (No mapping for pin 33)
pinFuelPump = 53; //Won't work (No mapping for pin 37)
pinFuelPump = 26; //Requires PVT4 adapter or above
pinFan = 50; //Won't work (No mapping for pin 35)
pinTachOut = 28; //Done
#endif