mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
32c133cd24
commit
f21821d1fd
|
@ -239,7 +239,7 @@ void setFordEscortGt(engine_configuration_s *engineConfiguration) {
|
|||
setFrankenso0_1_joystick(engineConfiguration);
|
||||
|
||||
engineConfiguration->specs.displacement = 1.839;
|
||||
engineConfiguration->algorithm = LM_MAF;
|
||||
engineConfiguration->algorithm = LM_PLAIN_MAF;
|
||||
boardConfiguration->tunerStudioSerialSpeed = 9600;
|
||||
|
||||
setFuelLoadBin(engineConfiguration, 1.2, 4.4);
|
||||
|
|
|
@ -174,8 +174,8 @@ case Force_4b_engine_load_mode:
|
|||
return "Force_4b_engine_load_mode";
|
||||
case LM_ALPHA_N:
|
||||
return "LM_ALPHA_N";
|
||||
case LM_MAF:
|
||||
return "LM_MAF";
|
||||
case LM_PLAIN_MAF:
|
||||
return "LM_PLAIN_MAF";
|
||||
case LM_MAP:
|
||||
return "LM_MAP";
|
||||
case LM_SPEED_DENSITY:
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "engine_state.h"
|
||||
#include "efiGpio.h"
|
||||
#include "trigger_central.h"
|
||||
#include "fuel_math.h"
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "injector_central.h"
|
||||
|
@ -34,6 +35,9 @@ EXTERN_ENGINE
|
|||
void Engine::updateSlowSensors() {
|
||||
engineState.iat = getIntakeAirTemperature(this);
|
||||
engineState.clt = getCoolantTemperature(this);
|
||||
|
||||
Engine *engine = this;
|
||||
injectorLagMs = getInjectorLag(getVBatt(engineConfiguration) PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
void Engine::onTriggerEvent(uint64_t nowNt) {
|
||||
|
|
|
@ -128,6 +128,12 @@ public:
|
|||
EngineState engineState;
|
||||
uint64_t lastTriggerEventTimeNt;
|
||||
|
||||
/**
|
||||
* this value depends on a slow-changing VBatt value, so
|
||||
* we update it once in a while
|
||||
*/
|
||||
float injectorLagMs;
|
||||
|
||||
/**
|
||||
* This coefficient translates ADC value directly into voltage adjusted according to
|
||||
* voltage divider configuration. This is a future (?) performance optimization.
|
||||
|
|
|
@ -261,7 +261,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
|
|||
engineConfiguration->overrideCrankingIgnition = true;
|
||||
engineConfiguration->analogChartFrequency = 20;
|
||||
|
||||
engineConfiguration->algorithm = LM_MAF;
|
||||
engineConfiguration->algorithm = LM_PLAIN_MAF;
|
||||
|
||||
engineConfiguration->vbattDividerCoeff = ((float) (15 + 65)) / 15;
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ float getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
}
|
||||
|
||||
float getRunningFuel(float baseFuelMs, int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
float iatCorrection = getIatCorrection(getIntakeAirTemperature(engine) PASS_ENGINE_PARAMETER);
|
||||
float cltCorrection = getCltCorrection(getCoolantTemperature(engine) PASS_ENGINE_PARAMETER);
|
||||
float iatCorrection = getIatCorrection(engine->engineState.iat PASS_ENGINE_PARAMETER);
|
||||
float cltCorrection = getCltCorrection(engine->engineState.clt PASS_ENGINE_PARAMETER);
|
||||
|
||||
#if EFI_ACCEL_ENRICHMENT
|
||||
float accelEnrichment = getAccelEnrichment();
|
||||
|
|
|
@ -170,7 +170,7 @@ typedef enum {
|
|||
/**
|
||||
* raw Mass Air Flow sensor value algorithm. http://en.wikipedia.org/wiki/Mass_flow_sensor
|
||||
*/
|
||||
LM_MAF = 0,
|
||||
LM_PLAIN_MAF = 0,
|
||||
/**
|
||||
* Throttle Position Sensor value is used as engine load. http://en.wikipedia.org/wiki/Throttle_position_sensor
|
||||
*/
|
||||
|
|
|
@ -51,7 +51,8 @@ static volatile int perRevolutionCounter = 0;
|
|||
static volatile int perRevolution = 0;
|
||||
|
||||
/**
|
||||
* In this lock-free imlementation 'readIndex'
|
||||
* In this lock-free imlementation 'readIndex' is always pointing
|
||||
* to the consistent copy of accumulator and counter pair
|
||||
*/
|
||||
static int readIndex = 0;
|
||||
static float accumulators[2];
|
||||
|
@ -121,6 +122,18 @@ void mapAveragingCallback(adcsample_t adcValue) {
|
|||
}
|
||||
#endif /* EFI_ANALOG_CHART */
|
||||
|
||||
/**
|
||||
* Local copy is now safe, but it's an overkill: we only
|
||||
* have one writing thread anyway
|
||||
*/
|
||||
int readIndexLocal = readIndex;
|
||||
int writeIndex = readIndexLocal ^ 1;
|
||||
accumulators[writeIndex] = accumulators[readIndexLocal] + adcValue;
|
||||
counters[writeIndex] = counters[readIndexLocal] + 1;
|
||||
// this would commit the new pair of values
|
||||
readIndex = writeIndex;
|
||||
|
||||
// todo: migrate to the lock-free implementation
|
||||
chSysLockFromIsr()
|
||||
;
|
||||
// with locking we would have a consistent state
|
||||
|
@ -151,7 +164,7 @@ static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DE
|
|||
if (index != 0)
|
||||
return;
|
||||
|
||||
int rpm = getRpmE(engine);
|
||||
int rpm = engine->rpmCalculator.rpmValue;
|
||||
if (!isValidRpm(rpm))
|
||||
return;
|
||||
|
||||
|
@ -186,7 +199,7 @@ float getMapVoltage(void) {
|
|||
* @return Manifold Absolute Pressure, in kPa
|
||||
*/
|
||||
float getMap(void) {
|
||||
if (getRpm() == 0)
|
||||
if (!isValidRpm(engine->rpmCalculator.rpmValue))
|
||||
return getRawMap(); // maybe return NaN in case of stopped engine?
|
||||
return getMapByVoltage(v_averagedMapValue);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F) {
|
|||
efiAssert(engine!=NULL, "engine 2NULL", NAN);
|
||||
efiAssert(engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
|
||||
switch (engineConfiguration->algorithm) {
|
||||
case LM_MAF:
|
||||
case LM_PLAIN_MAF:
|
||||
return getMafT(engineConfiguration);
|
||||
case LM_SPEED_DENSITY:
|
||||
// SD engine load is used for timing lookup but not for fuel calculation
|
||||
|
|
|
@ -69,8 +69,8 @@ float getSpeedDensityFuel(Engine *engine, int rpm) {
|
|||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||
|
||||
float tps = getTPS(PASS_ENGINE_PARAMETER_F);
|
||||
float coolantC = getCoolantTemperature(engine);
|
||||
float intakeC = getIntakeAirTemperature(engine);
|
||||
float coolantC = engine->engineState.clt;
|
||||
float intakeC = engine->engineState.iat;
|
||||
float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC));
|
||||
float map = getMap();
|
||||
float VE = veMap.getValue(map, engineConfiguration->veLoadBins, rpm,
|
||||
|
|
|
@ -99,7 +99,7 @@ float RpmCalculator::getRpmAcceleration() {
|
|||
*
|
||||
* @return -1 in case of isNoisySignal(), current RPM otherwise
|
||||
*/
|
||||
// todo: migrate to float return result or add a float verion? this would have with calculations
|
||||
// todo: migrate to float return result or add a float version? this would have with calculations
|
||||
// todo: add a version which does not check time & saves time? need to profile
|
||||
int RpmCalculator::rpm(DECLARE_ENGINE_PARAMETER_F) {
|
||||
#if !EFI_PROD_CODE
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
float getRpmAcceleration();
|
||||
/**
|
||||
* This is public because sometimes we cannot afford to call isRunning() and the value is good enough
|
||||
* Zero if engine is not running
|
||||
*/
|
||||
volatile int rpmValue;
|
||||
int previousRpmValue;
|
||||
|
|
|
@ -55,6 +55,7 @@ void testFuelMap(void) {
|
|||
eth.engine.engineConfiguration->injector.battLagCorr[i] = 2 * i;
|
||||
}
|
||||
|
||||
eth.engine.updateSlowSensors();
|
||||
|
||||
// because all the correction tables are zero
|
||||
printf("*************************************************** getRunningFuel 1\r\n");
|
||||
|
|
|
@ -373,6 +373,7 @@ static void testRpmCalculator(void) {
|
|||
engine_configuration_s *engineConfiguration = ð.persistentConfig.engineConfiguration;
|
||||
|
||||
initThermistors(PASS_ENGINE_PARAMETER_F);
|
||||
engine->updateSlowSensors();
|
||||
|
||||
engineConfiguration->trigger.customTotalToothCount = 8;
|
||||
engineConfiguration->globalFuelCorrection = 3;
|
||||
|
@ -382,6 +383,7 @@ static void testRpmCalculator(void) {
|
|||
// engine.engineConfiguration = eth.engine.engineConfiguration;
|
||||
eth.engine.engineConfiguration->injector.lag = 0.0;
|
||||
|
||||
engine->updateSlowSensors();
|
||||
timeNow = 0;
|
||||
assertEquals(0, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
|
|
Loading…
Reference in New Issue