bye frequency map (#3285)

* bye freq map

* map.cpp

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-09-29 21:20:21 -07:00 committed by GitHub
parent 1cfb1432e1
commit 4b6a67f8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 74 deletions

View File

@ -84,9 +84,4 @@ void setSachs(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
setTimingRpmBin(800, 15000 PASS_CONFIG_PARAMETER_SUFFIX);
setLinearCurve(config->veRpmBins, 7000, 15000, 1);
setLinearCurve(config->lambdaRpmBins, 500, 7000, 1);
engineConfiguration->hasFrequencyReportingMapSensor = true;
engineConfiguration->frequencyReportingMapInputPin = GPIOC_6;
engineConfiguration->mapFrequency100Kpa = 159;
engineConfiguration->mapFrequency0Kpa = 80;
}

View File

@ -327,10 +327,6 @@ float getMap(void) {
if (!isAdcChannelValid(engineConfiguration->map.sensor.hwChannel))
return 0;
if (engineConfiguration->hasFrequencyReportingMapSensor) {
return getRawMap();
}
#if EFI_ANALOG_SENSORS
if (!isValidRpm(GET_RPM()) || currentPressure == NO_VALUE_YET)
return validateMap(getRawMap()); // maybe return NaN in case of stopped engine?

View File

@ -15,9 +15,6 @@
#if EFI_ANALOG_SENSORS
static FastInterpolation customMap;
static efitick_t prevWidthTimeNt = 0;
static float mapFreq = 0;
// See 'useFixedBaroCorrFromMap'
static float storedInitialBaroPressure = NAN;
@ -154,10 +151,6 @@ float getMapByVoltage(float voltage DECLARE_ENGINE_PARAMETER_SUFFIX) {
* @return Manifold Absolute Pressure, in kPa
*/
float getRawMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (engineConfiguration->hasFrequencyReportingMapSensor) {
return interpolateMsg("rmap", CONFIG(mapFrequency0Kpa), 0, CONFIG(mapFrequency100Kpa), 100, mapFreq);
}
float voltage = getVoltageDivided("map", engineConfiguration->map.sensor.hwChannel PASS_ENGINE_PARAMETER_SUFFIX);
return getMapByVoltage(voltage PASS_ENGINE_PARAMETER_SUFFIX);
}
@ -216,14 +209,6 @@ static void applyConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
mapDecoder = getDecoder(engineConfiguration->map.sensor.type);
}
static void digitalMapWidthCallback(void) {
efitick_t nowNt = getTimeNowNt();
mapFreq = US_PER_SECOND_F / NT2US(nowNt - prevWidthTimeNt);
prevWidthTimeNt = nowNt;
}
#if EFI_PROD_CODE
extern int mapMinBufferLength;
@ -232,29 +217,24 @@ static void printMAPInfo(void) {
#if EFI_ANALOG_SENSORS
efiPrintf("instant value=%.2fkPa", getRawMap());
if (engineConfiguration->hasFrequencyReportingMapSensor) {
efiPrintf("instant value=%.2fHz @ %s", mapFreq, hwPortname(CONFIG(frequencyReportingMapInputPin)));
} else {
#if EFI_MAP_AVERAGING
efiPrintf("map type=%d/%s MAP=%.2fkPa mapMinBufferLength=%d", engineConfiguration->map.sensor.type,
getAir_pressure_sensor_type_e(engineConfiguration->map.sensor.type),
getMap(),
mapMinBufferLength);
efiPrintf("map type=%d/%s MAP=%.2fkPa mapMinBufferLength=%d", engineConfiguration->map.sensor.type,
getAir_pressure_sensor_type_e(engineConfiguration->map.sensor.type),
getMap(),
mapMinBufferLength);
#endif // EFI_MAP_AVERAGING
adc_channel_e mapAdc = engineConfiguration->map.sensor.hwChannel;
char pinNameBuffer[16];
adc_channel_e mapAdc = engineConfiguration->map.sensor.hwChannel;
char pinNameBuffer[16];
efiPrintf("MAP %.2fv @%s", getVoltage("mapinfo", mapAdc PASS_ENGINE_PARAMETER_SUFFIX),
getPinNameByAdcChannel("map", mapAdc, pinNameBuffer));
if (engineConfiguration->map.sensor.type == MT_CUSTOM) {
efiPrintf("at %.2fv=%.2f at %.2fv=%.2f",
engineConfiguration->mapLowValueVoltage,
engineConfiguration->map.sensor.lowValue,
engineConfiguration->mapHighValueVoltage,
engineConfiguration->map.sensor.highValue);
}
efiPrintf("MAP %.2fv @%s", getVoltage("mapinfo", mapAdc PASS_ENGINE_PARAMETER_SUFFIX),
getPinNameByAdcChannel("map", mapAdc, pinNameBuffer));
if (engineConfiguration->map.sensor.type == MT_CUSTOM) {
efiPrintf("at %.2fv=%.2f at %.2fv=%.2f",
engineConfiguration->mapLowValueVoltage,
engineConfiguration->map.sensor.lowValue,
engineConfiguration->mapHighValueVoltage,
engineConfiguration->map.sensor.highValue);
}
if (Sensor::hasSensor(SensorType::BarometricPressure)) {
@ -276,24 +256,6 @@ void initMapDecoder(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
applyConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
//engine->configurationListeners.registerCallback(applyConfiguration);
if (engineConfiguration->hasFrequencyReportingMapSensor) {
#if EFI_ICU_INPUTS
digital_input_s* digitalMapInput = startDigitalCapture("MAP freq", CONFIG(frequencyReportingMapInputPin));
digitalMapInput->setWidthCallback((VoidInt) digitalMapWidthCallback, NULL);
#else
#if EFI_PROD_CODE
efiExtiEnablePin(
"Frequency MAP",
CONFIG(frequencyReportingMapInputPin),
PAL_EVENT_MODE_RISING_EDGE,
(palcallback_t)digitalMapWidthCallback,
nullptr
);
#endif /* EFI_PROD_CODE */
#endif /* HAL_USE_ICU */
}
if (CONFIG(useFixedBaroCorrFromMap)) {
// Read initial MAP sensor value and store it for Baro correction.
storedInitialBaroPressure = getRawMap(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -777,8 +777,8 @@ end_struct
float manIdlePosition;value between 0 and 100 used in Manual mode;"%", 1, 0, 0, 100, 0
float mapFrequency0Kpa;;"Hz", 1, 0, 0, 100000, 2
float mapFrequency100Kpa;;"Hz", 1, 0, 0, 100000, 2
float unused612;;"", 1, 0, 0, 1, 0
float unused616;;"", 1, 0, 0, 1, 0
! todo: rename to triggerSimulatorRpm
int triggerSimulatorFrequency;+Same RPM is used for two ways of producing simulated RPM. See also triggerSimulatorPins (with wires)\nSee also directSelfStimulation (no wires, bypassing input hardware)\nrpm X\nTODO: rename to triggerSimulatorRpm;"Rpm", 1, 0, 0, 30000, 0
@ -1011,7 +1011,7 @@ custom maf_sensor_type_e 4 bits, S32, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@
brain_input_pin_e vehicleSpeedSensorInputPin;
switch_input_pin_e clutchUpPin;+Some vehicles have a switch to indicate that clutch pedal is all the way up
brain_input_pin_e frequencyReportingMapInputPin;
uint8_t unused970;;"", 1, 0, 0, 1, 0
pin_input_mode_e clutchUpPinMode;
uint16_t multisparkMaxRpm;+Disable multispark above this engine speed.;"rpm", 1, 0, 0, 3000, 0
uint8_t multisparkMaxSparkingAngle;+This parameter sets the latest that the last multispark can occur after the main ignition event. For example, if the ignition timing is 30 degrees BTDC, and this parameter is set to 45, no multispark will ever be fired after 15 degrees ATDC.;"deg", 1, 0, 0, 60, 0
@ -1144,7 +1144,7 @@ bit cutFuelOnHardLimit,"yes","no"
bit cutSparkOnHardLimit,"yes","no"
bit launchFuelCutEnable
bit launchSparkCutEnable;+This is the Cut Mode normally used
bit hasFrequencyReportingMapSensor
bit unused1464b20
bit unusedBitWasHere1
bit unusedBitWasHere2
bit unusedBitWasHere3

View File

@ -2269,7 +2269,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "AFR ADC input", afr_hwChannel
field = "Baro ADC input", baroSensor_hwChannel
field = "MAP ADC input", map_sensor_hwChannel
field = "FrequencyReportingMapInputPin", frequencyReportingMapInputPin
field = "FuelLevelSensor", fuelLevelSensor
field = "Vehicle Speed Input pin", vehicleSpeedSensorInputPin
field = "clutchDownPin", clutchDownPin
@ -2557,14 +2556,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "MAP voltage low point", mapLowValueVoltage, { map_sensor_hwChannel != @@ADC_CHANNEL_NONE@@ && map_sensor_type == 0 }
field = "MAP value high point", map_sensor_highValue,{ map_sensor_hwChannel != @@ADC_CHANNEL_NONE@@ && map_sensor_type == 0 }
field = "MAP voltage high value", mapHighValueVoltage, { map_sensor_hwChannel != @@ADC_CHANNEL_NONE@@ && map_sensor_type == 0 }
dialog = mapSensorFreq, "MAP frequency sensor", yAxis
field = "MAP Freq", frequencyReportingMapInputPin
field = "0 kPa freq", mapFrequency0Kpa
field = "100 kpa freq", mapFrequency100Kpa
dialog = mapCommon, "MAP common settings"
field = "frequency-based MAP", hasFrequencyReportingMapSensor
field = "Low value threshold", mapErrorDetectionTooLow
field = "High value threshold", mapErrorDetectionTooHigh
field = ""
@ -2573,8 +2566,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = mapSettings, "", yAxis
panel = mapCommon
panel = mapSensorAnalog, {hasFrequencyReportingMapSensor == 0}
panel = mapSensorFreq, {hasFrequencyReportingMapSensor == 1}
panel = mapSensorAnalog
dialog = baroSettings, "Baro sensor"
field = "Baro ADC input", baroSensor_hwChannel