VSS from Aux input (#710)
Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
parent
da57378684
commit
a93811c8df
|
@ -431,7 +431,7 @@ page = 1
|
|||
#endif
|
||||
|
||||
;VSS settings
|
||||
vssMode = bits, U08, 102, [0:1], "Off", "INVALID", "Pulses per KM", "Pulses per mile" ;INVALID value will be CAN
|
||||
vssMode = bits, U08, 102, [0:1], "Off", "CAN/Serial/Analog", "Pulses per KM", "Pulses per mile"
|
||||
;vssPullup = bits, U08, 102, [1:1], "Off", "On"
|
||||
vssPin = bits, U08, 102, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "INVALID", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID"
|
||||
vssPulsesPerKm= scalar, U16, 103, "pulses", 1.0, 0.0, 0.0, 25500, 0
|
||||
|
@ -463,7 +463,7 @@ page = 1
|
|||
;These are reserved for future use, in case of more CAN broadcasting features are added
|
||||
enable1Cluster = bits, U08, 126, [2:2], "Off", "On"
|
||||
enable2Cluster = bits, U08, 126, [3:3], "Off", "On"
|
||||
unusedClusterBits = bits, U08, 126, [4:7], "Off","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID"
|
||||
vssAuxCh = bits, U08, 126, [4:7], "Aux0", "Aux1", "Aux2", "Aux3", "Aux4", "Aux5", "Aux6", "Aux7", "Aux8", "Aux9", "Aux10", "Aux11", "Aux12", "Aux13", "Aux14", "Aux15"
|
||||
|
||||
decelAmount = scalar, U08, 127, "%", 1.0, 0.0, 0.0, 150.0, 0
|
||||
|
||||
|
@ -2064,7 +2064,8 @@ menuDialog = main
|
|||
airConIdleUpRPMAdder = "Increase the idle RPM target (as used by Idle Advance and Closed-Loop Idle) by this amount when the A/C request is active."
|
||||
airConPwmFanMinDuty = "If you are using a PWM cooling fan, the fan duty will be clamped to this value or higher (based on the coolant temp./duty cycle table) when the A/C compressor is engaged."
|
||||
|
||||
vssPulsesPerKm = "The number of pulses on the VSS signal per KM/Mile"
|
||||
vssPulsesPerKm = "The number of pulses on the VSS signal per KM/Mile when "pulses per KM/Mile" -mode is used.\nIn "CAN/Serial/Analog" -mode the Aux input value is divided by this number to get correct VSS. 0 = No dividing/disabled."
|
||||
vssAuxCh = "Use the Auxilary Input Channel Configuration -menus to read VSS from desired source (CAN/Serial/Analog) and then select that Aux in channel here"
|
||||
vssSmoothing = "A smoothing factor to help reduce noise in the VSS signal. Typical values are between 0 and 50"
|
||||
|
||||
aeTime = "The duration of the acceleration enrichment"
|
||||
|
@ -2482,22 +2483,22 @@ menuDialog = main
|
|||
|
||||
dialog = vss_gear_1, "", xAxis
|
||||
field = "Speed ratio 1", vssRatio1
|
||||
commandButton = "Set Gear 1", cmdVSSratio1, { vssMode > 1 }
|
||||
commandButton = "Set Gear 1", cmdVSSratio1, { vssMode > 0 }
|
||||
dialog = vss_gear_2, "", xAxis
|
||||
field = "Speed ratio 2", vssRatio2
|
||||
commandButton = "Set Gear 2", cmdVSSratio2, { vssMode > 1 }
|
||||
commandButton = "Set Gear 2", cmdVSSratio2, { vssMode > 0 }
|
||||
dialog = vss_gear_3, "", xAxis
|
||||
field = "Speed ratio 3", vssRatio3
|
||||
commandButton = "Set Gear 3", cmdVSSratio3, { vssMode > 1 }
|
||||
commandButton = "Set Gear 3", cmdVSSratio3, { vssMode > 0 }
|
||||
dialog = vss_gear_4, "", xAxis
|
||||
field = "Speed ratio 4", vssRatio4
|
||||
commandButton = "Set Gear 4", cmdVSSratio4, { vssMode > 1 }
|
||||
commandButton = "Set Gear 4", cmdVSSratio4, { vssMode > 0 }
|
||||
dialog = vss_gear_5, "", xAxis
|
||||
field = "Speed ratio 5", vssRatio5
|
||||
commandButton = "Set Gear 5", cmdVSSratio5, { vssMode > 1 }
|
||||
commandButton = "Set Gear 5", cmdVSSratio5, { vssMode > 0 }
|
||||
dialog = vss_gear_6, "", xAxis
|
||||
field = "Speed ratio 6", vssRatio6
|
||||
commandButton = "Set Gear 6", cmdVSSratio6, { vssMode > 1 }
|
||||
commandButton = "Set Gear 6", cmdVSSratio6, { vssMode > 0 }
|
||||
|
||||
dialog = vss_gear_detection, "Gear Detection", yAxis
|
||||
field = "After setting 'Pulses per km/mile' above"
|
||||
|
@ -2510,15 +2511,16 @@ menuDialog = main
|
|||
panel = vss_gear_6
|
||||
|
||||
dialog = vss_calibration, "VSS Calibration"
|
||||
field = "Pulses Per KM", vssPulsesPerKm, { vssMode > 1 }
|
||||
commandButton = "60km/h auto-calibrate", cmdVSS60kmh, { vssMode > 1 }
|
||||
field = "Smoothing Factor", vssSmoothing, { vssMode > 1 }
|
||||
field = "Pulses Per KM/VSS ratio", vssPulsesPerKm, { vssMode > 0 }
|
||||
commandButton = "60km/h auto-calibrate", cmdVSS60kmh, { vssMode > 0 }
|
||||
field = "Smoothing Factor", vssSmoothing, { vssMode > 0 }
|
||||
|
||||
dialog = vssSettings, "", yAxis
|
||||
topicHelp = "https://wiki.speeduino.com/en/configuration/VSS"
|
||||
field = "VSS Input Mode", vssMode
|
||||
field = "VSS Pin", vssPin, { vssMode > 1 }
|
||||
;field = "Use Pullup", vssPullup, { vssMode > 1 }
|
||||
field = "VSS Aux in Channel", vssAuxCh, { vssMode == 1 }
|
||||
|
||||
panel = vss_calibration
|
||||
panel = vss_gear_detection
|
||||
|
@ -3184,7 +3186,7 @@ menuDialog = main
|
|||
field = "Valve minimum duty cycle", boostMinDuty, { boostEnabled && boostType == 1 }
|
||||
field = "Valve maximum duty cycle", boostMaxDuty, { boostEnabled && boostType == 1 }
|
||||
panel = boostCut
|
||||
panel = boostByGear, { boostEnabled && vssMode > 1 }
|
||||
panel = boostByGear, { boostEnabled && vssMode > 0 }
|
||||
field = "Closed Loop settings"
|
||||
field = "Control mode", boostMode, { boostEnabled && boostType == 1 }
|
||||
field = "Boost control enable trigger", boostControlEnable { boostEnabled && boostType == 1 }
|
||||
|
|
|
@ -292,14 +292,24 @@ bool TS_CommandButtonsHandler(uint16_t buttonCommand)
|
|||
//VSS Calibration routines
|
||||
case TS_CMD_VSS_60KMH:
|
||||
{
|
||||
//Calibrate the actual pulses per distance
|
||||
uint32_t calibrationGap = vssGetPulseGap(0);
|
||||
if( calibrationGap > 0 )
|
||||
if(configPage2.vssMode == 1)
|
||||
{
|
||||
configPage2.vssPulsesPerKm = 60000000UL / calibrationGap;
|
||||
//Calculate the ratio of VSS reading from Aux input and actual VSS (assuming that actual VSS is really 60km/h).
|
||||
configPage2.vssPulsesPerKm = (currentStatus.canin[configPage2.vssAuxCh] / 60);
|
||||
writeConfig(1); // Need to manually save the new config value as it will not trigger a burn in tunerStudio due to use of ControllerPriority
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_VSS_REFRESH); //Set the flag to trigger the UI reset
|
||||
}
|
||||
else
|
||||
{
|
||||
//Calibrate the actual pulses per distance
|
||||
uint32_t calibrationGap = vssGetPulseGap(0);
|
||||
if( calibrationGap > 0 )
|
||||
{
|
||||
configPage2.vssPulsesPerKm = 60000000UL / calibrationGap;
|
||||
writeConfig(1); // Need to manually save the new config value as it will not trigger a burn in tunerStudio due to use of ControllerPriority
|
||||
BIT_SET(currentStatus.status3, BIT_STATUS3_VSS_REFRESH); //Set the flag to trigger the UI reset
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -905,7 +905,7 @@ struct config2 {
|
|||
byte canVAGCluster : 1;
|
||||
byte enableCluster1 : 1;
|
||||
byte enableCluster2 : 1;
|
||||
byte unusedClusterBits : 4;
|
||||
byte vssAuxCh : 4;
|
||||
|
||||
byte decelAmount;
|
||||
|
||||
|
|
|
@ -627,10 +627,20 @@ uint32_t vssGetPulseGap(byte historyIndex)
|
|||
uint16_t getSpeed(void)
|
||||
{
|
||||
uint16_t tempSpeed = 0;
|
||||
|
||||
// Get VSS from CAN, Serial or Analog by using Aux input channels.
|
||||
if(configPage2.vssMode == 1)
|
||||
{
|
||||
//VSS mode 1 is (Will be) CAN
|
||||
// Direct reading from Aux channel
|
||||
if (configPage2.vssPulsesPerKm == 0)
|
||||
{
|
||||
tempSpeed = currentStatus.canin[configPage2.vssAuxCh];
|
||||
}
|
||||
// Adjust the reading by dividing it by set amount.
|
||||
else
|
||||
{
|
||||
tempSpeed = (currentStatus.canin[configPage2.vssAuxCh] / configPage2.vssPulsesPerKm);
|
||||
}
|
||||
tempSpeed = ADC_FILTER(tempSpeed, configPage2.vssSmoothing, currentStatus.vss); //Apply speed smoothing factor
|
||||
}
|
||||
// Interrupt driven mode
|
||||
else if(configPage2.vssMode > 1)
|
||||
|
|
Loading…
Reference in New Issue