auto-sync
This commit is contained in:
parent
a8836cfc30
commit
65f430f464
|
@ -1,15 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* @file aux_pid.cpp
|
* @file aux_pid.cpp
|
||||||
*
|
*
|
||||||
|
* This class is a copy-paste of alternatorController.cpp TODO: do something about it? extract more common logic?
|
||||||
|
*
|
||||||
* @date Jun 26, 2016
|
* @date Jun 26, 2016
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2016
|
* @author Andrey Belomutskiy, (c) 2012-2016
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "aux_pid.h"
|
#include "aux_pid.h"
|
||||||
#include "LocalVersionHolder.h"
|
#include "LocalVersionHolder.h"
|
||||||
|
#include "allsensors.h"
|
||||||
|
|
||||||
#if EFI_AUX_PID || defined(__DOXYGEN__)
|
#if EFI_AUX_PID || defined(__DOXYGEN__)
|
||||||
#include "pwm_generator.h"
|
#include "pwm_generator.h"
|
||||||
|
#include "tunerstudio_configuration.h"
|
||||||
|
|
||||||
EXTERN_ENGINE
|
EXTERN_ENGINE
|
||||||
;
|
;
|
||||||
|
@ -17,13 +21,16 @@ EXTERN_ENGINE
|
||||||
// todo: this is to some extent a copy-paste of alternatorController. maybe same loop
|
// todo: this is to some extent a copy-paste of alternatorController. maybe same loop
|
||||||
// for all PIDs?
|
// for all PIDs?
|
||||||
|
|
||||||
|
extern TunerStudioOutputChannels tsOutputChannels;
|
||||||
|
|
||||||
static THD_WORKING_AREA(auxPidThreadStack, UTILITY_THREAD_STACK_SIZE);
|
static THD_WORKING_AREA(auxPidThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
static LocalVersionHolder parametersVersion;
|
static LocalVersionHolder parametersVersion;
|
||||||
static SimplePwm auxPid1;
|
static SimplePwm auxPid1;
|
||||||
static OutputPin auxPid1Pin;
|
static OutputPin auxPid1Pin;
|
||||||
static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl;
|
static pid_s *auxPidS = &persistentState.persistentConfiguration.engineConfiguration.auxPid1;
|
||||||
static Pid altPid(altPidS, 1, 90);
|
static Pid auxPid(auxPidS, 1, 90);
|
||||||
|
static Logging *logger;
|
||||||
|
|
||||||
static msg_t auxPidThread(int param) {
|
static msg_t auxPidThread(int param) {
|
||||||
UNUSED(param);
|
UNUSED(param);
|
||||||
|
@ -33,8 +40,24 @@ static msg_t auxPidThread(int param) {
|
||||||
chThdSleepMilliseconds(dt);
|
chThdSleepMilliseconds(dt);
|
||||||
|
|
||||||
if (parametersVersion.isOld())
|
if (parametersVersion.isOld())
|
||||||
altPid.reset();
|
auxPid.reset();
|
||||||
|
|
||||||
|
float value = getVBatt(PASS_ENGINE_PARAMETER_F); // that's temporary
|
||||||
|
float targetValue = engineConfiguration->targetVBatt; // that's temporary
|
||||||
|
|
||||||
|
float pwm = auxPid.getValue(targetValue, value, 1);
|
||||||
|
if (engineConfiguration->isVerboseAuxPid) {
|
||||||
|
scheduleMsg(logger, "aux duty: %f/value=%f/p=%f/i=%f/d=%f int=%f", pwm, value,
|
||||||
|
auxPid.getP(), auxPid.getI(), auxPid.getD(), auxPid.getIntegration());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (engineConfiguration->debugMode == AUX_PID_1) {
|
||||||
|
tsOutputChannels.debugFloatField1 = pwm;
|
||||||
|
auxPid.postState(&tsOutputChannels);
|
||||||
|
}
|
||||||
|
|
||||||
|
auxPid1.setSimplePwmDutyCycle(pwm / 100);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +70,8 @@ void initAuxPid(Logging *sharedLogger) {
|
||||||
chThdCreateStatic(auxPidThreadStack, sizeof(auxPidThreadStack), LOWPRIO,
|
chThdCreateStatic(auxPidThreadStack, sizeof(auxPidThreadStack), LOWPRIO,
|
||||||
(tfunc_t) auxPidThread, NULL);
|
(tfunc_t) auxPidThread, NULL);
|
||||||
|
|
||||||
|
logger = sharedLogger;
|
||||||
|
|
||||||
if (engineConfiguration->activateAuxPid1) {
|
if (engineConfiguration->activateAuxPid1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 26 20:48:53 EDT 2016
|
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jun 30 21:51:57 EDT 2016
|
||||||
// begin
|
// begin
|
||||||
#ifndef ENGINE_CONFIGURATION_GENERATED_H_
|
#ifndef ENGINE_CONFIGURATION_GENERATED_H_
|
||||||
#define ENGINE_CONFIGURATION_GENERATED_H_
|
#define ENGINE_CONFIGURATION_GENERATED_H_
|
||||||
|
@ -785,7 +785,7 @@ typedef struct {
|
||||||
bool activateAuxPid1 : 1;
|
bool activateAuxPid1 : 1;
|
||||||
/**
|
/**
|
||||||
offset 80 bit 2 */
|
offset 80 bit 2 */
|
||||||
bool issue_294_2 : 1;
|
bool isVerboseAuxPid : 1;
|
||||||
/**
|
/**
|
||||||
offset 80 bit 3 */
|
offset 80 bit 3 */
|
||||||
bool issue_294_3 : 1;
|
bool issue_294_3 : 1;
|
||||||
|
@ -1832,4 +1832,4 @@ typedef struct {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// end
|
// end
|
||||||
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 26 20:48:53 EDT 2016
|
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jun 30 21:51:57 EDT 2016
|
||||||
|
|
|
@ -599,6 +599,7 @@ typedef enum {
|
||||||
DBG_EL_ACCEL = 4,
|
DBG_EL_ACCEL = 4,
|
||||||
TRIGGER_COUNT = 5,
|
TRIGGER_COUNT = 5,
|
||||||
FSIO_ADC = 6,
|
FSIO_ADC = 6,
|
||||||
|
AUX_PID_1 = 7,
|
||||||
|
|
||||||
Force_4b_debug_mode_e = ENUM_32_BITS,
|
Force_4b_debug_mode_e = ENUM_32_BITS,
|
||||||
} debug_mode_e;
|
} debug_mode_e;
|
||||||
|
|
|
@ -47,8 +47,8 @@
|
||||||
#define directSelfStimulation_offset_hex 50
|
#define directSelfStimulation_offset_hex 50
|
||||||
#define activateAuxPid1_offset 80
|
#define activateAuxPid1_offset 80
|
||||||
#define activateAuxPid1_offset_hex 50
|
#define activateAuxPid1_offset_hex 50
|
||||||
#define issue_294_2_offset 80
|
#define isVerboseAuxPid_offset 80
|
||||||
#define issue_294_2_offset_hex 50
|
#define isVerboseAuxPid_offset_hex 50
|
||||||
#define issue_294_3_offset 80
|
#define issue_294_3_offset 80
|
||||||
#define issue_294_3_offset_hex 50
|
#define issue_294_3_offset_hex 50
|
||||||
#define issue_294_4_offset 80
|
#define issue_294_4_offset 80
|
||||||
|
|
|
@ -86,7 +86,7 @@ static msg_t AltCtrlThread(int param) {
|
||||||
|
|
||||||
currentAltDuty = altPid.getValue(targetVoltage, vBatt, 1);
|
currentAltDuty = altPid.getValue(targetVoltage, vBatt, 1);
|
||||||
if (boardConfiguration->isVerboseAlternator) {
|
if (boardConfiguration->isVerboseAlternator) {
|
||||||
scheduleMsg(logger, "alt duty: %f/vbatt=%f/p=%f/i=%f/d=%f int=%f", currentAltDuty, getVBatt(PASS_ENGINE_PARAMETER_F),
|
scheduleMsg(logger, "alt duty: %f/vbatt=%f/p=%f/i=%f/d=%f int=%f", currentAltDuty, vBatt,
|
||||||
altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration());
|
altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -856,6 +856,8 @@ static void enableOrDisable(const char *param, bool isEnabled) {
|
||||||
engineConfiguration->isJoystickEnabled = isEnabled;
|
engineConfiguration->isJoystickEnabled = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "HIP9011")) {
|
} else if (strEqualCaseInsensitive(param, "HIP9011")) {
|
||||||
boardConfiguration->isHip9011Enabled = isEnabled;
|
boardConfiguration->isHip9011Enabled = isEnabled;
|
||||||
|
} else if (strEqualCaseInsensitive(param, "auxdebug")) {
|
||||||
|
engineConfiguration->isVerboseAuxPid = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "altdebug")) {
|
} else if (strEqualCaseInsensitive(param, "altdebug")) {
|
||||||
boardConfiguration->isVerboseAlternator = isEnabled;
|
boardConfiguration->isVerboseAlternator = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "tpic_advanced_mode")) {
|
} else if (strEqualCaseInsensitive(param, "tpic_advanced_mode")) {
|
||||||
|
|
|
@ -167,7 +167,7 @@ injector_s injector
|
||||||
|
|
||||||
bit directSelfStimulation;+Should trigger emulator push data right into trigger handling logic, eliminating the need for physical jumper wires?\nPS: Funny name, right? :)
|
bit directSelfStimulation;+Should trigger emulator push data right into trigger handling logic, eliminating the need for physical jumper wires?\nPS: Funny name, right? :)
|
||||||
bit activateAuxPid1;
|
bit activateAuxPid1;
|
||||||
bit issue_294_2;
|
bit isVerboseAuxPid;
|
||||||
bit issue_294_3;
|
bit issue_294_3;
|
||||||
bit issue_294_4;
|
bit issue_294_4;
|
||||||
bit issue_294_5;
|
bit issue_294_5;
|
||||||
|
|
|
@ -42,7 +42,7 @@ enable2ndByteCanID = false
|
||||||
|
|
||||||
; see PAGE_0_SIZE in C source code
|
; see PAGE_0_SIZE in C source code
|
||||||
; CONFIG_DEFINITION_START
|
; CONFIG_DEFINITION_START
|
||||||
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 26 20:48:53 EDT 2016
|
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jun 30 21:51:57 EDT 2016
|
||||||
|
|
||||||
pageSize = 17080
|
pageSize = 17080
|
||||||
page = 1
|
page = 1
|
||||||
|
@ -54,7 +54,7 @@ page = 1
|
||||||
injector_battLagCorr = array, F32, 48, [8], "ms/V", 1, 0, 0.0, 50.0, 2
|
injector_battLagCorr = array, F32, 48, [8], "ms/V", 1, 0, 0.0, 50.0, 2
|
||||||
directSelfStimulation = bits, U32, 80, [0:0], "false", "true"
|
directSelfStimulation = bits, U32, 80, [0:0], "false", "true"
|
||||||
activateAuxPid1 = bits, U32, 80, [1:1], "false", "true"
|
activateAuxPid1 = bits, U32, 80, [1:1], "false", "true"
|
||||||
issue_294_2 = bits, U32, 80, [2:2], "false", "true"
|
isVerboseAuxPid = bits, U32, 80, [2:2], "false", "true"
|
||||||
issue_294_3 = bits, U32, 80, [3:3], "false", "true"
|
issue_294_3 = bits, U32, 80, [3:3], "false", "true"
|
||||||
issue_294_4 = bits, U32, 80, [4:4], "false", "true"
|
issue_294_4 = bits, U32, 80, [4:4], "false", "true"
|
||||||
issue_294_5 = bits, U32, 80, [5:5], "false", "true"
|
issue_294_5 = bits, U32, 80, [5:5], "false", "true"
|
||||||
|
@ -578,7 +578,7 @@ page = 1
|
||||||
auxPid1_iFactor = scalar, F32, 2416, "value", 1, 0, 0, 1000, 5
|
auxPid1_iFactor = scalar, F32, 2416, "value", 1, 0, 0, 1000, 5
|
||||||
auxPid1_dFactor = scalar, F32, 2420, "value", 1, 0, 0, 1000, 5
|
auxPid1_dFactor = scalar, F32, 2420, "value", 1, 0, 0, 1000, 5
|
||||||
auxPid1_offset = scalar, F32, 2424, "value", 1, 0, 0, 1000, 3
|
auxPid1_offset = scalar, F32, 2424, "value", 1, 0, 0, 1000, 3
|
||||||
crankingIdleAdjustment = scalar, F32, 2428, "value", 1, 0, -100.0, 100,
|
crankingIdleAdjustment = scalar, F32, 2428, "percent", 1, 0, -100.0, 100,
|
||||||
;skipping unused offset 2432
|
;skipping unused offset 2432
|
||||||
le_formulas1 = array, U08, 3048, [200],"char", 1, 0, 0.0, 3.0, 2
|
le_formulas1 = array, U08, 3048, [200],"char", 1, 0, 0.0, 3.0, 2
|
||||||
le_formulas2 = array, U08, 3248, [200],"char", 1, 0, 0.0, 3.0, 2
|
le_formulas2 = array, U08, 3248, [200],"char", 1, 0, 0.0, 3.0, 2
|
||||||
|
@ -1625,6 +1625,7 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01"
|
||||||
field = "Enabled", activateAuxPid1
|
field = "Enabled", activateAuxPid1
|
||||||
field = "FSIO pin #1", fsioPins1
|
field = "FSIO pin #1", fsioPins1
|
||||||
field = "PWM Frequency", fsioFrequency1
|
field = "PWM Frequency", fsioFrequency1
|
||||||
|
field = "verbose", isVerboseAuxPid
|
||||||
field = "#target based on FSIO map#1"
|
field = "#target based on FSIO map#1"
|
||||||
field = "control period", auxPid1DT, {activateAuxPid1 == 1}
|
field = "control period", auxPid1DT, {activateAuxPid1 == 1}
|
||||||
field = "#PID control"
|
field = "#PID control"
|
||||||
|
|
Loading…
Reference in New Issue