Skip to content

Commit 342bd58

Browse files
committed
altos: Use pyro voltage to check igniters
Instead of using an absolute value for the igniter continuity good voltage, use 15/16 of the pyro voltage instead. This ensures we scale with the pyro voltage to find marginal igniters even with high voltage pyro systems. This doesn't work on TeleMetrum where we have no pyro voltage value. On these boards, continue to use a fixed 3.5V value. Signed-off-by: Keith Packard <[email protected]>
1 parent 92bbfac commit 342bd58

File tree

6 files changed

+86
-38
lines changed

6 files changed

+86
-38
lines changed

src/kernel/ao.h

-22
Original file line numberDiff line numberDiff line change
@@ -982,26 +982,4 @@ void ao_ms5607_init(void);
982982

983983
#include <ao_arch_funcs.h>
984984

985-
/*
986-
* dv = (sensor * (p+m) * ref_dv)/ (max * m)
987-
* value * (max * m) = (sensor * (p+m) * ref)
988-
* value * (max * m) / ((p+m) * ref) = sensor
989-
*/
990-
991-
#define AO_DV_MUL(p,m) ((int32_t) AO_ADC_MAX * (m))
992-
#define AO_DV_DIV(p,m) ((int32_t) AO_ADC_REFERENCE_DV * ((p) + (m)))
993-
#define AO_DV_ADD(p,m) (AO_DV_DIV(p,m) / 2)
994-
995-
#define ao_decivolt_to_adc(dv, p, m) \
996-
((int16_t) (((int32_t) (dv) * AO_DV_MUL(p,m) + AO_DV_ADD(p,m)) / AO_DV_DIV(p,m)))
997-
998-
#define AO_IGNITER_CLOSED_DV 35
999-
#define AO_IGNITER_OPEN_DV 10
1000-
1001-
#undef AO_IGNITER_OPEN
1002-
#undef AO_IGNITER_CLOSED
1003-
1004-
#define AO_IGNITER_OPEN ao_decivolt_to_adc(AO_IGNITER_OPEN_DV, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS)
1005-
#define AO_IGNITER_CLOSED ao_decivolt_to_adc(AO_IGNITER_CLOSED_DV, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS)
1006-
1007985
#endif /* _AO_H_ */

src/kernel/ao_config.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
#ifndef _AO_CONFIG_H_
2020
#define _AO_CONFIG_H_
2121

22+
#include <ao.h>
23+
24+
#if AO_PYRO_NUM
2225
#include <ao_pyro.h>
26+
#endif
2327

2428
#ifndef USE_STORAGE_CONFIG
2529
#define USE_STORAGE_CONFIG 1

src/kernel/ao_ignite.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
#include "ao.h"
2020
#include <ao_data.h>
21-
#if AO_PYRO_NUM
2221
#include <ao_pyro.h>
23-
#endif
2422

2523
#if HAS_IGNITE
2624
struct ao_ignition ao_ignition[2];
@@ -55,12 +53,7 @@ ao_igniter_status(enum ao_igniter igniter)
5553
value = AO_SENSE_MAIN(&packet);
5654
break;
5755
}
58-
if (value < AO_IGNITER_OPEN)
59-
return ao_igniter_open;
60-
else if (value > AO_IGNITER_CLOSED)
61-
return ao_igniter_ready;
62-
else
63-
return ao_igniter_unknown;
56+
return ao_igniter_check(value, AO_SENSE_PBATT(&packet));
6457
}
6558

6659
#define AO_IGNITER_SET_DROGUE(v) ao_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)

src/kernel/ao_pyro.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,8 @@ ao_pyro_status(uint8_t p)
4545
ao_data_get(&packet);
4646
);
4747

48-
value = (AO_IGNITER_CLOSED>>1);
4948
value = AO_SENSE_PYRO(&packet, p);
50-
if (value < AO_IGNITER_OPEN)
51-
return ao_igniter_open;
52-
else if (value > AO_IGNITER_CLOSED)
53-
return ao_igniter_ready;
54-
else
55-
return ao_igniter_unknown;
49+
return ao_igniter_check(value, AO_SENSE_PBATT(&packet));
5650
}
5751

5852
void

src/kernel/ao_pyro.h

+80
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,84 @@ ao_pyro_status(uint8_t p);
108108
void
109109
ao_pyro_print_status(void);
110110

111+
#ifndef AO_PYRO_BATTERY_DIV_PLUS
112+
#define AO_PYRO_BATTERY_DIV_PLUS AO_BATTERY_DIV_PLUS
113+
#define AO_PYRO_BATTERY_DIV_MINUS AO_BATTERY_DIV_MINUS
114+
#ifndef AO_SENSE_PBATT
115+
#define AO_SENSE_PBATT(p) ((p)->adc.v_batt)
116+
#endif
117+
#else
118+
#ifndef AO_SENSE_PBATT
119+
#define AO_SENSE_PBATT(p) ((p)->adc.v_pbatt)
120+
#endif
121+
#endif
122+
123+
/*
124+
* dv = (sensor * (p+m) * ref_dv)/ (max * m)
125+
* value * (max * m) = (sensor * (p+m) * ref)
126+
* value * (max * m) / ((p+m) * ref) = sensor
127+
*/
128+
129+
#define AO_DV_MUL(p,m) ((int32_t) AO_ADC_MAX * (m))
130+
#define AO_DV_DIV(p,m) ((int32_t) AO_ADC_REFERENCE_DV * ((p) + (m)))
131+
#define AO_DV_ADD(p,m) (AO_DV_DIV(p,m) / 2)
132+
133+
#define ao_decivolt_to_adc(dv, p, m) \
134+
((int16_t) (((int32_t) (dv) * AO_DV_MUL(p,m) + AO_DV_ADD(p,m)) / AO_DV_DIV(p,m)))
135+
136+
#define AO_IGNITER_CLOSED_DV 35
137+
#define AO_IGNITER_OPEN_DV 10
138+
139+
#define AO_PYRO_BATTERY_GOOD_DV 38
140+
141+
#undef AO_IGNITER_OPEN
142+
#undef AO_IGNITER_CLOSED
143+
144+
#define AO_IGNITER_OPEN ao_decivolt_to_adc(AO_IGNITER_OPEN_DV, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS)
145+
#define AO_IGNITER_CLOSED ao_decivolt_to_adc(AO_IGNITER_CLOSED_DV, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS)
146+
147+
#define AO_PYRO_BATTERY_GOOD ao_decivolt_to_adc(AO_PYRO_BATTERY_GOOD_DV, AO_PYRO_BATTERY_DIV_PLUS, AO_PYRO_BATTERY_DIV_MINUS)
148+
149+
/* For devices measuring the pyro battery voltage, we want to use a
150+
* fraction of that. We'll use 15/16 of the battery voltage as a limit
151+
* For devices not measuring the pyro battery voltage, we'll use 3.5V
152+
* instead (this is just TeleMetrum, which permits external pyro
153+
* batteries but has not provision to measure the voltage)
154+
*/
155+
156+
static inline int16_t
157+
ao_igniter_closed_value(int16_t battery)
158+
{
159+
#if AO_PYRO_BATTERY_DIV_PLUS != AO_IGNITE_DIV_PLUS || AO_PYRO_BATTERY_DIV_MINUS != AO_IGNITE_DIV_MINUS
160+
(void) battery;
161+
return AO_IGNITER_CLOSED;
162+
#else
163+
return (int16_t) (((int32_t) battery * 15) / 16);
164+
#endif
165+
}
166+
167+
static inline int16_t
168+
ao_igniter_open_value(int16_t battery)
169+
{
170+
#if AO_PYRO_BATTERY_DIV_PLUS != AO_IGNITE_DIV_PLUS || AO_PYRO_BATTERY_DIV_MINUS != AO_IGNITE_DIV_MINUS
171+
(void) battery;
172+
return AO_IGNITER_OPEN;
173+
#else
174+
return (int16_t) (((int32_t) battery * 1) / 8);
175+
#endif
176+
}
177+
178+
static inline enum ao_igniter_status
179+
ao_igniter_check(int16_t value, int16_t battery)
180+
{
181+
if (battery < AO_PYRO_BATTERY_GOOD)
182+
return ao_igniter_open;
183+
if (value < ao_igniter_open_value(battery))
184+
return ao_igniter_open;
185+
else if (value > ao_igniter_closed_value(battery))
186+
return ao_igniter_ready;
187+
else
188+
return ao_igniter_unknown;
189+
}
190+
111191
#endif

src/telelcotwo-v0.1/ao_telelcotwo.c

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <ao_packet.h>
2222
#include <ao_companion.h>
2323
#include <ao_profile.h>
24-
#include <ao_pyro.h>
2524
#include <ao_aes.h>
2625
#include <ao_button.h>
2726
#include <ao_lco.h>

0 commit comments

Comments
 (0)