Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2141 → Rev 2142

/branches/dongfang_FC_fixedwing/arduino_atmega328/analog.c
190,11 → 190,11
int16_t rawGyroValue(uint8_t axis) {
switch(axis) {
case PITCH:
return ITG3200SensorInputs[3];
return ITG3200SensorInputs[1];
case ROLL:
return ITG3200SensorInputs[1];
return ITG3200SensorInputs[2];
case YAW:
return ITG3200SensorInputs[2];
return ITG3200SensorInputs[3];
}
return 0;
}
/branches/dongfang_FC_fixedwing/arduino_atmega328/configuration.c
85,22 → 85,27
staticParams.IFactor = 52;
 
staticParams.airspeedCorrection = 1;
staticParams.isFlyingThreshold = 100;
staticParams.isFlyingThreshold = 10;
 
// Servos
staticParams.servoCount = 7;
staticParams.servoCount = 6;
staticParams.servos[CONTROL_ELEVATOR].reverse = 0;
staticParams.servos[CONTROL_AILERONS].reverse = 1;
staticParams.servos[CONTROL_AILERONS].reverse = 0; // 1 for extra.
staticParams.servos[CONTROL_RUDDER].reverse = 0;
for (uint8_t i=0; i<4; i++) {
staticParams.servos[i].minValue = 80;
staticParams.servos[i].maxValue = 80;
}
 
// Battery warning and emergency flight
staticParams.batteryWarningVoltage = 101; // 3.7 each for 3S
 
for (uint8_t i=0; i<3; i++) {
staticParams.gyroPID[i].P = 40;
staticParams.gyroPID[i].I = 40;
staticParams.gyroPID[i].D = 40;
staticParams.gyroPID[i].iMax = 60;
staticParams.gyroPID[i].I = 20;
staticParams.gyroPID[i].D = 20;
staticParams.gyroPID[i].iMax = 30; // 60 for extra.
}
 
staticParams.stickIElevator = 40;
113,7 → 118,7
staticParams.outputFlash[1].bitmask = 3; //0b11110011;
staticParams.outputFlash[1].timing = 15;
 
staticParams.outputDebugMask = 8;
staticParams.outputDebugMask = 0;
staticParams.outputFlags = OUTPUTFLAGS_FLASH_0_AT_BEEP | OUTPUTFLAGS_FLASH_1_AT_BEEP | OUTPUTFLAGS_USE_ONBOARD_LEDS;
}
 
139,7 → 144,7
IMUConfig.rateTolerance = 120;
IMUConfig.gyroDWindowLength = 8;
IMUConfig.gyroQuadrant = 4;
IMUConfig.imuReversedFlags = IMU_REVERSE_GYRO_PR;
IMUConfig.imuReversedFlags = 0;
}
 
/***************************************************/
/branches/dongfang_FC_fixedwing/arduino_atmega328/configuration.h
153,7 → 153,7
 
// Servos
uint8_t servoCount;
Servo_t servos[3];
Servo_t servos[4];
 
// Outputs
output_flash_t outputFlash[2];
/branches/dongfang_FC_fixedwing/arduino_atmega328/controlMixer.c
8,6 → 8,7
#include "commands.h"
#include "output.h"
 
// The -1024 is an arbrtrary, very low value that will shut off the motor. This is default until the control mixer runs for the first time.
int16_t controls[4] = { 0, 0, 0, -1024 };
 
// Internal variables for reading commands made with an R/C stick.
/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, weget 350 channel values/sec.
// With 7 channels and 50 frames/sec, we get 350 channel values/sec.
if (RCQuality < 200)
RCQuality += 2;
}
138,6 → 138,7
int16_t channel = RCChannel(CH_THROTTLE);
 
if (channel <= -TIME(0.55)) {
debugOut.analog[17] = 1;
int16_t aux = RCChannel(COMMAND_CHANNEL_HORIZONTAL);
if (abs(aux) >= TIME(0.3)) // If we pull on the stick, it is gyrocal. Else it is RC cal.
lastRCCommand = COMMAND_GYROCAL;
144,6 → 145,7
else
lastRCCommand = COMMAND_RCCAL;
} else {
debugOut.analog[17] = 0;
lastRCCommand = COMMAND_NONE;
}
return lastRCCommand;
204,7 → 206,7
}
 
int16_t RC_getZeroThrottle(void) {
return TIME (0.95f);
return TIME (1.0f);
}
 
void RC_setZeroTrim(void) {
/branches/dongfang_FC_fixedwing/arduino_atmega328/timer2.c
139,15 → 139,17
value = controlServos[axis];
 
// Apply configurable limits. These are signed: +-128 is twice the normal +- 0.5 ms limit and +- 64 is normal.
int16_t min = (staticParams.servos[axis].minValue * SERVO_NORMAL_LIMIT) >> 6;
int16_t max = (staticParams.servos[axis].maxValue * SERVO_NORMAL_LIMIT) >> 6;
int16_t min = (int16_t)staticParams.servos[axis].minValue * (SERVO_NORMAL_LIMIT >> 6);
int16_t max = (int16_t)staticParams.servos[axis].maxValue * (SERVO_NORMAL_LIMIT >> 6);
 
if (value < min) value = min;
if (value < -min) value = -min;
else if (value > max) value = max;
 
if (value < -SERVO_ABS_LIMIT) value = -SERVO_ABS_LIMIT;
else if (value > SERVO_ABS_LIMIT) value = SERVO_ABS_LIMIT;
 
debugOut.analog[24+axis] = value;
 
servoValues[axis] = value + NEUTRAL_PULSELENGTH;
}
}
173,6 → 175,8
}
*/
 
uint8_t finalServoMap[] = {1,0,0,2,4,5,6,7};
 
ISR(TIMER2_COMPA_vect) {
static uint16_t remainingPulseTime;
static uint8_t servoIndex = 0;
182,7 → 186,7
// Pulse is over, and the next pulse has already just started. Calculate length of next pulse.
if (servoIndex < staticParams.servoCount) {
// There are more signals to output.
sumOfPulseTimes += (remainingPulseTime = servoValues[servoIndex]);
sumOfPulseTimes += (remainingPulseTime = servoValues[finalServoMap[servoIndex]]);
servoIndex++;
} else {
// There are no more signals. Reset the counter and make this pulse cover the missing frame time.