From 667e80dc264264784cbaff783800dd30d5af239c Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Sun, 12 Feb 2017 14:31:37 +1300 Subject: [PATCH] Add boost target to log --- reference/speeduino.ini | 4 +++- speeduino/auxiliaries.ino | 1 + speeduino/comms.h | 4 ++-- speeduino/comms.ino | 1 + speeduino/globals.h | 1 + speeduino/speeduino.ino | 9 ++++----- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 39bdde3..a68a86c 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -1687,7 +1687,7 @@ menuDialog = main ochGetCommand = "A" - ochBlockSize = 37 + ochBlockSize = 38 secl = scalar, U08, 0, "sec", 1.000, 0.000 squirt = scalar, U08, 1, "bits", 1.000, 0.000 @@ -1749,6 +1749,7 @@ menuDialog = main errors = scalar, U08, 36, "bits", 1.000, 0.000 errorNum = bits, U08, 36, [0:1] currentError = bits, U08, 36, [2:7] + boostTarget = scalar, U08, 37, "kPa", 1.000, 0.000 ; Computed output channels. See "megatuneExamples.ini" for all the ; pre-defined variables, search for "???" and you'll see them. @@ -1858,6 +1859,7 @@ menuDialog = main entry = flex, "%", int, "%d" entry = errorNum, "Error #", int, "%d" entry = currentError, "Error ID", int, "%d" + entry = boostTarget, "Boost Target",int, "%d" [LoggerDefinition] ; valid logger types: composite, tooth, trigger, csv diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index ae7559e..ec71dcf 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -59,6 +59,7 @@ void boostControl() { if(currentStatus.MAP < 100) { TIMSK1 &= ~(1 << OCIE1A); digitalWrite(pinBoost, LOW); return; } //Set duty to 0 and turn off timer compare boost_cl_target_boost = get3DTableValue(&boostTable, currentStatus.TPS, currentStatus.RPM) * 2; //Boost target table is in kpa and divided by 2 + currentStatus.boostTarget = boost_cl_target_boost >> 1; //Boost target is sent as a byte value to TS and so is divided by 2 if( (boostCounter & 31) == 1) { boostPID.SetTunings(configPage3.boostKP, configPage3.boostKI, configPage3.boostKD); } //This only needs to be run very infrequently, once every 32 calls to boostControl(). This is approx. once per second boostPID.Compute(); TIMSK1 |= (1 << OCIE1A); //Turn on the compare unit (ie turn on the interrupt) diff --git a/speeduino/comms.h b/speeduino/comms.h index c48590e..6e33e05 100644 --- a/speeduino/comms.h +++ b/speeduino/comms.h @@ -12,7 +12,7 @@ #define seqFuelPage 9 #define canbusPage 10//Config Page 10 -#define packetSize 37 +#define packetSize 38 byte currentPage = 1;//Not the same as the speeduino config page numbers boolean isMap = true; @@ -31,7 +31,7 @@ const char pageTitles[] PROGMEM //This is being stored in the avr flash instead "\nVVT Map\0"//No need to put a trailing null because it's the last string and the compliler does it for you. "\nPage 10 Config" }; - + void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable. void sendValues(int packetlength, byte portnum); void receiveValue(int offset, byte newValue); diff --git a/speeduino/comms.ino b/speeduino/comms.ino index ebc58c5..7e3a8a4 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -261,6 +261,7 @@ void sendValues(int packetlength, byte portNum) response[34] = currentStatus.flexCorrection; //Flex fuel correction (% above or below 100) response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel response[36] = getNextError(); + response[37] = currentStatus.boostTarget; //cli(); if (portNum == 0) { Serial.write(response, (size_t)packetlength); } diff --git a/speeduino/globals.h b/speeduino/globals.h index 477ee0d..fe166f5 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -200,6 +200,7 @@ struct statuses { unsigned int clutchEngagedRPM; bool flatShiftingHard; volatile byte startRevolutions; //A counter for how many revolutions have been completed since sync was achieved. + byte boostTarget; //Helpful bitwise operations: //Useful reference: http://playground.arduino.cc/Code/BitMath diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 0cf4eab..f8c6047 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -843,10 +843,9 @@ void loop() //----------------------------------------------------------------------------------------------------- readMAP(); - //TPS setting to be performed every 32 loops (any faster and it can upset the TPSdot sampling time) - if ((mainLoopCount & 31) == 1) + if ((mainLoopCount & 31) == 1) //Every 32 loops { - readTPS(); + readTPS(); //TPS reading to be performed every 32 loops (any faster and it can upset the TPSdot sampling time) //Check for launching/flat shift (clutch) can be done around here too previousClutchTrigger = clutchTrigger; @@ -889,12 +888,12 @@ void loop() //And check whether the tooth log buffer is ready if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } } - if( (mainLoopCount & 63) == 1) + if( (mainLoopCount & 63) == 1) //Every 64 loops { boostControl(); //Most boost tends to run at about 30Hz, so placing it here ensures a new target time is fetched frequently enough } //The IAT and CLT readings can be done less frequently. This still runs about 4 times per second - if ((mainLoopCount & 255) == 1) + if ((mainLoopCount & 255) == 1) //Every 256 loops { readCLT();