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

#include <alternator_controller.h>

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

Public Member Functions

 AlternatorController ()
 
void onFastCallback () override
 
void onConfigurationChange (engine_configuration_s const *previousConfiguration) override
 
expected< floatgetSetpoint () override
 
expected< floatobservePlant () override
 
expected< percent_tgetOpenLoop (float target) override
 
expected< percent_tgetClosedLoop (float setpoint, float observation) override
 
void setOutput (expected< percent_t > outputValue) override
 
- 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< float, percent_t >
void update ()
 

Private Attributes

Pid alternatorPid
 

Detailed Description

Definition at line 19 of file alternator_controller.h.

Constructor & Destructor Documentation

◆ AlternatorController()

AlternatorController::AlternatorController ( )

Definition at line 24 of file alternator_controller.cpp.

24 {
26}
void initPidClass(pid_s *parameters)
Definition efi_pid.cpp:24
static constexpr engine_configuration_s * engineConfiguration
Here is the call graph for this function:

Member Function Documentation

◆ getClosedLoop()

expected< percent_t > AlternatorController::getClosedLoop ( float  setpoint,
float  observation 
)
overridevirtual

Implements ClosedLoopController< float, percent_t >.

Definition at line 67 of file alternator_controller.cpp.

67 {
70 return alternatorPid.getOutput(setpoint, observation, FAST_CALLBACK_PERIOD_MS / 1000.0f);
71}
float iTermMax
Definition efi_pid.h:69
float iTermMin
Definition efi_pid.h:68
float getOutput(float target, float input)
Definition efi_pid.cpp:56
Here is the call graph for this function:

◆ getOpenLoop()

expected< percent_t > AlternatorController::getOpenLoop ( float  target)
overridevirtual

Implements ClosedLoopController< float, percent_t >.

Definition at line 62 of file alternator_controller.cpp.

62 {
63 // see "idle air Bump for AC" comment
65}
constexpr auto & module()
Definition engine.h:200
static EngineAccessor engine
Definition engine.h:413
Here is the call graph for this function:

◆ getSetpoint()

expected< float > AlternatorController::getSetpoint ( )
overridevirtual

Implements ClosedLoopController< float, percent_t >.

Definition at line 42 of file alternator_controller.cpp.

42 {
43 const float rpm = Sensor::getOrZero(SensorType::Rpm);
44 bool alternatorShouldBeEnabledAtCurrentRpm = rpm > engineConfiguration->cranking.rpm;
45
46 if (!engineConfiguration->isAlternatorControlEnabled || !alternatorShouldBeEnabledAtCurrentRpm) {
47 return unexpected;
48 }
49
50 const float load = getEngineState()->fuelingLoad;
51 return interpolate3d(
55 );
56}
static float getOrZero(SensorType type)
Definition sensor.h:83
EngineState * getEngineState()
Definition engine.cpp:577
static constexpr persistent_config_s * config
uint16_t alternatorVoltageTargetLoadBins[ALTERNATOR_VOLTAGE_TARGET_SIZE]
scaled_channel< int16_t, 10, 1 > alternatorVoltageTargetTable[ALTERNATOR_VOLTAGE_TARGET_SIZE][ALTERNATOR_VOLTAGE_TARGET_SIZE]
uint16_t alternatorVoltageTargetRpmBins[ALTERNATOR_VOLTAGE_TARGET_SIZE]
Here is the call graph for this function:

◆ observePlant()

expected< float > AlternatorController::observePlant ( )
overridevirtual

Implements ClosedLoopController< float, percent_t >.

Definition at line 58 of file alternator_controller.cpp.

58 {
60}
virtual SensorResult get() const =0
Here is the call graph for this function:

◆ onConfigurationChange()

void AlternatorController::onConfigurationChange ( engine_configuration_s const *  previousConfiguration)
overridevirtual

Reimplemented from EngineModule.

Definition at line 83 of file alternator_controller.cpp.

83 {
84 if(!alternatorPid.isSame(&previousConfiguration->alternatorControl)) {
86 }
87}
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 AlternatorController::onFastCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 28 of file alternator_controller.cpp.

28 {
30 return;
31 }
32
33 // this block could be executed even in on/off alternator control mode
34 // but at least we would reflect latest state
35#if EFI_TUNER_STUDIO
37#endif /* EFI_TUNER_STUDIO */
38
39 update();
40}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
void postState(pid_status_s &pidStatus) const
Definition efi_pid.cpp:144
bool isBrainPinValid(brain_pin_e brainPin)
Here is the call graph for this function:

◆ setOutput()

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

Implements ClosedLoopController< float, percent_t >.

Definition at line 73 of file alternator_controller.cpp.

73 {
74 if (outputValue) {
75 alternatorControl.setSimplePwmDutyCycle(PERCENT_TO_DUTY(outputValue.Value));
76 } else {
77 // Shut off output if not needed
80 }
81}
static SimplePwm alternatorControl("alt")
void setSimplePwmDutyCycle(float dutyCycle) override
Here is the call graph for this function:

Field Documentation

◆ alternatorPid

Pid AlternatorController::alternatorPid
private

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