support Toyota ETCS-i tps/pps (#4898)

* cfg

* cfg

* configurable "ford tps" mode for TPS + PPS

* comments

* comment

* fix deinit RedundantFordTps

unregister sensor in case useFordRedundant* changes, avoiding ECU config error

* better validation

* use activeConfiguration on deinit path

* use define

* use smaller unused hole

* s

Co-authored-by: Nathan Schulte <nmschulte@desmas.net>
This commit is contained in:
Matthew Kennedy 2023-01-10 11:10:30 -08:00 committed by GitHub
parent a2aee25f4d
commit 15d41c31c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 17 deletions

View File

@ -41,7 +41,7 @@ public:
return m_sens.Register();
}
void unsubscribe() {
void deinit() {
AdcSubscription::UnsubscribeSensor(m_sens);
}
@ -101,7 +101,7 @@ public:
{
}
void init(bool isFordTps, RedundantFordTps* fordTps, const TpsConfig& primary, const TpsConfig& secondary) {
void init(bool isFordTps, RedundantFordTps* fordTps, float secondaryMaximum, const TpsConfig& primary, const TpsConfig& secondary) {
bool hasFirst = m_pri.init(primary);
if (!hasFirst) {
// no input if we have no first channel
@ -125,7 +125,7 @@ public:
if (isFordTps && fordTps) {
// we have a secondary
fordTps->configure(5.0f, 52.6f);
fordTps->configure(MAX_TPS_PPS_DISCREPANCY, secondaryMaximum);
fordTps->Register();
} else {
// not ford TPS
@ -137,9 +137,16 @@ printf("init m_redund.Register() %s\n", getSensorType(m_redund.type()));
}
}
void unsubscribe() {
m_pri.unsubscribe();
m_sec.unsubscribe();
void deinit(bool isFordTps, RedundantFordTps* fordTps) {
m_pri.deinit();
m_sec.deinit();
if (isFordTps && fordTps) {
fordTps->unregister();
} else {
m_redund.unregister();
}
}
private:
@ -161,6 +168,7 @@ static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2);
// Used only in case of weird Ford-style ETB TPS
static RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary);
static RedundantFordTps fordTps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary);
static RedundantFordTps fordPps(SensorType::AcceleratorPedal, SensorType::AcceleratorPedalPrimary, SensorType::AcceleratorPedalSecondary);
// Pedal sensors and redundancy
static FuncSensPair pedalPrimary(1, SensorType::AcceleratorPedalPrimary);
@ -181,19 +189,32 @@ void initTps() {
if (!engineConfiguration->consumeObdSensors) {
bool isFordTps = engineConfiguration->useFordRedundantTps;
bool isFordPps = engineConfiguration->useFordRedundantPps;
tps1.init(isFordTps, &fordTps1,
float tpsSecondaryMaximum = engineConfiguration->tpsSecondaryMaximum;
if (tpsSecondaryMaximum < 20) {
// don't allow <20% split point
tpsSecondaryMaximum = 20;
}
tps1.init(isFordTps, &fordTps1, tpsSecondaryMaximum,
{ engineConfiguration->tps1_1AdcChannel, (float)engineConfiguration->tpsMin, (float)engineConfiguration->tpsMax, min, max },
{ engineConfiguration->tps1_2AdcChannel, (float)engineConfiguration->tps1SecondaryMin, (float)engineConfiguration->tps1SecondaryMax, min, max }
);
tps2.init(isFordTps, &fordTps2,
tps2.init(isFordTps, &fordTps2, tpsSecondaryMaximum,
{ engineConfiguration->tps2_1AdcChannel, (float)engineConfiguration->tps2Min, (float)engineConfiguration->tps2Max, min, max },
{ engineConfiguration->tps2_2AdcChannel, (float)engineConfiguration->tps2SecondaryMin, (float)engineConfiguration->tps2SecondaryMax, min, max }
);
float ppsSecondaryMaximum = engineConfiguration->ppsSecondaryMaximum;
if (ppsSecondaryMaximum < 20) {
// don't allow <20% split point
ppsSecondaryMaximum = 20;
}
// Pedal sensors
pedal.init(false, nullptr,
pedal.init(isFordPps, &fordPps, ppsSecondaryMaximum,
{ engineConfiguration->throttlePedalPositionAdcChannel, engineConfiguration->throttlePedalUpVoltage, engineConfiguration->throttlePedalWOTVoltage, min, max },
{ engineConfiguration->throttlePedalPositionSecondAdcChannel, engineConfiguration->throttlePedalSecondaryUpVoltage, engineConfiguration->throttlePedalSecondaryWOTVoltage, min, max }
);
@ -214,10 +235,13 @@ void initTps() {
}
void deinitTps() {
tps1.unsubscribe();
tps2.unsubscribe();
pedal.unsubscribe();
bool isFordTps = activeConfiguration.useFordRedundantTps;
bool isFordPps = activeConfiguration.useFordRedundantPps;
wastegate.unsubscribe();
idlePos.unsubscribe();
tps1.deinit(isFordTps, &fordTps1);
tps2.deinit(isFordTps, &fordTps2);
pedal.deinit(isFordTps, &fordPps);
wastegate.deinit();
idlePos.deinit();
}

View File

@ -446,7 +446,7 @@ end_struct
injector_s injector
bit isForcedInduction;Does the vehicle have a turbo or supercharger?
bit useFordRedundantTps;On Ford vehicles one of the sensors is not linear on the full range, i.e. in the specific range of the positions we effectively have only one sensor.
bit useFordRedundantTps;On some Ford and Toyota vehicles one of the throttle sensors is not linear on the full range, i.e. in the specific range of the positions we effectively have only one sensor.
bit isVerboseAuxPid1
bit overrideTriggerGaps
bit enableFan1WithAc;Turn on this fan when AC is on.
@ -475,7 +475,7 @@ bit enableMapEstimationTableFallback;If enabled, the MAP estimate table will be
bit usescriptTableForCanSniffingFiltering
bit verboseCan,"Print all","Do not print";Print incoming and outgoing first bus CAN messages in rusEFI console
bit artificialTestMisfire,"Danger Mode","No thank you";Experimental setting that will cause a misfire\nDO NOT ENABLE.
bit issue_294_31,"si_example","nada_example"
bit useFordRedundantPps;On some Ford and Toyota vehicles one of the pedal sensors is not linear on the full range, i.e. in the specific range of the positions we effectively have only one sensor.
!todo: extract these two fields into a structure
@ -1560,7 +1560,8 @@ uint8_t alsEtbPosition;;"", 1, 0, 0, 20000, 0
uint8_t ALSMaxDriverThrottleIntent;;"%", 1, 0, 0, 10, 0
pin_input_mode_e ALSActivatePinMode;
uint8_t[2] unusedHereForYou
uint8_t autoscale tpsSecondaryMaximum;For Ford TPS, use 53%. For Toyota ETCS-i, use 65%;"%", 0.5, 0, 0, 100, 1
uint8_t autoscale ppsSecondaryMaximum;For Toyota ETCS-i, use xxx%;"%", 0.5, 0, 0, 100, 1
pin_input_mode_e[LUA_DIGITAL_INPUT_COUNT iterate] luaDigitalInputPinModes;
uint8_t[96] mainUnusedEnd;;"units", 1, 0, 0, 1, 0

View File

@ -4293,6 +4293,10 @@ dialog = tcuControls, "Transmission Settings"
field = "showHumanReadableWarning (affects Burn)", showHumanReadableWarning
field = "Warning Message", warning_message
field = "Ford redundant TPS mode", useFordRedundantTps
field = "Secondary TPS maximum", tpsSecondaryMaximum, {useFordRedundantTps}
field = "Ford redundant PPS mode", useFordRedundantPps
field = "Secondary PPS maximum", ppsSecondaryMaximum, {useFordRedundantPps}
field = "consumeObdSensors", consumeObdSensors, { canReadEnabled == 1 && canWriteEnabled == 1}
field = "Artificial Misfire", artificialTestMisfire
field = "Always use instant RPM", alwaysInstantRpm