mirror of https://github.com/rusefi/rusefi-1.git
ETB target is using integer values #945
now we have a unit test! now we can fix the issue :)
This commit is contained in:
parent
e99955fce5
commit
e7b658547b
|
@ -174,15 +174,12 @@ static percent_t currentEtbDuty;
|
||||||
// this macro clamps both positive and negative percentages from about -100% to 100%
|
// this macro clamps both positive and negative percentages from about -100% to 100%
|
||||||
#define ETB_PERCENT_TO_DUTY(X) (maxF(minF((X * 0.01), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT))
|
#define ETB_PERCENT_TO_DUTY(X) (maxF(minF((X * 0.01), ETB_DUTY_LIMIT - 0.01), 0.01 - ETB_DUTY_LIMIT))
|
||||||
|
|
||||||
class EtbController : public PeriodicTimerController {
|
|
||||||
public:
|
|
||||||
DECLARE_ENGINE_PTR;
|
|
||||||
|
|
||||||
int getPeriodMs() override {
|
int EtbController::getPeriodMs() {
|
||||||
return GET_PERIOD_LIMITED(&engineConfiguration->etb);
|
return GET_PERIOD_LIMITED(&engineConfiguration->etb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeriodicTask() override {
|
void EtbController::PeriodicTask() {
|
||||||
// set debug_mode 17
|
// set debug_mode 17
|
||||||
if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
|
if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
|
@ -312,9 +309,8 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor))
|
||||||
tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition;
|
tsOutputChannels.etb1Error = targetPosition - actualThrottlePosition;
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
#endif /* EFI_TUNER_STUDIO */
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
static EtbController etbController;
|
EtbController etbController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set_etb_duty X
|
* set_etb_duty X
|
||||||
|
|
|
@ -13,6 +13,16 @@
|
||||||
#define DEFAULT_ETB_PWM_FREQUENCY 300
|
#define DEFAULT_ETB_PWM_FREQUENCY 300
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
#include "periodic_task.h"
|
||||||
|
|
||||||
|
class EtbController : public PeriodicTimerController {
|
||||||
|
public:
|
||||||
|
DECLARE_ENGINE_PTR;
|
||||||
|
|
||||||
|
int getPeriodMs() override;
|
||||||
|
void PeriodicTask() override;
|
||||||
|
};
|
||||||
|
|
||||||
void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
void setDefaultEtbParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
void setDefaultEtbParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||||
|
|
|
@ -13,6 +13,7 @@ float testMafValue = 0;
|
||||||
float testCltValue = 0;
|
float testCltValue = 0;
|
||||||
float testIatValue = 0;
|
float testIatValue = 0;
|
||||||
|
|
||||||
|
// see setMockVoltage
|
||||||
float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
switch(hwChannel) {
|
switch(hwChannel) {
|
||||||
case TEST_MAF_CHANNEL:
|
case TEST_MAF_CHANNEL:
|
||||||
|
@ -24,7 +25,7 @@ float getVoltageDivided(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_
|
||||||
return testIatValue;
|
return testIatValue;
|
||||||
//return adcToVolts(engine->engineState.mockAdcState.getMockAdcValue(hwChannel));
|
//return adcToVolts(engine->engineState.mockAdcState.getMockAdcValue(hwChannel));
|
||||||
}
|
}
|
||||||
return 0;
|
return adcToVolts(engine->engineState.mockAdcState.getMockAdcValue(hwChannel));;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getVoltage(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getVoltage(const char *msg, adc_channel_e hwChannel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "idle_thread.h"
|
#include "idle_thread.h"
|
||||||
#include "allsensors.h"
|
#include "allsensors.h"
|
||||||
#include "engine_controller.h"
|
#include "engine_controller.h"
|
||||||
|
#include "electronic_throttle.h"
|
||||||
|
|
||||||
extern IdleController idleControllerInstance;
|
extern IdleController idleControllerInstance;
|
||||||
extern int timeNowUs;
|
extern int timeNowUs;
|
||||||
|
@ -183,10 +184,23 @@ TEST(idle, timingPid) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// not great that we are reusing shared instance. todo: move EtbController to Engine?
|
||||||
|
extern EtbController etbController;
|
||||||
|
|
||||||
TEST(idle, testTargetTpsIsFloatBug945) {
|
TEST(idle, testTargetTpsIsFloatBug945) {
|
||||||
|
|
||||||
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||||
|
|
||||||
|
setMockThrottlePedalSensorVoltage(3 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
etbController.PeriodicTask();
|
||||||
|
ASSERT_NEAR(50, engine->engineState.targetFromTable, EPS4D);
|
||||||
|
|
||||||
|
setMockThrottlePedalSensorVoltage(3.05 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
etbController.PeriodicTask();
|
||||||
|
ASSERT_NEAR(50, engine->engineState.targetFromTable, EPS4D);
|
||||||
|
|
||||||
|
setMockThrottlePedalSensorVoltage(3.1 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
etbController.PeriodicTask();
|
||||||
|
ASSERT_NEAR(51, engine->engineState.targetFromTable, EPS4D);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue