Subversion Repositories FlightCtrl

Rev

Rev 2015 | Rev 2019 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2015 Rev 2018
1
#ifndef _ANALOG_H
1
#ifndef _ANALOG_H
2
#define _ANALOG_H
2
#define _ANALOG_H
3
#include <inttypes.h>
3
#include <inttypes.h>
4
#include "configuration.h"
4
#include "configuration.h"
5
 
5
 
6
/*
6
/*
7
 * How much low pass filtering to apply for gyro_PID.
7
 * How much low pass filtering to apply for gyro_PID.
8
 * 0=illegal, 1=no filtering, 2=50% last value + 50% new value, 3=67% last value + 33 % new value etc...
8
 * 0=illegal, 1=no filtering, 2=50% last value + 50% new value, 3=67% last value + 33 % new value etc...
9
 * Temporarily replaced by userparam-configurable variable.
9
 * Temporarily replaced by userparam-configurable variable.
10
 */
10
 */
11
// #define GYROS_PID_FILTER 1
11
// #define GYROS_PID_FILTER 1
12
 
12
 
13
/*
13
/*
14
 * How much low pass filtering to apply for gyro_ATT.
14
 * How much low pass filtering to apply for gyro_ATT.
15
 * 0=illegal, 1=no filtering, 2=50% last value + 50% new value, 3=67% last value + 33 % new value etc...
15
 * 0=illegal, 1=no filtering, 2=50% last value + 50% new value, 3=67% last value + 33 % new value etc...
16
 * Temporarily replaced by userparam-configurable variable.
16
 * Temporarily replaced by userparam-configurable variable.
17
 */
17
 */
18
// #define GYROS_ATT_FILTER 1
18
// #define GYROS_ATT_FILTER 1
19
// Temporarily replaced by userparam-configurable variable.
-
 
20
// #define ACC_FILTER 4
19
// #define ACC_FILTER 4
21
 
20
 
22
/*
21
/*
23
 About setting constants for different gyros:
22
 About setting constants for different gyros:
24
 Main parameters are positive directions and voltage/angular speed gain.
23
 Main parameters are positive directions and voltage/angular speed gain.
25
 The "Positive direction" is the rotation direction around an axis where
24
 The "Positive direction" is the rotation direction around an axis where
26
 the corresponding gyro outputs a voltage > the no-rotation voltage.
25
 the corresponding gyro outputs a voltage > the no-rotation voltage.
27
 A gyro is considered, in this code, to be "forward" if its positive
26
 A gyro is considered, in this code, to be "forward" if its positive
28
 direction is:
27
 direction is:
29
 - Nose down for pitch
28
 - Nose down for pitch
30
 - Left hand side down for roll
29
 - Left hand side down for roll
31
 - Clockwise seen from above for yaw.
30
 - Clockwise seen from above for yaw.
32
 Declare the GYRO_REVERSE_YAW, GYRO_REVERSE_ROLL and
-
 
33
 GYRO_REVERSE_PITCH #define's if the respective gyros are reverse.
-
 
34
 
31
 
35
 Setting gyro gain correctly: All sensor measurements in analog.c take
32
 Setting gyro gain correctly: All sensor measurements in analog.c take
36
 place in a cycle, each cycle comprising all sensors. Some sensors are
33
 place in a cycle, each cycle comprising all sensors. Some sensors are
37
 sampled more than ones, and the results added. The pitch and roll gyros
34
 sampled more than ones, and the results added. The pitch and roll gyros
38
 are sampled 4 times and the yaw gyro 2 times in the original H&I V0.74
35
 are sampled 4 times and the yaw gyro 2 times in the original H&I V0.74
39
 code.
36
 code.
40
 In the H&I code, the results for pitch and roll are multiplied by 2 (FC1.0)
37
 In the H&I code, the results for pitch and roll are multiplied by 2 (FC1.0)
41
 or 4 (other versions), offset to zero, low pass filtered and then assigned
38
 or 4 (other versions), offset to zero, low pass filtered and then assigned
42
 to the "HiResXXXX" and "AdWertXXXXFilter" variables, where XXXX is nick or
39
 to the "HiResXXXX" and "AdWertXXXXFilter" variables, where XXXX is nick or
43
 roll.
40
 roll.
44
 So:
41
 So:
45
 
42
 
46
 gyro = V * (ADCValue1 + ADCValue2 + ADCValue3 + ADCValue4),
43
 gyro = V * (ADCValue1 + ADCValue2 + ADCValue3 + ADCValue4),
47
 where V is 2 for FC1.0 and 4 for all others.
44
 where V is 2 for FC1.0 and 4 for all others.
48
 
45
 
49
 Assuming constant ADCValue, in the H&I code:
46
 Assuming constant ADCValue, in the H&I code:
50
 
47
 
51
 gyro = I * ADCValue.
48
 gyro = I * ADCValue.
52
 
49
 
53
 where I is 8 for FC1.0 and 16 for all others.
50
 where I is 8 for FC1.0 and 16 for all others.
54
 
51
 
55
 The relation between rotation rate and ADCValue:
52
 The relation between rotation rate and ADCValue:
56
 ADCValue [units] =
53
 ADCValue [units] =
57
 rotational speed [deg/s] *
54
 rotational speed [deg/s] *
58
 gyro sensitivity [V / deg/s] *
55
 gyro sensitivity [V / deg/s] *
59
 amplifier gain [units] *
56
 amplifier gain [units] *
60
 1024 [units] /
57
 1024 [units] /
61
 3V full range [V]
58
 3V full range [V]
62
 
59
 
63
 or: H is the number of steps the ADC value changes with,
60
 or: H is the number of steps the ADC value changes with,
64
 for a 1 deg/s change in rotational velocity:
61
 for a 1 deg/s change in rotational velocity:
65
 H = ADCValue [units] / rotation rate [deg/s] =
62
 H = ADCValue [units] / rotation rate [deg/s] =
66
 gyro sensitivity [V / deg/s] *
63
 gyro sensitivity [V / deg/s] *
67
 amplifier gain [units] *
64
 amplifier gain [units] *
68
 1024 [units] /
65
 1024 [units] /
69
 3V full range [V]
66
 3V full range [V]
70
 
67
 
71
 Examples:
68
 Examples:
72
 FC1.3 has 0.67 mV/deg/s gyros and amplifiers with a gain of 5.7:
69
 FC1.3 has 0.67 mV/deg/s gyros and amplifiers with a gain of 5.7:
73
 H = 0.00067 V / deg / s * 5.7 * 1024 / 3V = 1.304 units/(deg/s).
70
 H = 0.00067 V / deg / s * 5.7 * 1024 / 3V = 1.304 units/(deg/s).
74
 FC2.0 has 6*(3/5) mV/deg/s gyros (they are ratiometric) and no amplifiers:
71
 FC2.0 has 6*(3/5) mV/deg/s gyros (they are ratiometric) and no amplifiers:
75
 H = 0.006 V / deg / s * 1 * 1024 * 3V / (3V * 5V) = 1.2288 units/(deg/s).
72
 H = 0.006 V / deg / s * 1 * 1024 * 3V / (3V * 5V) = 1.2288 units/(deg/s).
76
 My InvenSense copter has 2mV/deg/s gyros and no amplifiers:
73
 My InvenSense copter has 2mV/deg/s gyros and no amplifiers:
77
 H = 0.002 V / deg / s * 1 * 1024 / 3V = 0.6827 units/(deg/s)
74
 H = 0.002 V / deg / s * 1 * 1024 / 3V = 0.6827 units/(deg/s)
78
 (only about half as sensitive as V1.3. But it will take about twice the
75
 (only about half as sensitive as V1.3. But it will take about twice the
79
 rotation rate!)
76
 rotation rate!)
80
 
77
 
81
 All together: gyro = I * H * rotation rate [units / (deg/s)].
78
 All together: gyro = I * H * rotation rate [units / (deg/s)].
82
 */
79
 */
83
 
80
 
84
/*
81
/*
85
 * A factor that the raw gyro values are multiplied by,
82
 * A factor that the raw gyro values are multiplied by,
86
 * before being filtered and passed to the attitude module.
83
 * before being filtered and passed to the attitude module.
87
 * A value of 1 would cause a little bit of loss of precision in the
84
 * A value of 1 would cause a little bit of loss of precision in the
88
 * filtering (on the other hand the values are so noisy in flight that
85
 * filtering (on the other hand the values are so noisy in flight that
89
 * it will not really matter - but when testing on the desk it might be
86
 * it will not really matter - but when testing on the desk it might be
90
 * noticeable). 4 is fine for the default filtering.
87
 * noticeable). 4 is fine for the default filtering.
91
 * Experiment: Set it to 1.
88
 * Experiment: Set it to 1.
92
 */
89
 */
93
#define GYRO_FACTOR_PITCHROLL 1
90
#define GYRO_FACTOR_PITCHROLL 1
94
 
91
 
95
/*
92
/*
96
 * How many samples are summed in one ADC loop, for pitch&roll and yaw,
93
 * How many samples are summed in one ADC loop, for pitch&roll and yaw,
97
 * respectively. This is = the number of occurences of each channel in the
94
 * respectively. This is = the number of occurences of each channel in the
98
 * channelsForStates array in analog.c.
95
 * channelsForStates array in analog.c.
99
 */
96
 */
100
#define GYRO_SUMMATION_FACTOR_PITCHROLL 4
97
#define GYRO_SUMMATION_FACTOR_PITCHROLL 4
101
#define GYRO_SUMMATION_FACTOR_YAW 2
98
#define GYRO_SUMMATION_FACTOR_YAW 2
102
 
99
 
103
#define ACC_SUMMATION_FACTOR_PITCHROLL 2
100
#define ACC_SUMMATION_FACTOR_PITCHROLL 2
104
#define ACC_SUMMATION_FACTOR_Z 1
101
#define ACC_SUMMATION_FACTOR_Z 1
105
 
102
 
106
/*
103
/*
107
 Integration:
104
 Integration:
108
 The HiResXXXX values are divided by 8 (in H&I firmware) before integration.
105
 The HiResXXXX values are divided by 8 (in H&I firmware) before integration.
109
 In the Killagreg rewrite of the H&I firmware, the factor 8 is called
106
 In the Killagreg rewrite of the H&I firmware, the factor 8 is called
110
 HIRES_GYRO_AMPLIFY. In this code, it is called HIRES_GYRO_INTEGRATION_FACTOR,
107
 HIRES_GYRO_AMPLIFY. In this code, it is called HIRES_GYRO_INTEGRATION_FACTOR,
111
 and care has been taken that all other constants (gyro to degree factor, and
108
 and care has been taken that all other constants (gyro to degree factor, and
112
 180 degree flip-over detection limits) are corrected to it. Because the
109
 180 degree flip-over detection limits) are corrected to it. Because the
113
 division by the constant takes place in the flight attitude code, the
110
 division by the constant takes place in the flight attitude code, the
114
 constant is there.
111
 constant is there.
115
 
112
 
116
 The control loop executes every 2ms, and for each iteration
113
 The control loop executes every 2ms, and for each iteration
117
 gyro_ATT[PITCH/ROLL] is added to gyroIntegral[PITCH/ROLL].
114
 gyro_ATT[PITCH/ROLL] is added to gyroIntegral[PITCH/ROLL].
118
 Assuming a constant rotation rate v and a zero initial gyroIntegral
115
 Assuming a constant rotation rate v and a zero initial gyroIntegral
119
 (for this explanation), we get:
116
 (for this explanation), we get:
120
 
117
 
121
 gyroIntegral =
118
 gyroIntegral =
122
 N * gyro / HIRES_GYRO_INTEGRATION_FACTOR =
119
 N * gyro / HIRES_GYRO_INTEGRATION_FACTOR =
123
 N * I * H * v / HIRES_GYRO_INTEGRATION_FACTOR
120
 N * I * H * v / HIRES_GYRO_INTEGRATION_FACTOR
124
 
121
 
125
 where N is the number of summations; N = t/2ms.
122
 where N is the number of summations; N = t/2ms.
126
 
123
 
127
 For one degree of rotation: t*v = 1:
124
 For one degree of rotation: t*v = 1:
128
 
125
 
129
 gyroIntegralXXXX = t/2ms * I * H * 1/t = INTEGRATION_FREQUENCY * I * H / HIRES_GYRO_INTEGRATION_FACTOR.
126
 gyroIntegralXXXX = t/2ms * I * H * 1/t = INTEGRATION_FREQUENCY * I * H / HIRES_GYRO_INTEGRATION_FACTOR.
130
 
127
 
131
 This number (INTEGRATION_FREQUENCY * I * H) is the integral-to-degree factor.
128
 This number (INTEGRATION_FREQUENCY * I * H) is the integral-to-degree factor.
132
 
129
 
133
 Examples:
130
 Examples:
134
 FC1.3: I=2, H=1.304, HIRES_GYRO_INTEGRATION_FACTOR=8 --> integralDegreeFactor = 1304
131
 FC1.3: I=2, H=1.304, HIRES_GYRO_INTEGRATION_FACTOR=8 --> integralDegreeFactor = 1304
135
 FC2.0: I=2, H=2.048, HIRES_GYRO_INTEGRATION_FACTOR=13 --> integralDegreeFactor = 1260
132
 FC2.0: I=2, H=2.048, HIRES_GYRO_INTEGRATION_FACTOR=13 --> integralDegreeFactor = 1260
136
 My InvenSense copter: HIRES_GYRO_INTEGRATION_FACTOR=4, H=0.6827 --> integralDegreeFactor = 1365
133
 My InvenSense copter: HIRES_GYRO_INTEGRATION_FACTOR=4, H=0.6827 --> integralDegreeFactor = 1365
137
 */
134
 */
138
 
135
 
139
/*
136
/*
140
 * The value of gyro[PITCH/ROLL] for one deg/s = The hardware factor H * the number of samples * multiplier factor.
137
 * The value of gyro[PITCH/ROLL] for one deg/s = The hardware factor H * the number of samples * multiplier factor.
141
 * Will be about 10 or so for InvenSense, and about 33 for ADXRS610.
138
 * Will be about 10 or so for InvenSense, and about 33 for ADXRS610.
142
 */
139
 */
143
#define GYRO_RATE_FACTOR_PITCHROLL (GYRO_HW_FACTOR * GYRO_SUMMATION_FACTOR_PITCHROLL * GYRO_FACTOR_PITCHROLL)
140
#define GYRO_RATE_FACTOR_PITCHROLL (GYRO_HW_FACTOR * GYRO_SUMMATION_FACTOR_PITCHROLL * GYRO_FACTOR_PITCHROLL)
144
#define GYRO_RATE_FACTOR_YAW (GYRO_HW_FACTOR * GYRO_SUMMATION_FACTOR_YAW)
141
#define GYRO_RATE_FACTOR_YAW (GYRO_HW_FACTOR * GYRO_SUMMATION_FACTOR_YAW)
145
 
142
 
146
/*
143
/*
147
 * Gyro saturation prevention.
144
 * Gyro saturation prevention.
148
 */
145
 */
149
// How far from the end of its range a gyro is considered near-saturated.
146
// How far from the end of its range a gyro is considered near-saturated.
150
#define SENSOR_MIN_PITCHROLL 32
147
#define SENSOR_MIN_PITCHROLL 32
151
// Other end of the range (calculated)
148
// Other end of the range (calculated)
152
#define SENSOR_MAX_PITCHROLL (GYRO_SUMMATION_FACTOR_PITCHROLL * 1023 - SENSOR_MIN_PITCHROLL)
149
#define SENSOR_MAX_PITCHROLL (GYRO_SUMMATION_FACTOR_PITCHROLL * 1023 - SENSOR_MIN_PITCHROLL)
153
// Max. boost to add "virtually" to gyro signal at total saturation.
150
// Max. boost to add "virtually" to gyro signal at total saturation.
154
#define EXTRAPOLATION_LIMIT 2500
151
#define EXTRAPOLATION_LIMIT 2500
155
// Slope of the boost (calculated)
152
// Slope of the boost (calculated)
156
#define EXTRAPOLATION_SLOPE (EXTRAPOLATION_LIMIT/SENSOR_MIN_PITCHROLL)
153
#define EXTRAPOLATION_SLOPE (EXTRAPOLATION_LIMIT/SENSOR_MIN_PITCHROLL)
157
 
154
 
158
/*
155
/*
159
 * This value is subtracted from the gyro noise measurement in each iteration,
156
 * This value is subtracted from the gyro noise measurement in each iteration,
160
 * making it return towards zero.
157
 * making it return towards zero.
161
 */
158
 */
162
#define GYRO_NOISE_MEASUREMENT_DAMPING 5
159
#define GYRO_NOISE_MEASUREMENT_DAMPING 5
163
 
160
 
164
#define PITCH 0
161
#define PITCH 0
165
#define ROLL 1
162
#define ROLL 1
166
#define YAW 2
163
#define YAW 2
167
#define Z 2
164
#define Z 2
168
/*
165
/*
169
 * The values that this module outputs
166
 * The values that this module outputs
170
 * These first 2 exported arrays are zero-offset. The "PID" ones are used
167
 * These first 2 exported arrays are zero-offset. The "PID" ones are used
171
 * in the attitude control as rotation rates. The "ATT" ones are for
168
 * in the attitude control as rotation rates. The "ATT" ones are for
172
 * integration to angles. For the same axis, the PID and ATT variables
169
 * integration to angles. For the same axis, the PID and ATT variables
173
 * generally have about the same values. There are just some differences
170
 * generally have about the same values. There are just some differences
174
 * in filtering, and when a gyro becomes near saturated.
171
 * in filtering, and when a gyro becomes near saturated.
175
 * Maybe this distinction is not really necessary.
172
 * Maybe this distinction is not really necessary.
176
 */
173
 */
177
extern int16_t gyro_PID[2];
174
extern int16_t gyro_PID[2];
178
extern int16_t gyro_ATT[2];
175
extern int16_t gyro_ATT[2];
179
extern int16_t gyroD[2];
176
extern int16_t gyroD[2];
180
extern int16_t yawGyro;
177
extern int16_t yawGyro;
181
extern volatile uint16_t ADCycleCount;
178
extern volatile uint16_t ADCycleCount;
182
extern int16_t UBat;
179
extern int16_t UBat;
183
 
180
 
184
// 1:11 voltage divider, 1024 counts per 3V, and result is divided by 3.
181
// 1:11 voltage divider, 1024 counts per 3V, and result is divided by 3.
185
#define UBAT_AT_5V (int16_t)((5.0 * (1.0/11.0)) * 1024 / (3.0 * 3))
182
#define UBAT_AT_5V (int16_t)((5.0 * (1.0/11.0)) * 1024 / (3.0 * 3))
186
 
183
 
187
extern sensorOffset_t gyroOffset;
184
extern sensorOffset_t gyroOffset;
188
extern sensorOffset_t accOffset;
185
extern sensorOffset_t accOffset;
189
extern sensorOffset_t gyroAmplifierOffset;
186
extern sensorOffset_t gyroAmplifierOffset;
190
 
187
 
191
/*
188
/*
192
 * This is not really for external use - but the ENC-03 gyro modules needs it.
189
 * This is not really for external use - but the ENC-03 gyro modules needs it.
193
 */
190
 */
194
//extern volatile int16_t rawGyroSum[3];
191
//extern volatile int16_t rawGyroSum[3];
195
 
192
 
196
/*
193
/*
197
 * The acceleration values that this module outputs. They are zero based.
194
 * The acceleration values that this module outputs. They are zero based.
198
 */
195
 */
199
extern int16_t acc[3];
196
extern int16_t acc[3];
200
extern int16_t filteredAcc[3];
197
extern int16_t filteredAcc[3];
201
// extern volatile int32_t stronglyFilteredAcc[3];
198
// extern volatile int32_t stronglyFilteredAcc[3];
202
 
199
 
203
/*
200
/*
204
 * Diagnostics: Gyro noise level because of motor vibrations. The variables
201
 * Diagnostics: Gyro noise level because of motor vibrations. The variables
205
 * only really reflect the noise level when the copter stands still but with
202
 * only really reflect the noise level when the copter stands still but with
206
 * its motors running.
203
 * its motors running.
207
 */
204
 */
208
extern uint16_t gyroNoisePeak[3];
205
extern uint16_t gyroNoisePeak[3];
209
extern uint16_t accNoisePeak[3];
206
extern uint16_t accNoisePeak[3];
210
 
207
 
211
/*
208
/*
212
 * Air pressure.
209
 * Air pressure.
213
 * The sensor has a sensitivity of 45 mV/kPa.
210
 * The sensor has a sensitivity of 45 mV/kPa.
214
 * An approximate p(h) formula is = p(h[m])[kPa] = p_0 - 11.95 * 10^-3 * h
211
 * An approximate p(h) formula is = p(h[m])[kPa] = p_0 - 11.95 * 10^-3 * h
215
 * p(h[m])[kPa] = 101.3 - 11.95 * 10^-3 * h
212
 * p(h[m])[kPa] = 101.3 - 11.95 * 10^-3 * h
216
 * 11.95 * 10^-3 * h = 101.3 - p[kPa]
213
 * 11.95 * 10^-3 * h = 101.3 - p[kPa]
217
 * h = (101.3 - p[kPa])/0.01195
214
 * h = (101.3 - p[kPa])/0.01195
218
 * That is: dV = -45 mV * 11.95 * 10^-3 dh = -0.53775 mV / m.
215
 * That is: dV = -45 mV * 11.95 * 10^-3 dh = -0.53775 mV / m.
219
 * That is, with 38.02 * 1.024 / 3 steps per mV: -7 steps / m
216
 * That is, with 38.02 * 1.024 / 3 steps per mV: -7 steps / m
220
 
217
 
221
Display pressures
218
Display pressures
222
4165 mV-->1084.7
219
4165 mV-->1084.7
223
4090 mV-->1602.4   517.7
220
4090 mV-->1602.4   517.7
224
3877 mV-->3107.8  1503.4
221
3877 mV-->3107.8  1503.4
225
 
222
 
226
4165 mV-->1419.1
223
4165 mV-->1419.1
227
3503 mV-->208.1
224
3503 mV-->208.1
228
Diff.:   1211.0
225
Diff.:   1211.0
229
 
226
 
230
Calculated  Vout = 5V(.009P-0.095) --> 5V .009P = Vout + 5V 0.095 --> P = (Vout + 5V 0.095)/(5V 0.009)
227
Calculated  Vout = 5V(.009P-0.095) --> 5V .009P = Vout + 5V 0.095 --> P = (Vout + 5V 0.095)/(5V 0.009)
231
4165 mV = 5V(0.009P-0.095)  P = 103.11 kPa  h = -151.4m
228
4165 mV = 5V(0.009P-0.095)  P = 103.11 kPa  h = -151.4m
232
4090 mV = 5V(0.009P-0.095)  P = 101.44 kPa  h = -11.7m   139.7m
229
4090 mV = 5V(0.009P-0.095)  P = 101.44 kPa  h = -11.7m   139.7m
233
3877 mV = 5V(0.009P-0.095)  P = 96.7   kPa  h = 385m     396.7m
230
3877 mV = 5V(0.009P-0.095)  P = 96.7   kPa  h = 385m     396.7m
234
 
231
 
235
4165 mV = 5V(0.009P-0.095)  P = 103.11 kPa  h = -151.4m
232
4165 mV = 5V(0.009P-0.095)  P = 103.11 kPa  h = -151.4m
236
3503 mV = 5V(0.009P-0.095)  P = 88.4   kPa  h = 384m  Diff: 1079.5m
233
3503 mV = 5V(0.009P-0.095)  P = 88.4   kPa  h = 384m  Diff: 1079.5m
237
Pressure at sea level: 101.3 kPa. voltage: 5V * (0.009P-0.095) = 4.0835V
234
Pressure at sea level: 101.3 kPa. voltage: 5V * (0.009P-0.095) = 4.0835V
238
This is OCR2 = 143.15 at 1.5V in --> simple pressure =
235
This is OCR2 = 143.15 at 1.5V in --> simple pressure =
239
*/
236
*/
240
 
237
 
241
#define AIRPRESSURE_SUMMATION_FACTOR 14
238
#define AIRPRESSURE_SUMMATION_FACTOR 14
242
#define AIRPRESSURE_FILTER 8
239
#define AIRPRESSURE_FILTER 8
243
// Minimum A/D value before a range change is performed.
240
// Minimum A/D value before a range change is performed.
244
#define MIN_RAWPRESSURE (200 * 2)
241
#define MIN_RAWPRESSURE (200 * 2)
245
// Maximum A/D value before a range change is performed.
242
// Maximum A/D value before a range change is performed.
246
#define MAX_RAWPRESSURE (1023 * 2 - MIN_RAWPRESSURE)
243
#define MAX_RAWPRESSURE (1023 * 2 - MIN_RAWPRESSURE)
247
 
244
 
248
#define MIN_RANGES_EXTRAPOLATION 15
245
#define MIN_RANGES_EXTRAPOLATION 15
249
#define MAX_RANGES_EXTRAPOLATION 240
246
#define MAX_RANGES_EXTRAPOLATION 240
250
 
247
 
251
#define PRESSURE_EXTRAPOLATION_COEFF 25L
248
#define PRESSURE_EXTRAPOLATION_COEFF 25L
252
#define AUTORANGE_WAIT_FACTOR 1
249
#define AUTORANGE_WAIT_FACTOR 1
253
 
250
 
254
#define ABS_ALTITUDE_OFFSET 108205
251
#define ABS_ALTITUDE_OFFSET 108205
255
 
252
 
256
extern uint16_t simpleAirPressure;
253
extern uint16_t simpleAirPressure;
257
/*
254
/*
258
 * At saturation, the filteredAirPressure may actually be (simulated) negative.
255
 * At saturation, the filteredAirPressure may actually be (simulated) negative.
259
 */
256
 */
260
extern int32_t filteredAirPressure;
257
extern int32_t filteredAirPressure;
261
 
258
 
262
/*
259
/*
263
 * Flag: Interrupt handler has done all A/D conversion and processing.
260
 * Flag: Interrupt handler has done all A/D conversion and processing.
264
 */
261
 */
265
extern volatile uint8_t analogDataReady;
262
extern volatile uint8_t analogDataReady;
266
 
263
 
267
void analog_init(void);
264
void analog_init(void);
268
 
265
 
269
/*
266
/*
270
 * This is really only for use for the ENC-03 code module, which needs to get the raw value
267
 * This is really only for use for the ENC-03 code module, which needs to get the raw value
271
 * for its calibration. The raw value should not be used for anything else.
268
 * for its calibration. The raw value should not be used for anything else.
272
 */
269
 */
273
uint16_t rawGyroValue(uint8_t axis);
270
uint16_t rawGyroValue(uint8_t axis);
274
 
271
 
275
/*
272
/*
276
 * Start the conversion cycle. It will stop automatically.
273
 * Start the conversion cycle. It will stop automatically.
277
 */
274
 */
278
void startAnalogConversionCycle(void);
275
void startAnalogConversionCycle(void);
279
 
276
 
280
/*
277
/*
281
 * Process the sensor data to update the exported variables. Must be called after each measurement cycle and before the data is used.
278
 * Process the sensor data to update the exported variables. Must be called after each measurement cycle and before the data is used.
282
 */
279
 */
283
void analog_update(void);
280
void analog_update(void);
284
 
281
 
285
/*
282
/*
286
 * Read gyro and acc.meter calibration from EEPROM.
283
 * Read gyro and acc.meter calibration from EEPROM.
287
 */
284
 */
288
void analog_setNeutral(void);
285
void analog_setNeutral(void);
289
 
286
 
290
/*
287
/*
291
 * Zero-offset gyros and write the calibration data to EEPROM.
288
 * Zero-offset gyros and write the calibration data to EEPROM.
292
 */
289
 */
293
void analog_calibrateGyros(void);
290
void analog_calibrateGyros(void);
294
 
291
 
295
/*
292
/*
296
 * Zero-offset accelerometers and write the calibration data to EEPROM.
293
 * Zero-offset accelerometers and write the calibration data to EEPROM.
297
 */
294
 */
298
void analog_calibrateAcc(void);
295
void analog_calibrateAcc(void);
299
#endif //_ANALOG_H
296
#endif //_ANALOG_H
300
 
297