Subversion Repositories FlightCtrl

Rev

Rev 2018 | Rev 2033 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2018 Rev 2019
Line 92... Line 92...
92
/*
92
/*
93
 * 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,
94
 * 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
95
 * channelsForStates array in analog.c.
95
 * channelsForStates array in analog.c.
96
 */
96
 */
97
#define GYRO_SUMMATION_FACTOR_PITCHROLL 4
97
#define GYRO_OVERSAMPLING_PITCHROLL 4
98
#define GYRO_SUMMATION_FACTOR_YAW 2
98
#define GYRO_OVERSAMPLING_YAW 2
Line 99... Line 99...
99
 
99
 
100
#define ACC_SUMMATION_FACTOR_PITCHROLL 2
100
#define ACC_OVERSAMPLING_XY 2
Line 101... Line 101...
101
#define ACC_SUMMATION_FACTOR_Z 1
101
#define ACC_OVERSAMPLING_Z 1
102
 
102
 
103
/*
103
/*
104
 Integration:
104
 Integration:
Line 135... Line 135...
135
 
135
 
136
/*
136
/*
137
 * 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.
138
 * 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.
139
 */
139
 */
140
#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_OVERSAMPLING_PITCHROLL * GYRO_FACTOR_PITCHROLL)
Line 141... Line 141...
141
#define GYRO_RATE_FACTOR_YAW (GYRO_HW_FACTOR * GYRO_SUMMATION_FACTOR_YAW)
141
#define GYRO_RATE_FACTOR_YAW (GYRO_HW_FACTOR * GYRO_OVERSAMPLING_YAW)
142
 
142
 
143
/*
143
/*
144
 * Gyro saturation prevention.
144
 * Gyro saturation prevention.
145
 */
145
 */
146
// 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.
147
#define SENSOR_MIN_PITCHROLL 32
147
#define SENSOR_MIN_PITCHROLL 32
148
// Other end of the range (calculated)
148
// Other end of the range (calculated)
149
#define SENSOR_MAX_PITCHROLL (GYRO_SUMMATION_FACTOR_PITCHROLL * 1023 - SENSOR_MIN_PITCHROLL)
149
#define SENSOR_MAX_PITCHROLL (GYRO_OVERSAMPLING_PITCHROLL * 1023 - SENSOR_MIN_PITCHROLL)
150
// Max. boost to add "virtually" to gyro signal at total saturation.
150
// Max. boost to add "virtually" to gyro signal at total saturation.
151
#define EXTRAPOLATION_LIMIT 2500
151
#define EXTRAPOLATION_LIMIT 2500
Line 233... Line 233...
233
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
234
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
235
This is OCR2 = 143.15 at 1.5V in --> simple pressure =
235
This is OCR2 = 143.15 at 1.5V in --> simple pressure =
236
*/
236
*/
Line 237... Line 237...
237
 
237
 
238
#define AIRPRESSURE_SUMMATION_FACTOR 14
238
#define AIRPRESSURE_OVERSAMPLING 14
239
#define AIRPRESSURE_FILTER 8
239
#define AIRPRESSURE_FILTER 8
240
// Minimum A/D value before a range change is performed.
240
// Minimum A/D value before a range change is performed.
241
#define MIN_RAWPRESSURE (200 * 2)
241
#define MIN_RAWPRESSURE (200 * 2)
242
// Maximum A/D value before a range change is performed.
242
// Maximum A/D value before a range change is performed.