ETB online settings

This commit is contained in:
rusefi 2017-05-27 23:01:41 -04:00
parent ff454170d0
commit 3f40e95f0d
4 changed files with 24 additions and 5 deletions

View File

@ -162,6 +162,11 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__)
onConfigurationChangeAlternatorCallback(&activeConfiguration);
#endif /* EFI_ALTERNATOR_CONTROL */
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
onConfigurationChangeElectronicThrottleCallback(&activeConfiguration);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
rememberCurrentConfiguration();
}

View File

@ -55,6 +55,7 @@
#include "pin_repository.h"
#include "pwm_generator.h"
extern TunerStudioOutputChannels tsOutputChannels;
static bool shouldResetPid = false;
#define ETB_FREQ 400
@ -72,20 +73,26 @@ static SimplePwm etbPwmDown CCM_OPTIONAL;
static OutputPin outputDirectionOpen CCM_OPTIONAL;
static OutputPin outputDirectionClose CCM_OPTIONAL;
static pid_s etbS;
static Pid pid(&etbS, 0, 100);
EXTERN_ENGINE;
static Pid pid(&engineConfiguration->etb, 0, 100);
static float prevTps;
static float currentEtbDuty;
EXTERN_ENGINE;
static bool wasEtbBraking = false;
static msg_t etbThread(void *arg) {
UNUSED(arg);
while (true) {
if (shouldResetPid) {
pid.reset();
// alternatorPidResetCounter++;
shouldResetPid = false;
}
percent_t pedal = getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE);
percent_t tps = getTPS();
@ -176,6 +183,11 @@ void stopETBPins(void) {
unmarkPin(activeConfiguration.bc.etbDirectionPin2);
}
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration) {
shouldResetPid = !pid.isSame(&engineConfiguration->etb);
}
void startETBPins(void) {
// this line used for PWM
startSimplePwmExt(&etbPwmUp, "etb1",

View File

@ -8,11 +8,13 @@
#ifndef ELECTRONIC_THROTTLE_H_
#define ELECTRONIC_THROTTLE_H_
#include "engine.h"
void initElectronicThrottle(void);
void setDefaultEtbParameters(void);
void setEtbPFactor(float value);
void setEtbIFactor(float value);
void stopETBPins(void);
void startETBPins(void);
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration);
#endif /* ELECTRONIC_THROTTLE_H_ */

View File

@ -251,5 +251,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20170527;
return 20170528;
}