Rev 1870 | Rev 1887 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1870 | Rev 1872 | ||
---|---|---|---|
Line 77... | Line 77... | ||
77 | * the offsets with the DAC. |
77 | * the offsets with the DAC. |
78 | */ |
78 | */ |
79 | volatile int16_t rawGyroSum[3]; |
79 | volatile int16_t rawGyroSum[3]; |
80 | volatile int16_t acc[3]; |
80 | volatile int16_t acc[3]; |
81 | volatile int16_t filteredAcc[2] = { 0,0 }; |
81 | volatile int16_t filteredAcc[2] = { 0,0 }; |
82 | volatile int32_t stronglyFilteredAcc[3] = { 0,0,0 }; |
82 | // volatile int32_t stronglyFilteredAcc[3] = { 0,0,0 }; |
Line 83... | Line 83... | ||
83 | 83 | ||
84 | /* |
84 | /* |
85 | * These 4 exported variables are zero-offset. The "PID" ones are used |
85 | * These 4 exported variables are zero-offset. The "PID" ones are used |
86 | * in the attitude control as rotation rates. The "ATT" ones are for |
86 | * in the attitude control as rotation rates. The "ATT" ones are for |
Line 252... | Line 252... | ||
252 | static uint16_t pressureAutorangingWait = 25; |
252 | static uint16_t pressureAutorangingWait = 25; |
253 | uint16_t rawAirPressure; |
253 | uint16_t rawAirPressure; |
254 | uint8_t i, axis; |
254 | uint8_t i, axis; |
255 | int16_t newrange; |
255 | int16_t newrange; |
Line 256... | Line -... | ||
256 | - | ||
257 | J5HIGH; |
- | |
258 | 256 | ||
259 | // for various filters... |
257 | // for various filters... |
Line 260... | Line 258... | ||
260 | int16_t tempOffsetGyro, tempGyro; |
258 | int16_t tempOffsetGyro, tempGyro; |
Line 271... | Line 269... | ||
271 | if (ACC_REVERSED[Z]) |
269 | if (ACC_REVERSED[Z]) |
272 | acc[Z] = accOffset[Z] - sensorInputs[AD_ACC_Z]; |
270 | acc[Z] = accOffset[Z] - sensorInputs[AD_ACC_Z]; |
273 | else |
271 | else |
274 | acc[Z] = sensorInputs[AD_ACC_Z] - accOffset[Z]; |
272 | acc[Z] = sensorInputs[AD_ACC_Z] - accOffset[Z]; |
Line -... | Line 273... | ||
- | 273 | ||
275 | 274 | /* |
|
276 | stronglyFilteredAcc[Z] = |
275 | stronglyFilteredAcc[Z] = |
- | 276 | (stronglyFilteredAcc[Z] * 99 + acc[Z] * 10) / 100; |
|
Line 277... | Line 277... | ||
277 | (stronglyFilteredAcc[Z] * 99 + acc[Z] * 10) / 100; |
277 | */ |
Line 278... | Line 278... | ||
278 | 278 | ||
279 | break; |
279 | break; |
Line 293... | Line 293... | ||
293 | acc[PITCH] = sensorInputs[AD_ACC_PITCH] - accOffset[PITCH]; |
293 | acc[PITCH] = sensorInputs[AD_ACC_PITCH] - accOffset[PITCH]; |
Line 294... | Line 294... | ||
294 | 294 | ||
295 | filteredAcc[PITCH] = |
295 | filteredAcc[PITCH] = |
Line -... | Line 296... | ||
- | 296 | (filteredAcc[PITCH] * (ACC_FILTER - 1) + acc[PITCH]) / ACC_FILTER; |
|
296 | (filteredAcc[PITCH] * (ACC_FILTER - 1) + acc[PITCH]) / ACC_FILTER; |
297 | |
297 | 298 | /* |
|
298 | stronglyFilteredAcc[PITCH] = |
299 | stronglyFilteredAcc[PITCH] = |
Line 299... | Line 300... | ||
299 | (stronglyFilteredAcc[PITCH] * 99 + acc[PITCH] * 10) / 100; |
300 | (stronglyFilteredAcc[PITCH] * 99 + acc[PITCH] * 10) / 100; |
300 | 301 | */ |
|
Line 301... | Line 302... | ||
301 | 302 | ||
Line 308... | Line 309... | ||
308 | else |
309 | else |
309 | acc[ROLL] = sensorInputs[AD_ACC_ROLL] - accOffset[ROLL]; |
310 | acc[ROLL] = sensorInputs[AD_ACC_ROLL] - accOffset[ROLL]; |
310 | filteredAcc[ROLL] = |
311 | filteredAcc[ROLL] = |
311 | (filteredAcc[ROLL] * (ACC_FILTER - 1) + acc[ROLL]) / ACC_FILTER; |
312 | (filteredAcc[ROLL] * (ACC_FILTER - 1) + acc[ROLL]) / ACC_FILTER; |
Line -... | Line 313... | ||
- | 313 | ||
312 | 314 | /* |
|
313 | stronglyFilteredAcc[ROLL] = |
315 | stronglyFilteredAcc[ROLL] = |
- | 316 | (stronglyFilteredAcc[ROLL] * 99 + acc[ROLL] * 10) / 100; |
|
Line 314... | Line 317... | ||
314 | (stronglyFilteredAcc[ROLL] * 99 + acc[ROLL] * 10) / 100; |
317 | */ |
315 | 318 | ||
Line 316... | Line 319... | ||
316 | measureNoise(acc[ROLL], &accNoisePeak[ROLL], 1); |
319 | measureNoise(acc[ROLL], &accNoisePeak[ROLL], 1); |
Line 480... | Line 483... | ||
480 | // set adc muxer to next ad_channel |
483 | // set adc muxer to next ad_channel |
481 | ADMUX = (ADMUX & 0xE0) | ad_channel; |
484 | ADMUX = (ADMUX & 0xE0) | ad_channel; |
482 | // after full cycle stop further interrupts |
485 | // after full cycle stop further interrupts |
483 | if (state) |
486 | if (state) |
484 | analog_start(); |
487 | analog_start(); |
485 | else |
- | |
486 | J4LOW; |
- | |
487 | - | ||
488 | J5LOW; |
- | |
489 | } |
488 | } |
Line 490... | Line 489... | ||
490 | 489 | ||
491 | void analog_calibrate(void) { |
490 | void analog_calibrate(void) { |
492 | #define GYRO_OFFSET_CYCLES 32 |
491 | #define GYRO_OFFSET_CYCLES 32 |