CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_EFI/AP_EFI_State.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
#pragma once
17
18
#include <AP_EFI/AP_EFI_config.h>
19
20
#if HAL_EFI_ENABLED
21
22
#include <AP_Common/AP_Common.h>
23
#include <AP_HAL/AP_HAL.h>
24
25
// Time in milliseconds before we declare the EFI to be "unhealthy"
26
#define HEALTHY_LAST_RECEIVED_MS 3000
27
28
/***************
29
*
30
* Status enums
31
*
32
***************/
33
34
enum class Engine_State : uint8_t {
35
STOPPED = 0,
36
STARTING = 1,
37
RUNNING = 2,
38
FAULT = 3
39
};
40
41
enum class Crankshaft_Sensor_Status : uint8_t {
42
NOT_SUPPORTED = 0,
43
OK = 1,
44
ERROR = 2
45
};
46
47
enum class Temperature_Status : uint8_t {
48
NOT_SUPPORTED = 0,
49
OK = 1,
50
BELOW_NOMINAL = 2,
51
ABOVE_NOMINAL = 3,
52
OVERHEATING = 4,
53
EGT_ABOVE_NOMINAL = 5
54
};
55
56
enum class Fuel_Pressure_Status : uint8_t {
57
NOT_SUPPORTED = 0,
58
OK = 1,
59
BELOW_NOMINAL = 2,
60
ABOVE_NOMINAL = 3
61
};
62
63
enum class Oil_Pressure_Status : uint8_t {
64
NOT_SUPPORTED = 0,
65
OK = 1,
66
BELOW_NOMINAL = 2,
67
ABOVE_NOMINAL = 3
68
};
69
70
enum class Detonation_Status : uint8_t {
71
NOT_SUPPORTED = 0,
72
NOT_OBSERVED = 1,
73
OBSERVED = 2
74
};
75
76
enum class Misfire_Status : uint8_t {
77
NOT_SUPPORTED = 0,
78
NOT_OBSERVED = 1,
79
OBSERVED = 2
80
};
81
82
enum class Debris_Status : uint8_t {
83
NOT_SUPPORTED = 0,
84
NOT_DETECTED = 1,
85
DETECTED = 2
86
};
87
88
enum class Spark_Plug_Usage : uint8_t {
89
SINGLE = 0,
90
FIRST_ACTIVE = 1,
91
SECOND_ACTIVE = 2,
92
BOTH_ACTIVE = 3
93
};
94
95
96
/***************
97
* Status structs.
98
* EFIs may not provide all data in the message, therefore, the following guidelines should be followed.
99
* All integer fields are required unless stated otherwise.
100
* All floating point fields are optional unless stated otherwise; unknown/unapplicable fields will be NaN.
101
***************/
102
103
104
// Per-cylinder status struct
105
struct Cylinder_Status {
106
// Cylinder ignition timing (angular degrees of the crankshaft)
107
float ignition_timing_deg;
108
109
// Fuel injection time (millisecond)
110
float injection_time_ms;
111
112
// Cylinder head temperature (CHT) (kelvin)
113
float cylinder_head_temperature;
114
115
// 2nd Cylinder head temperature (CHT) (kelvin), 0 if not applicable
116
float cylinder_head_temperature2;
117
118
// Exhaust gas temperature (EGT) (kelvin)
119
// If this cylinder is not equipped with an EGT sensor - will be NaN
120
// If there is a single shared EGT sensor, will be the same value for all cylinders
121
float exhaust_gas_temperature;
122
123
// 2nd cylinder exhaust gas temperature, 0 if not applicable
124
float exhaust_gas_temperature2;
125
126
// Estimated lambda coefficient (dimensionless ratio)
127
// Useful for monitoring and tuning purposes.
128
float lambda_coefficient;
129
};
130
131
// Stores the current state read by the EFI system
132
// All backends are required to fill in this state structure
133
struct EFI_State {
134
// When this structure was last updated (milliseconds)
135
uint32_t last_updated_ms;
136
137
// Current overall engine state
138
Engine_State engine_state;
139
140
// If there is an error that does not fit other error types
141
bool general_error;
142
143
// Error/status fields
144
Crankshaft_Sensor_Status crankshaft_sensor_status;
145
Temperature_Status temperature_status;
146
Fuel_Pressure_Status fuel_pressure_status;
147
Oil_Pressure_Status oil_pressure_status;
148
Detonation_Status detonation_status;
149
Misfire_Status misfire_status;
150
Debris_Status debris_status;
151
152
// Engine load (percent)
153
uint8_t engine_load_percent;
154
155
// Engine speed (revolutions per minute)
156
uint32_t engine_speed_rpm;
157
158
// Spark dwell time (milliseconds)
159
float spark_dwell_time_ms;
160
161
// Atmospheric (barometric) pressure (kilopascal)
162
float atmospheric_pressure_kpa;
163
164
// Engine intake manifold pressure (kilopascal)
165
float intake_manifold_pressure_kpa;
166
167
// Engine intake manifold temperature (kelvin)
168
float intake_manifold_temperature;
169
170
// Engine coolant temperature (kelvin)
171
float coolant_temperature;
172
173
// Oil pressure (kilopascal)
174
float oil_pressure;
175
176
// Oil temperature (kelvin)
177
float oil_temperature;
178
179
// Fuel pressure (kilopascal)
180
float fuel_pressure;
181
182
// Instant fuel consumption estimate, which
183
// should be low-pass filtered in order to prevent aliasing effects.
184
// (centimeter^3)/minute.
185
float fuel_consumption_rate_cm3pm;
186
187
// Estimate of the consumed fuel since the start of the engine (centimeter^3)
188
// This variable is reset when the engine is stopped.
189
float estimated_consumed_fuel_volume_cm3;
190
191
// Throttle position (percent)
192
uint8_t throttle_position_percent;
193
194
// The index of the publishing ECU.
195
uint8_t ecu_index;
196
197
// Spark plug activity report.
198
// Can be used during pre-flight tests of the spark subsystem.
199
// Use case is that usually on double spark plug engines, the
200
// engine switch has the positions OFF-LEFT-RIGHT-BOTH-START.
201
// Gives pilots the possibility to test both spark plugs on
202
// ground before takeoff.
203
Spark_Plug_Usage spark_plug_usage;
204
205
// Status for each cylinder in the engine
206
Cylinder_Status cylinder_status;
207
208
// ignition voltage in Volts
209
float ignition_voltage = -1; // -1 is "unknown";
210
211
// throttle output percentage
212
float throttle_out;
213
214
// PT compensation
215
float pt_compensation;
216
};
217
218
#endif // HAL_EFI_ENABLED
219
220