ETB progress

This commit is contained in:
rusefi 2019-04-24 23:46:49 -04:00
parent 2baca12920
commit 7a857ae298
4 changed files with 29 additions and 4 deletions

View File

@ -350,7 +350,25 @@ void setTle8888TestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->fuelPumpPin = TLE8888_PIN_20;
engineConfiguration->tpsAdcChannel = EFI_ADC_3; // PA3
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_4; // PA4
engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7; // PA7
engineConfiguration->etb.pFactor = 1.07;
engineConfiguration->etb.iFactor = 0.18;
engineConfiguration->etb.dFactor = 0.24;
engineConfiguration->etb.offset = 80;
#if EFI_PROD_CODE
engineConfiguration->etb.periodMs = (1000 / DEFAULT_ETB_LOOP_FREQUENCY);
engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
#endif
engineConfiguration->etb_iTermMin = -300;
engineConfiguration->etb_iTermMax = 300;
// VAG test ETB, no divider on red board - direct 3v TPS sensor
// set tps_min 332
engineConfiguration->tpsMin = 332;
// by the way this ETB has default position of ADC=74 which is about 4%
// set tps_max 540
engineConfiguration->tpsMax = 799;
}
#endif /* CONFIG_ENGINES_CUSTOM_ENGINE_CPP_ */

View File

@ -232,7 +232,7 @@ private:
}
*/
currentEtbDuty = feedForward +
pid.getOutput(targetPosition, actualThrottlePosition);
pid.getOutput(targetPosition, actualThrottlePosition, engineConfiguration->etb.periodMs / 1000.0);
etb1.dcMotor.Set(PERCENT_TO_DUTY(currentEtbDuty));
/*
@ -349,8 +349,8 @@ void setDefaultEtbParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->etb.pFactor = 1;
engineConfiguration->etb.iFactor = 0.05;
engineConfiguration->etb.dFactor = 0.0;
engineConfiguration->etb.periodMs = 100;
engineConfiguration->etbFreq = 300;
engineConfiguration->etb.periodMs = (1000 / DEFAULT_ETB_LOOP_FREQUENCY);
engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
engineConfiguration->etb_iTermMin = -300;
engineConfiguration->etb_iTermMax = 300;

View File

@ -8,6 +8,10 @@
#ifndef ELECTRONIC_THROTTLE_H_
#define ELECTRONIC_THROTTLE_H_
// https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem
#define DEFAULT_ETB_LOOP_FREQUENCY 200
#define DEFAULT_ETB_PWM_FREQUENCY 300
#include "engine.h"
void initElectronicThrottle(void);
void setDefaultEtbBiasCurve(DECLARE_ENGINE_PARAMETER_SIGNATURE);

View File

@ -56,6 +56,9 @@ float Pid::getUnclampedOutput(float target, float input, float dTime) {
return pTerm + iTerm + dTerm + pid->offset;
}
/**
* @param dTime seconds probably? :)
*/
float Pid::getOutput(float target, float input, float dTime) {
float output = getUnclampedOutput(target, input, dTime);