rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
VvtController Class Reference

#include <vvt.h>

Inheritance diagram for VvtController:
Inheritance graph
[legend]
Collaboration diagram for VvtController:
Collaboration graph
[legend]

Public Member Functions

 VvtController (int index)
 
void init (const ValueProvider3D *targetMap, IPwm *pwm)
 
void onFastCallback () override
 
void onConfigurationChange (engine_configuration_s const *previousConfig) override
 
expected< angle_tobservePlant () override
 
expected< angle_tgetSetpoint () override
 
expected< percent_tgetOpenLoop (angle_t target) override
 
expected< percent_tgetClosedLoop (angle_t setpoint, angle_t observation) override
 
void setOutput (expected< percent_t > outputValue) override
 
uint8_t getCamIndex ()
 
- Public Member Functions inherited from EngineModule
virtual void initNoConfiguration ()
 
virtual void setDefaultConfiguration ()
 
virtual void onSlowCallback ()
 
virtual void onEngineStop ()
 
virtual void onIgnitionStateChanged (bool)
 
virtual bool needsDelayedShutoff ()
 
virtual void onEnginePhase (float, efitick_t, angle_t, angle_t)
 
- Public Member Functions inherited from ClosedLoopController< angle_t, percent_t >
void update ()
 

Private Attributes

const int index
 
const uint8_t m_bank
 
const uint8_t m_cam
 
Pid m_pid
 
bool m_engineRunningLongEnough = false
 
bool m_isRpmHighEnough = false
 
bool m_isCltWarmEnough = false
 
const ValueProvider3Dm_targetMap = nullptr
 
IPwmm_pwm = nullptr
 

Additional Inherited Members

- Data Fields inherited from vvt_s
scaled_channel< int16_t, 10, 1 > vvtTarget = (int16_t)0
 
scaled_channel< uint8_t, 2, 1 > vvtOutput = (uint8_t)0
 
uint8_t alignmentFill_at_3 [1] = {}
 

Detailed Description

Definition at line 26 of file vvt.h.

Constructor & Destructor Documentation

◆ VvtController()

VvtController::VvtController ( int  index)

Definition at line 22 of file vvt.cpp.

23 : index(p_index)
26{
27}
const uint8_t m_bank
Definition vvt.h:51
const int index
Definition vvt.h:49
const uint8_t m_cam
Definition vvt.h:53

Member Function Documentation

◆ getCamIndex()

uint8_t VvtController::getCamIndex ( )
inline

Definition at line 44 of file vvt.h.

44 {
45 return m_cam;
46 }

◆ getClosedLoop()

expected< percent_t > VvtController::getClosedLoop ( angle_t  setpoint,
angle_t  observation 
)
overridevirtual

Implements ClosedLoopController< angle_t, percent_t >.

Definition at line 106 of file vvt.cpp.

106 {
107 // User labels say "advance" and "retard"
108 // "advance" means that additional solenoid duty makes indicated VVT position more positive
109 // "retard" means that additional solenoid duty makes indicated VVT position more negative
111 m_pid.setErrorAmplification(isInverted ? -1.0f : 1.0f);
112
113 float retVal = m_pid.getOutput(target, observation);
114
115#if EFI_TUNER_STUDIO
117#endif /* EFI_TUNER_STUDIO */
118
119 return retVal;
120}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
void setErrorAmplification(float coef)
Definition efi_pid.cpp:138
void postState(pid_status_s &pidStatus) const
Definition efi_pid.cpp:144
float getOutput(float target, float input)
Definition efi_pid.cpp:56
Pid m_pid
Definition vvt.h:55
static EngineAccessor engine
Definition engine.h:413
pid_status_s vvtStatus[CAM_INPUTS_COUNT]
static bool shouldInvertVvt(int camIndex)
Definition vvt.cpp:96
Here is the call graph for this function:

◆ getOpenLoop()

expected< percent_t > VvtController::getOpenLoop ( angle_t  target)
overridevirtual

Implements ClosedLoopController< angle_t, percent_t >.

Definition at line 90 of file vvt.cpp.

90 {
91 // TODO: could we do VVT open loop?
92 UNUSED(target);
93 return 0;
94}
UNUSED(samplingTimeSeconds)
Here is the call graph for this function:

◆ getSetpoint()

expected< angle_t > VvtController::getSetpoint ( )
overridevirtual

Implements ClosedLoopController< angle_t, percent_t >.

Definition at line 66 of file vvt.cpp.

66 {
68 bool enabled = m_engineRunningLongEnough &&
69#if EFI_PROD_CODE || EFI_UNIT_TEST
70// simulator functional test does not have CLT or flag?
72#endif
74 if (!enabled) {
75 return unexpected;
76 }
77
78 float load = getFuelingLoad();
79 float target = m_targetMap->getValue(rpm, load);
80
81#if EFI_TUNER_STUDIO
83#endif
84
85 vvtTarget = target;
86
87 return target;
88}
static float getOrZero(SensorType type)
Definition sensor.h:83
virtual float getValue(float xColumn, float yRow) const =0
bool m_engineRunningLongEnough
Definition vvt.h:58
bool m_isCltWarmEnough
Definition vvt.h:60
const ValueProvider3D * m_targetMap
Definition vvt.h:62
bool m_isRpmHighEnough
Definition vvt.h:59
float getFuelingLoad()
scaled_channel< int16_t, 10, 1 > vvtTarget
Here is the call graph for this function:

◆ init()

void VvtController::init ( const ValueProvider3D targetMap,
IPwm pwm 
)

Definition at line 29 of file vvt.cpp.

29 {
30 // Use the same settings for the Nth cam in every bank (ie, all exhaust cams use the same PID)
32
34 m_pwm = pwm;
35}
void initPidClass(pid_s *parameters)
Definition efi_pid.cpp:24
IPwm * m_pwm
Definition vvt.h:63
static constexpr engine_configuration_s * engineConfiguration
Here is the call graph for this function:

◆ observePlant()

expected< angle_t > VvtController::observePlant ( )
overridevirtual

Implements ClosedLoopController< angle_t, percent_t >.

Definition at line 58 of file vvt.cpp.

58 {
59#if EFI_SHAFT_POSITION_INPUT
61#else
62 return unexpected;
63#endif // EFI_SHAFT_POSITION_INPUT
64}
TriggerCentral triggerCentral
Definition engine.h:318
angle_t getVVTPosition(uint8_t bankIndex, uint8_t camIndex)
Here is the call graph for this function:

◆ onConfigurationChange()

void VvtController::onConfigurationChange ( engine_configuration_s const previousConfig)
overridevirtual

Reimplemented from EngineModule.

Definition at line 52 of file vvt.cpp.

52 {
53 if (!previousConfig || !m_pid.isSame(&previousConfig->auxPid[m_cam])) {
54 m_pid.reset();
55 }
56}
bool isSame(const pid_s *parameters) const
Definition efi_pid.cpp:39
virtual void reset()
Definition efi_pid.cpp:103
Here is the call graph for this function:

◆ onFastCallback()

void VvtController::onFastCallback ( )
overridevirtual

◆ setOutput()

void VvtController::setOutput ( expected< percent_t outputValue)
overridevirtual

Implements ClosedLoopController< angle_t, percent_t >.

Definition at line 122 of file vvt.cpp.

122 {
123#if EFI_SHAFT_POSITION_INPUT
124 vvtOutput = outputValue.value_or(0);
125
126 if (outputValue) {
128 } else {
130
131 // we need to avoid accumulating iTerm while engine is not running
132 m_pid.reset();
133 }
134#endif // EFI_SHAFT_POSITION_INPUT
135}
virtual void setSimplePwmDutyCycle(float dutyCycle)=0
scaled_channel< uint8_t, 2, 1 > vvtOutput
Here is the call graph for this function:

Field Documentation

◆ index

const int VvtController::index
private

◆ m_bank

const uint8_t VvtController::m_bank
private

Definition at line 51 of file vvt.h.

Referenced by observePlant().

◆ m_cam

const uint8_t VvtController::m_cam
private

Definition at line 53 of file vvt.h.

Referenced by getCamIndex(), getClosedLoop(), init(), observePlant(), and onConfigurationChange().

◆ m_engineRunningLongEnough

bool VvtController::m_engineRunningLongEnough = false
private

Definition at line 58 of file vvt.h.

Referenced by getSetpoint(), and onFastCallback().

◆ m_isCltWarmEnough

bool VvtController::m_isCltWarmEnough = false
private

Definition at line 60 of file vvt.h.

Referenced by getSetpoint(), and onFastCallback().

◆ m_isRpmHighEnough

bool VvtController::m_isRpmHighEnough = false
private

Definition at line 59 of file vvt.h.

Referenced by getSetpoint(), and onFastCallback().

◆ m_pid

Pid VvtController::m_pid
private

Definition at line 55 of file vvt.h.

Referenced by getClosedLoop(), init(), onConfigurationChange(), and setOutput().

◆ m_pwm

IPwm* VvtController::m_pwm = nullptr
private

Definition at line 63 of file vvt.h.

Referenced by init(), onFastCallback(), and setOutput().

◆ m_targetMap

const ValueProvider3D* VvtController::m_targetMap = nullptr
private

Definition at line 62 of file vvt.h.

Referenced by getSetpoint(), init(), and onFastCallback().


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