Moved WMI to VVT2 (#845)
* Moved WMI to VVT2 WMI to VVT2 channel and increased PWM resolution to 0.5% * Enable WMI and VVT at the same time * Move MWI to VVT2 options on INI file * Rename auxiliaries.ino to auxiliaries.cpp * Rename updates.ino to updates.cpp --------- Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
parent
7079b50aa1
commit
f7ee4c6415
|
@ -1305,7 +1305,7 @@ page = 11
|
|||
;Water methanol injection and vvt2 maps (Page 12)
|
||||
;--------------------------------------------------
|
||||
page = 12
|
||||
wmiTable = array, U08, 0,[8x8], "%", 1.0, 0.0, 0.0, {wmiLoadMax}, 0
|
||||
wmiTable = array, U08, 0,[8x8], "%",{wmiLoadRes}, 0.0, 0.0, {wmiLoadMax}, 1
|
||||
rpmBinsWMI = array, U08, 64,[ 8], "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
mapBinsWMI = array, U08, 72,[ 8], "kPa", 2.0, 0.0, 0.0, 511.0, 0
|
||||
vvt2Table = array, U08, 80,[8x8], "%", 0.5, 0.0, 0, 100, 1
|
||||
|
@ -1981,8 +1981,8 @@ menuDialog = main
|
|||
subMenu = vvtTbl, "VVT Target/Duty", 8, { vvtEnabled }
|
||||
subMenu = vvt2Tbl, "VVT2 Target/Duty", 8, { vvtEnabled && vvt2Enabled }
|
||||
subMenu = std_separator
|
||||
subMenu = wmiSettings, "WMI Control", { !vvtEnabled }
|
||||
subMenu = wmiTbl, "WMI duty cycle", 8, { !vvtEnabled && wmiEnabled && wmiMode > 1 }
|
||||
subMenu = wmiSettings, "WMI Control", { !vvt2Enabled }
|
||||
subMenu = wmiTbl, "WMI duty cycle", 8, { !vvt2Enabled && wmiEnabled && wmiMode > 1 }
|
||||
subMenu = std_separator
|
||||
subMenu = tacho, "Tacho Output"
|
||||
|
||||
|
@ -3303,7 +3303,8 @@ menuDialog = main
|
|||
field = "D", boostKD, { boostEnabled && boostMode && boostType == 1 }
|
||||
|
||||
dialog = vvt2, "Second VVT output"
|
||||
field = "VVT2 Control Enabled", vvt2Enabled
|
||||
field = "!VVT2 PWM is shared with WMI. The 2 cannot be used at the same time.", {}, {}, { wmiEnabled }
|
||||
field = "VVT2 Control Enabled", vvt2Enabled, { !wmiEnabled }
|
||||
field = "VVT2 output pin", vvt2Pin, { vvt2Enabled }
|
||||
field = "VVT2 Trigger edge", TrigEdgeThrd, { vvt2Enabled }
|
||||
field = "Increased duty direction",vvt2PWMdir, { vvt2Enabled && vvtMode == 2 }
|
||||
|
@ -3329,8 +3330,7 @@ menuDialog = main
|
|||
|
||||
dialog = vvtSettings, "VVT Control"
|
||||
topicHelp = "http://wiki.speeduino.com/en/configuration/VVT"
|
||||
field = "!VVT PWM is shared with WMI. The 2 cannot be used at the same time.", {}, {}, { wmiEnabled }
|
||||
field = "VVT Control Enabled", vvtEnabled, { !wmiEnabled }
|
||||
field = "VVT Control Enabled", vvtEnabled
|
||||
field = "VVT Minimum CLT", vvtMinClt, { vvtEnabled }
|
||||
field = "VVT Delay", vvtDelay, { vvtEnabled }
|
||||
field = "VVT Mode", vvtMode, { vvtEnabled }
|
||||
|
@ -3343,8 +3343,8 @@ menuDialog = main
|
|||
panel = vvt2, { vvtEnabled }
|
||||
|
||||
dialog = wmiSettings, "WMI Control"
|
||||
field = "!WMI PWM is shared with VVT. The 2 cannot be used at the same time.", {}, {}, { vvtEnabled }
|
||||
field = "WMI Control Enabled", wmiEnabled, { !vvtEnabled }
|
||||
field = "!WMI PWM is shared with VVT2. The 2 cannot be used at the same time.", {}, {}, { vvt2Enabled }
|
||||
field = "WMI Control Enabled", wmiEnabled, { !vvt2Enabled }
|
||||
field = "WMI Mode", wmiMode, { wmiEnabled }
|
||||
field = "WMI min TPS", wmiTPS, { wmiEnabled }
|
||||
field = "WMI min RPM", wmiRPM , { wmiEnabled }
|
||||
|
@ -3353,7 +3353,8 @@ menuDialog = main
|
|||
field = "WMI min IAT", wmiIAT, { wmiEnabled }
|
||||
field = "WMI offset", wmiOffset, { wmiEnabled && wmiMode == 3}
|
||||
field = ""
|
||||
field = "WMI PWM output pin", vvt1Pin, { wmiEnabled }
|
||||
field = "WMI PWM output pin", vvt2Pin, { wmiEnabled }
|
||||
field = "!WMI PWM frequency is the same as VVT. The 2 cannot be set independently.", {}, {}, { vvt2Enabled }
|
||||
field = "WMI PWM freq.", vvtFreq, { wmiEnabled }
|
||||
field = ""
|
||||
field = "WMI enabled output pin", wmiEnabledPin, { wmiEnabled }
|
||||
|
@ -5452,6 +5453,7 @@ cmdVSSratio6 = "E\x99\x06"
|
|||
idleResMax = { (iacAlgorithm == 5 || iacAlgorithm == 7) ? (iacStepHome-3) : 100.0 }
|
||||
|
||||
vvtLoadRes = { (vvtLoadSource == 0) ? 2.000 : 0.500 }
|
||||
wmiLoadRes = { (wmiMode >= 2) ? 0.5 : 1.0 }
|
||||
|
||||
fuelLoadRes = { ((algorithm == 0) || (algorithm == 2)) ? 2.000 : 0.500 }
|
||||
ignLoadRes = { ((ignAlgorithm == 0) || (ignAlgorithm == 2)) ? 2.000 : 0.500 }
|
||||
|
|
|
@ -511,6 +511,7 @@ void initialiseAuxPWM(void)
|
|||
vvtTimeHold = false;
|
||||
if (currentStatus.coolant >= (int)(configPage4.vvtMinClt - CALIBRATION_TEMPERATURE_OFFSET)) { vvtIsHot = true; } //Checks to see if coolant's already at operating temperature
|
||||
}
|
||||
|
||||
if( (configPage6.vvtEnabled == 0) && (configPage10.wmiEnabled >= 1) )
|
||||
{
|
||||
// config wmi pwm output to use vvt output
|
||||
|
@ -892,51 +893,79 @@ void vvtControl(void)
|
|||
}
|
||||
|
||||
//Set the PWM state based on the above lookups
|
||||
if( (currentStatus.vvt1Duty == 0) && (currentStatus.vvt2Duty == 0) )
|
||||
if( configPage10.wmiEnabled == 0 ) //Added possibility to use vvt and wmi at the same time
|
||||
{
|
||||
//Make sure solenoid is off (0% duty)
|
||||
VVT1_PIN_OFF();
|
||||
VVT2_PIN_OFF();
|
||||
vvt1_pwm_state = false;
|
||||
vvt1_max_pwm = false;
|
||||
vvt2_pwm_state = false;
|
||||
vvt2_max_pwm = false;
|
||||
DISABLE_VVT_TIMER();
|
||||
}
|
||||
else if( (currentStatus.vvt1Duty >= 200) && (currentStatus.vvt2Duty >= 200) )
|
||||
{
|
||||
//Make sure solenoid is on (100% duty)
|
||||
VVT1_PIN_ON();
|
||||
VVT2_PIN_ON();
|
||||
vvt1_pwm_state = true;
|
||||
vvt1_max_pwm = true;
|
||||
vvt2_pwm_state = true;
|
||||
vvt2_max_pwm = true;
|
||||
DISABLE_VVT_TIMER();
|
||||
if( (currentStatus.vvt1Duty == 0) && (currentStatus.vvt2Duty == 0) )
|
||||
{
|
||||
//Make sure solenoid is off (0% duty)
|
||||
VVT1_PIN_OFF();
|
||||
VVT2_PIN_OFF();
|
||||
vvt1_pwm_state = false;
|
||||
vvt1_max_pwm = false;
|
||||
vvt2_pwm_state = false;
|
||||
vvt2_max_pwm = false;
|
||||
DISABLE_VVT_TIMER();
|
||||
}
|
||||
else if( (currentStatus.vvt1Duty >= 200) && (currentStatus.vvt2Duty >= 200) )
|
||||
{
|
||||
//Make sure solenoid is on (100% duty)
|
||||
VVT1_PIN_ON();
|
||||
VVT2_PIN_ON();
|
||||
vvt1_pwm_state = true;
|
||||
vvt1_max_pwm = true;
|
||||
vvt2_pwm_state = true;
|
||||
vvt2_max_pwm = true;
|
||||
DISABLE_VVT_TIMER();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Duty cycle is between 0 and 100. Make sure the timer is enabled
|
||||
ENABLE_VVT_TIMER();
|
||||
if(currentStatus.vvt1Duty < 200) { vvt1_max_pwm = false; }
|
||||
if(currentStatus.vvt2Duty < 200) { vvt2_max_pwm = false; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Duty cycle is between 0 and 100. Make sure the timer is enabled
|
||||
ENABLE_VVT_TIMER();
|
||||
if(currentStatus.vvt1Duty < 200) { vvt1_max_pwm = false; }
|
||||
if(currentStatus.vvt2Duty < 200) { vvt2_max_pwm = false; }
|
||||
if( currentStatus.vvt1Duty == 0 )
|
||||
{
|
||||
//Make sure solenoid is off (0% duty)
|
||||
VVT1_PIN_OFF();
|
||||
vvt1_pwm_state = false;
|
||||
vvt1_max_pwm = false;
|
||||
}
|
||||
else if( currentStatus.vvt1Duty >= 200 )
|
||||
{
|
||||
//Make sure solenoid is on (100% duty)
|
||||
VVT1_PIN_ON();
|
||||
vvt1_pwm_state = true;
|
||||
vvt1_max_pwm = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Duty cycle is between 0 and 100. Make sure the timer is enabled
|
||||
ENABLE_VVT_TIMER();
|
||||
if(currentStatus.vvt1Duty < 200) { vvt1_max_pwm = false; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable timer channel
|
||||
DISABLE_VVT_TIMER();
|
||||
if (configPage10.wmiEnabled == 0)
|
||||
{
|
||||
// Disable timer channel
|
||||
DISABLE_VVT_TIMER();
|
||||
currentStatus.vvt2Duty = 0;
|
||||
vvt2_pwm_value = 0;
|
||||
vvt2_pwm_state = false;
|
||||
vvt2_max_pwm = false;
|
||||
}
|
||||
currentStatus.vvt1Duty = 0;
|
||||
vvt1_pwm_value = 0;
|
||||
currentStatus.vvt2Duty = 0;
|
||||
vvt2_pwm_value = 0;
|
||||
vvt1_pwm_state = false;
|
||||
vvt1_max_pwm = false;
|
||||
vvt2_pwm_state = false;
|
||||
vvt2_max_pwm = false;
|
||||
vvtTimeHold=false;
|
||||
vvtTimeHold = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1001,23 +1030,23 @@ void wmiControl(void)
|
|||
{
|
||||
int wmiPW = 0;
|
||||
|
||||
// wmi can only work when vvt is disabled
|
||||
if( (configPage6.vvtEnabled == 0) && (configPage10.wmiEnabled >= 1) )
|
||||
// wmi can only work when vvt2 is disabled
|
||||
if( (configPage10.vvt2Enabled == 0) && (configPage10.wmiEnabled >= 1) )
|
||||
{
|
||||
if( WMI_TANK_IS_EMPTY() )
|
||||
{
|
||||
BIT_CLEAR(currentStatus.status4, BIT_STATUS4_WMI_EMPTY);
|
||||
BIT_CLEAR(currentStatus.status4, BIT_STATUS4_WMI_EMPTY);
|
||||
if( (currentStatus.TPS >= configPage10.wmiTPS) && (currentStatus.RPMdiv100 >= configPage10.wmiRPM) && ( (currentStatus.MAP / 2) >= configPage10.wmiMAP) && ( (currentStatus.IAT + CALIBRATION_TEMPERATURE_OFFSET) >= configPage10.wmiIAT) )
|
||||
{
|
||||
switch(configPage10.wmiMode)
|
||||
{
|
||||
case WMI_MODE_SIMPLE:
|
||||
// Simple mode - Output is turned on when preset boost level is reached
|
||||
wmiPW = 100;
|
||||
wmiPW = 200;
|
||||
break;
|
||||
case WMI_MODE_PROPORTIONAL:
|
||||
// Proportional Mode - Output PWM is proportionally controlled between two MAP values - MAP Value 1 = PWM:0% / MAP Value 2 = PWM:100%
|
||||
wmiPW = map(currentStatus.MAP/2, configPage10.wmiMAP, configPage10.wmiMAP2, 0, 100);
|
||||
wmiPW = map(currentStatus.MAP/2, configPage10.wmiMAP, configPage10.wmiMAP2, 0, 200);
|
||||
break;
|
||||
case WMI_MODE_OPENLOOP:
|
||||
// Mapped open loop - Output PWM follows 2D map value (RPM vs MAP) Cell value contains desired PWM% [range 0-100%]
|
||||
|
@ -1025,39 +1054,44 @@ void wmiControl(void)
|
|||
break;
|
||||
case WMI_MODE_CLOSEDLOOP:
|
||||
// Mapped closed loop - Output PWM follows injector duty cycle with 2D correction map applied (RPM vs MAP). Cell value contains correction value% [nom 100%]
|
||||
wmiPW = max(0, ((int)currentStatus.PW1 + configPage10.wmiOffset)) * get3DTableValue(&wmiTable, currentStatus.MAP, currentStatus.RPM) / 100;
|
||||
wmiPW = max(0, ((int)currentStatus.PW1 + configPage10.wmiOffset)) * get3DTableValue(&wmiTable, currentStatus.MAP, currentStatus.RPM) / 200;
|
||||
break;
|
||||
default:
|
||||
// Wrong mode
|
||||
wmiPW = 0;
|
||||
break;
|
||||
}
|
||||
if (wmiPW > 100) { wmiPW = 100; } //without this the duty can get beyond 100%
|
||||
if (wmiPW > 200) { wmiPW = 200; } //without this the duty can get beyond 100%
|
||||
}
|
||||
}
|
||||
else { BIT_SET(currentStatus.status4, BIT_STATUS4_WMI_EMPTY); }
|
||||
|
||||
currentStatus.wmiPW = wmiPW;
|
||||
vvt1_pwm_value = percentage(currentStatus.wmiPW, vvt_pwm_max_count);
|
||||
vvt2_pwm_value = halfPercentage(currentStatus.wmiPW, vvt_pwm_max_count);
|
||||
|
||||
if(wmiPW == 0)
|
||||
{
|
||||
// Make sure water pump is off
|
||||
VVT1_PIN_LOW();
|
||||
DISABLE_VVT_TIMER();
|
||||
VVT2_PIN_LOW();
|
||||
vvt2_pwm_state = false;
|
||||
vvt2_max_pwm = false;
|
||||
if( configPage6.vvtEnabled == 0 ) { DISABLE_VVT_TIMER(); }
|
||||
digitalWrite(pinWMIEnabled, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(pinWMIEnabled, HIGH);
|
||||
if (wmiPW >= 100)
|
||||
if (wmiPW >= 200)
|
||||
{
|
||||
// Make sure water pump is on (100% duty)
|
||||
VVT1_PIN_HIGH();
|
||||
DISABLE_VVT_TIMER();
|
||||
VVT2_PIN_HIGH();
|
||||
vvt2_pwm_state = true;
|
||||
vvt2_max_pwm = true;
|
||||
if( configPage6.vvtEnabled == 0 ) { DISABLE_VVT_TIMER(); }
|
||||
}
|
||||
else
|
||||
{
|
||||
vvt2_max_pwm = false;
|
||||
ENABLE_VVT_TIMER();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "storage.h"
|
||||
#include "sensors.h"
|
||||
#include "updates.h"
|
||||
#include "pages.h"
|
||||
#include EEPROM_LIB_H //This is defined in the board .h files
|
||||
|
||||
void doUpdates(void)
|
||||
|
@ -727,6 +728,8 @@ void doUpdates(void)
|
|||
if(readEEPROMVersion() == 22)
|
||||
{
|
||||
//202311-dev
|
||||
|
||||
if( configPage10.wmiMode >= WMI_MODE_OPENLOOP ) { multiplyTableValue(wmiMapPage, 2); } //Increased PWM resolution from 0-100 to 0-200 to match VVT
|
||||
|
||||
//Default values for pulsed hw test modes
|
||||
configPage13.hwTestInjDuration = 8;
|
||||
|
@ -789,3 +792,21 @@ void divideTableLoad(void *pTable, table_type_t key, uint8_t divisor)
|
|||
++y_it;
|
||||
}
|
||||
}
|
||||
|
||||
void multiplyTableValue(uint8_t pageNum, uint8_t multiplier)
|
||||
{
|
||||
uint16_t count = getPageSize(pageNum);
|
||||
for (uint16_t i = 0; i < count; i++)
|
||||
{
|
||||
setPageValue(pageNum, i, (uint8_t)(getPageValue(pageNum, i) * multiplier));
|
||||
}
|
||||
}
|
||||
|
||||
void divideTableValue(uint8_t pageNum, uint8_t divisor)
|
||||
{
|
||||
uint16_t count = getPageSize(pageNum);
|
||||
for (uint16_t i = 0; i < count; i++)
|
||||
{
|
||||
setPageValue(pageNum, i, (uint8_t)(getPageValue(pageNum, i) / divisor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,5 +6,7 @@
|
|||
void doUpdates(void);
|
||||
void multiplyTableLoad(void *pTable, table_type_t key, uint8_t multiplier); //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 divideTableLoad(void *pTable, table_type_t key, uint8_t divisor); //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.
|
||||
void multiplyTableValue(uint8_t pageNum, uint8_t multiplier); //Added to update the table values. Multiplies the value by the multiplier
|
||||
void divideTableValue(uint8_t pageNum, uint8_t divisor); //Added to update the table values. Divide the value by divisor
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue