rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
vr_pwm.cpp File Reference

Functions

static void updateVrThresholdPwm (float rpm, size_t index)
 
void updateVrThresholdPwm ()
 
void initVrThresholdPwm ()
 
void setDefaultVrThresholds ()
 

Variables

static OutputPin pins [VR_THRESHOLD_COUNT]
 
static SimplePwm pwms [VR_THRESHOLD_COUNT]
 

Function Documentation

◆ initVrThresholdPwm()

void initVrThresholdPwm ( )

Definition at line 39 of file vr_pwm.cpp.

39 {
40 for (size_t i = 0; i < efi::size(engineConfiguration->vrThreshold); i++) {
41 auto& cfg = engineConfiguration->vrThreshold[i];
42
43 if (!isBrainPinValid(cfg.pin)) {
44 continue;
45 }
46
47 startSimplePwmHard(&pwms[i], "VR Threshold",
49 cfg.pin,
50 &pins[i],
51 10000, // it's guaranteed to be hardware PWM, the faster the PWM, the less noise makes it through
52 0
53 );
54 }
55}
SingleTimerExecutor scheduler
Definition engine.h:271
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
void startSimplePwmHard(SimplePwm *state, const char *msg, Scheduler *executor, brain_pin_e brainPin, OutputPin *output, float frequency, float dutyCycle)
static OutputPin pins[VR_THRESHOLD_COUNT]
Definition vr_pwm.cpp:5
static SimplePwm pwms[VR_THRESHOLD_COUNT]
Definition vr_pwm.cpp:6

Referenced by initRealHardwareEngineController().

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

◆ setDefaultVrThresholds()

void setDefaultVrThresholds ( )

Definition at line 57 of file vr_pwm.cpp.

57 {
58 for (int i = 0;i<VR_THRESHOLD_COUNT;i++) {
61 }
62}
void setRpmTableBin(TValue(&array)[TSize])
void setLinearCurve(TValue(&array)[TSize], float from, float to, float precision=0.01f)

Referenced by setDefaultBaseEngine().

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

◆ updateVrThresholdPwm() [1/2]

void updateVrThresholdPwm ( )

Definition at line 31 of file vr_pwm.cpp.

31 {
33
34 for (size_t i = 0; i < efi::size(engineConfiguration->vrThreshold); i++) {
36 }
37}
static float getOrZero(SensorType type)
Definition sensor.h:83
void updateVrThresholdPwm()
Definition vr_pwm.cpp:31

Referenced by Engine::periodicSlowCallback(), and updateVrThresholdPwm().

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

◆ updateVrThresholdPwm() [2/2]

static void updateVrThresholdPwm ( float  rpm,
size_t  index 
)
static

Definition at line 13 of file vr_pwm.cpp.

13 {
14 auto& cfg = engineConfiguration->vrThreshold[index];
15
16 if (!isBrainPinValid(cfg.pin)) {
17 return;
18 }
19
20 float thresholdVoltage = interpolate2d(rpm, cfg.rpmBins, cfg.values);
21
22 // 0v threshold voltage = 3.3v output from mcu = 100% duty
23 // 2.5v threshold voltage = 0v output from mcu = 0% duty
24 float thresholdInputVoltage = interpolateClamped(0, 3.3f, 2.5f, 0, thresholdVoltage);
25
26 float duty = thresholdInputVoltage / VR_SUPPLY_VOLTAGE;
27
29}
void setSimplePwmDutyCycle(float dutyCycle) override
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
static float duty
Here is the call graph for this function:

Variable Documentation

◆ pins

OutputPin pins[VR_THRESHOLD_COUNT]
static

Definition at line 5 of file vr_pwm.cpp.

Referenced by initVrThresholdPwm().

◆ pwms

SimplePwm pwms[VR_THRESHOLD_COUNT]
static

Definition at line 6 of file vr_pwm.cpp.

Referenced by initVrThresholdPwm(), and updateVrThresholdPwm().

Go to the source code of this file.