From bf36263a314881bcffe25d647d5a457734ffdb11 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sat, 2 Jul 2016 20:01:32 -0400 Subject: [PATCH] auto-sync --- firmware/config/engines/dodge_neon.cpp | 1 + firmware/controllers/algo/aux_pid.cpp | 19 ++++++++++++++++++- firmware/integration/rusefi_config.txt | 4 ++-- firmware/tunerstudio/rusefi.ini | 4 ++-- .../models/src/com/rusefi/config/Fields.java | 4 ++-- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 0962088aa4..42c414e029 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -438,6 +438,7 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { // boardConfiguration->clutchUpPin = GPIOA_14; // note SWCLK - conflict with SWD boardConfiguration->clutchUpPinMode = PI_PULLUP; + engineConfiguration->activateAuxPid1 = 1; engineConfiguration->auxPidPins[0] = GPIOD_5; // playing with AUX PID for alternator engineConfiguration->auxPidFrequency[0] = 300; diff --git a/firmware/controllers/algo/aux_pid.cpp b/firmware/controllers/algo/aux_pid.cpp index 15584028c9..41f1cc892f 100644 --- a/firmware/controllers/algo/aux_pid.cpp +++ b/firmware/controllers/algo/aux_pid.cpp @@ -14,10 +14,14 @@ #if EFI_AUX_PID || defined(__DOXYGEN__) #include "pwm_generator.h" #include "tunerstudio_configuration.h" +#include "fsio_impl.h" +#include "engine_math.h" EXTERN_ENGINE ; +extern fsio8_Map3D_f32t fsioTable1; + // todo: this is to some extent a copy-paste of alternatorController. maybe same loop // for all PIDs? @@ -42,8 +46,20 @@ static msg_t auxPidThread(int param) { if (parametersVersion.isOld()) auxPid.reset(); + float rpm = engine->rpmCalculator.rpmValue; + + // todo: make this configurable? + bool enabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm; + + if (!enabledAtCurrentRpm) { + // we need to avoid accumulating iTerm while engine is not running + auxPid.reset(); + continue; + } + + float value = getVBatt(PASS_ENGINE_PARAMETER_F); // that's temporary - float targetValue = engineConfiguration->targetVBatt; // that's temporary + float targetValue = fsioTable1.getValue(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_F)); float pwm = auxPid.getValue(targetValue, value, 1); if (engineConfiguration->isVerboseAuxPid) { @@ -55,6 +71,7 @@ static msg_t auxPidThread(int param) { if (engineConfiguration->debugMode == AUX_PID_1) { tsOutputChannels.debugFloatField1 = pwm; auxPid.postState(&tsOutputChannels); + tsOutputChannels.debugIntField3 = 10 * targetValue; } auxPid1.setSimplePwmDutyCycle(pwm / 100); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index d18fa48142..2e37fd84c7 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -96,8 +96,8 @@ float baseFuel;+Fuel squirt duration while cranking\nA number of curves adjust t int16_t rpm;+Cranking mode threshold. Special cranking logic controls fuel and spark while RPM is below this threshold;"RPM", 1, 0, 0, 3000, 0 end_struct -#define debug_mode_e_enum "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "mode6", "mode7" -custom debug_mode_e 4 bits, U32, @OFFSET@, [0:2], @@debug_mode_e_enum@@ +#define debug_mode_e_enum "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "mode8", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" +custom debug_mode_e 4 bits, U32, @OFFSET@, [0:3], @@debug_mode_e_enum@@ #define brain_input_pin_e_enum "INVALID", "INVALID", "PA2", "PA3", "INVALID", "PA5", "INVALID", "INVALID", "PA8", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PC6", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PE5", "INVALID", "PE7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 9745e9e91e..b73911f626 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -42,7 +42,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 Sat Jul 02 16:24:07 EDT 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Jul 02 18:47:29 EDT 2016 pageSize = 16376 page = 1 @@ -552,7 +552,7 @@ page = 1 tpsDecelEnleanmentThreshold = scalar, F32, 2232, "roc", 1, 0, 0, 200, 3 tpsDecelEnleanmentMultiplier = scalar, F32, 2236, "coeff", 1, 0, 0, 200, 3 slowAdcAlpha = scalar, F32, 2240, "coeff", 1, 0, 0, 200, 3 - debugMode = bits, U32, 2244, [0:2], "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "mode6", "mode7" + debugMode = bits, U32, 2244, [0:3], "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "mode8", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" warmupAfrPid_pFactor = scalar, F32, 2248, "value", 1, 0, 0, 1000, 5 warmupAfrPid_iFactor = scalar, F32, 2252, "value", 1, 0, 0, 1000, 5 warmupAfrPid_dFactor = scalar, F32, 2256, "value", 1, 0, 0, 1000, 5 diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 5d5e6f801f..de3683c4cc 100644 --- a/java_console/models/src/com/rusefi/config/Fields.java +++ b/java_console/models/src/com/rusefi/config/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config; -// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Jul 02 16:24:07 EDT 2016 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Jul 02 18:47:29 EDT 2016 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int FSIO_ADC_COUNT = 4; @@ -1432,7 +1432,7 @@ public class Fields { public static final Field TPSDECELENLEANMENTTHRESHOLD = Field.create("TPSDECELENLEANMENTTHRESHOLD", 2232, FieldType.FLOAT); public static final Field TPSDECELENLEANMENTMULTIPLIER = Field.create("TPSDECELENLEANMENTMULTIPLIER", 2236, FieldType.FLOAT); public static final Field SLOWADCALPHA = Field.create("SLOWADCALPHA", 2240, FieldType.FLOAT); - public static final String[] debug_mode_e = {"Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "mode6", "mode7"}; + public static final String[] debug_mode_e = {"Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "mode8", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15"}; public static final Field DEBUGMODE = Field.create("DEBUGMODE", 2244, FieldType.INT, debug_mode_e); public static final Field WARMUPAFRPID_PFACTOR = Field.create("WARMUPAFRPID_PFACTOR", 2248, FieldType.FLOAT); public static final Field WARMUPAFRPID_IFACTOR = Field.create("WARMUPAFRPID_IFACTOR", 2252, FieldType.FLOAT);