Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
5b51c826df
|
@ -31,7 +31,9 @@ static const LogField fields[] = {
|
|||
{tsOutputChannels.pedalPosition, GAUGE_NAME_THROTTLE_PEDAL, "%", 2},
|
||||
{tsOutputChannels.manifoldAirPressure, GAUGE_NAME_MAP, "kPa", 1},
|
||||
{tsOutputChannels.airFuelRatio, GAUGE_NAME_AFR, "afr", 2},
|
||||
{tsOutputChannels.airFuelRatio2, GAUGE_NAME_AFR2, "afr", 2},
|
||||
{tsOutputChannels.lambda, GAUGE_NAME_LAMBDA, "", 3},
|
||||
{tsOutputChannels.lambda2, GAUGE_NAME_LAMBDA2, "", 3},
|
||||
{tsOutputChannels.vBatt, GAUGE_NAME_VBAT, "v", 2},
|
||||
{tsOutputChannels.oilPressure, GAUGE_NAME_OIL_PRESSURE, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0},
|
||||
{tsOutputChannels.lowFuelPressure, GAUGE_NAME_FUEL_PRESSURE_LOW, GAUGE_NAME_FUEL_PRESSURE_LOW_UNITS, 0},
|
||||
|
|
|
@ -512,11 +512,14 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
// offset 16
|
||||
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
|
||||
|
||||
// offset 20
|
||||
float lambdaValue = Sensor::get(SensorType::Lambda).value_or(0);
|
||||
float lambdaValue = Sensor::get(SensorType::Lambda1).value_or(0);
|
||||
tsOutputChannels->lambda = lambdaValue;
|
||||
tsOutputChannels->airFuelRatio = lambdaValue * ENGINE(engineState.stoichiometricRatio);
|
||||
|
||||
float lambda2Value = Sensor::get(SensorType::Lambda2).value_or(0);
|
||||
tsOutputChannels->lambda2 = lambda2Value;
|
||||
tsOutputChannels->airFuelRatio2 = lambda2Value * ENGINE(engineState.stoichiometricRatio);
|
||||
|
||||
// offset 24
|
||||
tsOutputChannels->engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
float mockRpm = 0;
|
||||
float mockCrankingRpm = 0;
|
||||
float mockTimeSinceBoot = 0;
|
||||
float mockTimeSinceTrigger = 0;
|
||||
int mockAcToggle = 0;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ struct Sensors2 {
|
|||
};
|
||||
|
||||
static void populateFrame(Sensors2& msg) {
|
||||
msg.afr = Sensor::get(SensorType::Lambda).value_or(0) * 14.7f;
|
||||
msg.afr = Sensor::get(SensorType::Lambda1).value_or(0) * 14.7f;
|
||||
msg.oilPressure = Sensor::get(SensorType::OilPressure).value_or(-1);
|
||||
msg.vvtPos = engine->triggerCentral.getVVTPosition();
|
||||
msg.vbatt = getVBatt();
|
||||
|
|
|
@ -157,7 +157,7 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
|
|||
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Tps1).value_or(0) * ODB_TPS_BYTE_PERCENT); // (A*100/255)
|
||||
break;
|
||||
case PID_FUEL_AIR_RATIO_1: {
|
||||
float lambda = Sensor::get(SensorType::Lambda).value_or(0);
|
||||
float lambda = Sensor::get(SensorType::Lambda1).value_or(0);
|
||||
// phi = 1 / lambda
|
||||
float phi = clampF(0, 1 / lambda, 1.99f);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef enum {
|
|||
LE_METHOD_FSIO_DIGITAL_INPUT = 123,
|
||||
LE_METHOD_FSIO_SETTING = 124,
|
||||
LE_METHOD_PPS = 125,
|
||||
LE_METHOD_TIME_SINCE_TRIGGER_EVENT = 126,
|
||||
LE_METHOD_TIME_SINCE_TRIGGER_EVENT = 127,
|
||||
|
||||
#include "fsio_enums_generated.def"
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#pragma once
|
||||
#define VCS_DATE 20201209
|
||||
#define VCS_DATE 20201210
|
||||
|
|
|
@ -710,7 +710,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
|
|||
* UNUSED_SIZE constants.
|
||||
*/
|
||||
#ifndef RAM_UNUSED_SIZE
|
||||
#define RAM_UNUSED_SIZE 3400
|
||||
#define RAM_UNUSED_SIZE 3300
|
||||
#endif
|
||||
#ifndef CCM_UNUSED_SIZE
|
||||
#define CCM_UNUSED_SIZE 2800
|
||||
|
|
|
@ -15,10 +15,6 @@ EXTERN_ENGINE;
|
|||
extern LoggingWithStorage sharedLogger;
|
||||
extern ButtonDebounce startStopButtonDebounce;
|
||||
|
||||
#if ! EFI_PROD_CODE
|
||||
extern bool mockPinStates[(1 << sizeof(brain_pin_e))];
|
||||
#endif
|
||||
|
||||
#if ENABLE_PERF_TRACE
|
||||
static uint8_t nextThreadId = 0;
|
||||
void threadInitHook(void* vtp) {
|
||||
|
|
|
@ -220,8 +220,8 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
|
|||
return;
|
||||
#endif
|
||||
case LL_AFR:
|
||||
if (Sensor::hasSensor(SensorType::Lambda)) {
|
||||
lcdPrintf("AFR: %.2f", Sensor::get(SensorType::Lambda).value_or(0));
|
||||
if (Sensor::hasSensor(SensorType::Lambda1)) {
|
||||
lcdPrintf("AFR: %.2f", Sensor::get(SensorType::Lambda1).value_or(0));
|
||||
} else {
|
||||
lcdPrintf("AFR: none");
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ bool shouldUpdateCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
// Pause (but don't reset) correction if the AFR is off scale.
|
||||
// It's probably a transient and poorly tuned transient correction
|
||||
auto afr = Sensor::get(SensorType::Lambda).value_or(0) * 14.7f;
|
||||
auto afr = Sensor::get(SensorType::Lambda1).value_or(0) * 14.7f;
|
||||
if (!afr || afr < (cfg.minAfr * 0.1f) || afr > (cfg.maxAfr * 0.1f)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ float ClosedLoopFuelCellBase::getAdjustment() const {
|
|||
}
|
||||
|
||||
float ClosedLoopFuelCellImpl::getLambdaError(DECLARE_ENGINE_PARAMETER_SIGNATURE) const {
|
||||
auto lambda = Sensor::get(SensorType::Lambda);
|
||||
auto lambda = Sensor::get(SensorType::Lambda1);
|
||||
|
||||
// Failed sensor -> no error
|
||||
if (!lambda) {
|
||||
|
|
|
@ -34,7 +34,8 @@ static const char* s_sensorNames[] = {
|
|||
"Aux Temp 1",
|
||||
"Aux Temp 2",
|
||||
|
||||
"Lambda",
|
||||
"Lambda 1",
|
||||
"Lambda 2",
|
||||
|
||||
"Wastegate Position",
|
||||
"Idle Valve Position",
|
||||
|
|
|
@ -52,7 +52,8 @@ enum class SensorType : unsigned char {
|
|||
AuxTemp1,
|
||||
AuxTemp2,
|
||||
|
||||
Lambda,
|
||||
Lambda1,
|
||||
Lambda2,
|
||||
|
||||
WastegatePosition,
|
||||
IdlePosition,
|
||||
|
|
|
@ -537,11 +537,15 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
|||
|
||||
this->currentLogicValue = 0;
|
||||
|
||||
#endif // briefly leave the include guard because we need to set default state in tests
|
||||
|
||||
// The order of the next two calls may look strange, which is a good observation.
|
||||
// We call them in this order so that the pin is set to a known state BEFORE
|
||||
// it's enabled. Enabling the pin then setting it could result in a (brief)
|
||||
// mystery state being driven on the pin (potentially dangerous).
|
||||
setDefaultPinState(outputMode);
|
||||
|
||||
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
||||
efiSetPadMode(msg, brainPin, mode);
|
||||
if (brain_pin_is_onchip(brainPin)) {
|
||||
int actualValue = palReadPad(port, pin);
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
// Human-readable: (fan and (coolant > cfg_fanOffTemperature)) | (coolant > cfg_fanOnTemperature) | is_clt_broken
|
||||
#define FAN_CONTROL_LOGIC "fan coolant cfg_fanofftemperature > and coolant cfg_fanontemperature > | is_clt_broken |"
|
||||
|
||||
// Human-readable: ((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (rpm > 0)
|
||||
#define FUEL_PUMP_LOGIC "time_since_boot 0 >= time_since_boot startup_fuel_pump_duration < & rpm 0 > |"
|
||||
// Human-readable: ((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (time_since_trigger > 0)
|
||||
#define FUEL_PUMP_LOGIC "time_since_boot 0 >= time_since_boot startup_fuel_pump_duration < & time_since_trigger 1 < |"
|
||||
|
||||
// Human-readable: vbatt < 14.5
|
||||
#define ALTERNATOR_LOGIC "vbatt 14.5 <"
|
||||
|
|
|
@ -18,7 +18,7 @@ FAN_CONTROL_LOGIC=(fan and (coolant > cfg_fanOffTemperature)) | (coolant > cfg_f
|
|||
# todo: 'time_since_boot' means 'getTimeIgnitionSeconds' in case of EFI_MAIN_RELAY_CONTROL like Proteus
|
||||
# and it's negative if ignition is off? does Proteus not get fuel pump start-up priming pulse?!
|
||||
#
|
||||
FUEL_PUMP_LOGIC=((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (rpm > 0)
|
||||
FUEL_PUMP_LOGIC=((time_since_boot >= 0) & (time_since_boot < startup_fuel_pump_duration)) | (time_since_trigger < 1)
|
||||
|
||||
ALTERNATOR_LOGIC=vbatt < 14.5
|
||||
|
||||
|
|
|
@ -125,7 +125,10 @@ void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config) {
|
|||
#endif /* HAL_USE_ICU */
|
||||
|
||||
#else
|
||||
extern bool mockPinStates[(1 << sizeof(brain_pin_e))];
|
||||
|
||||
// This has been made global so we don't need to worry about efiReadPin having access the object
|
||||
// we store it in, every time we need to use efiReadPin.
|
||||
bool mockPinStates[BRAIN_PIN_COUNT];
|
||||
|
||||
bool efiReadPin(brain_pin_e pin) {
|
||||
return mockPinStates[static_cast<int>(pin)];
|
||||
|
|
|
@ -29,5 +29,10 @@ EXTERNC iomode_t getInputMode(pin_input_mode_e mode);
|
|||
#if HAL_USE_ICU
|
||||
EXTERNC void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config);
|
||||
#endif /* HAL_USE_ICU */
|
||||
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
||||
#if ! EFI_PROD_CODE
|
||||
#define BRAIN_PIN_COUNT (1 << 8 * sizeof(brain_pin_e))
|
||||
extern bool mockPinStates[BRAIN_PIN_COUNT];
|
||||
#endif
|
||||
|
|
|
@ -18,14 +18,15 @@ struct GetAfrWrapper {
|
|||
|
||||
static GetAfrWrapper afrWrapper;
|
||||
|
||||
static FunctionPointerSensor lambdaSensor(SensorType::Lambda,
|
||||
static FunctionPointerSensor lambdaSensor(SensorType::Lambda1,
|
||||
[]() {
|
||||
return afrWrapper.getLambda();
|
||||
});
|
||||
|
||||
#if EFI_CAN_SUPPORT
|
||||
#include "AemXSeriesLambda.h"
|
||||
static AemXSeriesWideband aem(0, SensorType::Lambda);
|
||||
static AemXSeriesWideband aem1(0, SensorType::Lambda1);
|
||||
static AemXSeriesWideband aem2(1, SensorType::Lambda2);
|
||||
#endif
|
||||
|
||||
void initLambda(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
|
@ -33,7 +34,8 @@ void initLambda(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
#if EFI_CAN_SUPPORT
|
||||
if (CONFIG(enableAemXSeries)) {
|
||||
registerCanSensor(aem);
|
||||
registerCanSensor(aem1);
|
||||
registerCanSensor(aem2);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -71,3 +71,5 @@
|
|||
#define EFI_JOYSTICK FALSE
|
||||
|
||||
#define EFI_MAP_AVERAGING TRUE
|
||||
|
||||
#define EFI_FUEL_PUMP TRUE
|
||||
|
|
|
@ -24,10 +24,6 @@ extern engine_configuration_s & activeConfiguration;
|
|||
extern bool printTriggerDebug;
|
||||
extern bool printFuelDebug;
|
||||
|
||||
// This has been made global so we don't need to worry about efiReadPin having access the object
|
||||
// we store it in, every time we need to use efiReadPin.
|
||||
bool mockPinStates[BRAIN_PIN_COUNT];
|
||||
|
||||
EngineTestHelperBase::EngineTestHelperBase() {
|
||||
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
||||
timeNowUs = 0;
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define BRAIN_PIN_COUNT (1 << sizeof(brain_pin_e))
|
||||
|
||||
#include "engine.h"
|
||||
#include "trigger_central.h"
|
||||
#include "rpm_calculator.h"
|
||||
|
|
|
@ -215,6 +215,6 @@ TEST(SensorInit, Lambda) {
|
|||
|
||||
initLambda(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
auto s = Sensor::getSensorOfType(SensorType::Lambda);
|
||||
auto s = Sensor::getSensorOfType(SensorType::Lambda1);
|
||||
ASSERT_NE(nullptr, s);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@ FsioValue getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
return engine->fsioState.mockCrankingRpm;
|
||||
case LE_METHOD_TIME_SINCE_BOOT:
|
||||
return engine->fsioState.mockTimeSinceBoot;
|
||||
case LE_METHOD_STARTUP_FUEL_PUMP_DURATION:
|
||||
return 2.0f;
|
||||
case LE_METHOD_TIME_SINCE_TRIGGER_EVENT:
|
||||
return engine->fsioState.mockTimeSinceTrigger;
|
||||
case LE_METHOD_VBATT:
|
||||
return 12;
|
||||
case LE_METHOD_AC_TOGGLE:
|
||||
|
@ -299,3 +303,41 @@ TEST(fsio, testLogicExpressions) {
|
|||
testExpression2(0, "rpm cranking_rpm > ", 1, engine);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(fsio, fuelPump) {
|
||||
// this will init fuel pump fsio logic
|
||||
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||
|
||||
// Mock a fuel pump pin
|
||||
CONFIG(fuelPumpPin) = GPIOA_0;
|
||||
// Re-init so it picks up the new config
|
||||
enginePins.fuelPumpRelay.init(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// ECU just started, haven't seen trigger yet
|
||||
engine->fsioState.mockTimeSinceBoot = 0.5f;
|
||||
engine->fsioState.mockTimeSinceTrigger = 100;
|
||||
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
// Pump should be on!
|
||||
EXPECT_TRUE(efiReadPin(GPIOA_0));
|
||||
|
||||
// Long time since ecu start, haven't seen trigger yet
|
||||
engine->fsioState.mockTimeSinceBoot = 60;
|
||||
engine->fsioState.mockTimeSinceTrigger = 100;
|
||||
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
// Pump should be off!
|
||||
EXPECT_FALSE(efiReadPin(GPIOA_0));
|
||||
|
||||
// Long time since ecu start, just saw a trigger!
|
||||
engine->fsioState.mockTimeSinceBoot = 60;
|
||||
engine->fsioState.mockTimeSinceTrigger = 0.1f;
|
||||
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
// Pump should be on!
|
||||
EXPECT_TRUE(efiReadPin(GPIOA_0));
|
||||
|
||||
// ECU just started, and we just saw a trigger!
|
||||
engine->fsioState.mockTimeSinceBoot = 0.5f;
|
||||
engine->fsioState.mockTimeSinceTrigger = 0.1f;
|
||||
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
// Pump should be on!
|
||||
EXPECT_TRUE(efiReadPin(GPIOA_0));
|
||||
}
|
||||
|
|
|
@ -87,12 +87,12 @@ TEST(ClosedLoopFuel, afrLimits) {
|
|||
engineConfiguration->stft.minAfr = 100; // 10.0 AFR
|
||||
engineConfiguration->stft.maxAfr = 180; // 18.0 AFR
|
||||
|
||||
Sensor::setMockValue(SensorType::Lambda, 0.1f);
|
||||
Sensor::setMockValue(SensorType::Lambda1, 0.1f);
|
||||
EXPECT_FALSE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
|
||||
Sensor::setMockValue(SensorType::Lambda, 1.0f);
|
||||
Sensor::setMockValue(SensorType::Lambda1, 1.0f);
|
||||
EXPECT_TRUE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
|
||||
Sensor::setMockValue(SensorType::Lambda, 2.0f);
|
||||
Sensor::setMockValue(SensorType::Lambda1, 2.0f);
|
||||
EXPECT_FALSE(shouldUpdateCorrection(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue