Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2140 → Rev 2141

/branches/dongfang_FC_fixedwing/arduino_atmega328/analog.c
285,6 → 285,7
gyroD[axis] -= gyroDWindow[axis][gyroDWindowIdx];
gyroD[axis] += diff;
gyroDWindow[axis][gyroDWindowIdx] = diff;
debugOut.analog[9+axis] = gyroD[axis];
 
// 6) Done.
gyro_PID[axis] = tempOffsetGyro[axis];
/branches/dongfang_FC_fixedwing/arduino_atmega328/analog.h
105,7 → 105,7
extern int16_t gyro_ATT[3];
extern int16_t gyroD[3];
 
#define GYRO_D_WINDOW_LENGTH 8
#define GYRO_D_WINDOW_LENGTH 16
 
extern uint16_t UBat;
extern uint16_t airspeedVelocity;
/branches/dongfang_FC_fixedwing/arduino_atmega328/attitude.h
8,6 → 8,7
#include <inttypes.h>
 
#include "analog.h"
#include "timer0.h"
 
// For debugging only.
#include "uart0.h"
21,7 → 22,7
/*
* The frequency at which numerical integration takes place. 488 in original code.
*/
#define INTEGRATION_FREQUENCY 488
#define INTEGRATION_FREQUENCY (uint16_t)(F_MAINLOOP)
 
/*
* Constant for deriving an attitude angle from acceleration measurement.
62,8 → 63,8
*/
//#define GYRO_ACC_FACTOR ((GYRO_DEG_FACTOR_PITCHROLL) / (DEG_ACC_FACTOR))
 
#define OVER180 ((int32_t)GYRO_DEG_FACTOR * 180L)
#define OVER360 ((int32_t)GYRO_DEG_FACTOR * 360L)
#define OVER180 ((int32_t)(GYRO_DEG_FACTOR * 180.0f))
#define OVER360 ((int32_t)(GYRO_DEG_FACTOR * 360.0f))
 
/*
* Rotation rates
/branches/dongfang_FC_fixedwing/arduino_atmega328/configuration.c
137,7 → 137,7
IMUConfig.gyroPIDFilterConstant = 10;
IMUConfig.gyroDFilterConstant = 1;
IMUConfig.rateTolerance = 120;
IMUConfig.gyroDWindowLength = 3;
IMUConfig.gyroDWindowLength = 8;
IMUConfig.gyroQuadrant = 4;
IMUConfig.imuReversedFlags = IMU_REVERSE_GYRO_PR;
}
147,7 → 147,7
/***************************************************/
void channelMap_default(void) {
channelMap.RCPolarity = 1;
channelMap.HWTrim = 10;
channelMap.HWTrim = 175;
channelMap.variableOffset = 131;
channelMap.channels[CH_ELEVATOR] = 1;
channelMap.channels[CH_AILERONS] = 0;
/branches/dongfang_FC_fixedwing/arduino_atmega328/eeprom.c
5,6 → 5,7
#include "eeprom.h"
#include "printf_P.h"
#include "output.h"
#include "rc.h"
#include <avr/wdt.h>
#include <avr/eeprom.h>
 
/branches/dongfang_FC_fixedwing/arduino_atmega328/eeprom.h
35,6 → 35,7
void rcTrim_readOrDefault(void);
void IMUConfig_readOrDefault(void);
void IMUConfig_writeToEEprom(void);
void rcTrim_writeToEEProm(void);
 
uint8_t paramSet_readFromEEProm(uint8_t setnumber);
void paramSet_writeToEEProm(uint8_t setnumber);
/branches/dongfang_FC_fixedwing/arduino_atmega328/flight.c
165,8 → 165,6
}
#endif
 
debugOut.analog[9+axis] = error / (GYRO_DEG_FACTOR / 10); // in 0.1 deg
 
/************************************************************************/
/* Calculate control feedback from angle (gyro integral) */
/* and angular velocity (gyro signal) */
243,10 → 241,5
debugOut.analog[13] = term[ROLL];
debugOut.analog[14] = term[YAW];
debugOut.analog[15] = term[THROTTLE];
 
//DebugOut.Analog[18] = (10 * controlIntegrals[CONTROL_ELEVATOR]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
//DebugOut.Analog[19] = (10 * controlIntegrals[CONTROL_AILERONS]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
//debugOut.analog[22] = (10 * IPart[PITCH]) / GYRO_DEG_FACTOR; // in 0.1 deg
//debugOut.analog[23] = (10 * IPart[ROLL]) / GYRO_DEG_FACTOR; // in 0.1 deg
}
}
/branches/dongfang_FC_fixedwing/arduino_atmega328/makefile
15,7 → 15,7
 
GYRO=IMU3200
GYRO_HW_NAME=IMU3200
GYRO_HW_FACTOR=3.0f
GYRO_HW_FACTOR=3.67f
GYRO_CORRECTION=1.0f
 
#-------------------------------------------------------------------
/branches/dongfang_FC_fixedwing/arduino_atmega328/rc.c
103,7 → 103,7
if ((signal >= TIME(0.8)) && (signal < TIME(2.2))) {
signal -= (TIME(1.5) - 128 + channelMap.HWTrim);
if (abs(signal - PPM_in[channel]) < TIME(0.05)) {
// With 7 channels and 50 frames/sec, we get 350 channel values/sec.
// With 7 channels and 50 frames/sec, weget 350 channel values/sec.
if (RCQuality < 200)
RCQuality += 2;
}
177,7 → 177,6
if (varNum < 4) {
// 0th variable is 5th channel (1-based) etc.
int16_t result = (RCChannel(varNum + CH_POTS) / 6) + channelMap.variableOffset;
if (varNum<2) debugOut.analog[18+varNum] = result;
return result;
}
/*
184,7 → 183,7
* Let's just say:
* The RC variable i is hardwired to channel i, i>=4
*/
return (PPM_in[varNum] >> 3) + channelMap.variableOffset;
return (PPM_in[varNum] / 6) + channelMap.variableOffset;
}
 
uint8_t RC_getSignalQuality(void) {
205,7 → 204,7
}
 
int16_t RC_getZeroThrottle(void) {
return TIME (1.0f);
return TIME (0.95f);
}
 
void RC_setZeroTrim(void) {
/branches/dongfang_FC_fixedwing/arduino_atmega328/timer0.c
84,11 → 84,11
global10kHzClock++;
#endif
 
if (!cnt--) { // every 10th run (9.765625kHz/10 = 976.5625Hz)
if (!cnt--) { // every 10th run
cnt = 9;
cnt_1ms ^= 1;
if (!cnt_1ms) {
runFlightControl = 1; // every 2nd run (976.5625 Hz/2 = 488.28125 Hz)
runFlightControl = 1; // every 2nd run
}
globalMillisClock++; // increment millisecond counter
}
/branches/dongfang_FC_fixedwing/arduino_atmega328/uart0.c
91,9 → 91,9
"Target P ",
"Target R ",
"Target Y ",
"Error P ",
"Error R ", //10
"Error Y ",
"GyroD P ",
"GyroD R ", //10
"GyroD Y ",
"Term P ",
"Term R ",
"Term Y ",
/branches/dongfang_FC_fixedwing/attitude.h
8,6 → 8,7
#include <inttypes.h>
 
#include "analog.h"
#include "timer0.h"
 
// For debugging only.
#include "uart0.h"
21,7 → 22,7
/*
* The frequency at which numerical integration takes place. 488 in original code.
*/
#define INTEGRATION_FREQUENCY 488
#define INTEGRATION_FREQUENCY (uint16_t)(F_MAINLOOP)
 
/*
* Constant for deriving an attitude angle from acceleration measurement.
62,8 → 63,8
*/
//#define GYRO_ACC_FACTOR ((GYRO_DEG_FACTOR_PITCHROLL) / (DEG_ACC_FACTOR))
 
#define OVER180 ((int32_t)GYRO_DEG_FACTOR * 180)
#define OVER360 ((int32_t)GYRO_DEG_FACTOR * 360)
#define OVER180 ((int32_t)(GYRO_DEG_FACTOR * 180.0f))
#define OVER360 ((int32_t)(GYRO_DEG_FACTOR * 360.0f))
 
/*
* Rotation rates
/branches/dongfang_FC_fixedwing/eeprom.c
5,6 → 5,7
#include "eeprom.h"
#include "printf_P.h"
#include "output.h"
#include "rc.h"
#include <avr/wdt.h>
#include <avr/eeprom.h>
 
/branches/dongfang_FC_fixedwing/eeprom.h
35,6 → 35,7
void rcTrim_readOrDefault(void);
void IMUConfig_readOrDefault(void);
void IMUConfig_writeToEEprom(void);
void rcTrim_writeToEEProm(void);
 
uint8_t paramSet_readFromEEProm(uint8_t setnumber);
void paramSet_writeToEEProm(uint8_t setnumber);