rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
vvl_controller.cpp
Go to the documentation of this file.
1/*
2 * @file VvlController.cpp
3 *
4 * @date: ago 25, 2025
5 * @author FDSoftware
6 */
7
8#include "pch.h"
9#include "vvl_controller.h"
10
26
28 float result = 1.0f;
29 if (engineConfiguration->vvlControlEnabled && isVvlCondition) {
30 result += engineConfiguration->vvlController.fuelAdderPercent / 100.0f;
31 }
32 return result;
33}
34
36 if (engineConfiguration->vvlControlEnabled && isVvlCondition) {
37 // note the "-" here to remove timing!
38 return -engineConfiguration->vvlController.ignitionRetard;
39 }
40 return 0.0f;
41}
42
44 if (engineConfiguration->vvlController.minimumTps != 0) {
45 const expected<float> tps = Sensor::get(SensorType::DriverThrottleIntent);
46 isVvlTpsCondition = tps.Valid && (engineConfiguration->vvlController.minimumTps <= tps.Value);
47 } else {
48 isVvlTpsCondition = true;
49 }
50}
51
53 if (engineConfiguration->vvlController.minimumClt != 0) {
54 const expected<float> clt = Sensor::get(SensorType::Clt);
55 isVvlCltCondition = clt.Valid && (engineConfiguration->vvlController.minimumClt <= clt.Value);
56 } else {
57 isVvlCltCondition = true;
58 }
59}
60
62 if (engineConfiguration->vvlController.maximumMap != 0) {
63 const expected<float> map = Sensor::get(SensorType::Map);
64 isVvlMapCondition = map.Valid && (map.Value <= engineConfiguration->vvlController.maximumMap);
65 } else {
66 isVvlMapCondition = true;
67 }
68}
69
71 if (static_cast<float>(engineConfiguration->vvlController.maximumAfr) != 0.0f) {
72 const expected<float> lambda1 = Sensor::get(SensorType::Lambda1);
73 if (lambda1.Valid) {
74 const float afr = lambda1.Value * STOICH_RATIO;
75 isVvlAfrCondition = (afr <= static_cast<float>(engineConfiguration->vvlController.maximumAfr));
76 } else {
77 isVvlAfrCondition = false;
78 }
79 } else {
80 isVvlAfrCondition = true;
81 }
82}
83
84namespace {
86}
87
89 const expected<float> rpmSensorReading = Sensor::get(SensorType::Rpm);
90 if (rpmSensorReading.Valid) {
91 const float rpm = rpmSensorReading.Value;
92 if (rpmHysteresis.checkIfLimitIsExceeded(
93 rpm,
94 engineConfiguration->vvlController.deactivationRpm,
95 engineConfiguration->vvlController.deactivationRpmWindow
96 )) {
97 isVvlRpmCondition = false;
98 } else {
99 isVvlRpmCondition = (engineConfiguration->vvlController.activationRpm <= rpm);
100 }
101 } else {
102 isVvlRpmCondition = false;
103 }
104}
RegisteredOutputPin vvlRelay
Definition efi_gpio.h:93
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
virtual SensorResult get() const =0
void updateTpsConditionSatisfied()
void updateAfrConditionSatisfied()
void updateCltConditionSatisfied()
void updateMapConditionSatisfied()
float getTimingModifier() const
void updateRpmConditionSatisfied()
void onSlowCallback() override
float getFuelCoefficient() const
EnginePins enginePins
Definition efi_gpio.cpp:24
static constexpr engine_configuration_s * engineConfiguration
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
@ DriverThrottleIntent