Further memory work on the sequential tables
This commit is contained in:
parent
8b95fe891a
commit
940c3a5be7
42
comms.ino
42
comms.ino
|
@ -286,13 +286,13 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
if (valueOffset < 272)
|
||||
{
|
||||
//X Axis
|
||||
fuelTable.axisX[(valueOffset - 256)] = ((int)(newValue) * 100); //The RPM values sent by megasquirt are divided by 100, need to multiple it back by 100 to make it correct
|
||||
fuelTable.axisX[(valueOffset - 256)] = ((int)(newValue) * TABLE_RPM_MULTIPLIER); //The RPM values sent by megasquirt are divided by 100, need to multiple it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
}
|
||||
else
|
||||
{
|
||||
//Y Axis
|
||||
valueOffset = 15 - (valueOffset - 272); //Need to do a translation to flip the order (Due to us using (0,0) in the top left rather than bottom right
|
||||
fuelTable.axisY[valueOffset] = (int)(newValue);
|
||||
fuelTable.axisY[valueOffset] = (int)(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -319,13 +319,13 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
if (valueOffset < 272)
|
||||
{
|
||||
//X Axis
|
||||
ignitionTable.axisX[(valueOffset - 256)] = (int)(newValue) * int(100); //The RPM values sent by megasquirt are divided by 100, need to multiple it back by 100 to make it correct
|
||||
ignitionTable.axisX[(valueOffset - 256)] = (int)(newValue) * TABLE_RPM_MULTIPLIER; //The RPM values sent by megasquirt are divided by 100, need to multiple it back by 100 to make it correct
|
||||
}
|
||||
else
|
||||
{
|
||||
//Y Axis
|
||||
valueOffset = 15 - (valueOffset - 272); //Need to do a translation to flip the order
|
||||
ignitionTable.axisY[valueOffset] = (int)(newValue);
|
||||
ignitionTable.axisY[valueOffset] = (int)(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
//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; //Need to subtract 80 because the map and bins (Which make up 80 bytes) aren't part of the config pages
|
||||
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -351,13 +351,13 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
if (valueOffset < 272)
|
||||
{
|
||||
//X Axis
|
||||
afrTable.axisX[(valueOffset - 256)] = int(newValue) * int(100); //The RPM values sent by megasquirt are divided by 100, need to multiply it back by 100 to make it correct
|
||||
afrTable.axisX[(valueOffset - 256)] = int(newValue) * TABLE_RPM_MULTIPLIER; //The RPM values sent by megasquirt are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
}
|
||||
else
|
||||
{
|
||||
//Y Axis
|
||||
valueOffset = 15 - (valueOffset - 272); //Need to do a translation to flip the order
|
||||
afrTable.axisY[valueOffset] = int(newValue);
|
||||
afrTable.axisY[valueOffset] = int(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
|
||||
}
|
||||
return;
|
||||
|
@ -368,7 +368,7 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
//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; //Need to subtract 80 because the map and bins (Which make up 80 bytes) aren't part of the config pages
|
||||
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -388,12 +388,12 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
}
|
||||
else if (valueOffset < 72) //New value is on the X (RPM) axis of the boost table
|
||||
{
|
||||
boostTable.axisX[(valueOffset - 64)] = int(newValue) * int(100); //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct
|
||||
boostTable.axisX[(valueOffset - 64)] = int(newValue) * TABLE_RPM_MULTIPLIER; //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
return;
|
||||
}
|
||||
else if (valueOffset < 80) //New value is on the Y (TPS) axis of the boost table
|
||||
{
|
||||
boostTable.axisY[(7 - (valueOffset - 72))] = int(newValue);
|
||||
boostTable.axisY[(7 - (valueOffset - 72))] = int(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
return;
|
||||
}
|
||||
else if (valueOffset < 144) //New value is part of the vvt map
|
||||
|
@ -405,15 +405,33 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
else if (valueOffset < 152) //New value is on the X (RPM) axis of the vvt table
|
||||
{
|
||||
valueOffset = valueOffset - 144;
|
||||
vvtTable.axisX[valueOffset] = int(newValue) * int(100); //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct
|
||||
vvtTable.axisX[valueOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
return;
|
||||
}
|
||||
else //New value is on the Y (Load) axis of the vvt table
|
||||
{
|
||||
valueOffset = valueOffset - 152;
|
||||
vvtTable.axisY[(7 - valueOffset)] = int(newValue);
|
||||
vvtTable.axisY[(7 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
return;
|
||||
}
|
||||
case seqFuelPage:
|
||||
if (valueOffset < 36) { trim1Table.values[5 - valueOffset / 6][valueOffset % 6] = newValue; } //Trim1 values
|
||||
else if (valueOffset < 42) { trim1Table.axisX[(valueOffset - 36)] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the trim1 table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
else if (valueOffset < 48) { trim1Table.axisY[(5 - (valueOffset - 42))] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (TPS) axis of the boost table
|
||||
//Trim table 2
|
||||
else if (valueOffset < 84) { valueOffset = valueOffset - 48; trim2Table.values[5 - valueOffset / 6][valueOffset % 6] = newValue; } //New value is part of the trim2 map
|
||||
else if (valueOffset < 90) { valueOffset = valueOffset - 84; trim2Table.axisX[valueOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
else if (valueOffset < 96) { valueOffset = valueOffset - 90; trim2Table.axisY[(5 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
|
||||
//Trim table 3
|
||||
else if (valueOffset < 132) { valueOffset = valueOffset - 96; trim3Table.values[5 - valueOffset / 6][valueOffset % 6] = newValue; } //New value is part of the trim2 map
|
||||
else if (valueOffset < 138) { valueOffset = valueOffset - 132; trim3Table.axisX[valueOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
else if (valueOffset < 144) { valueOffset = valueOffset - 138; trim3Table.axisY[(5 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
|
||||
//Trim table 4
|
||||
else if (valueOffset < 180) { valueOffset = valueOffset - 144; trim4Table.values[5 - valueOffset / 6][valueOffset % 6] = newValue; } //New value is part of the trim2 map
|
||||
else if (valueOffset < 186) { valueOffset = valueOffset - 180; trim4Table.axisX[valueOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. //The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
|
||||
else if (valueOffset < 192) { valueOffset = valueOffset - 186; trim4Table.axisY[(5 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -146,6 +146,9 @@ struct statuses {
|
|||
volatile byte spark;
|
||||
byte engine;
|
||||
unsigned int PW; //In uS
|
||||
unsigned int PW2; //In uS
|
||||
unsigned int PW3; //In uS
|
||||
unsigned int PW4; //In uS
|
||||
volatile byte runSecs; //Counter of seconds since cranking commenced (overflows at 255 obviously)
|
||||
volatile byte secl; //Continous
|
||||
volatile unsigned int loopsPerSecond;
|
||||
|
@ -357,7 +360,8 @@ struct config3 {
|
|||
byte boostKD;
|
||||
|
||||
byte lnchPullRes : 2;
|
||||
byte unused60 : 6;
|
||||
bool fuelTrimEnabled : 1;
|
||||
byte unused60 : 5;
|
||||
byte unused61;
|
||||
byte unused62;
|
||||
byte unused63;
|
||||
|
|
|
@ -382,7 +382,8 @@ page = 6
|
|||
boostKD = scalar, U08, 59, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
||||
|
||||
lnchPullRes = bits, U08, 60 [0:1], "Float" , "Pullup", "INVALID", "INVALID"
|
||||
unused6-60 = bits, U08, 60, [2:7], "ONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
fuelTrimEnabled= bits, U08, 60, [2:2], "No", "Yes"
|
||||
unused6-60 = bits, U08, 60, [3:7], "ONE", "INVALID"
|
||||
unused6-61 = scalar, U08, 61, "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
unused6-62 = scalar, U08, 62, "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
unused6-63 = scalar, U08, 63, "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
|
@ -423,7 +424,7 @@ page = 7
|
|||
|
||||
; Begin fan control vairables
|
||||
fanInv = bits, U08, 56, [0:0], "No", "Yes"
|
||||
fanEnable = bits, U08, 56, [1:2], "Off", "On/Off", "PWM", "INVALID"
|
||||
fanEnable = bits, U08, 56, [1:2], "Off", "On/Off", "INVALID", "INVALID"
|
||||
unused7-55b = bits, U08, 56, [3:3], "No", "Yes"
|
||||
unused7-55c = bits, U08, 56, [4:4], "No", "Yes"
|
||||
unused7-55d = bits, U08, 56, [5:5], "No", "Yes"
|
||||
|
@ -695,6 +696,9 @@ menuDialog = main
|
|||
sparkMode = "Wasted Spark: Ignition outputs are on the channels <= half the number of cylinders. Eg 4 cylinder outputs on IGN1 and IGN2.\nSingle Channel: All ignition pulses are output on IGN1.\nWasted COP: Ignition pulses are output on all ignition channels up to the number of cylinders. Eg 4 cylinder outputs on all ignition channels. No valid for >4 cylinders"
|
||||
IgInv = "Whether the spark fires when the ignition sign goes high or goes low. Most ignition systems 'Going Low' but please verify this as damage to coils can result from the incorrect selection"
|
||||
|
||||
fanInv = ""
|
||||
fanHyster = "The number of degrees of hysteresis to be used in controlling the fan. Recommended values are between 2 and 5"
|
||||
|
||||
taeTime = "The duration of the acceleration enrichment"
|
||||
|
||||
iacChannels = "The number of output channels used for PWM valves. Select 1 for 2-wire valves or 2 for 3-wire valves."
|
||||
|
@ -846,7 +850,7 @@ menuDialog = main
|
|||
|
||||
dialog = fanSettings,"Fan Settings",7
|
||||
field = "Fan Mode", fanEnable
|
||||
field = "Fan Output Inverted (see F1)", fanInv
|
||||
field = "Fan Output Inverted", fanInv
|
||||
field = "Fan temperature SP", fanSP
|
||||
field = "Fan hysteresis", fanHyster
|
||||
|
||||
|
|
|
@ -1076,6 +1076,12 @@ void loop()
|
|||
injector2StartAngle += 360;
|
||||
injector3StartAngle += 360;
|
||||
injector4StartAngle += 360;
|
||||
|
||||
if(configPage3.fuelTrimEnabled)
|
||||
{
|
||||
|
||||
//currentStatus.PW = currentStatus.PW * (100 + get3DTableValue(&trim1Table, currentStatus.MAP, currentStatus.RPM) ); //Perform lookup into fuel map for RPM vs MAP value
|
||||
}
|
||||
}
|
||||
break;
|
||||
//5 cylinders
|
||||
|
|
3
table.h
3
table.h
|
@ -5,6 +5,9 @@ This file is used for everything related to maps/tables including their definiti
|
|||
#define TABLE_H
|
||||
#include <Arduino.h>
|
||||
|
||||
#define TABLE_RPM_MULTIPLIER 100
|
||||
#define TABLE_LOAD_MULTIPLIER 1
|
||||
|
||||
/*
|
||||
The 2D table can contain either 8-bit (byte) or 16-bit (int) values
|
||||
The valueSize variable should be set to either 8 or 16 to indicate this BEFORE the table is used
|
||||
|
|
Loading…
Reference in New Issue