rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
aux_valves.cpp
Go to the documentation of this file.
1/*
2 * @file aux_valves.cpp
3 *
4 *
5 * Here we have two auxilary digital on/off outputs which would open once per each 360 degrees of engine crank revolution.
6 * The second valve is 180 degrees after the first one.
7 *
8 * Valve open and close angles are taken from scriptCurve1 and scriptCurve2 tables respectively, the position depend on TPS input.
9 *
10 * https://github.com/rusefi/rusefi/issues/490
11 *
12 * @date Nov 25, 2017
13 * @author Andrey Belomutskiy, (c) 2012-2020
14 */
15
16#include "pch.h"
17
18#include "aux_valves.h"
19#include "trigger_central.h"
20#include "spark_logic.h"
21
22#if EFI_AUX_VALVES
23
24static void plainPinTurnOff(NamedOutputPin *output) {
25 output->setLow();
26}
27
28
29static void scheduleOpen(AuxActor *current) {
30 engine->module<TriggerScheduler>()->schedule(
31 "aux-valve",
32 &current->open,
34 action_s::make<auxPlainPinTurnOn>( current )
35 );
36}
37
39 NamedOutputPin *output = &enginePins.auxValve[current->valveIndex];
40 output->setHigh();
41
42 scheduleOpen(current);
43
45
46 wrapAngle(duration, "duration", ObdCode::CUSTOM_ERR_6557);
47
48 engine->module<TriggerScheduler>()->schedule(
49 "aux-valve",
50 &current->close,
52 action_s::make<plainPinTurnOff>( output )
53 );
54 }
55
58 return;
59 }
60
62 firmwareError(ObdCode::CUSTOM_OBD_91, "No TPS for Aux Valves");
63 return;
64 }
65
67
68 for (int valveIndex = 0; valveIndex < AUX_DIGITAL_VALVE_COUNT; valveIndex++) {
69
70 for (int phaseIndex = 0; phaseIndex < 2; phaseIndex++) {
71 AuxActor *actor = &engine->auxValves[valveIndex][phaseIndex];
72 actor->phaseIndex = phaseIndex;
73 actor->valveIndex = valveIndex;
74 actor->extra = phaseIndex * 360 + valveIndex * 180;
75
76 scheduleOpen(actor);
77 }
78 }
79}
80
83 return;
84 }
85
87 if (!tps) {
88 // error should be already reported by now
89 return;
90 }
91
92 engine->engineState.auxValveStart = interpolate2d(tps.Value,
95
96 engine->engineState.auxValveEnd = interpolate2d(tps.Value,
99
101 // this is a fatal error to make this really visible
102 firmwareError(ObdCode::CUSTOM_AUX_OUT_OF_ORDER, "out of order at %.2f %.2f %.2f", tps,
105 }
106}
107
108#endif // EFI_AUX_VALVES
static void plainPinTurnOff(NamedOutputPin *output)
void initAuxValves()
static void scheduleOpen(AuxActor *current)
void recalculateAuxValveTiming()
void auxPlainPinTurnOn(AuxActor *current)
angle_t extra
AngleBasedEvent close
AngleBasedEvent open
AuxActor auxValves[AUX_DIGITAL_VALVE_COUNT][2]
Definition engine.h:253
EngineState engineState
Definition engine.h:344
constexpr auto & module()
Definition engine.h:200
NamedOutputPin auxValve[AUX_DIGITAL_VALVE_COUNT]
Definition efi_gpio.h:131
float auxValveStart
float auxValveEnd
virtual void setLow(const char *msg)
Definition efi_gpio.cpp:464
virtual void setHigh(const char *msg)
Definition efi_gpio.cpp:442
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
EnginePins enginePins
Definition efi_gpio.cpp:24
static EngineAccessor engine
Definition engine.h:413
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_AUX_OUT_OF_ORDER
@ CUSTOM_OBD_91
@ CUSTOM_ERR_6557
bool isBrainPinValid(brain_pin_e brainPin)
float angle_t
@ DriverThrottleIntent
void wrapAngle(angle_t &angle, const char *msg, ObdCode code)