Merge branch 'master' of https://github.com/rusefi/rusefi
This commit is contained in:
commit
15d3dc02e4
|
@ -14,6 +14,7 @@ const char * getBoardSpecificPinName(brain_pin_e brainPin) {
|
|||
case Gpio::C13: return "C2-1 - IGN 1";
|
||||
case Gpio::D10: return "C2-70 INJ 4";
|
||||
case Gpio::D11: return "C2-16 INJ 3";
|
||||
case Gpio::D13: return "C3-7 - Alternator Enable";
|
||||
case Gpio::D15: return "C1-25 Tach";
|
||||
case Gpio::D2: return "C1-13 - Fuel Pump";
|
||||
case Gpio::D9: return "C2-49 INJ 5";
|
||||
|
@ -22,12 +23,14 @@ const char * getBoardSpecificPinName(brain_pin_e brainPin) {
|
|||
case Gpio::E4: return "C2-55 - IGN 3";
|
||||
case Gpio::E5: return "C2-53 - IGN 2";
|
||||
case Gpio::E6: return "C2-17 - IGN 8";
|
||||
case Gpio::F11: return "C3-66 - VSS Input";
|
||||
case Gpio::F12: return "C2-52 INJ 6";
|
||||
case Gpio::F13: return "C2-71 INJ 7";
|
||||
case Gpio::F14: return "C2-48 INJ 8";
|
||||
case Gpio::F4: return "C2-63 - Crank";
|
||||
case Gpio::F6: return "C2-59 - Cam";
|
||||
case Gpio::G11: return "C1-26 - Starter Relay";
|
||||
case Gpio::G13: return "C3-16 - Coolant Pump";
|
||||
case Gpio::G14: return "C1-40 - MAIN";
|
||||
case Gpio::G2: return "C1-12 Check Engine";
|
||||
case Gpio::G4: return "C1-56 - Starter Enable";
|
||||
|
|
|
@ -114,6 +114,15 @@ pins:
|
|||
type: ls
|
||||
color: purple
|
||||
|
||||
- pin: 60
|
||||
# H144_IN_O2S2
|
||||
id: EFI_ADC_1
|
||||
class: analog_inputs
|
||||
ts_name: C2-60 - Oil Pressure
|
||||
function: Oil Pressure
|
||||
type: av
|
||||
color: purple
|
||||
|
||||
- pin: 63
|
||||
# H144_IN_SENS2
|
||||
id: F4
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
pins:
|
||||
- pin: 7
|
||||
# H144_OUT_PWM1
|
||||
id: D13
|
||||
class: outputs
|
||||
function: Alternator Enable
|
||||
type: hs
|
||||
ts_name: C3-7 - Alternator Enable
|
||||
|
||||
- pin: 16
|
||||
# H144_OUT_IO9
|
||||
id: G13
|
||||
class: outputs
|
||||
function: Coolant Pump
|
||||
type: hs
|
||||
ts_name: C3-16 - Coolant Pump
|
||||
|
||||
- pin: 33
|
||||
function: CAN bus low
|
||||
type: can
|
||||
|
@ -59,3 +75,16 @@ pins:
|
|||
ts_name: C3-59 - MAP
|
||||
function: MAP
|
||||
color: purple
|
||||
|
||||
- pin: 66
|
||||
# H144_IN_VSS
|
||||
id: F11
|
||||
class: switch_inputs
|
||||
function: Vehicle Speed Sensor Input Pos
|
||||
type: hall
|
||||
ts_name: C3-66 - VSS Input
|
||||
color: gray
|
||||
|
||||
- pin: 67
|
||||
function: Vehicle Speed Sensor Input Neg
|
||||
color: gray
|
|
@ -1,2 +1,2 @@
|
|||
#pragma once
|
||||
#define VCS_DATE 20220603
|
||||
#define VCS_DATE 20220604
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 705317436
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.48way.705317436"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.48way.705317436"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1026376307
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.all.1026376307"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.all.1026376307"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 255844127
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.alphax-2chan.255844127"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.alphax-2chan.255844127"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 513912112
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.alphax-4chan.513912112"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.alphax-4chan.513912112"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 568833876
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.atlas.568833876"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.atlas.568833876"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3418428298
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.core8.3418428298"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.core8.3418428298"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1026376307
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.f407-discovery.1026376307"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.f407-discovery.1026376307"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1026376307
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.f429-discovery.1026376307"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.f429-discovery.1026376307"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2135015095
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.frankenso_na6.2135015095"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.frankenso_na6.2135015095"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1237392652
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.harley81.1237392652"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.harley81.1237392652"
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
|
||||
//
|
||||
|
||||
#define SIGNATURE_HASH 2003219992
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen-gm-e67.2003219992"
|
||||
#define SIGNATURE_HASH 2168582308
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen-gm-e67.2168582308"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3836113855
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen-nb1.3836113855"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen-nb1.3836113855"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3820612870
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen121nissan.3820612870"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen121nissan.3820612870"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1897585401
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen121vag.1897585401"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen121vag.1897585401"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1392942754
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen128.1392942754"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen128.1392942754"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2774675703
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen154hyundai.2774675703"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen154hyundai.2774675703"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2325188489
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen72.2325188489"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen72.2325188489"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 530094713
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen81.530094713"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen81.530094713"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1639613655
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen88bmw.1639613655"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen88bmw.1639613655"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3215373075
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellenNA6.3215373075"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellenNA6.3215373075"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2298012637
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellenNA8_96.2298012637"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellenNA8_96.2298012637"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2013334649
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.hellen_cypress.2013334649"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.hellen_cypress.2013334649"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 641887220
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.kin.641887220"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.kin.641887220"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1883235271
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.mre_f4.1883235271"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.mre_f4.1883235271"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1883235271
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.mre_f7.1883235271"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.mre_f7.1883235271"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1841798037
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.prometheus_405.1841798037"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.prometheus_405.1841798037"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 1841798037
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.prometheus_469.1841798037"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.prometheus_469.1841798037"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3760342879
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.proteus_f4.3760342879"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.proteus_f4.3760342879"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3760342879
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.proteus_f7.3760342879"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.proteus_f7.3760342879"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 3760342879
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.proteus_h7.3760342879"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.proteus_h7.3760342879"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 909949889
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.subaru_eg33_f7.909949889"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.subaru_eg33_f7.909949889"
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
//
|
||||
|
||||
#define SIGNATURE_HASH 2535820327
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.03.tdg-pdm8.2535820327"
|
||||
#define TS_SIGNATURE "rusEFI 2022.06.04.tdg-pdm8.2535820327"
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
* Get a friendly name for the sensor.
|
||||
* For example, CLT, IAT, Throttle Position 2, etc.
|
||||
*/
|
||||
const char* getSensorName() { return getSensorName(m_type); }
|
||||
const char* getSensorName() const { return getSensorName(m_type); }
|
||||
static const char* getSensorName(SensorType type);
|
||||
|
||||
// Retrieve the current reading from the sensor.
|
||||
|
@ -170,6 +170,10 @@ public:
|
|||
|
||||
void unregister();
|
||||
|
||||
SensorType type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Protected constructor - only subclasses call this
|
||||
explicit Sensor(SensorType type)
|
||||
|
|
|
@ -8,114 +8,180 @@
|
|||
#include "linear_func.h"
|
||||
#include "tps.h"
|
||||
|
||||
LinearFunc tpsFunc1p(TPS_TS_CONVERSION);
|
||||
LinearFunc tpsFunc1s(TPS_TS_CONVERSION);
|
||||
LinearFunc tpsFunc2p(TPS_TS_CONVERSION);
|
||||
LinearFunc tpsFunc2s(TPS_TS_CONVERSION);
|
||||
struct TpsConfig {
|
||||
adc_channel_e channel;
|
||||
float closed;
|
||||
float open;
|
||||
float min;
|
||||
float max;
|
||||
};
|
||||
|
||||
FunctionalSensor tpsSens1p(SensorType::Tps1Primary, MS2NT(10));
|
||||
FunctionalSensor tpsSens1s(SensorType::Tps1Secondary, MS2NT(10));
|
||||
FunctionalSensor tpsSens2p(SensorType::Tps2Primary, MS2NT(10));
|
||||
FunctionalSensor tpsSens2s(SensorType::Tps2Secondary, MS2NT(10));
|
||||
class FuncSensPair {
|
||||
public:
|
||||
FuncSensPair(float divideInput, SensorType type)
|
||||
: m_func(divideInput)
|
||||
, m_sens(type, MS2NT(10))
|
||||
{
|
||||
m_sens.setFunction(m_func);
|
||||
}
|
||||
|
||||
bool init(const TpsConfig& cfg) {
|
||||
// If the configuration was invalid, don't continue to configure the sensor
|
||||
if (!configure(cfg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AdcSubscription::SubscribeSensor(m_sens, cfg.channel, 200);
|
||||
|
||||
return m_sens.Register();
|
||||
}
|
||||
|
||||
void unsubscribe() {
|
||||
AdcSubscription::UnsubscribeSensor(m_sens);
|
||||
}
|
||||
|
||||
SensorType type() const {
|
||||
return m_sens.type();
|
||||
}
|
||||
|
||||
const char* name() const {
|
||||
return m_sens.getSensorName();
|
||||
}
|
||||
|
||||
private:
|
||||
bool configure(const TpsConfig& cfg) {
|
||||
// Only configure if we have a channel
|
||||
if (!isAdcChannelValid(cfg.channel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float scaledClosed = cfg.closed / m_func.getDivideInput();
|
||||
float scaledOpen = cfg.open / m_func.getDivideInput();
|
||||
|
||||
float split = absF(scaledOpen - scaledClosed);
|
||||
|
||||
// If the voltage for closed vs. open is very near, something is wrong with your calibration
|
||||
if (split < 0.5f) {
|
||||
firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", name(),
|
||||
cfg.open,
|
||||
cfg.closed);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_func.configure(
|
||||
cfg.closed, 0,
|
||||
cfg.open, 100,
|
||||
cfg.min, cfg.max
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LinearFunc m_func;
|
||||
FunctionalSensor m_sens;
|
||||
};
|
||||
|
||||
struct RedundantPair {
|
||||
public:
|
||||
RedundantPair(FuncSensPair& pri, FuncSensPair& sec, SensorType outputType)
|
||||
: m_pri(pri)
|
||||
, m_sec(sec)
|
||||
, m_redund(outputType, m_pri.type(), m_sec.type())
|
||||
{
|
||||
}
|
||||
|
||||
void init(bool isFordTps, RedundantFordTps* fordTps, const TpsConfig& primary, const TpsConfig& secondary) {
|
||||
{
|
||||
// Check that the primary and secondary aren't too close together - if so, the user may have done
|
||||
// an unsafe thing where they wired a single sensor to both inputs. Don't do that!
|
||||
bool hasBothSensors = isAdcChannelValid(primary.channel) && isAdcChannelValid(secondary.channel);
|
||||
bool tooCloseClosed = absF(primary.closed - secondary.closed) < 0.2f;
|
||||
bool tooCloseOpen = absF(primary.open - secondary.open) < 0.2f;
|
||||
|
||||
if (hasBothSensors && tooCloseClosed && tooCloseOpen) {
|
||||
firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "Configuration for redundant pair %s/%s are too similar - did you wire one sensor to both inputs...?", m_pri.name(), m_sec.name());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_pri.init(primary);
|
||||
|
||||
bool hasSecond = m_sec.init(secondary);
|
||||
|
||||
if (isFordTps && fordTps) {
|
||||
// we have a secondary
|
||||
fordTps->configure(5.0f, 52.6f);
|
||||
fordTps->Register();
|
||||
} else {
|
||||
// not ford TPS
|
||||
m_redund.configure(5.0f, !hasSecond);
|
||||
m_redund.Register();
|
||||
}
|
||||
}
|
||||
|
||||
void unsubscribe() {
|
||||
m_pri.unsubscribe();
|
||||
m_sec.unsubscribe();
|
||||
}
|
||||
|
||||
private:
|
||||
FuncSensPair& m_pri;
|
||||
FuncSensPair& m_sec;
|
||||
|
||||
RedundantSensor m_redund;
|
||||
};
|
||||
|
||||
static FuncSensPair tps1p(TPS_TS_CONVERSION, SensorType::Tps1Primary);
|
||||
static FuncSensPair tps1s(TPS_TS_CONVERSION, SensorType::Tps1Secondary);
|
||||
static FuncSensPair tps2p(TPS_TS_CONVERSION, SensorType::Tps2Primary);
|
||||
static FuncSensPair tps2s(TPS_TS_CONVERSION, SensorType::Tps2Secondary);
|
||||
|
||||
// Used in case of "normal", non-Ford ETB TPS
|
||||
RedundantSensor tps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary);
|
||||
RedundantSensor tps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary);
|
||||
static RedundantPair tps1(tps1p, tps1s, SensorType::Tps1);
|
||||
static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2);
|
||||
|
||||
// Used only in case of weird Ford-style ETB TPS
|
||||
RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary);
|
||||
RedundantFordTps fordTps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary);
|
||||
static RedundantFordTps fordTps1(SensorType::Tps1, SensorType::Tps1Primary, SensorType::Tps1Secondary);
|
||||
static RedundantFordTps fordTps2(SensorType::Tps2, SensorType::Tps2Primary, SensorType::Tps2Secondary);
|
||||
|
||||
LinearFunc pedalFuncPrimary;
|
||||
LinearFunc pedalFuncSecondary;
|
||||
FunctionalSensor pedalSensorPrimary(SensorType::AcceleratorPedalPrimary, MS2NT(10));
|
||||
FunctionalSensor pedalSensorSecondary(SensorType::AcceleratorPedalSecondary, MS2NT(10));
|
||||
|
||||
RedundantSensor pedal(SensorType::AcceleratorPedal, SensorType::AcceleratorPedalPrimary, SensorType::AcceleratorPedalSecondary);
|
||||
// Pedal sensors and redundancy
|
||||
static FuncSensPair pedalPrimary(1, SensorType::AcceleratorPedalPrimary);
|
||||
static FuncSensPair pedalSecondary(1, SensorType::AcceleratorPedalSecondary);
|
||||
static RedundantPair pedal(pedalPrimary, pedalSecondary, SensorType::AcceleratorPedal);
|
||||
|
||||
// This sensor indicates the driver's throttle intent - Pedal if we have one, TPS if not.
|
||||
ProxySensor driverIntent(SensorType::DriverThrottleIntent);
|
||||
static ProxySensor driverIntent(SensorType::DriverThrottleIntent);
|
||||
|
||||
// These sensors are TPS-like, so handle them in here too
|
||||
LinearFunc wastegateFunc(PACK_MULT_VOLTAGE);
|
||||
LinearFunc idlePosFunc(PACK_MULT_VOLTAGE);
|
||||
FunctionalSensor wastegateSens(SensorType::WastegatePosition, MS2NT(10));
|
||||
FunctionalSensor idlePosSens(SensorType::IdlePosition, MS2NT(10));
|
||||
|
||||
static bool configureTps(LinearFunc& func, adc_channel_e channel, float closed, float open, float min, float max, const char* msg) {
|
||||
// Only configure if we have a channel
|
||||
if (!isAdcChannelValid(channel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float scaledClosed = closed / func.getDivideInput();
|
||||
float scaledOpen = open / func.getDivideInput();
|
||||
|
||||
float split = absF(scaledOpen - scaledClosed);
|
||||
|
||||
// If the voltage for closed vs. open is very near, something is wrong with your calibration
|
||||
if (split < 0.5f) {
|
||||
firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", msg,
|
||||
open,
|
||||
closed);
|
||||
return false;
|
||||
}
|
||||
|
||||
func.configure(
|
||||
closed, 0,
|
||||
open, 100,
|
||||
min, max
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) {
|
||||
// If the configuration was invalid, don't continue to configure the sensor
|
||||
if (!configureTps(func, channel, closed, open, min, max, sensor.getSensorName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sensor.setFunction(func);
|
||||
|
||||
AdcSubscription::SubscribeSensor(sensor, channel, 200);
|
||||
|
||||
return sensor.Register();
|
||||
}
|
||||
|
||||
static void initTpsFuncAndRedund(RedundantSensor& redund, RedundantFordTps* fordTps, bool isFordTps, LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) {
|
||||
bool hasSecond = initTpsFunc(func, sensor, channel, closed, open, min, max);
|
||||
|
||||
if (isFordTps && fordTps) {
|
||||
fordTps->configure(5.0f, 52.6f);
|
||||
fordTps->Register();
|
||||
} else {
|
||||
redund.configure(5.0f, !hasSecond);
|
||||
redund.Register();
|
||||
}
|
||||
}
|
||||
static FuncSensPair wastegate(PACK_MULT_VOLTAGE, SensorType::WastegatePosition);
|
||||
static FuncSensPair idlePos(PACK_MULT_VOLTAGE, SensorType::IdlePosition);
|
||||
|
||||
void initTps() {
|
||||
percent_t min = engineConfiguration->tpsErrorDetectionTooLow;
|
||||
percent_t max = engineConfiguration->tpsErrorDetectionTooHigh;
|
||||
|
||||
if (!engineConfiguration->consumeObdSensors) {
|
||||
// primary TPS sensors
|
||||
initTpsFunc(tpsFunc1p, tpsSens1p, engineConfiguration->tps1_1AdcChannel, engineConfiguration->tpsMin, engineConfiguration->tpsMax, min, max);
|
||||
initTpsFunc(tpsFunc2p, tpsSens2p, engineConfiguration->tps2_1AdcChannel, engineConfiguration->tps2Min, engineConfiguration->tps2Max, min, max);
|
||||
|
||||
// Secondary TPS sensors (and redundant combining)
|
||||
bool isFordTps = engineConfiguration->useFordRedundantTps;
|
||||
initTpsFuncAndRedund(tps1, &fordTps1, isFordTps, tpsFunc1s, tpsSens1s, engineConfiguration->tps1_2AdcChannel, engineConfiguration->tps1SecondaryMin, engineConfiguration->tps1SecondaryMax, min, max);
|
||||
initTpsFuncAndRedund(tps2, &fordTps2, isFordTps, tpsFunc2s, tpsSens2s, engineConfiguration->tps2_2AdcChannel, engineConfiguration->tps2SecondaryMin, engineConfiguration->tps2SecondaryMax, min, max);
|
||||
|
||||
tps1.init(isFordTps, &fordTps1,
|
||||
{ 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,
|
||||
{ engineConfiguration->tps2_1AdcChannel, (float)engineConfiguration->tps2Min, (float)engineConfiguration->tps2Max, min, max },
|
||||
{ engineConfiguration->tps2_2AdcChannel, (float)engineConfiguration->tps2SecondaryMin, (float)engineConfiguration->tps2SecondaryMax, min, max }
|
||||
);
|
||||
|
||||
// Pedal sensors
|
||||
initTpsFunc(pedalFuncPrimary, pedalSensorPrimary, engineConfiguration->throttlePedalPositionAdcChannel, engineConfiguration->throttlePedalUpVoltage, engineConfiguration->throttlePedalWOTVoltage, min, max);
|
||||
initTpsFuncAndRedund(pedal, nullptr, false, pedalFuncSecondary, pedalSensorSecondary, engineConfiguration->throttlePedalPositionSecondAdcChannel, engineConfiguration->throttlePedalSecondaryUpVoltage, engineConfiguration->throttlePedalSecondaryWOTVoltage, min, max);
|
||||
pedal.init(false, nullptr,
|
||||
{ engineConfiguration->throttlePedalPositionAdcChannel, engineConfiguration->throttlePedalUpVoltage, engineConfiguration->throttlePedalWOTVoltage, min, max },
|
||||
{ engineConfiguration->throttlePedalPositionSecondAdcChannel, engineConfiguration->throttlePedalSecondaryUpVoltage, engineConfiguration->throttlePedalSecondaryWOTVoltage, min, max }
|
||||
);
|
||||
|
||||
// TPS-like stuff that isn't actually a TPS
|
||||
initTpsFunc(wastegateFunc, wastegateSens, engineConfiguration->wastegatePositionSensor, engineConfiguration->wastegatePositionMin, engineConfiguration->wastegatePositionMax, min, max);
|
||||
initTpsFunc(idlePosFunc, idlePosSens, engineConfiguration->idlePositionSensor, engineConfiguration->idlePositionMin, engineConfiguration->idlePositionMax, min, max);
|
||||
wastegate.init({ engineConfiguration->wastegatePositionSensor, (float)engineConfiguration->wastegatePositionMin, (float)engineConfiguration->wastegatePositionMax, min, max });
|
||||
idlePos.init({ engineConfiguration->idlePositionSensor, (float)engineConfiguration->idlePositionMin, (float)engineConfiguration->idlePositionMax, min, max });
|
||||
}
|
||||
|
||||
// Route the pedal or TPS to driverIntent as appropriate
|
||||
|
@ -129,15 +195,10 @@ void initTps() {
|
|||
}
|
||||
|
||||
void deinitTps() {
|
||||
AdcSubscription::UnsubscribeSensor(tpsSens1p);
|
||||
AdcSubscription::UnsubscribeSensor(tpsSens1s);
|
||||
tps1.unsubscribe();
|
||||
tps2.unsubscribe();
|
||||
pedal.unsubscribe();
|
||||
|
||||
AdcSubscription::UnsubscribeSensor(tpsSens2p);
|
||||
AdcSubscription::UnsubscribeSensor(tpsSens2s);
|
||||
|
||||
AdcSubscription::UnsubscribeSensor(pedalSensorPrimary);
|
||||
AdcSubscription::UnsubscribeSensor(pedalSensorSecondary);
|
||||
|
||||
AdcSubscription::UnsubscribeSensor(wastegateSens);
|
||||
AdcSubscription::UnsubscribeSensor(idlePosSens);
|
||||
wastegate.unsubscribe();
|
||||
idlePos.unsubscribe();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// This file was generated by Version2Header
|
||||
// Fri Jun 03 00:17:45 UTC 2022
|
||||
// Sat Jun 04 00:20:22 UTC 2022
|
||||
|
||||
|
||||
#ifndef GIT_HASH
|
||||
#define GIT_HASH "e3dfc02faabd84bf9cca7793e110aebdfb6256ae"
|
||||
#define GIT_HASH "0116be2f176acca81a40d144fca008b2086391d7"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VCS_VERSION
|
||||
#define VCS_VERSION "40664"
|
||||
#define VCS_VERSION "41194"
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue