DC is not ETB

This commit is contained in:
rusefi 2023-02-18 22:39:45 -05:00
parent 7d83c7374f
commit 096be69c20
23 changed files with 150 additions and 152 deletions

View File

@ -2374,7 +2374,7 @@ struct engine_configuration_s {
/** /**
* offset 1200 * offset 1200
*/ */
etb_function_e etbFunctions[ETB_COUNT]; dc_function_e etbFunctions[ETB_COUNT];
/** /**
* offset 1202 * offset 1202
*/ */

View File

@ -387,12 +387,12 @@
#define ERROR_BUFFER_SIZE 120 #define ERROR_BUFFER_SIZE 120
#define ETB_BIAS_CURVE_LENGTH 8 #define ETB_BIAS_CURVE_LENGTH 8
#define ETB_COUNT 2 #define ETB_COUNT 2
#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" #define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate"
#define etb_function_e_ETB_IdleValve 3 #define dc_function_e_DC_IdleValve 3
#define etb_function_e_ETB_None 0 #define dc_function_e_DC_None 0
#define etb_function_e_ETB_Throttle1 1 #define dc_function_e_DC_Throttle1 1
#define etb_function_e_ETB_Throttle2 2 #define dc_function_e_DC_Throttle2 2
#define etb_function_e_ETB_Wastegate 4 #define dc_function_e_DC_Wastegate 4
#define ETB_HW_MAX_FREQUENCY 3000 #define ETB_HW_MAX_FREQUENCY 3000
#define FLASH_DATA_VERSION 10020 #define FLASH_DATA_VERSION 10020
#define FUEL_LEVEL_TABLE_COUNT 8 #define FUEL_LEVEL_TABLE_COUNT 8

View File

@ -122,8 +122,8 @@ void setBoardDefaultConfiguration() {
// "required" hardware is done - set some reasonable defaults // "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs(); setupDefaultSensorInputs();
engineConfiguration->etbFunctions[0] = ETB_None; engineConfiguration->etbFunctions[0] = DC_None;
engineConfiguration->etbFunctions[1] = ETB_Wastegate; engineConfiguration->etbFunctions[1] = DC_Wastegate;
// Some sensible defaults for other options // Some sensible defaults for other options
setCrankOperationMode(); setCrankOperationMode();

View File

@ -169,7 +169,7 @@ void setBoardDefaultConfiguration() {
// "required" hardware is done - set some reasonable defaults // "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs(); setupDefaultSensorInputs();
engineConfiguration->etbFunctions[1] = ETB_Wastegate; engineConfiguration->etbFunctions[1] = DC_Wastegate;
// Some sensible defaults for other options // Some sensible defaults for other options
setCrankOperationMode(); setCrankOperationMode();

View File

@ -2374,7 +2374,7 @@ struct engine_configuration_s {
/** /**
* offset 1200 * offset 1200
*/ */
etb_function_e etbFunctions[ETB_COUNT]; dc_function_e etbFunctions[ETB_COUNT];
/** /**
* offset 1202 * offset 1202
*/ */

View File

@ -387,12 +387,12 @@
#define ERROR_BUFFER_SIZE 120 #define ERROR_BUFFER_SIZE 120
#define ETB_BIAS_CURVE_LENGTH 8 #define ETB_BIAS_CURVE_LENGTH 8
#define ETB_COUNT 2 #define ETB_COUNT 2
#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" #define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate"
#define etb_function_e_ETB_IdleValve 3 #define dc_function_e_DC_IdleValve 3
#define etb_function_e_ETB_None 0 #define dc_function_e_DC_None 0
#define etb_function_e_ETB_Throttle1 1 #define dc_function_e_DC_Throttle1 1
#define etb_function_e_ETB_Throttle2 2 #define dc_function_e_DC_Throttle2 2
#define etb_function_e_ETB_Wastegate 4 #define dc_function_e_DC_Wastegate 4
#define ETB_HW_MAX_FREQUENCY 3000 #define ETB_HW_MAX_FREQUENCY 3000
#define FLASH_DATA_VERSION 10020 #define FLASH_DATA_VERSION 10020
#define FUEL_LEVEL_TABLE_COUNT 8 #define FUEL_LEVEL_TABLE_COUNT 8

View File

@ -2374,7 +2374,7 @@ struct engine_configuration_s {
/** /**
* offset 1200 * offset 1200
*/ */
etb_function_e etbFunctions[ETB_COUNT]; dc_function_e etbFunctions[ETB_COUNT];
/** /**
* offset 1202 * offset 1202
*/ */

View File

@ -381,12 +381,12 @@
#define ERROR_BUFFER_SIZE 120 #define ERROR_BUFFER_SIZE 120
#define ETB_BIAS_CURVE_LENGTH 8 #define ETB_BIAS_CURVE_LENGTH 8
#define ETB_COUNT 2 #define ETB_COUNT 2
#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" #define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate"
#define etb_function_e_ETB_IdleValve 3 #define dc_function_e_DC_IdleValve 3
#define etb_function_e_ETB_None 0 #define dc_function_e_DC_None 0
#define etb_function_e_ETB_Throttle1 1 #define dc_function_e_DC_Throttle1 1
#define etb_function_e_ETB_Throttle2 2 #define dc_function_e_DC_Throttle2 2
#define etb_function_e_ETB_Wastegate 4 #define dc_function_e_DC_Wastegate 4
#define ETB_HW_MAX_FREQUENCY 3000 #define ETB_HW_MAX_FREQUENCY 3000
#define FLASH_DATA_VERSION 10020 #define FLASH_DATA_VERSION 10020
#define FUEL_LEVEL_TABLE_COUNT 8 #define FUEL_LEVEL_TABLE_COUNT 8

View File

@ -577,8 +577,8 @@ static void mreBoardOldTest() {
void proteusDcWastegateTest() { void proteusDcWastegateTest() {
engineConfiguration->isBoostControlEnabled = true; engineConfiguration->isBoostControlEnabled = true;
engineConfiguration->etbFunctions[0] = ETB_Wastegate; engineConfiguration->etbFunctions[0] = DC_Wastegate;
engineConfiguration->etbFunctions[1] = ETB_None; engineConfiguration->etbFunctions[1] = DC_None;
engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE; engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_10; engineConfiguration->tps1_1AdcChannel = EFI_ADC_10;

View File

@ -141,7 +141,7 @@ end
void setProteusGmLs4() { void setProteusGmLs4() {
#if HW_PROTEUS #if HW_PROTEUS
engineConfiguration->etbFunctions[1] = ETB_None; engineConfiguration->etbFunctions[1] = DC_None;
engineConfiguration->mainRelayPin = PROTEUS_LS_12; engineConfiguration->mainRelayPin = PROTEUS_LS_12;
setPPSInputs(PROTEUS_IN_ANALOG_VOLT_2, PROTEUS_IN_ANALOG_VOLT_11); setPPSInputs(PROTEUS_IN_ANALOG_VOLT_2, PROTEUS_IN_ANALOG_VOLT_11);

View File

@ -59,7 +59,7 @@ void setTestCrankEngineConfiguration() {
void setTestDcWastegateConfiguration() { void setTestDcWastegateConfiguration() {
engineConfiguration->isBoostControlEnabled = 1; engineConfiguration->isBoostControlEnabled = 1;
engineConfiguration->etbFunctions[0] = ETB_Wastegate; engineConfiguration->etbFunctions[0] = DC_Wastegate;
setTable(config->boostTableOpenLoop, 50); setTable(config->boostTableOpenLoop, 50);
engineConfiguration->tps1_1AdcChannel = EFI_ADC_1; // PA1 engineConfiguration->tps1_1AdcChannel = EFI_ADC_1; // PA1

View File

@ -226,7 +226,7 @@ void initBoostCtrl() {
bool hasAnyEtbWastegate = false; bool hasAnyEtbWastegate = false;
for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) { for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) {
hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == ETB_Wastegate; hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == DC_Wastegate;
} }
// If we have neither a boost PWM pin nor ETB wastegate, nothing more to do // If we have neither a boost PWM pin nor ETB wastegate, nothing more to do

View File

@ -98,55 +98,55 @@ void setHitachiEtbBiasBins() {
copyArray(config->etbBiasValues, hardCodedetbHitachiBiasValues); copyArray(config->etbBiasValues, hardCodedetbHitachiBiasValues);
} }
static SensorType functionToPositionSensor(etb_function_e func) { static SensorType functionToPositionSensor(dc_function_e func) {
switch(func) { switch(func) {
case ETB_Throttle1: return SensorType::Tps1; case DC_Throttle1: return SensorType::Tps1;
case ETB_Throttle2: return SensorType::Tps2; case DC_Throttle2: return SensorType::Tps2;
case ETB_IdleValve: return SensorType::IdlePosition; case DC_IdleValve: return SensorType::IdlePosition;
case ETB_Wastegate: return SensorType::WastegatePosition; case DC_Wastegate: return SensorType::WastegatePosition;
default: return SensorType::Invalid; default: return SensorType::Invalid;
} }
} }
static SensorType functionToTpsSensorPrimary(etb_function_e func) { static SensorType functionToTpsSensorPrimary(dc_function_e func) {
switch(func) { switch(func) {
case ETB_Throttle1: return SensorType::Tps1Primary; case DC_Throttle1: return SensorType::Tps1Primary;
default: return SensorType::Tps2Primary; default: return SensorType::Tps2Primary;
} }
} }
static SensorType functionToTpsSensorSecondary(etb_function_e func) { static SensorType functionToTpsSensorSecondary(dc_function_e func) {
switch(func) { switch(func) {
case ETB_Throttle1: return SensorType::Tps1Secondary; case DC_Throttle1: return SensorType::Tps1Secondary;
default: return SensorType::Tps2Secondary; default: return SensorType::Tps2Secondary;
} }
} }
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
static TsCalMode functionToCalModePriMin(etb_function_e func) { static TsCalMode functionToCalModePriMin(dc_function_e func) {
switch (func) { switch (func) {
case ETB_Throttle1: return TsCalMode::Tps1Min; case DC_Throttle1: return TsCalMode::Tps1Min;
default: return TsCalMode::Tps2Min; default: return TsCalMode::Tps2Min;
} }
} }
static TsCalMode functionToCalModePriMax(etb_function_e func) { static TsCalMode functionToCalModePriMax(dc_function_e func) {
switch (func) { switch (func) {
case ETB_Throttle1: return TsCalMode::Tps1Max; case DC_Throttle1: return TsCalMode::Tps1Max;
default: return TsCalMode::Tps2Max; default: return TsCalMode::Tps2Max;
} }
} }
static TsCalMode functionToCalModeSecMin(etb_function_e func) { static TsCalMode functionToCalModeSecMin(dc_function_e func) {
switch (func) { switch (func) {
case ETB_Throttle1: return TsCalMode::Tps1SecondaryMin; case DC_Throttle1: return TsCalMode::Tps1SecondaryMin;
default: return TsCalMode::Tps2SecondaryMin; default: return TsCalMode::Tps2SecondaryMin;
} }
} }
static TsCalMode functionToCalModeSecMax(etb_function_e func) { static TsCalMode functionToCalModeSecMax(dc_function_e func) {
switch (func) { switch (func) {
case ETB_Throttle1: return TsCalMode::Tps1SecondaryMax; case DC_Throttle1: return TsCalMode::Tps1SecondaryMax;
default: return TsCalMode::Tps2SecondaryMax; default: return TsCalMode::Tps2SecondaryMax;
} }
} }
@ -158,8 +158,8 @@ static percent_t directPwmValue = NAN;
// 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) (clampF(-ETB_DUTY_LIMIT, 0.01f * (x), ETB_DUTY_LIMIT)) #define ETB_PERCENT_TO_DUTY(x) (clampF(-ETB_DUTY_LIMIT, 0.01f * (x), ETB_DUTY_LIMIT))
bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool hasPedal) { bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool hasPedal) {
if (function == ETB_None) { if (function == DC_None) {
// if not configured, don't init. // if not configured, don't init.
etbErrorCode = (int8_t)TpsState::None; etbErrorCode = (int8_t)TpsState::None;
return false; return false;
@ -251,12 +251,12 @@ void EtbController::setWastegatePosition(percent_t pos) {
expected<percent_t> EtbController::getSetpoint() { expected<percent_t> EtbController::getSetpoint() {
switch (m_function) { switch (m_function) {
case ETB_Throttle1: case DC_Throttle1:
case ETB_Throttle2: case DC_Throttle2:
return getSetpointEtb(); return getSetpointEtb();
case ETB_IdleValve: case DC_IdleValve:
return getSetpointIdleValve(); return getSetpointIdleValve();
case ETB_Wastegate: case DC_Wastegate:
return getSetpointWastegate(); return getSetpointWastegate();
default: default:
return unexpected; return unexpected;
@ -361,7 +361,7 @@ expected<percent_t> EtbController::getSetpointEtb() {
etbCurrentAdjustedTarget = targetPosition; etbCurrentAdjustedTarget = targetPosition;
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
if (m_function == ETB_Throttle1) { if (m_function == DC_Throttle1) {
engine->outputChannels.etbTarget = targetPosition; engine->outputChannels.etbTarget = targetPosition;
} }
#endif // EFI_TUNER_STUDIO #endif // EFI_TUNER_STUDIO
@ -390,8 +390,8 @@ percent_t EtbController2::getThrottleTrim(float rpm, percent_t targetPosition) c
expected<percent_t> EtbController::getOpenLoop(percent_t target) { expected<percent_t> EtbController::getOpenLoop(percent_t target) {
// Don't apply open loop for wastegate/idle valve, only real ETB // Don't apply open loop for wastegate/idle valve, only real ETB
if (m_function != ETB_Wastegate if (m_function != DC_Wastegate
&& m_function != ETB_IdleValve) { && m_function != DC_IdleValve) {
etbFeedForward = interpolate2d(target, config->etbBiasBins, config->etbBiasValues); etbFeedForward = interpolate2d(target, config->etbBiasBins, config->etbBiasValues);
} else { } else {
etbFeedForward = 0; etbFeedForward = 0;
@ -526,7 +526,7 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
void EtbController::setOutput(expected<percent_t> outputValue) { void EtbController::setOutput(expected<percent_t> outputValue) {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
// Only report first-throttle stats // Only report first-throttle stats
if (m_function == ETB_Throttle1) { if (m_function == DC_Throttle1) {
engine->outputChannels.etb1DutyCycle = outputValue.value_or(0); engine->outputChannels.etb1DutyCycle = outputValue.value_or(0);
} }
#endif #endif
@ -560,9 +560,9 @@ bool EtbController::checkStatus() {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
// Only debug throttle #1 // Only debug throttle #1
if (m_function == ETB_Throttle1) { if (m_function == DC_Throttle1) {
m_pid.postState(engine->outputChannels.etbStatus); m_pid.postState(engine->outputChannels.etbStatus);
} else if (m_function == ETB_Wastegate) { } else if (m_function == DC_Wastegate) {
m_pid.postState(engine->outputChannels.wastegateDcStatus); m_pid.postState(engine->outputChannels.wastegateDcStatus);
} }
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
@ -571,7 +571,7 @@ bool EtbController::checkStatus() {
// Update local state about autotune // Update local state about autotune
m_isAutotune = Sensor::getOrZero(SensorType::Rpm) == 0 m_isAutotune = Sensor::getOrZero(SensorType::Rpm) == 0
&& engine->etbAutoTune && engine->etbAutoTune
&& m_function == ETB_Throttle1; && m_function == DC_Throttle1;
bool shouldCheckSensorFunction = engine->module<SensorChecker>()->analogSensorsShouldWork(); bool shouldCheckSensorFunction = engine->module<SensorChecker>()->analogSensorsShouldWork();
@ -679,7 +679,7 @@ void EtbController::checkOutput(percent_t output) {
void EtbController::autoCalibrateTps() { void EtbController::autoCalibrateTps() {
// Only auto calibrate throttles // Only auto calibrate throttles
if (m_function == ETB_Throttle1 || m_function == ETB_Throttle2) { if (m_function == DC_Throttle1 || m_function == DC_Throttle2) {
m_isAutocal = true; m_isAutocal = true;
} }
} }
@ -963,8 +963,8 @@ void setDefaultEtbParameters() {
} }
// Default is to run each throttle off its respective hbridge // Default is to run each throttle off its respective hbridge
engineConfiguration->etbFunctions[0] = ETB_Throttle1; engineConfiguration->etbFunctions[0] = DC_Throttle1;
engineConfiguration->etbFunctions[1] = ETB_Throttle2; engineConfiguration->etbFunctions[1] = DC_Throttle2;
engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY; engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
@ -1006,9 +1006,9 @@ void unregisterEtbPins() {
// todo: we probably need an implementation here?! // todo: we probably need an implementation here?!
} }
static pid_s* getEtbPidForFunction(etb_function_e function) { static pid_s* getEtbPidForFunction(dc_function_e function) {
switch (function) { switch (function) {
case ETB_Wastegate: return &engineConfiguration->etbWastegatePid; case DC_Wastegate: return &engineConfiguration->etbWastegatePid;
default: return &engineConfiguration->etb; default: return &engineConfiguration->etb;
} }
} }
@ -1028,7 +1028,7 @@ void doInitElectronicThrottle() {
// todo: rename etbFunctions to something-without-etb for same reason? // todo: rename etbFunctions to something-without-etb for same reason?
for (int i = 0 ; i < ETB_COUNT; i++) { for (int i = 0 ; i < ETB_COUNT; i++) {
auto func = engineConfiguration->etbFunctions[i]; auto func = engineConfiguration->etbFunctions[i];
if (func == ETB_None) { if (func == DC_None) {
// do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly // do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly
continue; continue;
} }

View File

@ -48,7 +48,7 @@ class IEtbController : public ClosedLoopController<percent_t, percent_t> {
public: public:
// Initialize the throttle. // Initialize the throttle.
// returns true if the throttle was initialized, false otherwise. // returns true if the throttle was initialized, false otherwise.
virtual bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles = true) = 0; virtual bool init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles = true) = 0;
virtual void reset() = 0; virtual void reset() = 0;
virtual void setIdlePosition(percent_t pos) = 0; virtual void setIdlePosition(percent_t pos) = 0;
virtual void setWastegatePosition(percent_t pos) = 0; virtual void setWastegatePosition(percent_t pos) = 0;

View File

@ -27,7 +27,7 @@
class EtbController : public IEtbController, public electronic_throttle_s { class EtbController : public IEtbController, public electronic_throttle_s {
public: public:
bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override; bool init(dc_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override;
void setIdlePosition(percent_t pos) override; void setIdlePosition(percent_t pos) override;
void setWastegatePosition(percent_t pos) override; void setWastegatePosition(percent_t pos) override;
void reset() override; void reset() override;
@ -82,11 +82,11 @@ protected:
bool hadTpsError = false; bool hadTpsError = false;
bool hadPpsError = false; bool hadPpsError = false;
etb_function_e getFunction() const { return m_function; } dc_function_e getFunction() const { return m_function; }
DcMotor* getMotor() { return m_motor; } DcMotor* getMotor() { return m_motor; }
private: private:
etb_function_e m_function = ETB_None; dc_function_e m_function = DC_None;
SensorType m_positionSensor = SensorType::Invalid; SensorType m_positionSensor = SensorType::Invalid;
DcMotor *m_motor = nullptr; DcMotor *m_motor = nullptr;
Pid m_pid; Pid m_pid;
@ -99,7 +99,7 @@ private:
*/ */
bool checkStatus(); bool checkStatus();
bool isEtbMode() { bool isEtbMode() {
return m_function == ETB_Throttle1 || m_function == ETB_Throttle2; return m_function == DC_Throttle1 || m_function == DC_Throttle2;
} }
ExpAverage m_dutyRocAverage; ExpAverage m_dutyRocAverage;

View File

@ -337,18 +337,18 @@ case LM_SPEED_DENSITY:
} }
return NULL; return NULL;
} }
const char *getEtb_function_e(etb_function_e value){ const char *getdc_function_e(dc_function_e value){
switch(value) { switch(value) {
case ETB_IdleValve: case DC_IdleValve:
return "ETB_IdleValve"; return "DC_IdleValve";
case ETB_None: case DC_None:
return "ETB_None"; return "DC_None";
case ETB_Throttle1: case DC_Throttle1:
return "ETB_Throttle1"; return "DC_Throttle1";
case ETB_Throttle2: case DC_Throttle2:
return "ETB_Throttle2"; return "DC_Throttle2";
case ETB_Wastegate: case DC_Wastegate:
return "ETB_Wastegate"; return "DC_Wastegate";
} }
return NULL; return NULL;
} }

View File

@ -39,7 +39,7 @@ const char *getCan_vss_nbc_e(can_vss_nbc_e value);
const char *getDisplay_mode_e(display_mode_e value); const char *getDisplay_mode_e(display_mode_e value);
const char *getEgo_sensor_e(ego_sensor_e value); const char *getEgo_sensor_e(ego_sensor_e value);
const char *getEngine_load_mode_e(engine_load_mode_e value); const char *getEngine_load_mode_e(engine_load_mode_e value);
const char *getEtb_function_e(etb_function_e value); const char *getdc_function_e(dc_function_e value);
const char *getGear_e(gear_e value); const char *getGear_e(gear_e value);
const char *getGppwm_channel_e(gppwm_channel_e value); const char *getGppwm_channel_e(gppwm_channel_e value);
const char *getGppwm_compare_mode_e(gppwm_compare_mode_e value); const char *getGppwm_compare_mode_e(gppwm_compare_mode_e value);

View File

@ -602,14 +602,12 @@ typedef enum __attribute__ ((__packed__)) {
} load_override_e; } load_override_e;
typedef enum __attribute__ ((__packed__)) { typedef enum __attribute__ ((__packed__)) {
// todo: rename to HB_None? DC_None = 0,
ETB_None = 0, DC_Throttle1 = 1,
ETB_Throttle1 = 1, DC_Throttle2 = 2,
ETB_Throttle2 = 2, DC_IdleValve = 3,
ETB_IdleValve = 3, DC_Wastegate = 4,
ETB_Wastegate = 4, } dc_function_e;
// todo: rename to dc_function_e? rename to hbrg_function_e?
} etb_function_e;
typedef enum __attribute__ ((__packed__)) { typedef enum __attribute__ ((__packed__)) {
STEPPER_FULL = 0, STEPPER_FULL = 0,

View File

@ -2374,7 +2374,7 @@ struct engine_configuration_s {
/** /**
* offset 1200 * offset 1200
*/ */
etb_function_e etbFunctions[ETB_COUNT]; dc_function_e etbFunctions[ETB_COUNT];
/** /**
* offset 1202 * offset 1202
*/ */

View File

@ -387,12 +387,12 @@
#define ERROR_BUFFER_SIZE 120 #define ERROR_BUFFER_SIZE 120
#define ETB_BIAS_CURVE_LENGTH 8 #define ETB_BIAS_CURVE_LENGTH 8
#define ETB_COUNT 2 #define ETB_COUNT 2
#define etb_function_e_auto_enum 0="ETB_None",3="ETB_IdleValve",1="ETB_Throttle1",2="ETB_Throttle2",4="ETB_Wastegate" #define dc_function_e_auto_enum 0="DC_None",3="DC_IdleValve",1="DC_Throttle1",2="DC_Throttle2",4="DC_Wastegate"
#define etb_function_e_ETB_IdleValve 3 #define dc_function_e_DC_IdleValve 3
#define etb_function_e_ETB_None 0 #define dc_function_e_DC_None 0
#define etb_function_e_ETB_Throttle1 1 #define dc_function_e_DC_Throttle1 1
#define etb_function_e_ETB_Throttle2 2 #define dc_function_e_DC_Throttle2 2
#define etb_function_e_ETB_Wastegate 4 #define dc_function_e_DC_Wastegate 4
#define ETB_HW_MAX_FREQUENCY 3000 #define ETB_HW_MAX_FREQUENCY 3000
#define FLASH_DATA_VERSION 10020 #define FLASH_DATA_VERSION 10020
#define FUEL_LEVEL_TABLE_COUNT 8 #define FUEL_LEVEL_TABLE_COUNT 8

View File

@ -228,7 +228,7 @@ void initBoostCtrl() {
bool hasAnyEtbWastegate = false; bool hasAnyEtbWastegate = false;
for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) { for (size_t i = 0; i < efi::size(engineConfiguration->etbFunctions); i++) {
hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == ETB_Wastegate; hasAnyEtbWastegate |= engineConfiguration->etbFunctions[i] == DC_Wastegate;
} }
// If we have neither a boost PWM pin nor ETB wastegate, nothing more to do // If we have neither a boost PWM pin nor ETB wastegate, nothing more to do

View File

@ -21,7 +21,7 @@ public:
// IEtbController mocks // IEtbController mocks
MOCK_METHOD(void, reset, (), (override)); MOCK_METHOD(void, reset, (), (override));
MOCK_METHOD(void, update, (), (override)); MOCK_METHOD(void, update, (), (override));
MOCK_METHOD(bool, init, (etb_function_e function, DcMotor* motor, pid_s* pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles), (override)); MOCK_METHOD(bool, init, (dc_function_e function, DcMotor* motor, pid_s* pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles), (override));
MOCK_METHOD(void, setIdlePosition, (percent_t pos), (override)); MOCK_METHOD(void, setIdlePosition, (percent_t pos), (override));
MOCK_METHOD(void, setWastegatePosition, (percent_t pos), (override)); MOCK_METHOD(void, setWastegatePosition, (percent_t pos), (override));
MOCK_METHOD(void, autoCalibrateTps, (), (override)); MOCK_METHOD(void, autoCalibrateTps, (), (override));

View File

@ -27,8 +27,8 @@ TEST(etb, initializationNoPedal) {
engine->etbControllers[i] = &mocks[i]; engine->etbControllers[i] = &mocks[i];
} }
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, _, _, false)).WillOnce(Return(false)); EXPECT_CALL(mocks[0], init(DC_Throttle1, _, _, _, false)).WillOnce(Return(false));
EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, _, _, false)).WillOnce(Return(false)); EXPECT_CALL(mocks[1], init(DC_Throttle2, _, _, _, false)).WillOnce(Return(false));
// This shouldn't throw, since no throttles are configured, but no pedal is configured either // This shouldn't throw, since no throttles are configured, but no pedal is configured either
EXPECT_NO_FATAL_ERROR(doInitElectronicThrottle()); EXPECT_NO_FATAL_ERROR(doInitElectronicThrottle());
@ -38,16 +38,16 @@ TEST(etb, initializationMissingThrottle) {
StrictMock<MockEtb> mocks[ETB_COUNT]; StrictMock<MockEtb> mocks[ETB_COUNT];
EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
engineConfiguration->etbFunctions[0] = ETB_None; engineConfiguration->etbFunctions[0] = DC_None;
engineConfiguration->etbFunctions[1] = ETB_None; engineConfiguration->etbFunctions[1] = DC_None;
}); });
for (int i = 0; i < ETB_COUNT; i++) { for (int i = 0; i < ETB_COUNT; i++) {
engine->etbControllers[i] = &mocks[i]; engine->etbControllers[i] = &mocks[i];
} }
EXPECT_CALL(mocks[0], init(ETB_None, _, _, _, true)).Times(0); EXPECT_CALL(mocks[0], init(DC_None, _, _, _, true)).Times(0);
EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, true)).Times(0); EXPECT_CALL(mocks[1], init(DC_None, _, _, _, true)).Times(0);
// Must have a sensor configured before init // Must have a sensor configured before init
Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true);
@ -61,8 +61,8 @@ TEST(etb, initializationSingleThrottle) {
StrictMock<MockEtb> mocks[ETB_COUNT]; StrictMock<MockEtb> mocks[ETB_COUNT];
EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
engineConfiguration->etbFunctions[0] = ETB_Throttle1; engineConfiguration->etbFunctions[0] = DC_Throttle1;
engineConfiguration->etbFunctions[1] = ETB_None; engineConfiguration->etbFunctions[1] = DC_None;
}); });
for (int i = 0; i < ETB_COUNT; i++) { for (int i = 0; i < ETB_COUNT; i++) {
@ -74,10 +74,10 @@ TEST(etb, initializationSingleThrottle) {
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0); Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0);
// Expect mock0 to be init as throttle 1, and PID params // Expect mock0 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
// Expect mock1 to be init as none // Expect mock1 to be init as none
EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, true)).Times(0); EXPECT_CALL(mocks[1], init(DC_None, _, _, _, true)).Times(0);
doInitElectronicThrottle(); doInitElectronicThrottle();
} }
@ -86,8 +86,8 @@ TEST(etb, initializationSingleThrottleInSecondSlot) {
StrictMock<MockEtb> mocks[ETB_COUNT]; StrictMock<MockEtb> mocks[ETB_COUNT];
EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
engineConfiguration->etbFunctions[0] = ETB_None; engineConfiguration->etbFunctions[0] = DC_None;
engineConfiguration->etbFunctions[1] = ETB_Throttle1; engineConfiguration->etbFunctions[1] = DC_Throttle1;
}); });
for (int i = 0; i < ETB_COUNT; i++) { for (int i = 0; i < ETB_COUNT; i++) {
@ -99,10 +99,10 @@ TEST(etb, initializationSingleThrottleInSecondSlot) {
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0, false); Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0, false);
// Expect mock0 to be init as none // Expect mock0 to be init as none
EXPECT_CALL(mocks[0], init(ETB_None, _, _, _, true)).Times(0); EXPECT_CALL(mocks[0], init(DC_None, _, _, _, true)).Times(0);
// Expect mock1 to be init as throttle 1, and PID params // Expect mock1 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[1], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); EXPECT_CALL(mocks[1], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
doInitElectronicThrottle(); doInitElectronicThrottle();
} }
@ -123,14 +123,14 @@ TEST(etb, initializationDualThrottle) {
Sensor::setMockValue(SensorType::Tps1, 25.0f, true); Sensor::setMockValue(SensorType::Tps1, 25.0f, true);
Sensor::setMockValue(SensorType::Tps2, 25.0f, true); Sensor::setMockValue(SensorType::Tps2, 25.0f, true);
engineConfiguration->etbFunctions[0] = ETB_Throttle1; engineConfiguration->etbFunctions[0] = DC_Throttle1;
engineConfiguration->etbFunctions[1] = ETB_Throttle2; engineConfiguration->etbFunctions[1] = DC_Throttle2;
// Expect mock0 to be init as throttle 1, and PID params // Expect mock0 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[0], init(ETB_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
// Expect mock1 to be init as throttle 2, and PID params // Expect mock1 to be init as throttle 2, and PID params
EXPECT_CALL(mocks[1], init(ETB_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true)); EXPECT_CALL(mocks[1], init(DC_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
doInitElectronicThrottle(); doInitElectronicThrottle();
} }
@ -139,8 +139,8 @@ TEST(etb, initializationWastegate) {
StrictMock<MockEtb> mocks[ETB_COUNT]; StrictMock<MockEtb> mocks[ETB_COUNT];
EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
engineConfiguration->etbFunctions[0] = ETB_Wastegate; engineConfiguration->etbFunctions[0] = DC_Wastegate;
engineConfiguration->etbFunctions[1] = ETB_None; engineConfiguration->etbFunctions[1] = DC_None;
}); });
for (int i = 0; i < ETB_COUNT; i++) { for (int i = 0; i < ETB_COUNT; i++) {
@ -148,10 +148,10 @@ TEST(etb, initializationWastegate) {
} }
// Expect mock0 to be init as throttle 1, and PID wastegate params // Expect mock0 to be init as throttle 1, and PID wastegate params
EXPECT_CALL(mocks[0], init(ETB_Wastegate, _, &engineConfiguration->etbWastegatePid, Ne(nullptr), false)).WillOnce(Return(true)); EXPECT_CALL(mocks[0], init(DC_Wastegate, _, &engineConfiguration->etbWastegatePid, Ne(nullptr), false)).WillOnce(Return(true));
// Expect mock1 to be init as none // Expect mock1 to be init as none
EXPECT_CALL(mocks[1], init(ETB_None, _, _, _, false)).Times(0); EXPECT_CALL(mocks[1], init(DC_None, _, _, _, false)).Times(0);
doInitElectronicThrottle(); doInitElectronicThrottle();
} }
@ -161,8 +161,8 @@ TEST(etb, initializationNoFunction) {
EtbController dut; EtbController dut;
// When init called with ETB_None, should ignore the provided params and return false // When init called with DC_None, should ignore the provided params and return false
EXPECT_FALSE(dut.init(ETB_None, &motor, nullptr, nullptr, false)); EXPECT_FALSE(dut.init(DC_None, &motor, nullptr, nullptr, false));
// This should no-op, it shouldn't call motor.set(float duty) // This should no-op, it shouldn't call motor.set(float duty)
dut.setOutput(0.5f); dut.setOutput(0.5f);
@ -178,7 +178,7 @@ TEST(etb, initializationNotRedundantTps) {
Sensor::setMockValue(SensorType::Tps1Primary, 0); Sensor::setMockValue(SensorType::Tps1Primary, 0);
Sensor::setMockValue(SensorType::Tps1, 0.0f, false); Sensor::setMockValue(SensorType::Tps1, 0.0f, false);
EXPECT_FATAL_ERROR(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); EXPECT_FATAL_ERROR(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
} }
TEST(etb, initializationNotRedundantPedal) { TEST(etb, initializationNotRedundantPedal) {
@ -191,7 +191,7 @@ TEST(etb, initializationNotRedundantPedal) {
Sensor::setMockValue(SensorType::Tps1Primary, 0); Sensor::setMockValue(SensorType::Tps1Primary, 0);
Sensor::setMockValue(SensorType::Tps1, 0.0f, true); Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
EXPECT_FATAL_ERROR(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); EXPECT_FATAL_ERROR(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
} }
TEST(etb, initializationNoPrimarySensor) { TEST(etb, initializationNoPrimarySensor) {
@ -205,13 +205,13 @@ TEST(etb, initializationNoPrimarySensor) {
// Redundant, but no primary configured // Redundant, but no primary configured
Sensor::setMockValue(SensorType::Tps1, 0.0f, true); Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
EXPECT_FALSE(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); EXPECT_FALSE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
// Now configure primary TPS // Now configure primary TPS
Sensor::setMockValue(SensorType::Tps1Primary, 0); Sensor::setMockValue(SensorType::Tps1Primary, 0);
// With primary TPS, should return true (ie, throttle was configured) // With primary TPS, should return true (ie, throttle was configured)
EXPECT_TRUE(dut.init(ETB_Throttle1, nullptr, nullptr, nullptr, true)); EXPECT_TRUE(dut.init(DC_Throttle1, nullptr, nullptr, nullptr, true));
} }
TEST(etb, initializationNoThrottles) { TEST(etb, initializationNoThrottles) {
@ -225,8 +225,8 @@ TEST(etb, initializationNoThrottles) {
} }
// Configure ETB functions, but no pedal // Configure ETB functions, but no pedal
engineConfiguration->etbFunctions[0] = ETB_Throttle1; engineConfiguration->etbFunctions[0] = DC_Throttle1;
engineConfiguration->etbFunctions[1] = ETB_Throttle2; engineConfiguration->etbFunctions[1] = DC_Throttle2;
// No pedal - don't init ETBs // No pedal - don't init ETBs
Sensor::resetMockValue(SensorType::AcceleratorPedal); Sensor::resetMockValue(SensorType::AcceleratorPedal);
@ -274,7 +274,7 @@ TEST(etb, testSetpointOnlyPedal) {
Sensor::setMockValue(SensorType::Tps1, 0.0f, true); Sensor::setMockValue(SensorType::Tps1, 0.0f, true);
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true);
// Check endpoints and midpoint // Check endpoints and midpoint
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
@ -334,7 +334,7 @@ TEST(etb, setpointSecondThrottleTrim) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController2 etb(throttleTrimTable); EtbController2 etb(throttleTrimTable);
etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true);
Sensor::setMockValue(SensorType::AcceleratorPedal, 47, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 47, true);
EXPECT_EQ(51, etb.getSetpoint().value_or(-1)); EXPECT_EQ(51, etb.getSetpoint().value_or(-1));
@ -359,7 +359,7 @@ TEST(etb, setpointIdle) {
.WillRepeatedly([](float xRpm, float y) { .WillRepeatedly([](float xRpm, float y) {
return y; return y;
}); });
etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true);
// No idle range, should just pass pedal // No idle range, should just pass pedal
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
@ -416,7 +416,7 @@ TEST(etb, setpointRevLimit) {
.WillRepeatedly([](float, float) { .WillRepeatedly([](float, float) {
return 80; return 80;
}); });
etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true);
// Below threshold, should return unadjusted throttle // Below threshold, should return unadjusted throttle
Sensor::setMockValue(SensorType::Rpm, 1000); Sensor::setMockValue(SensorType::Rpm, 1000);
@ -447,7 +447,7 @@ TEST(etb, setpointNoPedalMap) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
// Don't pass a pedal map // Don't pass a pedal map
etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.getSetpoint(), unexpected); EXPECT_EQ(etb.getSetpoint(), unexpected);
} }
@ -455,7 +455,7 @@ TEST(etb, setpointNoPedalMap) {
TEST(etb, setpointIdleValveController) { TEST(etb, setpointIdleValveController) {
EtbController etb; EtbController etb;
etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, false); etb.init(DC_IdleValve, nullptr, nullptr, nullptr, false);
etb.setIdlePosition(0); etb.setIdlePosition(0);
EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1)); EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1));
@ -474,7 +474,7 @@ TEST(etb, setpointIdleValveController) {
TEST(etb, setpointWastegateController) { TEST(etb, setpointWastegateController) {
EtbController etb; EtbController etb;
etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false); etb.init(DC_Wastegate, nullptr, nullptr, nullptr, false);
etb.setWastegatePosition(0); etb.setWastegatePosition(0);
EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1)); EXPECT_FLOAT_EQ(0, etb.getSetpoint().value_or(-1));
@ -506,7 +506,7 @@ TEST(etb, setpointLuaAdder) {
.WillRepeatedly([](float, float) { .WillRepeatedly([](float, float) {
return 50; return 50;
}); });
etb.init(ETB_Throttle1, nullptr, nullptr, &pedalMap, true); etb.init(DC_Throttle1, nullptr, nullptr, &pedalMap, true);
// No adjustment, should be unadjusted // No adjustment, should be unadjusted
etb.setLuaAdjustment(0); etb.setLuaAdjustment(0);
@ -554,28 +554,28 @@ TEST(etb, etbTpsSensor) {
// Test first throttle // Test first throttle
{ {
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 25.0f); EXPECT_EQ(etb.observePlant().Value, 25.0f);
} }
// Test second throttle // Test second throttle
{ {
EtbController etb; EtbController etb;
etb.init(ETB_Throttle2, nullptr, nullptr, nullptr, true); etb.init(DC_Throttle2, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 75.0f); EXPECT_EQ(etb.observePlant().Value, 75.0f);
} }
// Test wastegate control // Test wastegate control
{ {
EtbController etb; EtbController etb;
etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, true); etb.init(DC_Wastegate, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 33.0f); EXPECT_EQ(etb.observePlant().Value, 33.0f);
} }
// Test idle valve control // Test idle valve control
{ {
EtbController etb; EtbController etb;
etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, true); etb.init(DC_IdleValve, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 66.0f); EXPECT_EQ(etb.observePlant().Value, 66.0f);
} }
} }
@ -591,7 +591,7 @@ TEST(etb, setOutputInvalid) {
StrictMock<MockMotor> motor; StrictMock<MockMotor> motor;
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be disabled in case of unexpected // Should be disabled in case of unexpected
EXPECT_CALL(motor, disable(_)); EXPECT_CALL(motor, disable(_));
@ -609,7 +609,7 @@ TEST(etb, setOutputValid) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be enabled and value set // Should be enabled and value set
EXPECT_CALL(motor, enable()); EXPECT_CALL(motor, enable());
@ -629,7 +629,7 @@ TEST(etb, setOutputValid2) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be enabled and value set // Should be enabled and value set
EXPECT_CALL(motor, enable()); EXPECT_CALL(motor, enable());
@ -649,7 +649,7 @@ TEST(etb, setOutputOutOfRangeHigh) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be enabled and value set // Should be enabled and value set
EXPECT_CALL(motor, enable()); EXPECT_CALL(motor, enable());
@ -669,7 +669,7 @@ TEST(etb, setOutputOutOfRangeLow) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be enabled and value set // Should be enabled and value set
EXPECT_CALL(motor, enable()); EXPECT_CALL(motor, enable());
@ -689,7 +689,7 @@ TEST(etb, setOutputPauseControl) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Pause control - should get no output // Pause control - should get no output
engineConfiguration->pauseEtbControl = true; engineConfiguration->pauseEtbControl = true;
@ -710,7 +710,7 @@ TEST(etb, setOutputLimpHome) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); etb.init(DC_Throttle1, &motor, nullptr, nullptr, true);
// Should be disabled when in ETB limp mode // Should be disabled when in ETB limp mode
EXPECT_CALL(motor, disable(_)); EXPECT_CALL(motor, disable(_));
@ -733,7 +733,7 @@ TEST(etb, closedLoopPid) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, nullptr, &pid, nullptr, true); etb.init(DC_Throttle1, nullptr, &pid, nullptr, true);
// Disable autotune for now // Disable autotune for now
Engine e; Engine e;
@ -774,7 +774,7 @@ TEST(etb, jamDetection) {
engineConfiguration->etbJamTimeout = 1; engineConfiguration->etbJamTimeout = 1;
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, nullptr, &pid, nullptr, true); etb.init(DC_Throttle1, nullptr, &pid, nullptr, true);
timeNowUs = 0; timeNowUs = 0;
@ -812,7 +812,7 @@ TEST(etb, openLoopThrottle) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true);
EtbController etb; EtbController etb;
etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); etb.init(DC_Throttle1, nullptr, nullptr, nullptr, true);
// Map [0, 100] -> [-50, 50] // Map [0, 100] -> [-50, 50]
setLinearCurve(config->etbBiasBins, 0, 100); setLinearCurve(config->etbBiasBins, 0, 100);
@ -834,7 +834,7 @@ TEST(etb, openLoopNonThrottle) {
Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true);
EtbController etb; EtbController etb;
etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false); etb.init(DC_Wastegate, nullptr, nullptr, nullptr, false);
// Map [0, 100] -> [-50, 50] // Map [0, 100] -> [-50, 50]
setLinearCurve(config->etbBiasBins, 0, 100); setLinearCurve(config->etbBiasBins, 0, 100);