Add boost target to log

This commit is contained in:
Josh Stewart 2017-02-12 14:31:37 +13:00
parent bec06bca3a
commit 667e80dc26
6 changed files with 12 additions and 8 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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); }

View File

@ -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

View File

@ -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();