Subversion Repositories FlightCtrl

Rev

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

Rev 2124 Rev 2125
Line 6... Line 6...
6
#include "analog.h"
6
#include "analog.h"
7
#include "attitude.h"
7
#include "attitude.h"
8
#include "printf_P.h"
8
#include "printf_P.h"
9
#include "isqrt.h"
9
#include "isqrt.h"
10
#include "sensors.h"
10
#include "sensors.h"
-
 
11
#include "configuration.h"
Line 11... Line 12...
11
 
12
 
12
// for Delay functions
13
// for Delay functions
Line 13... Line 14...
13
#include "timer0.h"
14
#include "timer0.h"
Line 293... Line 294...
293
                tempGyro = (tempGyro - SENSOR_MAX) * EXTRAPOLATION_SLOPE + SENSOR_MAX;
294
                tempGyro = (tempGyro - SENSOR_MAX) * EXTRAPOLATION_SLOPE + SENSOR_MAX;
294
      }
295
      }
295
    }
296
    }
Line 296... Line 297...
296
 
297
 
297
    // 2) Apply sign and offset, scale before filtering.
298
    // 2) Apply sign and offset, scale before filtering.
298
    tempOffsetGyro[axis] = (tempGyro - gyroOffset.offsets[axis]);
299
    tempOffsetGyro[axis] = (tempGyro - gyroOffset.offsets[axis] + IMUConfig.gyroCalibrationTweak[axis]);
Line 299... Line 300...
299
  }
300
  }
300
 
301
 
Line 317... Line 318...
317
 
318
 
318
    // 6) Done.
319
    // 6) Done.
Line 319... Line 320...
319
    gyro_PID[axis] = tempOffsetGyro[axis];
320
    gyro_PID[axis] = tempOffsetGyro[axis];
320
 
321
 
321
    // Prepare tempOffsetGyro for next calculation below...
322
    // Prepare tempOffsetGyro for next calculation below...
Line 322... Line 323...
322
    tempOffsetGyro[axis] = (rawGyroValue(axis) - gyroOffset.offsets[axis]);
323
    tempOffsetGyro[axis] = (rawGyroValue(axis) - gyroOffset.offsets[axis] + IMUConfig.gyroCalibrationTweak[axis]);
323
  }
324
  }
324
 
325
 
Line 373... Line 374...
373
void analog_update(void) {
374
void analog_update(void) {
374
  analog_updateGyros();
375
  analog_updateGyros();
375
  // analog_updateAccelerometers();
376
  // analog_updateAccelerometers();
376
  analog_updateAirspeed();
377
  analog_updateAirspeed();
377
  analog_updateBatteryVoltage();
378
  analog_updateBatteryVoltage();
378
#ifdef USE_MK3MAG
-
 
379
  magneticHeading = volatileMagneticHeading;
-
 
380
#endif
-
 
381
}
379
}
Line 382... Line 380...
382
 
380
 
383
void analog_setNeutral() {
381
void analog_setNeutral() {
Line 384... Line 382...
384
  gyro_init();
382
  gyro_init();
385
 
383
 
386
  if (gyroOffset_readFromEEProm()) {
384
  if (gyroOffset_readFromEEProm()) {
387
    printf("gyro offsets invalid%s",recal);
385
    printf("gyro offsets invalid%s",recal);
-
 
386
    gyroOffset.offsets[PITCH] = 0x0721-3;
388
    gyroOffset.offsets[PITCH] = gyroOffset.offsets[ROLL] = 512 * GYRO_OVERSAMPLING;
387
    gyroOffset.offsets[ROLL] = 0x0721-15;
Line 389... Line 388...
389
    gyroOffset.offsets[YAW] = 512 * GYRO_OVERSAMPLING;
388
    gyroOffset.offsets[YAW] = 0x0CD9+12; // these are practical values from my gyros :)
390
  }
389
  }
391
 
390