Fixes to 202201 update routine
This commit is contained in:
parent
23163bc341
commit
bd9d59a145
|
@ -468,8 +468,8 @@ void vvtControl()
|
|||
if( (configPage6.vvtMode == VVT_MODE_OPEN_LOOP) || (configPage6.vvtMode == VVT_MODE_ONOFF) )
|
||||
{
|
||||
//Lookup VVT duty based on either MAP or TPS
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt1Duty = get3DTableValue(&vvtTable, currentStatus.TPS, currentStatus.RPM); }
|
||||
else { currentStatus.vvt1Duty = get3DTableValue(&vvtTable, (currentStatus.MAP / 2), currentStatus.RPM); }
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt1Duty = get3DTableValue(&vvtTable, (currentStatus.TPS * 2), currentStatus.RPM); }
|
||||
else { currentStatus.vvt1Duty = get3DTableValue(&vvtTable, (currentStatus.MAP), currentStatus.RPM); }
|
||||
|
||||
//VVT table can be used for controlling on/off switching. If this is turned on, then disregard any interpolation or non-binary values
|
||||
if( (configPage6.vvtMode == VVT_MODE_ONOFF) && (currentStatus.vvt1Duty < 200) ) { currentStatus.vvt1Duty = 0; }
|
||||
|
@ -479,8 +479,8 @@ void vvtControl()
|
|||
if (configPage10.vvt2Enabled == 1) // same for VVT2 if it's enabled
|
||||
{
|
||||
//Lookup VVT duty based on either MAP or TPS
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt2Duty = get3DTableValue(&vvt2Table, currentStatus.TPS, currentStatus.RPM); }
|
||||
else { currentStatus.vvt2Duty = get3DTableValue(&vvt2Table, (currentStatus.MAP / 2), currentStatus.RPM); }
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt2Duty = get3DTableValue(&vvt2Table, (currentStatus.TPS * 2), currentStatus.RPM); }
|
||||
else { currentStatus.vvt2Duty = get3DTableValue(&vvt2Table, (currentStatus.MAP), currentStatus.RPM); }
|
||||
|
||||
//VVT table can be used for controlling on/off switching. If this is turned on, then disregard any interpolation or non-binary values
|
||||
if( (configPage6.vvtMode == VVT_MODE_ONOFF) && (currentStatus.vvt2Duty < 200) ) { currentStatus.vvt2Duty = 0; }
|
||||
|
@ -492,8 +492,8 @@ void vvtControl()
|
|||
else if( (configPage6.vvtMode == VVT_MODE_CLOSED_LOOP) )
|
||||
{
|
||||
//Lookup VVT duty based on either MAP or TPS
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt1TargetAngle = get3DTableValue(&vvtTable, currentStatus.TPS, currentStatus.RPM); }
|
||||
else { currentStatus.vvt1TargetAngle = get3DTableValue(&vvtTable, (currentStatus.MAP / 2), currentStatus.RPM); }
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt1TargetAngle = get3DTableValue(&vvtTable, (currentStatus.TPS * 2), currentStatus.RPM); }
|
||||
else { currentStatus.vvt1TargetAngle = get3DTableValue(&vvtTable, currentStatus.MAP, currentStatus.RPM); }
|
||||
|
||||
if( (vvtCounter & 31) == 1) { vvtPID.SetTunings(configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD); //This only needs to be run very infrequently, once every 32 calls to vvtControl(). This is approx. once per second
|
||||
vvtPID.SetControllerDirection(configPage6.vvtPWMdir); }
|
||||
|
@ -531,8 +531,8 @@ void vvtControl()
|
|||
|
||||
if (configPage10.vvt2Enabled == 1) // same for VVT2 if it's enabled
|
||||
{
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, currentStatus.TPS, currentStatus.RPM); }
|
||||
else { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, (currentStatus.MAP / 2), currentStatus.RPM); }
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS) { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, (currentStatus.TPS * 2), currentStatus.RPM); }
|
||||
else { currentStatus.vvt2TargetAngle = get3DTableValue(&vvt2Table, currentStatus.MAP, currentStatus.RPM); }
|
||||
|
||||
if( vvtCounter == 30) { vvt2PID.SetTunings(configPage10.vvtCLKP, configPage10.vvtCLKI, configPage10.vvtCLKD); //This only needs to be run very infrequently, once every 32 calls to vvtControl(). This is approx. once per second
|
||||
vvt2PID.SetControllerDirection(configPage4.vvt2PWMdir); }
|
||||
|
|
|
@ -304,7 +304,7 @@ uint16_t correctionAccel()
|
|||
TPS_change = (currentStatus.TPS - TPSlast);
|
||||
//TPS_rateOfChange = ldiv(1000000, (TPS_time - TPSlast_time)).quot * TPS_change; //This is the % per second that the TPS has moved
|
||||
TPS_rateOfChange = TPS_READ_FREQUENCY * TPS_change; //This is the % per second that the TPS has moved
|
||||
if(TPS_rateOfChange >= 0) { currentStatus.tpsDOT = TPS_rateOfChange / 20; } //The TAE bins are divided by 10 in order to allow them to be stored in a byte. Faster as this than divu10
|
||||
if(TPS_rateOfChange >= 0) { currentStatus.tpsDOT = TPS_rateOfChange / 20; } //The TAE bins are divided by 10 in order to allow them to be stored in a byte and then by 2 due to TPS being 0.5% resolution (0-200)
|
||||
else { currentStatus.tpsDOT = 0; } //Prevent overflow as tpsDOT is signed
|
||||
}
|
||||
|
||||
|
|
|
@ -436,8 +436,8 @@ extern struct table3d16RpmLoad ignitionTable2; //16x16 ignition map
|
|||
extern struct table3d16RpmLoad afrTable; //16x16 afr target map
|
||||
extern struct table3d8RpmLoad stagingTable; //8x8 fuel staging table
|
||||
extern struct table3d8RpmTps boostTable; //8x8 boost map
|
||||
extern struct table3d8RpmTps vvtTable; //8x8 vvt map
|
||||
extern struct table3d8RpmTps vvt2Table; //8x8 vvt map
|
||||
extern struct table3d8RpmLoad vvtTable; //8x8 vvt map
|
||||
extern struct table3d8RpmLoad vvt2Table; //8x8 vvt map
|
||||
extern struct table3d8RpmLoad wmiTable; //8x8 wmi map
|
||||
extern struct table3d6RpmLoad trim1Table; //6x6 Fuel trim 1 map
|
||||
extern struct table3d6RpmLoad trim2Table; //6x6 Fuel trim 2 map
|
||||
|
|
|
@ -15,8 +15,8 @@ struct table3d16RpmLoad ignitionTable2; ///< 16x16 ignition map
|
|||
struct table3d16RpmLoad afrTable; ///< 16x16 afr target map
|
||||
struct table3d8RpmLoad stagingTable; ///< 8x8 fuel staging table
|
||||
struct table3d8RpmTps boostTable; ///< 8x8 boost map
|
||||
struct table3d8RpmTps vvtTable; ///< 8x8 vvt map
|
||||
struct table3d8RpmTps vvt2Table; ///< 8x8 vvt2 map
|
||||
struct table3d8RpmLoad vvtTable; ///< 8x8 vvt map
|
||||
struct table3d8RpmLoad vvt2Table; ///< 8x8 vvt2 map
|
||||
struct table3d8RpmLoad wmiTable; ///< 8x8 wmi map
|
||||
struct table3d6RpmLoad trim1Table; ///< 6x6 Fuel trim 1 map
|
||||
struct table3d6RpmLoad trim2Table; ///< 6x6 Fuel trim 2 map
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#ifndef UPDATES_H
|
||||
#define UPDATES_H
|
||||
|
||||
#include "table3d.h"
|
||||
|
||||
void doUpdates();
|
||||
void updateTableY(const void*, table_type_t); //Added 202201 - to update the table Y axis as TPS now works at 0.5% increments
|
||||
void multiplyTableLoadTableLoad(const void*, table_type_t, uint8_t); //Added 202201 - to update the table Y axis as TPS now works at 0.5% increments. Multiplies the load axis values by 4 (most tables) or by 2 (VVT table)
|
||||
void divideTableLoadTableLoad(const void*, table_type_t, uint8_t); //Added 202201 - to update the table Y axis as TPS now works at 0.5% increments. This should only be needed by the VVT tables when using MAP as load.
|
||||
|
||||
#endif
|
|
@ -524,7 +524,7 @@ void doUpdates()
|
|||
configPage2.fanEnable = configPage6.fanUnused; // PWM Fan mode added, but take the previous setting of Fan in use.
|
||||
|
||||
//TPS resolution increased to 0.5%
|
||||
configPage2.taeThresh *= 2;
|
||||
//configPage2.taeThresh *= 2;
|
||||
configPage2.idleAdvTPS *= 2;
|
||||
configPage2.iacTPSlimit *= 2;
|
||||
configPage4.floodClear *= 2;
|
||||
|
@ -539,16 +539,16 @@ void doUpdates()
|
|||
// Each table Y axis need to be updated as well if TPS is the source
|
||||
if(configPage2.fuelAlgorithm == LOAD_SOURCE_TPS)
|
||||
{
|
||||
updateTableY(&fuelTable, fuelTable.type_key);
|
||||
updateTableY(&afrTable, afrTable.type_key);
|
||||
updateTableY(&trim1Table, trim1Table.type_key);
|
||||
updateTableY(&trim2Table, trim2Table.type_key);
|
||||
updateTableY(&trim3Table, trim3Table.type_key);
|
||||
updateTableY(&trim4Table, trim4Table.type_key);
|
||||
updateTableY(&trim5Table, trim5Table.type_key);
|
||||
updateTableY(&trim6Table, trim6Table.type_key);
|
||||
updateTableY(&trim7Table, trim7Table.type_key);
|
||||
updateTableY(&trim8Table, trim8Table.type_key);
|
||||
multiplyTableLoad(&fuelTable, fuelTable.type_key, 4);
|
||||
multiplyTableLoad(&afrTable, afrTable.type_key, 4);
|
||||
multiplyTableLoad(&trim1Table, trim1Table.type_key, 4);
|
||||
multiplyTableLoad(&trim2Table, trim2Table.type_key, 4);
|
||||
multiplyTableLoad(&trim3Table, trim3Table.type_key, 4);
|
||||
multiplyTableLoad(&trim4Table, trim4Table.type_key, 4);
|
||||
multiplyTableLoad(&trim5Table, trim5Table.type_key, 4);
|
||||
multiplyTableLoad(&trim6Table, trim6Table.type_key, 4);
|
||||
multiplyTableLoad(&trim7Table, trim7Table.type_key, 4);
|
||||
multiplyTableLoad(&trim8Table, trim8Table.type_key, 4);
|
||||
if(configPage4.sparkMode == IGN_MODE_ROTARY)
|
||||
{
|
||||
for(uint8_t x = 0; x < 8; x++)
|
||||
|
@ -557,16 +557,24 @@ void doUpdates()
|
|||
}
|
||||
}
|
||||
}
|
||||
if(configPage2.ignAlgorithm == LOAD_SOURCE_TPS) { updateTableY(&ignitionTable, ignitionTable.type_key); }
|
||||
if(configPage10.fuel2Algorithm == LOAD_SOURCE_TPS) { updateTableY(&fuelTable2, fuelTable2.type_key); }
|
||||
if(configPage10.spark2Algorithm == LOAD_SOURCE_TPS) { updateTableY(&ignitionTable2, ignitionTable2.type_key); }
|
||||
updateTableY(&boostTable, boostTable.type_key);
|
||||
if(configPage2.ignAlgorithm == LOAD_SOURCE_TPS) { multiplyTableLoad(&ignitionTable, ignitionTable.type_key, 4); }
|
||||
if(configPage10.fuel2Algorithm == LOAD_SOURCE_TPS) { multiplyTableLoad(&fuelTable2, fuelTable2.type_key, 4); }
|
||||
if(configPage10.spark2Algorithm == LOAD_SOURCE_TPS) { multiplyTableLoad(&ignitionTable2, ignitionTable2.type_key, 4); }
|
||||
multiplyTableLoad(&boostTable, boostTable.type_key, 2); // Boost table used 1.0 previously, so it only needs a 2x multiplier
|
||||
|
||||
if(configPage6.vvtLoadSource == VVT_LOAD_TPS)
|
||||
{
|
||||
updateTableY(&vvtTable, vvtTable.type_key);
|
||||
updateTableY(&vvt2Table, vvt2Table.type_key);
|
||||
//NOTE: The VVT tables all had 1.0 as the multiply value rather than 2.0 used in all other tables. For this reason they only need to be multiplied by 2 when updating
|
||||
multiplyTableLoad(&vvtTable, vvtTable.type_key, 2);
|
||||
multiplyTableLoad(&vvt2Table, vvt2Table.type_key, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
//NOTE: The VVT tables all had 1.0 as the multiply value rather than 2.0 used in all other tables. For this reason they need to be divided by 2 when updating
|
||||
divideTableLoad(&vvtTable, vvtTable.type_key, 2);
|
||||
divideTableLoad(&vvt2Table, vvt2Table.type_key, 2);
|
||||
}
|
||||
|
||||
|
||||
configPage4.vvtDelay = 0;
|
||||
configPage4.vvtMinClt = 0;
|
||||
|
@ -598,12 +606,22 @@ void doUpdates()
|
|||
if( readEEPROMVersion() > CURRENT_DATA_VERSION ) { storeEEPROMVersion(CURRENT_DATA_VERSION); }
|
||||
}
|
||||
|
||||
void updateTableY(const void *pTable, table_type_t key)
|
||||
void multiplyTableLoad(const void *pTable, table_type_t key, uint8_t multiplier)
|
||||
{
|
||||
auto y_it = y_begin(pTable, key);
|
||||
while(!y_it.at_end())
|
||||
{
|
||||
*y_it = (byte)*y_it * 4; //Previous TS scale was 2.0, now is 0.5, 4x increase
|
||||
*y_it = (byte)*y_it * multiplier;
|
||||
++y_it;
|
||||
}
|
||||
}
|
||||
|
||||
void divideTableLoad(const void *pTable, table_type_t key, uint8_t divisor)
|
||||
{
|
||||
auto y_it = y_begin(pTable, key);
|
||||
while(!y_it.at_end())
|
||||
{
|
||||
*y_it = (byte)*y_it / divisor; //Previous TS scale was 2.0, now is 0.5, 4x increase
|
||||
++y_it;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue