Accelerator pedal with new sensors (#1208)

* add pedal sensor

* update status loop

* add bit to ts

* fix math

* divide at config time

* this used a little bit of ram
This commit is contained in:
Matthew Kennedy 2020-03-22 14:09:46 -07:00 committed by GitHub
parent 1d8af48d28
commit 701f7fd7aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 26 deletions

View File

@ -59,7 +59,7 @@ typedef struct {
unsigned int isTriggerError : 1; // bit 23
unsigned int hasFatalError : 1; // bit 24
unsigned int isWarnNow : 1; // bit 25
unsigned int unused80b8 : 1; // bit 26
unsigned int isPedalError : 1; // bit 26
unsigned int isKnockChipOk : 1; // bit 27
// RPM, vss

View File

@ -323,24 +323,20 @@ static void printSensors(Logging *log) {
reportSensorF(log, GAUGE_NAME_TIMING_ADVANCE, "deg", engine->engineState.timingAdvance, 2);
if (hasPedalPositionSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
// 136
reportSensorF(log, GAUGE_NAME_THROTTLE_PEDAL, "%", getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE), 2);
}
reportSensorF(log, GAUGE_NAME_THROTTLE_PEDAL, "%", Sensor::get(SensorType::AcceleratorPedal).value_or(0), 2);
floatms_t fuelBase = getBaseFuel(rpm PASS_ENGINE_PARAMETER_SUFFIX);
reportSensorF(log, GAUGE_NAME_FUEL_BASE, "ms", fuelBase, 2);
reportSensorF(log, GAUGE_NAME_FUEL_LAST_INJECTION, "ms", ENGINE(actualLastInjection), 2);
reportSensorF(log, GAUGE_NAME_INJECTOR_LAG, "ms", engine->engineState.running.injectorLag, 2);
reportSensorF(log, GAUGE_NAME_FUEL_RUNNING, "ms", ENGINE(engineState.running.fuel), 2);
// 268
reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.running.pidCorrection), 2);
floatms_t fuelBase = getBaseFuel(rpm PASS_ENGINE_PARAMETER_SUFFIX);
reportSensorF(log, GAUGE_NAME_FUEL_BASE, "ms", fuelBase, 2);
reportSensorF(log, GAUGE_NAME_FUEL_LAST_INJECTION, "ms", ENGINE(actualLastInjection), 2);
reportSensorF(log, GAUGE_NAME_INJECTOR_LAG, "ms", engine->engineState.running.injectorLag, 2);
reportSensorF(log, GAUGE_NAME_FUEL_RUNNING, "ms", ENGINE(engineState.running.fuel), 2);
// 268
reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.running.pidCorrection), 2);
reportSensorF(log, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel[0]).getWallFuel(), 2);
reportSensorF(log, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel[0]).wallFuelCorrection, 2);
reportSensorF(log, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel[0]).getWallFuel(), 2);
reportSensorF(log, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel[0]).wallFuelCorrection, 2);
reportSensorI(log, GAUGE_NAME_VERSION, "#", getRusEfiVersion());
reportSensorI(log, GAUGE_NAME_VERSION, "#", getRusEfiVersion());
#if EFI_VEHICLE_SPEED
if (hasVehicleSpeedSensor()) {
@ -732,6 +728,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
SensorResult tps2 = Sensor::get(SensorType::Tps2);
tsOutputChannels->throttle2Position = tps2.Value;
SensorResult pedal = Sensor::get(SensorType::AcceleratorPedal);
tsOutputChannels->pedalPosition = pedal.Value;
tsOutputChannels->isPedalError = !pedal.Valid;
// offset 16
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
@ -771,8 +770,6 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->orderingErrorCounter = engine->triggerCentral.triggerState.orderingErrorCounter;
// 68
tsOutputChannels->baroCorrection = engine->engineState.baroCorrection;
// 136
tsOutputChannels->pedalPosition = hasPedalPositionSensor(PASS_ENGINE_PARAMETER_SIGNATURE) ? getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
// 140
#if EFI_ENGINE_CONTROL
tsOutputChannels->injectorDutyCycle = getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -828,7 +828,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
// help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail
// linking process which is the way to raise the alarm
#ifndef RAM_UNUSED_SIZE
#define RAM_UNUSED_SIZE 14300
#define RAM_UNUSED_SIZE 14200
#endif
#ifndef CCM_UNUSED_SIZE
#define CCM_UNUSED_SIZE 4100

View File

@ -6,6 +6,9 @@ void LinearFunc::configure(float in1, float out1, float in2, float out2, float m
m_minOutput = minOutput;
m_maxOutput = maxOutput;
in1 = in1 / m_divideInput;
in2 = in2 / m_divideInput;
m_a = INTERPOLATION_A(in1, out1, in2, out2);
m_b = out1 - m_a * in1;
}

View File

@ -4,7 +4,7 @@
class LinearFunc final : public SensorConverter {
public:
LinearFunc() = default;
LinearFunc(float divideInput = 1.0f) : m_divideInput(divideInput) {}
void configure(float in1, float out1, float in2, float out2, float minOutput, float maxOutput);
@ -18,4 +18,7 @@ private:
float m_minOutput = 0;
float m_maxOutput = 0;
// Divisor for the input values - some configurations use a ratio'd value for compat
const float m_divideInput;
};

View File

@ -32,6 +32,11 @@ enum class SensorType : unsigned char {
Tps2Primary,
Tps2Secondary,
// Redundant and combined sensors for acc pedal
AcceleratorPedal,
AcceleratorPedalPrimary,
AcceleratorPedalSecondary,
// Leave me at the end!
PlaceholderLast
};

View File

@ -8,20 +8,23 @@
EXTERN_ENGINE;
LinearFunc tpsFunc1p;
//LinearFunc tpsFunc1s;
LinearFunc tpsFunc2p;
//LinearFunc tpsFunc2s;
LinearFunc tpsFunc1p(TPS_TS_CONVERSION);
//LinearFunc tpsFunc1s(TPS_TS_CONVERSION);
LinearFunc tpsFunc2p(TPS_TS_CONVERSION);
//LinearFunc tpsFunc2s(TPS_TS_CONVERSION);
FunctionalSensor tpsSens1p(SensorType::Tps1, MS2NT(10));
//FunctionalSensor tpsSens1s(SensorType::Tps1Secondary, MS2NT(10));
FunctionalSensor tpsSens2p(SensorType::Tps2, MS2NT(10));
//FunctionalSensor tpsSens2s(SensorType::Tps2Secondary, MS2NT(10));
LinearFunc pedalFunc;
FunctionalSensor pedalSensor(SensorType::AcceleratorPedal, MS2NT(10));
static void configureTps(LinearFunc& func, float closed, float open) {
func.configure(
closed / TPS_TS_CONVERSION, 0,
open / TPS_TS_CONVERSION, 100,
closed, 0,
open, 100,
CONFIG(tpsErrorDetectionTooLow),
CONFIG(tpsErrorDetectionTooHigh)
);
@ -47,9 +50,11 @@ static void initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_
void initTps() {
initTpsFunc(tpsFunc1p, tpsSens1p, CONFIG(tps1_1AdcChannel), CONFIG(tpsMin), CONFIG(tpsMax));
initTpsFunc(tpsFunc2p, tpsSens2p, CONFIG(tps2_1AdcChannel), CONFIG(tps2Min), CONFIG(tps2Max));
initTpsFunc(pedalFunc, pedalSensor, CONFIG(throttlePedalPositionAdcChannel), CONFIG(throttlePedalUpVoltage), CONFIG(throttlePedalWOTVoltage));
}
void reconfigureTps() {
configureTps(tpsFunc1p, CONFIG(tpsMin), CONFIG(tpsMax));
configureTps(tpsFunc2p, CONFIG(tps2Min), CONFIG(tps2Max));
configureTps(pedalFunc, CONFIG(throttlePedalUpVoltage), CONFIG(throttlePedalWOTVoltage));
}

View File

@ -193,6 +193,7 @@ fileVersion = { @@TS_FILE_VERSION@@ }
ind_isTriggerError = bits, U32, 0, [23:23], "true", "false";
ind_hasFatalError=bits, U32, 0, [24:24], "true", "false";
ind_isWarnNow =bits, U32, 0, [25:25], "true", "false";
ind_pedal_error =bits, U32, 0, [26:26], "true", "false";
; RPM, vss
RPMValue = scalar, U16, 4, "RPM", 1, 0.00000
@ -1005,6 +1006,7 @@ gaugeCategory = Throttle Body (incl. ETB)
indicator = { ind_clt_error}, "clt", "clt error", white, black, red, black
indicator = { ind_iat_error}, "iat", "iat error", white, black, red, black
indicator = { ind_map_error}, "map", "map error", white, black, red, black
indicator = { ind_pedal_error}, "map", "map error", white, black, red, black
indicator = { knockEverIndicator }, "", "Knock recently", white, black, red, black
indicator = { knockNowIndicator }, "no knock", "Knock NOW", white, black, red, black