File tree 2 files changed +32
-25
lines changed
2 files changed +32
-25
lines changed Original file line number Diff line number Diff line change 156
156
157
157
typedef int16_t motor_pressure_t ;
158
158
159
- /* want about 50psi, or 344kPa */
159
+ /* want about 50psi, or 344kPa for boost and 30psi for coast */
160
160
161
161
#define AO_FULL_SCALE_PRESSURE 11031612 /* 1600psi */
162
162
#define AO_BOOST_DETECT_PRESSURE 344000 /* 50psi */
163
163
#define AO_QUIET_DETECT_PRESSURE 207000 /* 30psi */
164
164
165
- static inline int16_t ao_delta_pressure_to_adc (uint32_t pressure )
166
- {
167
- static const double volts_base = 0.5 ;
168
- static const double volts_max = 4.5 ;
169
-
170
- /* Compute change in voltage from the sensor */
171
- double volts = (double ) pressure / AO_FULL_SCALE_PRESSURE * (volts_max - volts_base );
172
-
173
- /* voltage divider in front of the ADC input to decivolts */
174
- double adc_dv = volts * 10 * 10.0 /15.6 ;
175
-
176
- /* convert to ADC output value */
177
- double adc = adc_dv * AO_ADC_MAX / AO_ADC_REFERENCE_DV ;
178
-
179
- if (adc > AO_ADC_MAX )
180
- adc = AO_ADC_MAX ;
181
- if (adc < 0 )
182
- adc = 0 ;
183
-
184
- return (int16_t ) adc ;
185
- }
186
-
187
- #define AO_BOOST_DETECT ao_delta_pressure_to_adc(AO_BOOST_DETECT_PRESSURE)
188
- #define AO_QUIET_DETECT ao_delta_pressure_to_adc(AO_QUIET_DETECT_PRESSURE)
165
+ #define AO_PRESSURE_VOLTS_BASE 0.5
166
+ #define AO_PRESSURE_VOLTS_MAX 4.5
189
167
190
168
struct ao_adc {
191
169
int16_t v_batt ;
Original file line number Diff line number Diff line change @@ -52,6 +52,35 @@ static AO_TICK_TYPE ao_interval_end;
52
52
53
53
uint8_t ao_flight_force_idle ;
54
54
55
+ /* Compute ADC value change given a defined pressure change in Pa */
56
+
57
+ static inline int16_t
58
+ ao_delta_pressure_to_adc (uint32_t pressure )
59
+ {
60
+ static const double volts_base = AO_PRESSURE_VOLTS_BASE ;
61
+ static const double volts_max = AO_PRESSURE_VOLTS_MAX ;
62
+
63
+ /* Compute change in voltage from the sensor */
64
+ double volts = (double ) pressure / AO_FULL_SCALE_PRESSURE * (volts_max - volts_base );
65
+
66
+ /* voltage divider in front of the ADC input to decivolts */
67
+ double adc_dv = volts * (10.0 * (double ) AO_PRESSURE_DIV_MINUS /
68
+ ((double ) AO_PRESSURE_DIV_PLUS + (double ) AO_PRESSURE_DIV_MINUS ));
69
+
70
+ /* convert to ADC output value */
71
+ double adc = adc_dv * AO_ADC_MAX / AO_ADC_REFERENCE_DV ;
72
+
73
+ if (adc > AO_ADC_MAX )
74
+ adc = AO_ADC_MAX ;
75
+ if (adc < 0 )
76
+ adc = 0 ;
77
+
78
+ return (int16_t ) adc ;
79
+ }
80
+
81
+ #define AO_BOOST_DETECT ao_delta_pressure_to_adc(AO_BOOST_DETECT_PRESSURE)
82
+ #define AO_QUIET_DETECT ao_delta_pressure_to_adc(AO_QUIET_DETECT_PRESSURE)
83
+
55
84
/*
56
85
* Landing is detected by getting constant readings from pressure sensor
57
86
* for a fairly long time (AO_INTERVAL_TICKS), along with the max being
You can’t perform that action at this time.
0 commit comments