Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2105 → Rev 2106

/branches/dongfang_FC_fixedwing/analog.c
51,7 → 51,7
* to be centered on zero.
*/
sensorOffset_t gyroOffset;
int16_t airpressureOffset;
uint16_t airpressureOffset;
 
/*
* In the MK coordinate system, nose-down is positive and left-roll is positive.
119,7 → 119,7
* So the initial value of 100 is for 9.7 volts.
*/
uint16_t UBat = 100;
uint16_t airspeed = 0;
uint16_t airspeedVelocity = 0;
 
/*
* Control and status.
371,7 → 371,7
void analog_update(void) {
analog_updateGyros();
// analog_updateAccelerometers();
analog_updateAirPressure();
analog_updateAirspeed();
analog_updateBatteryVoltage();
#ifdef USE_MK3MAG
magneticHeading = volatileMagneticHeading;
418,7 → 418,7
}
for (axis = PITCH; axis <= YAW; axis++) {
gyroOffset.offsets[axis] = (offsets[axis] + GYRO_OFFSET_CYCLES / 2) / GYRO_OFFSET_CYCLES;
gyroOffset.offsets[axis] = (offsets[axis] + OFFSET_CYCLES / 2) / OFFSET_CYCLES;
int16_t min = (512-200) * GYRO_OVERSAMPLING;
int16_t max = (512+200) * GYRO_OVERSAMPLING;
if(gyroOffset.offsets[axis] < min || gyroOffset.offsets[axis] > max)
428,7 → 428,7
airpressureOffset = (offsets[3] + OFFSET_CYCLES / 2) / OFFSET_CYCLES;
int16_t min = 200;
int16_t max = (1024-200) * 2;
if(airpressure < min || airpressure > max)
if(airpressureOffset < min || airpressureOffset > max)
versionInfo.hardwareErrors[0] |= FC_ERROR0_PRESSURE;
 
gyroOffset_writeToEEProm();
/branches/dongfang_FC_fixedwing/analog.h
108,12 → 108,12
#define GYRO_D_WINDOW_LENGTH 8
 
extern uint16_t UBat;
extern uint16_t airspeed;
extern uint16_t airspeedVelocity;
 
// 1:11 voltage divider, 1024 counts per 3V, and result is divided by 3.
#define UBAT_AT_5V (int16_t)((5.0 * (1.0/11.0)) * 1024 / (3.0 * 3))
 
extern sensorOffset_t gyroOffset;
extern uint16_t airpressureOffset;
 
/*
* This is not really for external use - but the ENC-03 gyro modules needs it.
199,11 → 199,6
/*
* Zero-offset gyros and write the calibration data to EEPROM.
*/
void analog_calibrateGyros(void);
void analog_calibrate(void);
 
/*
* Zero-offset accelerometers and write the calibration data to EEPROM.
*/
//void analog_calibrateAcc(void);
 
#endif //_ANALOG_H
/branches/dongfang_FC_fixedwing/commands.c
25,7 → 25,7
if (command == COMMAND_GYROCAL && !repeated) {
// Gyro calinbration, with or without selecting a new parameter-set.
paramSet_readFromEEProm(1);
analog_calibrateGyros();
analog_calibrate();
attitude_setNeutral();
controlMixer_setNeutral();
beepNumber(1);
/branches/dongfang_FC_fixedwing/eeprom.c
171,9 → 171,9
}
 
uint8_t airpressureOffset_readFromEEProm(void) {
return readChecksummedBlock(SENSOROFFSET_REVISION, (uint8_t*)&airspeedOffset, EEPROM_ADR_AIRSPEEDOFFSET, sizeof(uint16_t));
return readChecksummedBlock(SENSOROFFSET_REVISION, (uint8_t*)&airpressureOffset, EEPROM_ADR_AIRSPEEDOFFSET, sizeof(uint16_t));
}
 
void airpressureOffset_writeToEEProm(void) {
writeChecksummedBlock(SENSOROFFSET_REVISION, (uint8_t*)&airspeedOffset, EEPROM_ADR_AIRSPEEDOFFSET, sizeof(uint16_t));
writeChecksummedBlock(SENSOROFFSET_REVISION, (uint8_t*)&airpressureOffset, EEPROM_ADR_AIRSPEEDOFFSET, sizeof(uint16_t));
}
/branches/dongfang_FC_fixedwing/flight.c
68,9 → 68,9
return pid;
}
 
uint16_t result = (pid * 10) / airspeed;
uint16_t result = (pid * 10) / airspeedVelocity;
 
if (result > 240 || airspeed == 0) {
if (result > 240 || airspeedVelocity == 0) {
result = 240;
}