rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes
EtbImpl< TBase > Class Template Referencefinal

#include <electronic_throttle_impl.h>

Inheritance diagram for EtbImpl< TBase >:
Inheritance graph
[legend]
Collaboration diagram for EtbImpl< TBase >:
Collaboration graph
[legend]

Public Member Functions

template<typename... TArgs>
 EtbImpl (TArgs &&... args)
 
void update () override
 
void autoCalibrateTps (bool reportToTs) override
 
ACPhase doAutocal (ACPhase phase)
 

Private Types

enum class  ACPhase {
  Stopped , Start , Open , Close ,
  TransmitPrimaryMax , TransmitPrimaryMin , TransmitSecondaryMax , TransmitSecondaryMin
}
 

Private Attributes

ACPhase m_autocalPhase = ACPhase::Stopped
 
Timer m_autocalTimer
 
bool m_isAutocalTs
 
float m_primaryMax
 
float m_secondaryMax
 
float m_primaryMin
 
float m_secondaryMin
 

Detailed Description

template<typename TBase>
class EtbImpl< TBase >

Definition at line 155 of file electronic_throttle_impl.h.

Member Enumeration Documentation

◆ ACPhase

template<typename TBase >
enum class EtbImpl::ACPhase
strongprivate
Enumerator
Stopped 
Start 
Open 
Close 
TransmitPrimaryMax 
TransmitPrimaryMin 
TransmitSecondaryMax 
TransmitSecondaryMin 

Definition at line 157 of file electronic_throttle_impl.h.

157 {
158 Stopped,
159
160 Start,
161
162 // Drive the motor open
163 Open,
164
165 // Drive the motor closed
166 Close,
167
168 // Write learned values to TS
173 };

Constructor & Destructor Documentation

◆ EtbImpl()

template<typename TBase >
template<typename... TArgs>
EtbImpl< TBase >::EtbImpl ( TArgs &&...  args)
inline

Definition at line 177 of file electronic_throttle_impl.h.

177: TBase(std::forward<TArgs>(args)...) { }

Member Function Documentation

◆ autoCalibrateTps()

template<typename TBase >
void EtbImpl< TBase >::autoCalibrateTps ( bool  reportToTs)
inlineoverride

Definition at line 197 of file electronic_throttle_impl.h.

197 {
198 // Only auto calibrate throttles
199 if (TBase::getFunction() == DC_Throttle1 || TBase::getFunction() == DC_Throttle2 || TBase::getFunction() == DC_Wastegate) {
200 m_isAutocalTs = reportToTs;
202 }
203 }

◆ doAutocal()

template<typename TBase >
ACPhase EtbImpl< TBase >::doAutocal ( ACPhase  phase)
inline

Definition at line 205 of file electronic_throttle_impl.h.

205 {
206 // Don't allow if engine is running!
208 efiPrintf(" ****************** ERROR: Not while RPM ********************");
209 return ACPhase::Stopped;
210 }
211
212 auto motor = TBase::getMotor();
213 if (!motor) {
214 efiPrintf(" ****************** ERROR: No DC motor ********************");
215 return ACPhase::Stopped;
216 }
217
218 TBase::etbErrorCode = (uint8_t)EtbStatus::AutoCalibrate;
219
220 auto myFunction = TBase::getFunction();
221
222 switch (phase) {
223 case ACPhase::Start:
224 // Open the throttle
225 motor->set(0.5f);
226 motor->enable();
227 return ACPhase::Open;
228 case ACPhase::Open:
229 if (m_autocalTimer.hasElapsedMs(1000)) {
230 // Capture open position
233
234 // Next: close the throttle
235 motor->set(-0.5f);
236 return ACPhase::Close;
237 }
238 break;
239 case ACPhase::Close:
240 if (m_autocalTimer.hasElapsedMs(1000)) {
241 // Capture closed position
244
245 // Disable the motor, we're done
246 motor->disable("autotune");
247
248 // Check that the calibrate actually moved the throttle
249 if (std::abs(m_primaryMax - m_primaryMin) < 0.5f) {
250 firmwareError(ObdCode::OBD_TPS_Configuration, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", m_primaryMin, m_primaryMax);
251 return ACPhase::Stopped;
252 }
253
254 if (!m_isAutocalTs) {
255 if (myFunction == DC_Throttle1) {
260 } else if (myFunction == DC_Throttle2) {
265 } else if (myFunction == DC_Wastegate) {
268 } else {
269 /* TODO */
270 }
271 return ACPhase::Stopped;
272 }
273
274 // Next: start transmitting results
277 }
278 break;
280 if (tsCalibrationIsIdle()) {
283 }
284 break;
286 if (tsCalibrationIsIdle()) {
288 // No secondary sensor?
290 return ACPhase::Stopped;
292 }
293 break;
295 if (tsCalibrationIsIdle()) {
298 }
299 break;
301 if (tsCalibrationIsIdle()) {
302 // Done!
303 return ACPhase::Stopped;
304 }
305 break;
306 case ACPhase::Stopped: break;
307 }
308
309 // by default, stay in the same phase
310 return phase;
311 }
virtual float getRaw() const
Definition sensor.h:148
static float getOrZero(SensorType type)
Definition sensor.h:83
static TsCalMode functionToCalModePriMin(dc_function_e func)
static TsCalMode functionToCalModeSecMin(dc_function_e func)
static SensorType functionToTpsSensorPrimary(dc_function_e func)
static TsCalMode functionToCalModePriMax(dc_function_e func)
static SensorType functionToTpsSensorSecondary(dc_function_e func)
static TsCalMode functionToCalModeSecMax(dc_function_e func)
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
@ OBD_TPS_Configuration
constexpr int convertVoltageTo10bitADC(float voltage)
Definition tps.h:21
void tsCalibrationSetData(TsCalMode mode, float value, float value2, float timeoutMs)

Referenced by EtbImpl< TBase >::update().

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

◆ update()

template<typename TBase >
void EtbImpl< TBase >::update ( )
inlineoverride

Definition at line 179 of file electronic_throttle_impl.h.

179 {
180#if EFI_TUNER_STUDIO
182 ACPhase nextPhase = doAutocal(m_autocalPhase);
183
184 // if we changed phase, reset the phase timer
185 if (m_autocalPhase != nextPhase) {
186 m_autocalTimer.reset();
187 m_autocalPhase = nextPhase;
188 }
189 } else
190#endif /* EFI_TUNER_STUDIO */
191
192 {
193 TBase::update();
194 }
195 }
ACPhase doAutocal(ACPhase phase)
Here is the call graph for this function:

Field Documentation

◆ m_autocalPhase

template<typename TBase >
ACPhase EtbImpl< TBase >::m_autocalPhase = ACPhase::Stopped
private

◆ m_autocalTimer

template<typename TBase >
Timer EtbImpl< TBase >::m_autocalTimer
private

◆ m_isAutocalTs

template<typename TBase >
bool EtbImpl< TBase >::m_isAutocalTs
private

◆ m_primaryMax

template<typename TBase >
float EtbImpl< TBase >::m_primaryMax
private

Definition at line 319 of file electronic_throttle_impl.h.

Referenced by EtbImpl< TBase >::doAutocal().

◆ m_primaryMin

template<typename TBase >
float EtbImpl< TBase >::m_primaryMin
private

Definition at line 321 of file electronic_throttle_impl.h.

Referenced by EtbImpl< TBase >::doAutocal().

◆ m_secondaryMax

template<typename TBase >
float EtbImpl< TBase >::m_secondaryMax
private

Definition at line 320 of file electronic_throttle_impl.h.

Referenced by EtbImpl< TBase >::doAutocal().

◆ m_secondaryMin

template<typename TBase >
float EtbImpl< TBase >::m_secondaryMin
private

Definition at line 322 of file electronic_throttle_impl.h.

Referenced by EtbImpl< TBase >::doAutocal().


The documentation for this class was generated from the following file: