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 pickEtbOrStepper ()
 
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)
 
void etbBenchTestStart (size_t throttleIndex)
 
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 46 of file electronic_throttle.h.

46 : uint8_t {
47 Uninitialized, // 0
48 Autotune, // 1
49 NoMotor, // 2
50 NotEbt, // 3
51 LimpProhibited, // 4
52 Paused, // 5
53 NoOutput, // 6
54 Active, // 7
55 NoPedal, // 8
56 FailFast, // 9
57 InInit, // 10
58 SuccessfulInit, // 11
59};
@ 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:304
static EtbController * etbControllers[]
static EngineAccessor engine
Definition engine.h:415
etbErrorCode("etbErrorCode", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1884, 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 909 of file electronic_throttle.cpp.

909 {
910 bool anyEtbConfigured = false;
911
912 // todo: technical debt: we still have DC motor code initialization in ETB-specific file while DC motors are used not just as ETB
913 // like DC motor wastegate code flow should probably NOT go through electronic_throttle.cpp right?
914 // todo: rename etbFunctions to something-without-etb for same reason?
915 for (int i = 0 ; i < ETB_COUNT; i++) {
916 auto func = engineConfiguration->etbFunctions[i];
917 if (func == DC_None) {
918 // do not touch HW pins if function not selected, this way Lua can use DC motor hardware pins directly
919 continue;
920 }
921 auto motor = initDcMotor("ETB disable",
923
924 auto controller = engine->etbControllers[i];
925 criticalAssertVoid(controller != nullptr, "null ETB");
926
927 auto pid = getPidForDcFunction(func);
928
929 bool dcConfigured = controller->init(func, motor, pid, pedal2TpsProvider());
930 if (isStartupInit && dcConfigured) {
931 controller->reset("init");
932 }
933 anyEtbConfigured |= dcConfigured && controller->isEtbMode();
934 }
935
936 // It's not valid to have a PPS without any ETBs - check that at least one ETB was enabled along with the pedal
937 if (!anyEtbConfigured && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary)) {
938 criticalError("A pedal position sensor was configured, but no electronic throttles are configured.");
939 }
940
941#if 0 && ! EFI_UNIT_TEST
942 percent_t startupThrottlePosition = getTPS();
943 if (std::abs(startupThrottlePosition - engineConfiguration->etbNeutralPosition) > STARTUP_NEUTRAL_POSITION_ERROR_THRESHOLD) {
944 /**
945 * Unexpected electronic throttle start-up position is worth a critical error
946 */
948 startupThrottlePosition,
950 startupPositionError = true;
951 }
952#endif /* EFI_UNIT_TEST */
953
954#if !EFI_UNIT_TEST
955 static bool started = false;
956 if (started == false) {
957 dcThread.start();
958 started = true;
959 }
960#endif
961}
IEtbController * etbControllers[ETB_COUNT]
Definition engine.h:130
virtual bool hasSensor() const
Definition sensor.h:145
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:

◆ etbBenchTestStart()

void etbBenchTestStart ( size_t  throttleIndex)

Definition at line 789 of file electronic_throttle.cpp.

789 {
790 if (throttleIndex >= ETB_COUNT) {
791 efiPrintf("ETB bench test: invalid index %d", (int)throttleIndex);
792 return;
793 }
794 if (auto controller = etbControllers[throttleIndex]) {
795 assertNotNullVoid(controller);
796 controller->startBenchTest();
797 }
798}

Referenced by handleCommandX14().

Here is the caller graph for this function:

◆ etbGetState()

EtbStatus etbGetState ( size_t  throttleIndex)

Definition at line 800 of file electronic_throttle.cpp.

801{
802 if (throttleIndex >= ETB_COUNT) {
804 }
805
806 return (EtbStatus)etbControllers[throttleIndex]->etbErrorCode;
807}
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 963 of file electronic_throttle.cpp.

963 {
964 if (hasFirmwareError()) {
965 return;
966 }
967
968 for (int i = 0; i < ETB_COUNT; i++) {
970 }
971
972#if EFI_PROD_CODE
973 addConsoleAction("etbautocal", [](){
974 efiPrintf("etbAutocal invoked");
975 etbAutocal(DC_Throttle1);
976 });
977
978 addConsoleAction("etbinfo", [](){
979 efiPrintf("etbAutoTune=%d", engine->etbAutoTune);
980 efiPrintf("TPS=%.2f", Sensor::getOrZero(SensorType::Tps1));
981
982 efiPrintf("ETB1 duty=%.2f",
984
985 efiPrintf("ETB freq=%d",
987
988 for (int i = 0; i < ETB_COUNT; i++) {
989 efiPrintf("ETB%d", i);
990 efiPrintf(" dir1=%s", hwPortname(engineConfiguration->etbIo[i].directionPin1));
991 efiPrintf(" dir2=%s", hwPortname(engineConfiguration->etbIo[i].directionPin2));
992 efiPrintf(" control=%s", hwPortname(engineConfiguration->etbIo[i].controlPin));
993 efiPrintf(" disable=%s", hwPortname(engineConfiguration->etbIo[i].disablePin));
995 }
996 });
997
998#endif /* EFI_PROD_CODE */
999
1003
1004 doInitElectronicThrottle(/*isStartupInit*/true);
1005}
TunerStudioOutputChannels outputChannels
Definition engine.h:113
void initTable(TValueInit(&table)[TRowNum][TColNum], const TXColumnInit(&columnBins)[TColNum], const TRowInit(&rowBins)[TRowNum])
static float getOrZero(SensorType type)
Definition sensor.h:87
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_RPM_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_SPEED_SIZE][TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]
scaled_channel< int16_t, 100, 1 > etb1DutyCycle
uint8_t pedalToTpsTable[PEDAL_TO_TPS_SIZE][PEDAL_TO_TPS_RPM_SIZE]
scaled_channel< int8_t, 10, 1 > throttle2TrimTable[ETB2_TRIM_SIZE][ETB2_TRIM_RPM_SIZE]
scaled_channel< uint8_t, 1, 100 > throttle2TrimRpmBins[ETB2_TRIM_RPM_SIZE]
scaled_channel< uint8_t, 1, 100 > pedalToTpsRpmBins[PEDAL_TO_TPS_RPM_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 874 of file electronic_throttle.cpp.

874 {
875 for (int i = 0; i < ETB_COUNT; i++) {
876 etbControllers[i]->onConfigurationChange(&previousConfiguration->etb);
877 }
878}
void onConfigurationChange(pid_s *previousConfiguration)

Referenced by incrementGlobalConfigurationVersion().

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

◆ pickEtbOrStepper()

void pickEtbOrStepper ( )

Definition at line 1108 of file electronic_throttle.cpp.

1108 {
1110 return;
1111 }
1112 for (size_t i = 0;i<ETB_COUNT;i++) {
1113 if (engineConfiguration->etbFunctions[i] != DC_None) {
1114 criticalError("Cannot use H-bridge for stepper while DC function is selected");
1115 }
1116 }
1117}

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

◆ setBoschVAGETB()

void setBoschVAGETB ( )

Definition at line 819 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 832 of file electronic_throttle.cpp.

832 {
833 copyArray(config->etbBiasBins, boschBiasBins);
835}
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 887 of file electronic_throttle.cpp.

887 {
892}
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 837 of file electronic_throttle.cpp.

837 {
839
840 setLinearCurve(config->pedalToTpsPedalBins, /*from*/0, /*to*/100, 1);
842
843 for (int pedalIndex = 0;pedalIndex<PEDAL_TO_TPS_SIZE;pedalIndex++) {
844 for (int rpmIndex = 0;rpmIndex<PEDAL_TO_TPS_RPM_SIZE;rpmIndex++) {
845 config->pedalToTpsTable[pedalIndex][rpmIndex] = config->pedalToTpsPedalBins[pedalIndex];
846 }
847 }
848
849 // Default is to run each throttle off its respective hbridge
850 engineConfiguration->etbFunctions[0] = DC_Throttle1;
851 engineConfiguration->etbFunctions[1] = DC_Throttle2;
852
853 engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY;
854
855 // voltage, not ADC like with TPS
856 setPPSCalibration(0, 5, 5, 0);
857
859 1, // Kp
860 10, // Ki
861 0.05, // Kd
862 0, // offset
863 0, // Update rate, unused
864 -100, 100 // min/max
865 };
866
869
871// engineConfiguration->etbJamTimeout = 1;
872}
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 1007 of file electronic_throttle.cpp.

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

Referenced by applyIACposition().

Here is the caller graph for this function:

◆ setEtbLuaAdjustment()

void setEtbLuaAdjustment ( percent_t  adjustment)

Definition at line 1025 of file electronic_throttle.cpp.

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

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ setEtbWastegatePosition()

void setEtbWastegatePosition ( percent_t  pos)

Definition at line 1016 of file electronic_throttle.cpp.

1016 {
1017 for (int i = 0; i < ETB_COUNT; i++) {
1018 if (auto etb = engine->etbControllers[i]) {
1019 assertNotNullVoid(etb);
1020 etb->setWastegatePosition(pos);
1021 }
1022 }
1023}

Referenced by BoostController::setOutput().

Here is the caller graph for this function:

◆ setEwgLuaAdjustment()

void setEwgLuaAdjustment ( percent_t  pos)

Definition at line 1039 of file electronic_throttle.cpp.

1039 {
1040 for (int i = 0; i < ETB_COUNT; i++) {
1041 /* TODO: use from engine, add getFunction() to base class */
1042 //if (auto etb = engine->etbControllers[i]) {
1043 if (auto etb = etbControllers[i]) {
1044 assertNotNullVoid(etb);
1045 // try to adjust all ETB
1046 if (etb->getFunction() == DC_Wastegate) {
1047 etb->setLuaAdjustment(pos);
1048 }
1049 }
1050 }
1051}

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ setHitachiEtbCalibration()

void setHitachiEtbCalibration ( )

Definition at line 1057 of file electronic_throttle.cpp.

1057 {
1059
1061
1069
1070 // Nissan 60mm throttle
1075}
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 1077 of file electronic_throttle.cpp.

1077 {
1078#if HW_PROTEUS
1080
1081 // EFI_ADC_12: "Analog Volt 3"
1082 engineConfiguration->tps1_2AdcChannel = PROTEUS_IN_TPS1_2;
1083 // EFI_ADC_13: "Analog Volt 4"
1084 engineConfiguration->tps2_1AdcChannel = PROTEUS_IN_TPS2_1;
1085 // EFI_ADC_0: "Analog Volt 5"
1086 engineConfiguration->tps2_2AdcChannel = PROTEUS_IN_ANALOG_VOLT_5;
1087 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_6, PROTEUS_IN_PPS2);
1088#endif // HW_PROTEUS
1089}
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 1053 of file electronic_throttle.cpp.

1053 {
1054 setPPSCalibration(0, 4.1, 0.73, 4.9);
1055}

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 894 of file electronic_throttle.cpp.

894 {
895 // todo: we probably need an implementation here?!
896}

Referenced by EnginePins::unregisterPins().

Here is the caller graph for this function:

Go to the source code of this file.