From 4d45716cc94574b1f7dda1f71052dd2f59dfd4c7 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 31 Jan 2016 16:01:26 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/engine_controller.cpp | 2 ++ firmware/controllers/sensors/tps.cpp | 4 ++-- firmware/hw_layer/adc_inputs.cpp | 14 +++++++++++++- firmware/hw_layer/adc_inputs.h | 4 ---- firmware/tunerstudio/rusefi.ini | 14 +++++++------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 62ee2defbe..6f531fe9f7 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -240,6 +240,8 @@ static void periodicSlowCallback(Engine *engine) { * listeners we invoke them from here. */ engine->configurationListeners.invokeJustArgCallbacks(); + // todo: convert to a callback? + updateAccelParameters(); } engine->watchdog(); diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index dc7274a9a4..6804354b40 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -95,8 +95,8 @@ int getTPS10bitAdc(DECLARE_ENGINE_PARAMETER_F) { /** * @brief Position on physical primary TPS */ -static float getPrimatyRawTPS(DECLARE_ENGINE_PARAMETER_F) { - float tpsValue = getTpsValue(getTPS10bitAdc(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER); +static percent_t getPrimatyRawTPS(DECLARE_ENGINE_PARAMETER_F) { + percent_t tpsValue = getTpsValue(getTPS10bitAdc(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER); return tpsValue; } diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 808246ae43..f6950acd66 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -25,6 +25,11 @@ #include "board_test.h" #include "engine_controller.h" +/* Depth of the conversion buffer, channels are sampled X times each.*/ +#define ADC_BUF_DEPTH_SLOW 8 +#define ADC_BUF_DEPTH_FAST 4 + + static adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX]; static const char * adcHwChannelUsage[HW_MAX_ADC_INDEX]; @@ -206,7 +211,10 @@ int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) { if (adcHwChannelEnabled[hwChannel] == ADC_FAST) { int internalIndex = fastAdc.internalAdcIndexByHardwareIndex[hwChannel]; - return fastAdc.samples[internalIndex]; +// todo if ADC_BUF_DEPTH_FAST EQ 1 +// return fastAdc.samples[internalIndex]; + int value = getAvgAdcValue(internalIndex, fastAdc.samples, ADC_BUF_DEPTH_FAST, fastAdc.size()); + return value; } if (adcHwChannelEnabled[hwChannel] != ADC_SLOW) { warning(OBD_PCM_Processor_Fault, "ADC is off [%s] index=%d", msg, hwChannel); @@ -504,6 +512,10 @@ static void configureInputs(void) { void initAdcInputs(bool boardTestMode) { printMsg(&logger, "initAdcInputs()"); + if (ADC_BUF_DEPTH_FAST > MAX_ADC_GRP_BUF_DEPTH) + firmwareError("ADC_BUF_DEPTH_FAST too high"); + if (ADC_BUF_DEPTH_SLOW > MAX_ADC_GRP_BUF_DEPTH) + firmwareError("ADC_BUF_DEPTH_SLOW too high"); configureInputs(); diff --git a/firmware/hw_layer/adc_inputs.h b/firmware/hw_layer/adc_inputs.h index 56680ccbe7..660c93525f 100644 --- a/firmware/hw_layer/adc_inputs.h +++ b/firmware/hw_layer/adc_inputs.h @@ -26,10 +26,6 @@ int getAdcHardwareIndexByInternalIndex(int index); void printFullAdcReportIfNeeded(void); int getInternalAdcValue(const char *msg, adc_channel_e index); -/* Depth of the conversion buffer, channels are sampled X times each.*/ -#define ADC_BUF_DEPTH_SLOW 8 -#define ADC_BUF_DEPTH_FAST 1 - // max(ADC_BUF_DEPTH_SLOW, ADC_BUF_DEPTH_FAST) #define MAX_ADC_GRP_BUF_DEPTH 8 diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index d0a2750499..e73a8738b1 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -41,7 +41,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 29 20:39:58 EST 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jan 31 12:30:25 EST 2016 pageSize = 16088 page = 1 @@ -504,10 +504,10 @@ page = 1 alternatorControl_pFactor = scalar, F32, 2172, "value", 1, 0, 0, 1000, 2 alternatorControl_iFactor = scalar, F32, 2176, "value", 1, 0, 0, 1000, 2 alternatorControl_dFactor = scalar, F32, 2180, "value", 1, 0, 0, 1000, 2 - tpsAccelLength = scalar, S32, 2184, "len", 1, 0, 1, 200, 3 + tpsAccelLength = scalar, S32, 2184, "cycles", 1, 0, 1, 200, 0 tpsAccelEnrichmentThreshold = scalar, F32, 2188, "roc", 1, 0, 0, 200, 3 tpsAccelEnrichmentMultiplier = scalar, F32, 2192, "coeff", 1, 0, 0, 200, 3 - engineLoadAccelLength = scalar, S32, 2196, "len", 1, 0, 1, 200, 3 + engineLoadAccelLength = scalar, S32, 2196, "cycles", 1, 0, 1, 200, 0 engineLoadDecelEnleanmentThreshold = scalar, F32, 2200, "roc", 1, 0, 0, 200, 3 engineLoadDecelEnleanmentMultiplier = scalar, F32, 2204, "coeff", 1, 0, 0, 200, 3 engineLoadAccelEnrichmentThreshold = scalar, F32, 2208, "roc", 1, 0, 0, 200, 3 @@ -894,7 +894,7 @@ fileVersion = { 20160122 } #endif - throttleGauge = TPS, "Throttle Position", "%", 0, 100, 0, 0, 100, 100, 0, 0 + throttleGauge = TPS, "Throttle Position", "%", 0, 100, 0, 0, 100, 100, 2, 2 afr1Gauge = AFRactual, "Air:Fuel Ratio 1", "", 10, 19.4, 12, 13, 15, 16, 2, 2 mafGaugeVolts = MAF, "Mass Air Flow", "v", 0, 5, 0, 1, 3, 4, 1, 1 VBattGauge = VBatt, "Battery Voltage", "V", 8, 21, 9, 10, 17, 19, 1, 1 @@ -917,7 +917,7 @@ fileVersion = { 20160122 } rpmAccelerationGa = rpmAcceleration, "rpm delta", "dRpm", 0, 3, 0, 1, 3, 4, 1, 1 massAirFlowValueGa = massAirFlowValue,"Air Flow", "kg/hr", 0, 50, -999, -999, 999, 999, 1, 1 veValueGauge = veValue, "fuel: VE", "", 0, 120, 10, 10, 100, 100, 1, 1 - deltaTpsGauge = deltaTps, "fuel: tps delta", "", 0, 120, 10, 10, 100, 100, 1, 1 + deltaTpsGauge = deltaTps, "fuel: TPS delta", "", 0, 120, 10, 10, 100, 100, 1, 1 baroCorrectionGauge = baroCorrection,"BaroCorr", "%", 0, 120, 10, 10, 100, 100, 1, 1 pedalPositionGauge = pedalPosition,"Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1 knockCountGauge = knockCount,"Knock count", "count", 0, 120, 10, 10, 100, 100, 1, 1 @@ -994,7 +994,7 @@ fileVersion = { 20160122 } entry = rpm, "RPM", int, "%d" entry = coolant, "CLT", float, "%.2f" entry = intake, "IAT", float, "%.2f" - entry = TPS, "TPS", float, "%d" + entry = TPS, "TPS", float, "%.2f" entry = MAF, "MAF", float, "%.2f" entry = MAPValue, "MAP", float, "%.1f" entry = AFRactual, "AFR", float, "%.2f" @@ -1008,7 +1008,7 @@ fileVersion = { 20160122 } entry = pedalPosition, "pedal", float, "%.3f" entry = triggerErrorsCounter, "trg err",int, "%d" - entry = pulseWidth, "injPulse", float, "%.3f" + entry = pulseWidth, "fuel: pulse", float, "%.3f" entry = baseFuel, "fuel: base", float, "%.2f" entry = veValue, "fuel: VE", float, "%.3f" entry = engineLoadAccelDelta, "fuel: EL delta",float, "%.3f"