rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
electronic_throttle.h File Reference

Detailed Description

Date
Dec 7, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file electronic_throttle.h.

Data Structures

class  IEtbController
 

Enumerations

enum class  EtbState : uint8_t {
  Uninitialized , Autotune , NoMotor , NotEbt ,
  LimpProhibited , Paused , NoOutput , Active ,
  NoPedal , FailFast , InInit , SuccessfulInit
}
 

Functions

void initElectronicThrottle ()
 
void doInitElectronicThrottle (bool isStartupInit)
 
void setEtbIdlePosition (percent_t pos)
 
void setEtbWastegatePosition (percent_t pos)
 
void setEtbLuaAdjustment (percent_t adjustment)
 
void setEwgLuaAdjustment (percent_t pos)
 
void setHitachiEtbCalibration ()
 
void blinkEtbErrorCodes (bool blinkPhase)
 
void setToyota89281_33010_pedal_position_sensor ()
 
void setBoschVAGETB ()
 
void setDefaultEtbBiasCurve ()
 
void setDefaultEtbParameters ()
 
void setBoschVNH2SP30Curve ()
 
void onConfigurationChangeElectronicThrottleCallback (engine_configuration_s *previousConfiguration)
 
void unregisterEtbPins ()
 
void setProteusHitachiEtbDefaults ()
 
void etbAutocal (dc_function_e function, bool reportToTs=true)
 
EtbStatus etbGetState (size_t throttleIndex)
 
float getSanitizedPedal ()
 

Enumeration Type Documentation

◆ EtbState

enum class EtbState : uint8_t
strong
Enumerator
Uninitialized 
Autotune 
NoMotor 
NotEbt 
LimpProhibited 
Paused 
NoOutput 
Active 
NoPedal 
FailFast 
InInit 
SuccessfulInit 

Definition at line 43 of file electronic_throttle.h.

43 : uint8_t {
44 Uninitialized, // 0
45 Autotune, // 1
46 NoMotor, // 2
47 NotEbt, // 3
48 LimpProhibited, // 4
49 Paused, // 5
50 NoOutput, // 6
51 Active, // 7
52 NoPedal, // 8
53 FailFast, // 9
54 InInit, // 10
55 SuccessfulInit, // 11
56};
@ SuccessfulInit
@ LimpProhibited

Function Documentation

◆ blinkEtbErrorCodes()

void blinkEtbErrorCodes ( bool  blinkPhase)

Definition at line 733 of file electronic_throttle.cpp.

733 {
734 for (int i = 0;i<ETB_COUNT;i++) {
738 }
739 etbControllers[i]->etbErrorCodeBlinker = blinkPhase ? 0 : etbErrorCode;
740 }
741}
bool etbAutoTune
Definition engine.h:296
static EtbController * etbControllers[]
static EngineAccessor engine
Definition engine.h:413
etbErrorCode("etbErrorCode", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1864, 1.0, -1.0, -1.0, "")

Referenced by updateTunerStudioState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doInitElectronicThrottle()

void doInitElectronicThrottle ( bool  isStartupInit)

Unexpected electronic throttle start-up position is worth a critical error

Definition at line 898 of file electronic_throttle.cpp.

898 {
899 bool anyEtbConfigured = false;
900
901 // todo: technical debt: we still have DC motor code initialization in ETB-specific file while DC motors are used not just as ETB
902 // like DC motor wastegate code flow should probably NOT go through electronic_throttle.cpp right?
903 // todo: rename etbFunctions to something-without-etb for same reason?
904 for (int i = 0 ; i < ETB_COUNT; i++) {
905 auto func = engineConfiguration->etbFunctions[i];
906 if (func == DC_None) {
907 // do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly
908 continue;
909 }
910 auto motor = initDcMotor("ETB disable",
912
913 auto controller = engine->etbControllers[i];
914 criticalAssertVoid(controller != nullptr, "null ETB");
915
916 auto pid = getPidForDcFunction(func);
917
918 bool dcConfigured = controller->init(func, motor, pid, pedal2TpsProvider());
919 if (isStartupInit && dcConfigured) {
920 controller->reset("init");
921 }
922 anyEtbConfigured |= dcConfigured && controller->isEtbMode();
923 }
924
925 // It's not valid to have a PPS without any ETBs - check that at least one ETB was enabled along with the pedal
926 if (!anyEtbConfigured && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary)) {
927 criticalError("A pedal position sensor was configured, but no electronic throttles are configured.");
928 }
929
930#if 0 && ! EFI_UNIT_TEST
931 percent_t startupThrottlePosition = getTPS();
932 if (std::abs(startupThrottlePosition - engineConfiguration->etbNeutralPosition) > STARTUP_NEUTRAL_POSITION_ERROR_THRESHOLD) {
933 /**
934 * Unexpected electronic throttle start-up position is worth a critical error
935 */
937 startupThrottlePosition,
939 startupPositionError = true;
940 }
941#endif /* EFI_UNIT_TEST */
942
943#if !EFI_UNIT_TEST
944 static bool started = false;
945 if (started == false) {
946 dcThread.start();
947 started = true;
948 }
949#endif
950}
IEtbController * etbControllers[ETB_COUNT]
Definition engine.h:126
virtual bool hasSensor() const
Definition sensor.h:141
DcMotor * initDcMotor(const char *disPinMsg, const dc_io &io, size_t index, bool useTwoWires)
Definition dc_motors.cpp:90
static pid_s * getPidForDcFunction(dc_function_e function)
PUBLIC_API_WEAK ValueProvider3D * pedal2TpsProvider()
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
@ OBD_Throttle_Actuator_Control_Range_Performance_Bank_1
float percent_t
@ AcceleratorPedalPrimary

Referenced by configureRusefiLuaHooks(), initElectronicThrottle(), and EtbController::onConfigurationChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ etbAutocal()

void etbAutocal ( dc_function_e  function,
bool  reportToTs = true 
)

Definition at line 774 of file electronic_throttle.cpp.

774 {
775 for (size_t i = 0 ; i < ETB_COUNT; i++) {
776 /* TODO: use from engine, add getFunction() to base class */
777 //if (auto controller = engine->etbControllers[i]) {
778 if (auto controller = etbControllers[i]) {
779 assertNotNullVoid(controller);
780 if (controller->getFunction() == function) {
781 /* TODO: is it possible that we have several controllers with same function? */
782 controller->autoCalibrateTps(reportToTs);
783 // todo fix root cause! work-around: make sure not to write bad tune since that would brick requestBurn();
784 }
785 }
786 }
787}

Referenced by handleCommandX14(), and initElectronicThrottle().

Here is the caller graph for this function:

◆ etbGetState()

EtbStatus etbGetState ( size_t  throttleIndex)

Definition at line 789 of file electronic_throttle.cpp.

790{
791 if (throttleIndex >= ETB_COUNT) {
793 }
794
795 return (EtbStatus)etbControllers[throttleIndex]->etbErrorCode;
796}
EtbStatus

◆ getSanitizedPedal()

float getSanitizedPedal ( )

Definition at line 291 of file electronic_throttle.cpp.

291 {
292 auto pedalPosition = Sensor::get(SensorType::AcceleratorPedal);
293 // If the pedal has failed, just use 0 position.
294 // This is safer than disabling throttle control - we can at least push the throttle closed
295 // and let the engine idle.
296 return clampPercentValue(pedalPosition.value_or(0));
297}
virtual SensorResult get() const =0

Referenced by EtbController::getSetpointEtb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initElectronicThrottle()

void initElectronicThrottle ( )

Definition at line 952 of file electronic_throttle.cpp.

952 {
953 if (hasFirmwareError()) {
954 return;
955 }
956
957 for (int i = 0; i < ETB_COUNT; i++) {
959 }
960
961#if EFI_PROD_CODE
962 addConsoleAction("etbautocal", [](){
963 efiPrintf("etbAutocal invoked");
964 etbAutocal(DC_Throttle1);
965 });
966
967 addConsoleAction("etbinfo", [](){
968 efiPrintf("etbAutoTune=%d", engine->etbAutoTune);
969 efiPrintf("TPS=%.2f", Sensor::getOrZero(SensorType::Tps1));
970
971 efiPrintf("ETB1 duty=%.2f",
973
974 efiPrintf("ETB freq=%d",
976
977 for (int i = 0; i < ETB_COUNT; i++) {
978 efiPrintf("ETB%d", i);
979 efiPrintf(" dir1=%s", hwPortname(engineConfiguration->etbIo[i].directionPin1));
980 efiPrintf(" dir2=%s", hwPortname(engineConfiguration->etbIo[i].directionPin2));
981 efiPrintf(" control=%s", hwPortname(engineConfiguration->etbIo[i].controlPin));
982 efiPrintf(" disable=%s", hwPortname(engineConfiguration->etbIo[i].disablePin));
984 }
985 });
986
987#endif /* EFI_PROD_CODE */
988
992
993 doInitElectronicThrottle(/*isStartupInit*/true);
994}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
void initTable(TValueInit(&table)[TRowNum][TColNum], const TXColumnInit(&columnBins)[TColNum], const TRowInit(&rowBins)[TRowNum])
static float getOrZero(SensorType type)
Definition sensor.h:83
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void showDcMotorInfo(int i)
void etbAutocal(dc_function_e function, bool reportToTs)
static Map3D< TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t > tcEtbDropTable
static Map3D< ETB2_TRIM_SIZE, ETB2_TRIM_SIZE, int8_t, uint8_t, uint8_t > throttle2TrimTable
static pedal2tps_t pedal2tpsMap
void doInitElectronicThrottle(bool isStartupInit)
static constexpr persistent_config_s * config
const char * hwPortname(brain_pin_e brainPin)
uint8_t tractionControlSpeedBins[TRACTION_CONTROL_ETB_DROP_SPEED_SIZE]
scaled_channel< uint16_t, 100, 1 > tractionControlSlipBins[TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]
int8_t tractionControlEtbDrop[TRACTION_CONTROL_ETB_DROP_SLIP_SIZE][TRACTION_CONTROL_ETB_DROP_SPEED_SIZE]
scaled_channel< int16_t, 100, 1 > etb1DutyCycle
uint8_t pedalToTpsTable[PEDAL_TO_TPS_SIZE][PEDAL_TO_TPS_RPM_SIZE]
scaled_channel< uint8_t, 1, 100 > throttle2TrimRpmBins[ETB2_TRIM_SIZE]
scaled_channel< uint8_t, 1, 100 > pedalToTpsRpmBins[PEDAL_TO_TPS_RPM_SIZE]
scaled_channel< int8_t, 10, 1 > throttle2TrimTable[ETB2_TRIM_SIZE][ETB2_TRIM_SIZE]

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onConfigurationChangeElectronicThrottleCallback()

void onConfigurationChangeElectronicThrottleCallback ( engine_configuration_s previousConfiguration)

Definition at line 863 of file electronic_throttle.cpp.

863 {
864 for (int i = 0; i < ETB_COUNT; i++) {
865 etbControllers[i]->onConfigurationChange(&previousConfiguration->etb);
866 }
867}
void onConfigurationChange(pid_s *previousConfiguration)

Referenced by incrementGlobalConfigurationVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBoschVAGETB()

void setBoschVAGETB ( )

Definition at line 808 of file electronic_throttle.cpp.

Referenced by commonPassatB6(), and hellen121_vag_boardDefaultConfiguration().

Here is the caller graph for this function:

◆ setBoschVNH2SP30Curve()

void setBoschVNH2SP30Curve ( )

Definition at line 821 of file electronic_throttle.cpp.

821 {
822 copyArray(config->etbBiasBins, boschBiasBins);
824}
static const float boschBiasValues[]
static const float boschBiasBins[]

Referenced by setEtbTestConfiguration().

Here is the caller graph for this function:

◆ setDefaultEtbBiasCurve()

void setDefaultEtbBiasCurve ( )

Definition at line 876 of file electronic_throttle.cpp.

876 {
881}
static const float defaultBiasValues[]
static const float defaultBiasBins[]
scaled_channel< int16_t, 100, 1 > dcWastegateBiasValues[ETB_BIAS_CURVE_LENGTH]

Referenced by setDefaultEngineConfiguration().

Here is the caller graph for this function:

◆ setDefaultEtbParameters()

void setDefaultEtbParameters ( )

Definition at line 826 of file electronic_throttle.cpp.

826 {
828
829 setLinearCurve(config->pedalToTpsPedalBins, /*from*/0, /*to*/100, 1);
831
832 for (int pedalIndex = 0;pedalIndex<PEDAL_TO_TPS_SIZE;pedalIndex++) {
833 for (int rpmIndex = 0;rpmIndex<PEDAL_TO_TPS_RPM_SIZE;rpmIndex++) {
834 config->pedalToTpsTable[pedalIndex][rpmIndex] = config->pedalToTpsPedalBins[pedalIndex];
835 }
836 }
837
838 // Default is to run each throttle off its respective hbridge
839 engineConfiguration->etbFunctions[0] = DC_Throttle1;
840 engineConfiguration->etbFunctions[1] = DC_Throttle2;
841
842 engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
843
844 // voltage, not ADC like with TPS
845 setPPSCalibration(0, 5, 5, 0);
846
848 1, // Kp
849 10, // Ki
850 0.05, // Kd
851 0, // offset
852 0, // Update rate, unused
853 -100, 100 // min/max
854 };
855
858
860// engineConfiguration->etbJamTimeout = 1;
861}
void setPPSCalibration(float primaryUp, float primaryDown, float secondaryUp, float secondaryDown)
void setRpmTableBin(TValue(&array)[TSize])
void setLinearCurve(TValue(&array)[TSize], float from, float to, float precision=0.01f)

Referenced by setDefaultEngineConfiguration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEtbIdlePosition()

void setEtbIdlePosition ( percent_t  pos)

Definition at line 996 of file electronic_throttle.cpp.

996 {
997 for (int i = 0; i < ETB_COUNT; i++) {
998 if (auto etb = engine->etbControllers[i]) {
999 assertNotNullVoid(etb);
1000 etb->setIdlePosition(pos);
1001 }
1002 }
1003}

Referenced by applyIACposition().

Here is the caller graph for this function:

◆ setEtbLuaAdjustment()

void setEtbLuaAdjustment ( percent_t  adjustment)

Definition at line 1014 of file electronic_throttle.cpp.

1014 {
1015 for (int i = 0; i < ETB_COUNT; i++) {
1016 /* TODO: use from engine, add getFunction() to base class */
1017 //if (auto etb = engine->etbControllers[i]) {
1018 if (auto etb = etbControllers[i]) {
1019 assertNotNullVoid(etb);
1020 // try to adjust all ETB
1021 if (etb->getFunction() == DC_Throttle1 || etb->getFunction() == DC_Throttle2) {
1022 etb->setLuaAdjustment(pos);
1023 }
1024 }
1025 }
1026}

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ setEtbWastegatePosition()

void setEtbWastegatePosition ( percent_t  pos)

Definition at line 1005 of file electronic_throttle.cpp.

1005 {
1006 for (int i = 0; i < ETB_COUNT; i++) {
1007 if (auto etb = engine->etbControllers[i]) {
1008 assertNotNullVoid(etb);
1009 etb->setWastegatePosition(pos);
1010 }
1011 }
1012}

Referenced by BoostController::setOutput().

Here is the caller graph for this function:

◆ setEwgLuaAdjustment()

void setEwgLuaAdjustment ( percent_t  pos)

Definition at line 1028 of file electronic_throttle.cpp.

1028 {
1029 for (int i = 0; i < ETB_COUNT; i++) {
1030 /* TODO: use from engine, add getFunction() to base class */
1031 //if (auto etb = engine->etbControllers[i]) {
1032 if (auto etb = etbControllers[i]) {
1033 assertNotNullVoid(etb);
1034 // try to adjust all ETB
1035 if (etb->getFunction() == DC_Wastegate) {
1036 etb->setLuaAdjustment(pos);
1037 }
1038 }
1039 }
1040}

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ setHitachiEtbCalibration()

void setHitachiEtbCalibration ( )

Definition at line 1046 of file electronic_throttle.cpp.

1046 {
1048
1050
1058
1059 // Nissan 60mm throttle
1064}
void setToyota89281_33010_pedal_position_sensor()
void setHitachiEtbBiasBins()

Referenced by setProteusHitachiEtbDefaults().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setProteusHitachiEtbDefaults()

void setProteusHitachiEtbDefaults ( )

Definition at line 1066 of file electronic_throttle.cpp.

1066 {
1067#if HW_PROTEUS
1069
1070 // EFI_ADC_12: "Analog Volt 3"
1071 engineConfiguration->tps1_2AdcChannel = PROTEUS_IN_TPS1_2;
1072 // EFI_ADC_13: "Analog Volt 4"
1073 engineConfiguration->tps2_1AdcChannel = PROTEUS_IN_TPS2_1;
1074 // EFI_ADC_0: "Analog Volt 5"
1075 engineConfiguration->tps2_2AdcChannel = PROTEUS_IN_ANALOG_VOLT_5;
1076 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_6, PROTEUS_IN_PPS2);
1077#endif // HW_PROTEUS
1078}
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setHitachiEtbCalibration()

Referenced by setEngineBMW_M73_Proteus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToyota89281_33010_pedal_position_sensor()

void setToyota89281_33010_pedal_position_sensor ( )

Definition at line 1042 of file electronic_throttle.cpp.

1042 {
1043 setPPSCalibration(0, 4.1, 0.73, 4.9);
1044}

Referenced by setHitachiEtbCalibration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unregisterEtbPins()

void unregisterEtbPins ( )

Definition at line 883 of file electronic_throttle.cpp.

883 {
884 // todo: we probably need an implementation here?!
885}

Referenced by EnginePins::unregisterPins().

Here is the caller graph for this function:

Go to the source code of this file.