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