ETB target is using integer values #945

first we will write a unit test
This commit is contained in:
rusEfi 2019-09-22 00:36:13 -04:00
parent f843968636
commit e29318b939
3 changed files with 15 additions and 7 deletions

View File

@ -211,7 +211,7 @@ public:
return; return;
} }
percent_t actualThrottlePosition = getTPS(); percent_t actualThrottlePosition = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
if (engine->etbAutoTune) { if (engine->etbAutoTune) {
autoTune.input = actualThrottlePosition; autoTune.input = actualThrottlePosition;
@ -302,6 +302,7 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor))
/* DISPLAY_ELSE */ /* DISPLAY_ELSE */
DISPLAY_TEXT(No_Pedal_Sensor); DISPLAY_TEXT(No_Pedal_Sensor);
/* DISPLAY_ENDIF */ /* DISPLAY_ENDIF */
#if EFI_TUNER_STUDIO
// 312 // 312
tsOutputChannels.etbTarget = targetPosition; tsOutputChannels.etbTarget = targetPosition;
// 316 // 316
@ -309,6 +310,7 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor))
// 320 // 320
// Error is positive if the throttle needs to open further // Error is positive if the throttle needs to open further
tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition; tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition;
#endif /* EFI_TUNER_STUDIO */
} }
}; };
@ -331,6 +333,7 @@ void setThrottleDutyCycle(percent_t level) {
scheduleMsg(&logger, "duty ETB duty=%f", dc); scheduleMsg(&logger, "duty ETB duty=%f", dc);
} }
#if EFI_PROD_CODE
static void showEthInfo(void) { static void showEthInfo(void) {
static char pinNameBuffer[16]; static char pinNameBuffer[16];
@ -338,12 +341,12 @@ static void showEthInfo(void) {
engine->etbAutoTune); engine->etbAutoTune);
scheduleMsg(&logger, "throttlePedal=%.2f %.2f/%.2f @%s", scheduleMsg(&logger, "throttlePedal=%.2f %.2f/%.2f @%s",
getPedalPosition(), getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE),
engineConfiguration->throttlePedalUpVoltage, engineConfiguration->throttlePedalUpVoltage,
engineConfiguration->throttlePedalWOTVoltage, engineConfiguration->throttlePedalWOTVoltage,
getPinNameByAdcChannel("tPedal", engineConfiguration->throttlePedalPositionAdcChannel, pinNameBuffer)); getPinNameByAdcChannel("tPedal", engineConfiguration->throttlePedalPositionAdcChannel, pinNameBuffer));
scheduleMsg(&logger, "TPS=%.2f", getTPS()); scheduleMsg(&logger, "TPS=%.2f", getTPS(PASS_ENGINE_PARAMETER_SIGNATURE));
scheduleMsg(&logger, "dir=%d DC=%f", etb1.dcMotor.isOpenDirection(), etb1.dcMotor.Get()); scheduleMsg(&logger, "dir=%d DC=%f", etb1.dcMotor.isOpenDirection(), etb1.dcMotor.Get());
scheduleMsg(&logger, "etbControlPin1=%s duty=%.2f freq=%d", scheduleMsg(&logger, "etbControlPin1=%s duty=%.2f freq=%d",
@ -399,6 +402,7 @@ void setEtbOffset(int value) {
etbPid.reset(); etbPid.reset();
showEthInfo(); showEthInfo();
} }
#endif /* EFI_PROD_CODE */
void setBoschVNH2SP30Curve(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setBoschVNH2SP30Curve(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->etbBiasBins[0] = 0; engineConfiguration->etbBiasBins[0] = 0;
@ -485,7 +489,7 @@ void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *pre
shouldResetPid = !etbPid.isSame(&previousConfiguration->etb); shouldResetPid = !etbPid.isSame(&previousConfiguration->etb);
} }
void startETBPins(void) { void startETBPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// controlPinMode is a strange feature - it's simply because I am short on 5v I/O on Frankenso with Miata NB2 test mule // controlPinMode is a strange feature - it's simply because I am short on 5v I/O on Frankenso with Miata NB2 test mule
etb1.start( etb1.start(
@ -554,8 +558,10 @@ void unregisterEtbPins() {
} }
void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_PROD_CODE
addConsoleAction("ethinfo", showEthInfo); addConsoleAction("ethinfo", showEthInfo);
addConsoleAction("etbreset", etbReset); addConsoleAction("etbreset", etbReset);
#endif /* EFI_PROD_CODE */
etbPid.initPidClass(&engineConfiguration->etb); etbPid.initPidClass(&engineConfiguration->etb);
@ -570,7 +576,7 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} }
autoTune.SetOutputStep(0.1); autoTune.SetOutputStep(0.1);
startETBPins(); startETBPins(PASS_ENGINE_PARAMETER_SIGNATURE);
// manual duty cycle control without PID. Percent value from 0 to 100 // manual duty cycle control without PID. Percent value from 0 to 100
addConsoleActionNANF(CMD_ETB_DUTY, setThrottleDutyCycle); addConsoleActionNANF(CMD_ETB_DUTY, setThrottleDutyCycle);
@ -585,11 +591,13 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
tuneWorkingPidSettings.maxValue = 100; tuneWorkingPidSettings.maxValue = 100;
tuneWorkingPidSettings.periodMs = 100; tuneWorkingPidSettings.periodMs = 100;
#if EFI_PROD_CODE
// this is useful once you do "enable etb_auto" // this is useful once you do "enable etb_auto"
addConsoleActionF("set_etbat_output", setTempOutput); addConsoleActionF("set_etbat_output", setTempOutput);
addConsoleActionF("set_etbat_step", setAutoStep); addConsoleActionF("set_etbat_step", setAutoStep);
addConsoleActionI("set_etbat_period", setAutoPeriod); addConsoleActionI("set_etbat_period", setAutoPeriod);
addConsoleActionI("set_etbat_offset", setAutoOffset); addConsoleActionI("set_etbat_offset", setAutoOffset);
#endif /* EFI_PROD_CODE */
etbPid.reset(); etbPid.reset();

View File

@ -24,7 +24,7 @@ void setEtbOffset(int value);
void setThrottleDutyCycle(percent_t level); void setThrottleDutyCycle(percent_t level);
bool isETBRestartNeeded(void); bool isETBRestartNeeded(void);
void stopETBPins(void); void stopETBPins(void);
void startETBPins(void); void startETBPins(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration); void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration);
void unregisterEtbPins(); void unregisterEtbPins();

View File

@ -350,7 +350,7 @@ void applyNewHardwareSettings(void) {
#if EFI_ELECTRONIC_THROTTLE_BODY #if EFI_ELECTRONIC_THROTTLE_BODY
if (etbRestartNeeded) { if (etbRestartNeeded) {
startETBPins(); startETBPins(PASS_ENGINE_PARAMETER_SIGNATURE);
} }
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */ #endif /* EFI_ELECTRONIC_THROTTLE_BODY */