From 55859f8073d1478441455ff2e92acaf00199c940 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 11 Apr 2015 00:04:25 -0500 Subject: [PATCH] auto-sync --- firmware/config/engines/dodge_neon.cpp | 2 +- firmware/console/status_loop.cpp | 6 +++--- firmware/controllers/algo/accel_enrichment.cpp | 17 ++++++++++------- firmware/controllers/algo/accel_enrichment.h | 4 +++- firmware/controllers/algo/engine.h | 3 ++- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/engine_controller.cpp | 3 ++- firmware/controllers/math/speed_density.cpp | 2 +- firmware/controllers/sensors/tps.cpp | 6 ++++++ .../trigger/main_trigger_callback.cpp | 2 +- firmware/hw_layer/hardware.cpp | 4 +++- 11 files changed, 33 insertions(+), 18 deletions(-) diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 73c05f1458..5544de172c 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -333,7 +333,7 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->adcHwChannelEnabled[12] = ADC_SLOW; // CLT boardConfiguration->adcHwChannelEnabled[13] = ADC_SLOW; // AFR boardConfiguration->adcHwChannelEnabled[14] = ADC_SLOW; // VBatt - boardConfiguration->adcHwChannelEnabled[15] = ADC_SLOW; // TPS + boardConfiguration->adcHwChannelEnabled[15] = ADC_FAST; // TPS /** diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index b87febd8de..cec185e00b 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -556,9 +556,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->manifold_air_pressure = getMap(); tsOutputChannels->engineLoad = engineLoad; tsOutputChannels->rpmAcceleration = engine->rpmCalculator.getRpmAcceleration(); - tsOutputChannels->maxDelta = engine->accelEnrichment.maxDelta; - tsOutputChannels->minDelta = engine->accelEnrichment.minDelta; - tsOutputChannels->currentMapAccelDelta = engine->accelEnrichment.getEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); + tsOutputChannels->maxDelta = engine->mapAccelEnrichment.maxDelta; + tsOutputChannels->minDelta = engine->mapAccelEnrichment.minDelta; + tsOutputChannels->currentMapAccelDelta = engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(); tsOutputChannels->checkEngine = hasErrorCodes(); #if EFI_PROD_CODE || defined(__DOXYGEN__) diff --git a/firmware/controllers/algo/accel_enrichment.cpp b/firmware/controllers/algo/accel_enrichment.cpp index 43c34c5ab5..e6c7fe599d 100644 --- a/firmware/controllers/algo/accel_enrichment.cpp +++ b/firmware/controllers/algo/accel_enrichment.cpp @@ -21,8 +21,6 @@ EXTERN_ENGINE //static THD_WORKING_AREA(aeThreadStack, UTILITY_THREAD_STACK_SIZE); //#endif -static AccelEnrichmemnt mapInstance; -static AccelEnrichmemnt tpsInstance; static Logging *logger; void AccelEnrichmemnt::updateDiffEnrichment(engine_configuration_s *engineConfiguration, float engineLoad) { @@ -39,7 +37,7 @@ void AccelEnrichmemnt::updateDiffEnrichment(engine_configuration_s *engineConfig // return diffEnrichment; //} -float AccelEnrichmemnt::getEnrichment(DECLARE_ENGINE_PARAMETER_F) { +float AccelEnrichmemnt::getMapEnrichment(DECLARE_ENGINE_PARAMETER_F) { float d = cb.maxValue(cb.getSize()); if (d > engineConfiguration->mapAccelEnrichmentThreshold) { return d * engineConfiguration->mapAccelEnrichmentMultiplier; @@ -57,6 +55,11 @@ void AccelEnrichmemnt::reset() { currentEngineLoad = NAN; } +void AccelEnrichmemnt::onEngineCycleTps(DECLARE_ENGINE_PARAMETER_F) { + float tps = getTPS(); + cb.add(delta); +} + void AccelEnrichmemnt::onEngineCycle(DECLARE_ENGINE_PARAMETER_F) { float currentEngineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); @@ -105,11 +108,11 @@ AccelEnrichmemnt::AccelEnrichmemnt() { #if ! EFI_UNIT_TEST || defined(__DOXYGEN__) static void accelInfo() { - scheduleMsg(logger, "MAP accel length=%d", mapInstance.cb.getSize()); +// scheduleMsg(logger, "MAP accel length=%d", mapInstance.cb.getSize()); scheduleMsg(logger, "MAP accel th=%f/mult=%f", engineConfiguration->mapAccelEnrichmentThreshold, engineConfiguration->mapAccelEnrichmentMultiplier); scheduleMsg(logger, "MAP decel th=%f/mult=%f", engineConfiguration->decelEnrichmentThreshold, engineConfiguration->decelEnrichmentMultiplier); - scheduleMsg(logger, "TPS accel length=%d", tpsInstance.cb.getSize()); +// scheduleMsg(logger, "TPS accel length=%d", tpsInstance.cb.getSize()); scheduleMsg(logger, "TPS accel th=%f/mult=%f", engineConfiguration->tpsAccelEnrichmentThreshold, engineConfiguration->tpsAccelEnrichmentMultiplier); } @@ -144,12 +147,12 @@ static void setDecelMult(float value) { } static void setTpsAccelLen(int len) { - tpsInstance.cb.setSize(len); + engine->tpsAccelEnrichment.cb.setSize(len); accelInfo(); } static void setMapAccelLen(int len) { - mapInstance.cb.setSize(len); + engine->mapAccelEnrichment.cb.setSize(len); accelInfo(); } diff --git a/firmware/controllers/algo/accel_enrichment.h b/firmware/controllers/algo/accel_enrichment.h index 80dc5d1acc..de8a3d6861 100644 --- a/firmware/controllers/algo/accel_enrichment.h +++ b/firmware/controllers/algo/accel_enrichment.h @@ -20,10 +20,12 @@ public: AccelEnrichmemnt(); void updateDiffEnrichment(engine_configuration_s *engineConfiguration, float engineLoad); - float getEnrichment(DECLARE_ENGINE_PARAMETER_F); + float getMapEnrichment(DECLARE_ENGINE_PARAMETER_F); + float getTpsEnrichment(DECLARE_ENGINE_PARAMETER_F); // float getDiffEnrichment(void); void onEngineCycle(DECLARE_ENGINE_PARAMETER_F); + void onEngineCycleTps(DECLARE_ENGINE_PARAMETER_F); void reset(); float currentEngineLoad; float maxDelta; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 3c6ef6e34d..0335e66c1b 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -133,7 +133,8 @@ public: Thermistor iat; Thermistor clt; - AccelEnrichmemnt accelEnrichment; + AccelEnrichmemnt mapAccelEnrichment; + AccelEnrichmemnt tpsAccelEnrichment; /** * Fuel injection duration for current engine cycle diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index d427f87f37..f6afa0776d 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -76,7 +76,7 @@ float getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { if (engineConfiguration->algorithm == LM_SPEED_DENSITY) { return getSpeedDensityFuel(rpm PASS_ENGINE_PARAMETER); } else if (engineConfiguration->algorithm == LM_REAL_MAF) { - float maf = getRealMaf(PASS_ENGINE_PARAMETER_F) + engine->accelEnrichment.getEnrichment(PASS_ENGINE_PARAMETER_F); + float maf = getRealMaf(PASS_ENGINE_PARAMETER_F) + engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); return getRealMafFuel(maf, rpm PASS_ENGINE_PARAMETER); } else { float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 78fed4516c..642dd30b43 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -395,7 +395,8 @@ static void setFloat(const char *offsetStr, const char *valueStr) { #if EFI_PROD_CODE || defined(__DOXYGEN__) static void resetAccel(void) { - engine->accelEnrichment.reset(); + engine->mapAccelEnrichment.reset(); + engine->tpsAccelEnrichment.reset(); } #endif diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 4ae4bedc13..1a3bb6381f 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -85,7 +85,7 @@ float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { float coolantC = engine->engineState.clt; float intakeC = engine->engineState.iat; float tChargeK = convertCelsiusToKelvin(getTCharge(rpm, tps, coolantC, intakeC)); - float map = getMap() + engine->accelEnrichment.getEnrichment(PASS_ENGINE_PARAMETER_F); + float map = getMap() + engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); /** * *0.01 because of https://sourceforge.net/p/rusefi/tickets/153/ */ diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index 9648007951..f96cfc9fd7 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -17,6 +17,8 @@ */ static tps_roc_s states[2]; +int tpsFastAdc = 0; + static volatile int tpsRocIndex = 0; /** @@ -85,6 +87,10 @@ int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) { #endif if(engineConfiguration->tpsAdcChannel==EFI_ADC_NONE) return -1; +#if EFI_PROD_CODE + if(boardConfiguration->adcHwChannelEnabled[engineConfiguration->tpsAdcChannel]==ADC_FAST) + return tpsFastAdc / 4; +#endif /* EFI_PROD_CODE */ int adc = getAdcValue(engineConfiguration->tpsAdcChannel); return (int) adc / 4; // Only for TunerStudio compatibility. Max TS adc value in 1023 } diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index ff06643b44..e1d92a0f44 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -357,7 +357,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL } if (eventIndex == 0) { - engine->accelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F); + engine->mapAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F); engine->m.beforeFuelCalc = GET_TIMESTAMP(); ENGINE(fuelMs) = getFuelMs(rpm PASS_ENGINE_PARAMETER) * engineConfiguration->globalFuelCorrection; engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc; diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 41d412b061..ec2829a679 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -140,6 +140,8 @@ static int fastMapSampleIndex; static int hipSampleIndex; static int tpsSampleIndex; +extern int tpsFastAdc; + /** * This method is not in the adc* lower-level file because it is more business logic then hardware. */ @@ -167,7 +169,7 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) { } #endif if(tpsSampleIndex!=TPS_IS_SLOW) { - + tpsFastAdc = fastAdc.samples[tpsSampleIndex]; } } }