Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1968 → Rev 1969

/branches/dongfang_FC_rewrite/analog.c
73,6 → 73,8
// set ADC enable & ADC Start Conversion & ADC Interrupt Enable bit
#define startADC() (ADCSRA |= (1<<ADEN)|(1<<ADSC)|(1<<ADIE))
 
const char* recal = ", recalibration needed.";
 
/*
* For each A/D conversion cycle, each analog channel is sampled a number of times
* (see array channelsForStates), and the results for each channel are summed.
103,9 → 105,9
* to be centered on zero.
*/
 
volatile sensorOffset_t gyroOffset;
volatile sensorOffset_t accOffset;
volatile sensorOffset_t gyroAmplifierOffset;
sensorOffset_t gyroOffset;
sensorOffset_t accOffset;
sensorOffset_t gyroAmplifierOffset;
 
/*
* This allows some experimentation with the gyro filters.
342,10 → 344,6
yawGyro = gyroOffset.offsets[YAW] - sensorInputs[AD_GYRO_YAW];
else
yawGyro = sensorInputs[AD_GYRO_YAW] - gyroOffset.offsets[YAW];
 
debugOut.analog[3] = rawGyroSum[0];
debugOut.analog[4] = rawGyroSum[1];
debugOut.analog[5] = rawGyroSum[2];
}
 
void analog_updateAccelerometers(void) {
473,12 → 471,13
 
void analog_setNeutral() {
if (gyroAmplifierOffset_readFromEEProm()) {
printf("gyro amp invalid, you must recalibrate.");
printf("gyro amp invalid%s",recal);
gyro_loadOffsets(1);
}
} else
gyro_loadOffsets(0);
 
if (gyroOffset_readFromEEProm()) {
printf("gyro offsets invalid, you must recalibrate.");
printf("gyro offsets invalid%s",recal);
gyroOffset.offsets[PITCH] = gyroOffset.offsets[ROLL] = 512 * GYRO_SUMMATION_FACTOR_PITCHROLL;
gyroOffset.offsets[YAW] = 512 * GYRO_SUMMATION_FACTOR_YAW;
}
487,7 → 486,7
debugOut.analog[7] = gyroOffset.offsets[ROLL];
 
if (accOffset_readFromEEProm()) {
printf("acc. meter offsets invalid, you must recalibrate.");
printf("acc. meter offsets invalid%s",recal);
accOffset.offsets[PITCH] = accOffset.offsets[ROLL] = 512 * ACC_SUMMATION_FACTOR_PITCHROLL;
accOffset.offsets[Z] = 512 * ACC_SUMMATION_FACTOR_Z;
}