Subversion Repositories FlightCtrl

Rev

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

Rev 2105 Rev 2106
Line 49... Line 49...
49
 * Offset values. These are the raw gyro and acc. meter sums when the copter is
49
 * Offset values. These are the raw gyro and acc. meter sums when the copter is
50
 * standing still. They are used for adjusting the gyro and acc. meter values
50
 * standing still. They are used for adjusting the gyro and acc. meter values
51
 * to be centered on zero.
51
 * to be centered on zero.
52
 */
52
 */
53
sensorOffset_t gyroOffset;
53
sensorOffset_t gyroOffset;
54
int16_t airpressureOffset;
54
uint16_t airpressureOffset;
Line 55... Line 55...
55
 
55
 
56
/*
56
/*
57
 * In the MK coordinate system, nose-down is positive and left-roll is positive.
57
 * In the MK coordinate system, nose-down is positive and left-roll is positive.
58
 * If a sensor is used in an orientation where one but not both of the axes has
58
 * If a sensor is used in an orientation where one but not both of the axes has
Line 117... Line 117...
117
 * Battery voltage, in units of: 1k/11k / 3V * 1024 = 31.03 per volt.
117
 * Battery voltage, in units of: 1k/11k / 3V * 1024 = 31.03 per volt.
118
 * That is divided by 3 below, for a final 10.34 per volt.
118
 * That is divided by 3 below, for a final 10.34 per volt.
119
 * So the initial value of 100 is for 9.7 volts.
119
 * So the initial value of 100 is for 9.7 volts.
120
 */
120
 */
121
uint16_t UBat = 100;
121
uint16_t UBat = 100;
122
uint16_t airspeed = 0;
122
uint16_t airspeedVelocity = 0;
Line 123... Line 123...
123
 
123
 
124
/*
124
/*
125
 * Control and status.
125
 * Control and status.
126
 */
126
 */
Line 369... Line 369...
369
}
369
}
Line 370... Line 370...
370
 
370
 
371
void analog_update(void) {
371
void analog_update(void) {
372
  analog_updateGyros();
372
  analog_updateGyros();
373
  // analog_updateAccelerometers();
373
  // analog_updateAccelerometers();
374
  analog_updateAirPressure();
374
  analog_updateAirspeed();
375
  analog_updateBatteryVoltage();
375
  analog_updateBatteryVoltage();
376
#ifdef USE_MK3MAG
376
#ifdef USE_MK3MAG
377
  magneticHeading = volatileMagneticHeading;
377
  magneticHeading = volatileMagneticHeading;
378
#endif
378
#endif
Line 416... Line 416...
416
    }
416
    }
417
    offsets[3] += sensorInputs[AD_AIRPRESSURE];
417
    offsets[3] += sensorInputs[AD_AIRPRESSURE];
418
  }
418
  }
Line 419... Line 419...
419
 
419
 
420
  for (axis = PITCH; axis <= YAW; axis++) {
420
  for (axis = PITCH; axis <= YAW; axis++) {
421
    gyroOffset.offsets[axis] = (offsets[axis] + GYRO_OFFSET_CYCLES / 2) / GYRO_OFFSET_CYCLES;
421
    gyroOffset.offsets[axis] = (offsets[axis] + OFFSET_CYCLES / 2) / OFFSET_CYCLES;
422
    int16_t min = (512-200) * GYRO_OVERSAMPLING;
422
    int16_t min = (512-200) * GYRO_OVERSAMPLING;
423
    int16_t max = (512+200) * GYRO_OVERSAMPLING;
423
    int16_t max = (512+200) * GYRO_OVERSAMPLING;
424
    if(gyroOffset.offsets[axis] < min || gyroOffset.offsets[axis] > max)
424
    if(gyroOffset.offsets[axis] < min || gyroOffset.offsets[axis] > max)
425
      versionInfo.hardwareErrors[0] |= FC_ERROR0_GYRO_PITCH << axis;
425
      versionInfo.hardwareErrors[0] |= FC_ERROR0_GYRO_PITCH << axis;
Line 426... Line 426...
426
  }
426
  }
427
 
427
 
428
  airpressureOffset = (offsets[3] + OFFSET_CYCLES / 2) / OFFSET_CYCLES;
428
  airpressureOffset = (offsets[3] + OFFSET_CYCLES / 2) / OFFSET_CYCLES;
429
  int16_t min = 200;
429
  int16_t min = 200;
430
  int16_t max = (1024-200) * 2;
430
  int16_t max = (1024-200) * 2;
Line 431... Line 431...
431
  if(airpressure < min || airpressure > max)
431
  if(airpressureOffset < min || airpressureOffset > max)
Line 432... Line 432...
432
    versionInfo.hardwareErrors[0] |= FC_ERROR0_PRESSURE;
432
    versionInfo.hardwareErrors[0] |= FC_ERROR0_PRESSURE;