diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 1ed58633..c0d22a56 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -97,8 +97,9 @@ ;---------------------------------------------------------------------------- endianness = little - nPages = 11 + nPages = 10 ;pageSize = 288, 64, 288, 64, 288, 64, 64, 160, 192, 128, 192 + pageSize = 288, 64, 288, 64, 288, 128, 160, 192, 128, 192 ;burnCommand = "B" ;pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011", "P\012", "P\013" @@ -110,11 +111,11 @@ ;pageChunkWrite = "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v", "X%o%c%v" ; New commands - pageSize = 288, 128, 288, 128, 288, 128, 128, 160, 192, 128, 192 - pageIdentifier = "\$tsCanId\x01", "\$tsCanId\x02", "\$tsCanId\x03", "\$tsCanId\x04", "\$tsCanId\x05", "\$tsCanId\x06", "\$tsCanId\x07", "\$tsCanId\x08", "\$tsCanId\x09", "\$tsCanId\x0A", "\$tsCanId\x0B" - burnCommand = "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i" - pageReadCommand = "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v" - pageValueWrite = "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v" + ;pageSize = 288, 128, 288, 128, 288, 128, 128, 160, 192, 128, 192 + pageIdentifier = "\$tsCanId\x01", "\$tsCanId\x02", "\$tsCanId\x03", "\$tsCanId\x04", "\$tsCanId\x05", "\$tsCanId\x06", "\$tsCanId\x07", "\$tsCanId\x08", "\$tsCanId\x09", "\$tsCanId\x0A" + burnCommand = "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i", "b%2i" + pageReadCommand = "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v", "p%2i%2o%2c%v" + pageValueWrite = "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v" ;pageChunkWrite = "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v" ;pageChunkWrite = "w%2i%2o%2c%v", "", "w%2i%2o%2c%v", "", "w%2i%2o%2c%v", "", "", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v", "w%2i%2o%2c%v" @@ -448,62 +449,58 @@ page = 6 flatSRetard = scalar, U08, 62, "deg", 1.0, 0.0, 0.0, 80, 0 flatSArm = scalar, U08, 63, "rpm", 100, 0.0, 100, 25500, 0 -;-------------------------------------------------- -;Start idle and fan controls (Page 7) -;-------------------------------------------------- -page = 7 - iacCLValues = array, U08, 0, [10], "RPM", 10.0, 0.0, 0, 2550, 0 - iacOLStepVal = array, U08, 10, [10], "Steps", 3, 0, 0, 765, 0 - iacOLPWMVal = array, U08, 20, [10], "Duty %", 1.0, 0, 0, 100, 0 + iacCLValues = array, U08, 64, [10], "RPM", 10.0, 0.0, 0, 2550, 0 + iacOLStepVal = array, U08, 74, [10], "Steps", 3, 0, 0, 765, 0 + iacOLPWMVal = array, U08, 84, [10], "Duty %", 1.0, 0, 0, 100, 0 #if CELSIUS - iacBins = array, U08, 30, [10], "C", 1.0, -40, -40, 215, 0 + iacBins = array, U08, 94, [10], "C", 1.0, -40, -40, 215, 0 #else - iacBins = array, U08, 30, [10], "F", 1.8, -22.23, -40, 215, 0 + iacBins = array, U08, 94, [10], "F", 1.8, -22.23, -40, 215, 0 #endif - iacCrankSteps= array, U08, 40, [4], "Steps", 3, 0, 0, 765, 0 - iacCrankDuty = array, U08, 44, [4], "Duty %", 1.0, 0, 0, 100, 0 + iacCrankSteps= array, U08, 104, [4], "Steps", 3, 0, 0, 765, 0 + iacCrankDuty = array, U08, 108, [4], "Duty %", 1.0, 0, 0, 100, 0 #if CELSIUS - iacCrankBins = array, U08, 48, [4], "C", 1.0, -40, -40, 215, 0 + iacCrankBins = array, U08, 112, [4], "C", 1.0, -40, -40, 215, 0 #else - iacCrankBins = array, U08, 48, [4], "F", 1.8, -22.23, -40, 215, 0 + iacCrankBins = array, U08, 112, [4], "F", 1.8, -22.23, -40, 215, 0 #endif - iacAlgorithm = bits , U08, 52, [0:2], "None", "On/Off", "PWM Open loop", "PWM Closed loop", "Stepper Open Loop", "Stepper Closed Loop", "INVALID", "INVALID" - iacStepTime = bits , U08, 52, [3:5], "INVALID","1", "2", "3", "4", "5", "6","INVALID" - iacChannels = bits, U08, 52, [6:6], "1", "2" - iacPWMdir = bits , U08, 52, [7:7], "Normal", "Reverse" + iacAlgorithm = bits , U08, 116, [0:2], "None", "On/Off", "PWM Open loop", "PWM Closed loop", "Stepper Open Loop", "Stepper Closed Loop", "INVALID", "INVALID" + iacStepTime = bits , U08, 116, [3:5], "INVALID","1", "2", "3", "4", "5", "6","INVALID" + iacChannels = bits, U08, 116, [6:6], "1", "2" + iacPWMdir = bits , U08, 116, [7:7], "Normal", "Reverse" #if CELSIUS - iacFastTemp = scalar, U08, 53, "C", 1.0, -40, -40, 215, 0 + iacFastTemp = scalar, U08, 117, "C", 1.0, -40, -40, 215, 0 #else - iacFastTemp = scalar, U08, 53, "F", 1.8, -22.23, -40, 215, 0 + iacFastTemp = scalar, U08, 117, "F", 1.8, -22.23, -40, 215, 0 #endif - iacStepHome = scalar, U08, 54, "Steps", 3, 0, 0, 765, 0 - iacStepHyster= scalar, U08, 55, "Steps", 1, 0.0, 0.0, 10, 0 + iacStepHome = scalar, U08, 118, "Steps", 3, 0, 0, 765, 0 + iacStepHyster= scalar, U08, 119, "Steps", 1, 0.0, 0.0, 10, 0 ; Begin fan control vairables - fanInv = bits, U08, 56, [0:0], "No", "Yes" - fanEnable = bits, U08, 56, [1:1], "Off", "On/Off" - fanPin = bits , U08, 56, [2:7], "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", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" + fanInv = bits, U08, 120, [0:0], "No", "Yes" + fanEnable = bits, U08, 120, [1:1], "Off", "On/Off" + fanPin = bits , U08, 120, [2:7], "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", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" #if CELSIUS - fanSP = scalar, U08, 57, "C", 1.0, -40, -40, 215.0, 0 - fanHyster = scalar, U08, 58, "C", 1.0, 0.0, 0.0, 40, 0 + fanSP = scalar, U08, 121, "C", 1.0, -40, -40, 215.0, 0 + fanHyster = scalar, U08, 122, "C", 1.0, 0.0, 0.0, 40, 0 #else - fanSP = scalar, U08, 57, "F", 1.8, -22.23, -40, 215.0, 0 - fanHyster = scalar, U08, 58, "F", 1.0, 0.0, 0.0, 40, 0 + fanSP = scalar, U08, 121, "F", 1.8, -22.23, -40, 215.0, 0 + fanHyster = scalar, U08, 122, "F", 1.0, 0.0, 0.0, 40, 0 #endif - fanFreq = scalar, U08 , 59, "Hz", 2.0, 0.0, 10, 511, 0 + fanFreq = scalar, U08 , 123, "Hz", 2.0, 0.0, 10, 511, 0 #if CELSIUS - fanPWMBins = array, U08, 60, [4], "C", 1.0, -40, -40, 215, 0 + fanPWMBins = array, U08, 124, [4], "C", 1.0, -40, -40, 215, 0 #else - fanPWMBins = array, U08, 60, [4], "F", 1.8, -22.23, -40, 215, 0 + fanPWMBins = array, U08, 124, [4], "F", 1.8, -22.23, -40, 215, 0 #endif ;-------------------------------------------------- -;Boost and vvt maps (Page 8) +;Boost and vvt maps (Page 7) ;-------------------------------------------------- -page = 8 +page = 7 ;notes for boostTable in PSI~~~There are 6.895 psis to a kPa then x 2 like the kPa ver~~~div atmos. pressure in kPa by 2 and make neg so to subtract instead of add ; #if BOOSTPSI ; boostTable = array, U08, 0,[8x8], "PSI", 0.29007547546041846, -50.6625, 0, 74, 0 @@ -517,9 +514,9 @@ page = 8 tpsBinsVVT = array, U08, 152,[ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0 ;-------------------------------------------------- -;Sequential fuel trim tables (Page 9) +;Sequential fuel trim tables (Page 8) ;-------------------------------------------------- -page = 9 +page = 8 fuelTrim1Table = array, U08, 0,[6x6], "%", 1.0, -128, -50, 50, 0 fuelTrim1rpmBins = array, U08, 36,[ 6], "RPM", 100.0, 0.0, 100, 25500, 0 #if SPEED_DENSITY @@ -553,9 +550,9 @@ page = 9 #endif ;-------------------------------------------------- -;CANBUS control (Page 10) +;CANBUS control (Page 9) ;-------------------------------------------------- -page = 10 +page = 9 #if CAN_COMMANDS enable_canbus = bits, U08, 0, [0:1], "Disable", "On Via Secondary Serial", "ON via Internal CAN ", "INVALID" #else @@ -703,7 +700,7 @@ page = 10 unused10_126 = scalar, U08, 126, "", 1, 0, 0, 255, 0 unused10_127 = scalar, U08, 127, "", 1, 0, 0, 255, 0 -page = 11 +page = 10 #if CELSIUS crankingEnrichBins = array, U08, 0, [4], "C", 1.0, -40, -40, 215, 0 #else diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index e164d0f1..d10d5ac9 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -12,7 +12,7 @@ Fan control */ void initialiseFan() { - if( configPage4.fanInv == 1 ) { fanHIGH = LOW; fanLOW = HIGH; } + if( configPage3.fanInv == 1 ) { fanHIGH = LOW; fanLOW = HIGH; } else { fanHIGH = HIGH; fanLOW = LOW; } digitalWrite(pinFan, fanLOW); //Initiallise program with the fan in the off state currentStatus.fanOn = false; @@ -20,10 +20,10 @@ void initialiseFan() void fanControl() { - if( configPage4.fanEnable == 1 ) + if( configPage3.fanEnable == 1 ) { - int onTemp = (int)configPage4.fanSP - CALIBRATION_TEMPERATURE_OFFSET; - int offTemp = onTemp - configPage4.fanHyster; + int onTemp = (int)configPage3.fanSP - CALIBRATION_TEMPERATURE_OFFSET; + int offTemp = onTemp - configPage3.fanHyster; if ( (!currentStatus.fanOn) && (currentStatus.coolant >= onTemp) ) { digitalWrite(pinFan,fanHIGH); currentStatus.fanOn = true; } if ( (currentStatus.fanOn) && (currentStatus.coolant <= offTemp) ) { digitalWrite(pinFan, fanLOW); currentStatus.fanOn = false; } diff --git a/speeduino/comms.h b/speeduino/comms.h index 5f84a81e..be7969fd 100644 --- a/speeduino/comms.h +++ b/speeduino/comms.h @@ -7,11 +7,10 @@ #define ignSetPage 4//Config Page 2 #define afrMapPage 5 #define afrSetPage 6//Config Page 3 -#define iacPage 7//Config Page 4 -#define boostvvtPage 8 -#define seqFuelPage 9 -#define canbusPage 10//Config Page 10 -#define warmupPage 11 //Config Page 11 +#define boostvvtPage 7 +#define seqFuelPage 8 +#define canbusPage 9//Config Page 9 +#define warmupPage 10 //Config Page 10 #define packetSize 74 diff --git a/speeduino/comms.ino b/speeduino/comms.ino index d9da098b..4b406fe5 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -479,7 +479,7 @@ void receiveValue(int valueOffset, byte newValue) case veSetPage: pnt_configPage = &configPage1; //Setup a pointer to the relevant config page //For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size - if (valueOffset < page_size) + if (valueOffset < npage_size[veSetPage]) { *((byte *)pnt_configPage + (byte)valueOffset) = newValue; } @@ -510,7 +510,7 @@ void receiveValue(int valueOffset, byte newValue) case ignSetPage: pnt_configPage = &configPage2; //For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size - if (valueOffset < page_size) + if (valueOffset < npage_size[ignSetPage]) { *((byte *)pnt_configPage + (byte)valueOffset) = newValue; } @@ -542,16 +542,7 @@ void receiveValue(int valueOffset, byte newValue) case afrSetPage: pnt_configPage = &configPage3; //For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size - if (valueOffset < page_size) - { - *((byte *)pnt_configPage + (byte)valueOffset) = newValue; - } - break; - - case iacPage: //Idle Air Control settings page (Page 4) - pnt_configPage = &configPage4; - //For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size - if (valueOffset < page_size) + if (valueOffset < npage_size[afrSetPage]) { *((byte *)pnt_configPage + (byte)valueOffset) = newValue; } @@ -679,7 +670,7 @@ void sendPage(bool useChar) for (pnt_configPage = (uint16_t *)&configPage1.inj4Ang + 1; pnt_configPage < &configPage1.mapMax; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } Serial.println(configPage1.mapMax); // Following loop displays remaining byte values of the page - for (pnt_configPage = (uint16_t *)&configPage1.mapMax + 1; pnt_configPage < (byte *)&configPage1 + page_size; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } + for (pnt_configPage = (uint16_t *)&configPage1.mapMax + 1; pnt_configPage < (byte *)&configPage1 + npage_size[veSetPage]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } sendComplete = true; } else { pnt_configPage = &configPage1; } //Create a pointer to Page 1 in memory @@ -729,7 +720,7 @@ void sendPage(bool useChar) Serial.print(' '); } Serial.println(); - for (pnt_configPage = (byte *)&configPage2.dwellCorrectionValues[5] + 1; pnt_configPage < (byte *)&configPage2 + page_size; pnt_configPage = (byte *)pnt_configPage + 1) + for (pnt_configPage = (byte *)&configPage2.dwellCorrectionValues[5] + 1; pnt_configPage < (byte *)&configPage2 + npage_size[ignSetPage]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage));// Displaying remaining byte values of the page } @@ -780,16 +771,15 @@ void sendPage(bool useChar) Serial.println(); } // Following loop displays the remaining byte values of the page - for (pnt_configPage = (byte *)&configPage3.airDenRates[8] + 1; pnt_configPage < (byte *)&configPage3 + page_size; pnt_configPage = (byte *)pnt_configPage + 1) + for (pnt_configPage = (byte *)&configPage3.airDenRates[8] + 1; pnt_configPage < (byte *)&configPage3 + npage_size[afrSetPage]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } sendComplete = true; } else { pnt_configPage = &configPage3; } //Create a pointer to Page 3 in memory - break; - case iacPage: + //Old configPage4 STARTED HERE! //currentTitleIndex = 106; //To Display Values from Config Page 4 if (useChar) @@ -800,10 +790,10 @@ void sendPage(bool useChar) byte * currentVar; switch (y) { - case 1: currentVar = configPage4.iacBins; break; - case 2: currentVar = configPage4.iacOLPWMVal; break; - case 3: currentVar = configPage4.iacOLStepVal; break; - case 4: currentVar = configPage4.iacCLValues; break; + case 1: currentVar = configPage3.iacBins; break; + case 2: currentVar = configPage3.iacOLPWMVal; break; + case 3: currentVar = configPage3.iacOLStepVal; break; + case 4: currentVar = configPage3.iacCLValues; break; default: break; } for (byte x = 10; x; x--) @@ -818,9 +808,9 @@ void sendPage(bool useChar) byte * currentVar; switch (y) { - case 1: currentVar = configPage4.iacCrankBins; break; - case 2: currentVar = configPage4.iacCrankDuty; break; - case 3: currentVar = configPage4.iacCrankSteps; break; + case 1: currentVar = configPage3.iacCrankBins; break; + case 2: currentVar = configPage3.iacCrankDuty; break; + case 3: currentVar = configPage3.iacCrankSteps; break; default: break; } for (byte x = 4; x; x--) @@ -831,10 +821,10 @@ void sendPage(bool useChar) Serial.println(); } // Following loop is for remaining byte value of page - for (pnt_configPage = (byte *)&configPage4.iacCrankBins[3] + 1; pnt_configPage < (byte *)&configPage4 + page_size; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } + for (pnt_configPage = (byte *)&configPage3.iacCrankBins[3] + 1; pnt_configPage < (byte *)&configPage3 + npage_size[afrSetPage]; pnt_configPage = (byte *)pnt_configPage + 1) { Serial.println(*((byte *)pnt_configPage)); } sendComplete = true; } - else { pnt_configPage = &configPage4; } //Create a pointer to Page 4 in memory + else { pnt_configPage = &configPage3; } //Create a pointer to Page 4 in memory break; case boostvvtPage: @@ -1106,11 +1096,6 @@ byte getPageValue(byte page, uint16_t valueAddress) returnValue = *((byte *)pnt_configPage + valueAddress); break; - case iacPage: - pnt_configPage = &configPage4; //Create a pointer to Page 4 in memory - returnValue = *((byte *)pnt_configPage + valueAddress); - break; - case boostvvtPage: { diff --git a/speeduino/globals.h b/speeduino/globals.h index fd4ee3be..cabea41e 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -139,8 +139,8 @@ const char displaySignature[] = "speeduino 201609-dev"; const char TSfirmwareVersion[] = "Speeduino 2016.09"; const byte data_structure_version = 2; //This identifies the data structure when reading / writing. -const byte page_size = 64; -const int npage_size[12] = {0,288,64,288,64,288,64,64,160,192,128,192}; +//const byte page_size = 64; +const int npage_size[11] = {0,288,64,288,64,288,128,160,192,128,192}; //const byte page11_size = 128; #define MAP_PAGE_SIZE 288 @@ -511,16 +511,6 @@ struct config3 { byte flatSRetard; byte flatSArm; -#if defined(CORE_AVR) - }; -#else - } __attribute__((__packed__)); //The 32 bit systems require all structs to be fully packed -#endif - - -//Page 4 of the config mostly deals with idle control -//See ini file for further info (Config Page 7 in the ini) -struct config4 { byte iacCLValues[10]; //Closed loop target RPM value byte iacOLStepVal[10]; //Open loop step values for stepper motors byte iacOLPWMVal[10]; //Open loop duty values for PMWM valves diff --git a/speeduino/idle.ino b/speeduino/idle.ino index ec0b0d7e..00a4769d 100644 --- a/speeduino/idle.ino +++ b/speeduino/idle.ino @@ -24,7 +24,7 @@ void initialiseIdle() #elif defined (CORE_TEENSY) - if( (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_OL) || (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_CL) ) + if( (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_OL) || (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_CL) ) { //FlexTimer 2 is used for idle FTM2_MODE |= FTM_MODE_WPDIS; // Write Protection Disable @@ -84,14 +84,14 @@ void initialiseIdle() #endif //Initialising comprises of setting the 2D tables with the relevant values from the config pages - switch(configPage4.iacAlgorithm) + switch(configPage3.iacAlgorithm) { case IAC_ALGORITHM_NONE: //Case 0 is no idle control ('None') break; case IAC_ALGORITHM_ONOFF: //Case 1 is on/off idle control - if ((currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < configPage4.iacFastTemp) + if ((currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < configPage3.iacFastTemp) { digitalWrite(pinIdle1, HIGH); idleOn = true; @@ -102,14 +102,14 @@ void initialiseIdle() //Case 2 is PWM open loop iacPWMTable.xSize = 10; iacPWMTable.valueSize = SIZE_BYTE; - iacPWMTable.values = configPage4.iacOLPWMVal; - iacPWMTable.axisX = configPage4.iacBins; + iacPWMTable.values = configPage3.iacOLPWMVal; + iacPWMTable.axisX = configPage3.iacBins; iacCrankDutyTable.xSize = 4; iacCrankDutyTable.valueSize = SIZE_BYTE; - iacCrankDutyTable.values = configPage4.iacCrankDuty; - iacCrankDutyTable.axisX = configPage4.iacCrankBins; + iacCrankDutyTable.values = configPage3.iacCrankDuty; + iacCrankDutyTable.axisX = configPage3.iacCrankBins; idle_pin_port = portOutputRegister(digitalPinToPort(pinIdle1)); idle_pin_mask = digitalPinToBitMask(pinIdle1); @@ -127,13 +127,13 @@ void initialiseIdle() //Case 3 is PWM closed loop iacClosedLoopTable.xSize = 10; iacClosedLoopTable.valueSize = SIZE_BYTE; - iacClosedLoopTable.values = configPage4.iacCLValues; - iacClosedLoopTable.axisX = configPage4.iacBins; + iacClosedLoopTable.values = configPage3.iacCLValues; + iacClosedLoopTable.axisX = configPage3.iacBins; iacCrankDutyTable.xSize = 4; iacCrankDutyTable.valueSize = SIZE_BYTE; - iacCrankDutyTable.values = configPage4.iacCrankDuty; - iacCrankDutyTable.axisX = configPage4.iacCrankBins; + iacCrankDutyTable.values = configPage3.iacCrankDuty; + iacCrankDutyTable.axisX = configPage3.iacCrankBins; idle_pin_port = portOutputRegister(digitalPinToPort(pinIdle1)); idle_pin_mask = digitalPinToBitMask(pinIdle1); @@ -155,13 +155,13 @@ void initialiseIdle() //Case 2 is Stepper open loop iacStepTable.xSize = 10; iacStepTable.valueSize = SIZE_BYTE; - iacStepTable.values = configPage4.iacOLStepVal; - iacStepTable.axisX = configPage4.iacBins; + iacStepTable.values = configPage3.iacOLStepVal; + iacStepTable.axisX = configPage3.iacBins; iacCrankStepsTable.xSize = 4; - iacCrankStepsTable.values = configPage4.iacCrankSteps; - iacCrankStepsTable.axisX = configPage4.iacCrankBins; - iacStepTime = configPage4.iacStepTime * 1000; + iacCrankStepsTable.values = configPage3.iacCrankSteps; + iacCrankStepsTable.axisX = configPage3.iacCrankBins; + iacStepTime = configPage3.iacStepTime * 1000; completedHomeSteps = 0; idleStepper.curIdleStep = 0; @@ -172,20 +172,20 @@ void initialiseIdle() //Case 5 is Stepper closed loop iacClosedLoopTable.xSize = 10; iacClosedLoopTable.valueSize = SIZE_BYTE; - iacClosedLoopTable.values = configPage4.iacCLValues; - iacClosedLoopTable.axisX = configPage4.iacBins; + iacClosedLoopTable.values = configPage3.iacCLValues; + iacClosedLoopTable.axisX = configPage3.iacBins; iacCrankStepsTable.xSize = 4; - iacCrankStepsTable.values = configPage4.iacCrankSteps; - iacCrankStepsTable.axisX = configPage4.iacCrankBins; - iacStepTime = configPage4.iacStepTime * 1000; + iacCrankStepsTable.values = configPage3.iacCrankSteps; + iacCrankStepsTable.axisX = configPage3.iacCrankBins; + iacStepTime = configPage3.iacStepTime * 1000; completedHomeSteps = 0; idleCounter = 0; idleStepper.curIdleStep = 0; idleStepper.stepperStatus = SOFF; - idlePID.SetOutputLimits(0, (configPage4.iacStepHome * 3)); //Maximum number of steps probably needs its own setting + idlePID.SetOutputLimits(0, (configPage3.iacStepHome * 3)); //Maximum number of steps probably needs its own setting idlePID.SetTunings(configPage3.idleKP, configPage3.idleKI, configPage3.idleKD); idlePID.SetMode(AUTOMATIC); //Turn PID on break; @@ -194,21 +194,21 @@ void initialiseIdle() //Well this just shouldn't happen break; } - idleInitComplete = configPage4.iacAlgorithm; //Sets which idle method was initialised + idleInitComplete = configPage3.iacAlgorithm; //Sets which idle method was initialised currentStatus.idleLoad = 0; } void idleControl() { - if(idleInitComplete != configPage4.iacAlgorithm) { initialiseIdle(); } + if(idleInitComplete != configPage3.iacAlgorithm) { initialiseIdle(); } - switch(configPage4.iacAlgorithm) + switch(configPage3.iacAlgorithm) { case IAC_ALGORITHM_NONE: //Case 0 is no idle control ('None') break; case IAC_ALGORITHM_ONOFF: //Case 1 is on/off idle control - if ( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < configPage4.iacFastTemp) //All temps are offset by 40 degrees + if ( (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) < configPage3.iacFastTemp) //All temps are offset by 40 degrees { digitalWrite(pinIdle1, HIGH); idleOn = true; @@ -270,7 +270,7 @@ void idleControl() { //Only do a lookup of the required value around 4 times per second. Any more than this can create too much jitter and require a hyster value that is too high idleStepper.targetIdleStep = table2D_getValue(&iacStepTable, (currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)) * 3; //All temps are offset by 40 degrees. Step counts are divided by 3 in TS. Multiply back out here - iacStepTime = configPage4.iacStepTime * 1000; + iacStepTime = configPage3.iacStepTime * 1000; } doStep(); } @@ -286,7 +286,7 @@ void idleControl() { //This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second idlePID.SetTunings(configPage3.idleKP, configPage3.idleKI, configPage3.idleKD); - iacStepTime = configPage4.iacStepTime * 1000; + iacStepTime = configPage3.iacStepTime * 1000; } idle_cl_target_rpm = table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) * 10; //All temps are offset by 40 degrees @@ -314,7 +314,7 @@ False: If the motor has not yet been homed. Will also perform another homing ste static inline byte isStepperHomed() { bool isHomed = true; //As it's the most common scenario, default value is true - if( completedHomeSteps < (configPage4.iacStepHome * 3) ) //Home steps are divided by 3 from TS + if( completedHomeSteps < (configPage3.iacStepHome * 3) ) //Home steps are divided by 3 from TS { digitalWrite(pinStepperDir, STEPPER_BACKWARD); //Sets stepper direction to backwards digitalWrite(pinStepperStep, HIGH); @@ -369,7 +369,7 @@ Performs a step */ static inline void doStep() { - if ( (idleStepper.targetIdleStep <= (idleStepper.curIdleStep - configPage4.iacStepHyster)) || (idleStepper.targetIdleStep >= (idleStepper.curIdleStep + configPage4.iacStepHyster)) ) //Hysteris check + if ( (idleStepper.targetIdleStep <= (idleStepper.curIdleStep - configPage3.iacStepHyster)) || (idleStepper.targetIdleStep >= (idleStepper.curIdleStep + configPage3.iacStepHyster)) ) //Hysteris check { if(idleStepper.targetIdleStep < idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_BACKWARD); idleStepper.curIdleStep--; }//Sets stepper direction to backwards else if (idleStepper.targetIdleStep > idleStepper.curIdleStep) { digitalWrite(pinStepperDir, STEPPER_FORWARD); idleStepper.curIdleStep++; }//Sets stepper direction to forwards @@ -385,12 +385,12 @@ static inline void doStep() //This function simply turns off the idle PWM and sets the pin low static inline void disableIdle() { - if( (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_CL) || (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_OL) ) + if( (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_CL) || (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_OL) ) { IDLE_TIMER_DISABLE(); digitalWrite(pinIdle1, LOW); } - else if ( (configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_CL) || (configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_OL) ) + else if ( (configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_CL) || (configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_OL) ) { digitalWrite(pinStepperEnable, HIGH); //Disable the DRV8825 idleStepper.targetIdleStep = idleStepper.curIdleStep; //Don't try to move anymore @@ -401,11 +401,11 @@ static inline void disableIdle() //Typically this is enabling the PWM interrupt static inline void enableIdle() { - if( (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_CL) || (configPage4.iacAlgorithm == IAC_ALGORITHM_PWM_OL) ) + if( (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_CL) || (configPage3.iacAlgorithm == IAC_ALGORITHM_PWM_OL) ) { IDLE_TIMER_ENABLE(); } - else if ( (configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_CL) || (configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_OL) ) + else if ( (configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_CL) || (configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_OL) ) { } @@ -419,34 +419,34 @@ static inline void idleInterrupt() //Most ARM chips can simply call a function { if (idle_pwm_state) { - if (configPage4.iacPWMdir == 0) + if (configPage3.iacPWMdir == 0) { //Normal direction *idle_pin_port &= ~(idle_pin_mask); // Switch pin to low (1 pin mode) - if(configPage4.iacChannels == 1) { *idle2_pin_port |= (idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 + if(configPage3.iacChannels == 1) { *idle2_pin_port |= (idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 } else { //Reversed direction *idle_pin_port |= (idle_pin_mask); // Switch pin high - if(configPage4.iacChannels == 1) { *idle2_pin_port &= ~(idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 + if(configPage3.iacChannels == 1) { *idle2_pin_port &= ~(idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 } IDLE_COMPARE = IDLE_COUNTER + (idle_pwm_max_count - idle_pwm_cur_value); idle_pwm_state = false; } else { - if (configPage4.iacPWMdir == 0) + if (configPage3.iacPWMdir == 0) { //Normal direction *idle_pin_port |= (idle_pin_mask); // Switch pin high - if(configPage4.iacChannels == 1) { *idle2_pin_port &= ~(idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 + if(configPage3.iacChannels == 1) { *idle2_pin_port &= ~(idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 } else { //Reversed direction *idle_pin_port &= ~(idle_pin_mask); // Switch pin to low (1 pin mode) - if(configPage4.iacChannels == 1) { *idle2_pin_port |= (idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 + if(configPage3.iacChannels == 1) { *idle2_pin_port |= (idle2_pin_mask); } //If 2 idle channels are in use, flip idle2 to be the opposite of idle1 } IDLE_COMPARE = IDLE_COUNTER + idle_pwm_target_value; idle_pwm_cur_value = idle_pwm_target_value; diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 03c8378e..df944b60 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -52,7 +52,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct config1 configPage1; struct config2 configPage2; struct config3 configPage3; -struct config4 configPage4; struct config10 configPage10; struct config11 configPage11; @@ -872,7 +871,7 @@ void loop() readBaro(); //Infrequent baro readings are not an issue. } - if(configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_OL || configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_CL) { idleControl(); } //Run idlecontrol every loop for stepper idle. + if(configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_OL || configPage3.iacAlgorithm == IAC_ALGORITHM_STEP_CL) { idleControl(); } //Run idlecontrol every loop for stepper idle. //Always check for sync //Main loop runs within this clause diff --git a/speeduino/storage.h b/speeduino/storage.h index 0d109e97..26724003 100644 --- a/speeduino/storage.h +++ b/speeduino/storage.h @@ -83,9 +83,7 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes) #define EEPROM_CONFIG5_XBINS 967 #define EEPROM_CONFIG5_YBINS 983 #define EEPROM_CONFIG6_START 999 -#define EEPROM_CONFIG6_END 1063 -#define EEPROM_CONFIG7_START 1063 -#define EEPROM_CONFIG7_END 1127 +#define EEPROM_CONFIG6_END 1127 #define EEPROM_CONFIG8_XSIZE1 1127 #define EEPROM_CONFIG8_YSIZE1 1128 #define EEPROM_CONFIG8_MAP1 1129 diff --git a/speeduino/storage.ino b/speeduino/storage.ino index dfe9dfd1..b647bec3 100644 --- a/speeduino/storage.ino +++ b/speeduino/storage.ino @@ -22,7 +22,6 @@ void writeAllConfig() writeConfig(8); writeConfig(9); writeConfig(10); - writeConfig(11); } @@ -177,20 +176,6 @@ void writeConfig(byte tableNum) } break; - case iacPage: - /*--------------------------------------------------- - | Config page 4 (See storage.h for data layout) - | 64 byte long config table - -----------------------------------------------------*/ - pnt_configPage = (byte *)&configPage4; //Create a pointer to Page 4 in memory - //The next 128 bytes can simply be pulled straight from the configTable - for(int x=EEPROM_CONFIG7_START; x EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time. - if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))); writeCounter++; } - } - break; - case boostvvtPage: { /*--------------------------------------------------- @@ -434,17 +419,6 @@ void loadConfig() *(pnt_configPage + byte(x - EEPROM_CONFIG6_START)) = EEPROM.read(x); } - //********************************************************************************************************************************************************************************* - - //CONFIG PAGE (4) - pnt_configPage = (byte *)&configPage4; //Create a pointer to Page 3 in memory - //Begin writing the Ignition table, basically the same thing as above - //The first 64 bytes can simply be pulled straight from the configTable - for(int x=EEPROM_CONFIG7_START; x