diff --git a/comms.h b/comms.h index 30369e12..fd7822c2 100644 --- a/comms.h +++ b/comms.h @@ -9,6 +9,7 @@ #define afrSetPage 6//Config Page 3 #define iacPage 7//Config Page 4 #define boostvvtPage 8 +#define seqFuelPage 9 byte currentPage = 1;//Not the same as the speeduino config page numbers boolean isMap = true; @@ -36,4 +37,4 @@ void receiveCalibration(byte tableID); void sendToothLog(bool useChar); void testComm(); -#endif // COMMS_H +#endif // COMMS_H diff --git a/comms.ino b/comms.ino index 26a6c8d8..dd20fa05 100644 --- a/comms.ino +++ b/comms.ino @@ -659,6 +659,15 @@ void sendPage(bool useChar) } break; } + case seqFuelPage: + { + byte response[200]; //Bit hacky, but the size is: (8x8 + 8 + 8) + (8x8 + 8 + 8) = 160 + + + for (int x = 0; x < 200; x++) { 0; } + Serial.write((byte *)&response, sizeof(response)); + break; + } default: { Serial.println(F("\nPage has not been implemented yet. Change to another page.")); diff --git a/decoders.ino b/decoders.ino index 2dd223a2..f3489b57 100644 --- a/decoders.ino +++ b/decoders.ino @@ -506,6 +506,7 @@ void triggerSec_4G63() if(BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) || !currentStatus.hasSync) { triggerFilterTime = 1500; //If this is removed, can have trouble getting sync again after the engine is turned off (but ECU not reset). + //Check the status of the crank trigger bool crank = digitalRead(pinTrigger); if(crank == HIGH) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index e9a61b6d..1bc9f3ab 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -92,13 +92,13 @@ ;---------------------------------------------------------------------------- endianness = little - nPages = 8 + nPages = 9 burnCommand = "B" - pageSize = 288, 64, 288, 64, 288, 64, 64, 160 + pageSize = 288, 64, 288, 64, 288, 64, 64, 160, 200 pageActivationDelay = 10 - pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010" - pageReadCommand = "V", "V", "V", "V", "V", "V", "V", "V" - pageValueWrite = "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%o%v", "W%o%v" + pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011" + pageReadCommand = "V", "V", "V", "V", "V", "V", "V", "V", "V" + pageValueWrite = "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%o%v", "W%o%v", "W%o%v" ; pageChunkWrite = "" ; No chunk write for standard MS blockingFactor = 2048 @@ -459,6 +459,52 @@ page = 8 vvtTable = array, U08, 80,[8x8], "%", 1.0, 0.0, 0, 100, 0 rpmBinsVVT = array, U08, 144,[ 8], "RPM", 100.0, 0.0, 100, 25500, 0 tpsBinsVVT = array, U08, 152,[ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0 + +;-------------------------------------------------- +;Sequential fuel trim tables (Page 9) +;-------------------------------------------------- +page = 9 + fuelTrim1Table = array, U08, 0,[6x6], "%", 1.0, -128, -128, 128, 0 + fuelTrim1rpmBins = array, U08, 36,[ 6], "RPM", 100.0, 0.0, 100, 25500, 0 +#if SPEED_DENSITY + fuelTrim1loadBins = array, U08, 42,[ 6], "kPa", 1.0, 0.0, 0.0, 255.0, 0 +#elif ALPHA_N + fuelTrim1loadBins = array, U08, 42,[ 6], "TPS", 1.0, 0.0, 0.0, 255.0, 0 +#endif + + fuelTrim2Table = array, U08, 48,[6x6], "%", 1.0, -128, -128, 128, 0 + fuelTrim2rpmBins = array, U08, 84,[ 6], "RPM", 100.0, 0.0, 100, 25500, 0 +#if SPEED_DENSITY + fuelTrim2loadBins = array, U08, 90,[ 6], "kPa", 1.0, 0.0, 0.0, 255.0, 0 +#elif ALPHA_N + fuelTrim2loadBins = array, U08, 90,[ 6], "TPS", 1.0, 0.0, 0.0, 255.0, 0 +#endif + + fuelTrim3Table = array, U08, 96,[6x6], "%", 1.0, -128, -128, 128, 0 + fuelTrim3rpmBins = array, U08, 132,[ 6], "RPM", 100.0, 0.0, 100, 25500, 0 +#if SPEED_DENSITY + fuelTrim3loadBins = array, U08, 138,[ 6], "kPa", 1.0, 0.0, 0.0, 255.0, 0 +#elif ALPHA_N + fuelTrim3loadBins = array, U08, 138,[ 6], "TPS", 1.0, 0.0, 0.0, 255.0, 0 +#endif + + fuelTrim4Table = array, U08, 144,[6x6], "%", 1.0, -128, -128, 128, 0 + fuelTrim4rpmBins = array, U08, 180,[ 6], "RPM", 100.0, 0.0, 100, 25500, 0 +#if SPEED_DENSITY + fuelTrim4loadBins = array, U08, 186,[ 6], "kPa", 1.0, 0.0, 0.0, 255.0, 0 +#elif ALPHA_N + fuelTrim4loadBins = array, U08, 186,[ 6], "TPS", 1.0, 0.0, 0.0, 255.0, 0 +#endif + + unused9-192 = scalar, U08, 192, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-193 = scalar, U08, 193, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-194 = scalar, U08, 194, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-195 = scalar, U08, 195, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-196 = scalar, U08, 196, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-197 = scalar, U08, 197, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-198 = scalar, U08, 198, "RPM", 100.0, 0.0, 100, 25500, 0 + unused9-199 = scalar, U08, 199, "RPM", 100.0, 0.0, 100, 25500, 0 + ;------------------------------------------------------------------------------- @@ -555,6 +601,8 @@ menuDialog = main subMenu = veTableDialog, "&VE Table", 0 subMenu = sparkTbl, "&Spark Table", 2 subMenu = afrTable1Tbl, "A&FR Table", 5 + subMenu = std_separator + subMenu = inj_trimad, "Sequential fuel trim", 9 menu = "&Spark" subMenu = sparkSettings, "&Spark Settings" @@ -948,7 +996,28 @@ menuDialog = main panel = wc_note field = "" panel = aseSettings - + + ;Fuel trim composite dialog + dialog = inj_trim1TblTitle, "Channel #1" + panel = fuelTrimTable1Tbl, Center + dialog = inj_trim2TblTitle, "Channel #2" + panel = fuelTrimTable1Tbl + dialog = inj_trim3TblTitle, "Channel #3" + panel = fuelTrimTable1Tbl + dialog = inj_trim4TblTitle, "Channel #4" + panel = fuelTrimTable1Tbl + + dialog = inj_trimadt, "", xAxis + panel = inj_trim1TblTitle + panel = inj_trim2TblTitle + dialog = inj_trimadb, "", xAxis + panel = inj_trim3TblTitle + panel = inj_trim4TblTitle + + dialog = inj_trimad,"Injector Cyl 1-4 Trims", yAxis + topicHelp = "file://$getProjectsDirPath()/docs/Megasquirt3_TunerStudio_MS_Lite_Reference-1.4.pdf#injtrim1-4" + panel = inj_trimadt + panel = inj_trimadb ;------------------------------------------------------------------------------- ; General help text @@ -1126,7 +1195,22 @@ menuDialog = main zBins = vvtTable gridHeight = 3.0 upDownLabel = "HIGHER", "LOWER" + +;--------- Sequential fuel trim maps ----------- + table = fuelTrimTable1Tbl, fuelTrimTable1Map, "Fuel trim Table", 9 + topicHelp = "http://speeduino.com/wiki/index.php/Tuning" + xBins = fuelTrim1rpmBins, rpm + #if SPEED_DENSITY + yBins = fuelTrim1loadBins, map + #else + yBins = fuelTrim1loadBins, throttle + #endif + zBins = fuelTrim1Table + gridHeight = 2.0 + gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees. + upDownLabel = "(RICHER)", "(LEANER)" + ;------------------------------------------------------------------------------- [GaugeConfigurations] diff --git a/scheduler.ino b/scheduler.ino index 28b77a85..7e2883f8 100644 --- a/scheduler.ino +++ b/scheduler.ino @@ -35,8 +35,43 @@ void initialiseSchedulers() TIFR4 = 0x00; //Timer4 INT Flag Reg: Clear Timer Overflow Flag TCCR4A = 0x00; //Timer4 Control Reg A: Wave Gen Mode normal TCCR4B = (1 << CS12); //Timer4 Control Reg B: aka Divisor = 256 = 122.5HzTimer Prescaler set to 256. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg + #elif defined (CORE_TEENSY) && defined (__MK20DX256__) + //Configure ARM timers here + FTM0_MODE |= FTM_MODE_WPDIS; // Write Protection Disable + FTM0_MODE |= FTM_MODE_FTMEN; // Unrestricted FTM mode + FTM0_SC |= FTM_SC_TOIE; // enable Overflow Interrupt + + // enable the clock for FTM0 + FTM0_SC |= FTM_SC_CLKS(0b10); + // 00 No clock selected. This in effect disables the FTM counter. + // 01 System clock + // 10 Fixed frequency clock + // 11 External clock + + // set Prescaler + //FTM0_SC |= FTM_SC_PS(0b111); + FTM0_SC |= 0b000; + // 000 Divide by 1 + // 001 Divide by 2 + // 010 Divide by 4 + // 011 Divide by 8 + // 100 Divide by 16 + // 101 Divide by 32 + // 110 Divide by 64 + // 111 Divide by 128 + + // set the counter initial value + FTM0_CNT = 0; + + // enable the clock for FTM0 + SIM_SCGC6 |= SIM_SCGC6_FTM0; + + // enable IRQ Interrupt + NVIC_ENABLE_IRQ(IRQ_FTM0); + + FTM0_FMS |= FTM0_WPEN; #endif @@ -229,7 +264,7 @@ void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsign IGN2_COMPARE = ignitionSchedule2.startCompare; ignitionSchedule2.Status = PENDING; //Turn this schedule on interrupts(); - IGN1_TIMER_ENABLE(); + IGN2_TIMER_ENABLE(); } void setIgnitionSchedule3(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)()) { diff --git a/speeduino.ino b/speeduino.ino index 0f56e74e..1e0aee7a 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -562,10 +562,10 @@ void setup() } //For alternatiing 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; + channel2InjDegrees = 180; } else if (configPage1.injLayout == INJ_SEQUENTIAL) { @@ -680,7 +680,7 @@ void setup() switch(configPage2.sparkMode) { - case 0: + case IGN_MODE_WASTED: //Wasted Spark (Normal mode) ign1StartFunction = beginCoil1Charge; ign1EndFunction = endCoil1Charge; @@ -694,7 +694,7 @@ void setup() ign5EndFunction = endCoil5Charge; break; - case 1: + case IGN_MODE_SINGLE: //Single channel mode. All ignition pulses are on channel 1 ign1StartFunction = beginCoil1Charge; ign1EndFunction = endCoil1Charge; @@ -708,7 +708,7 @@ void setup() ign5EndFunction = endCoil1Charge; break; - case 2: + case IGN_MODE_WASTEDCOP: //Wasted COP mode. Ignition channels 1&3 and 2&4 are paired together //This is not a valid mode for >4 cylinders if( configPage1.nCylinders <= 4 )