Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2068 → Rev 2069

/branches/dongfang_FC_rewrite/analog.c
398,6 → 398,8
acc[Z] = accOffset.offsets[Z] - sensorInputs[AD_ACC_Z];
else
acc[Z] = sensorInputs[AD_ACC_Z] - accOffset.offsets[Z];
 
debugOut.analog[29] = acc[Z];
}
 
void analog_updateAirPressure(void) {
/branches/dongfang_FC_rewrite/externalControl.c
43,7 → 43,7
}
 
uint8_t EC_getSignalQuality(void) {
if (externalControlActive > 80)
if (externalControlActive > 40)
// Configured and heard from recently
return SIGNAL_GOOD;
 
/branches/dongfang_FC_rewrite/failsafeControl.c
15,6 → 15,8
 
debugOut.analog[25] = emergencyFlightTime;
 
debugOut.analog[30] = controlMixer_getSignalQuality();
 
if (controlMixer_getSignalQuality() <= SIGNAL_BAD) { // the rc-frame signal is not reveived or noisy
if (controlMixer_didReceiveSignal)
beepRCAlarm(); // Only make alarm if a control signal was received before the signal loss.
/branches/dongfang_FC_rewrite/heightControl.c
12,12 → 12,12
 
#define INTEGRAL_LIMIT 100000
 
#define LATCH_TIME 40
#define LATCH_TIME 3
 
int32_t targetHeight;
int32_t rampedTargetHeight;
//int32_t rampedTargetHeight;
 
uint8_t heightRampingTimer = 0;
//rampinguint8_t heightRampingTimer = 0;
int32_t maxHeightThisFlight;
int32_t iHeight;
 
24,11 → 24,15
void HC_setGround(void) {
analog_setGround();
// This should also happen when height control is enabled in-flight.
rampedTargetHeight = targetHeight = analog_getHeight();
/*rampedTargetHeight = */ targetHeight = analog_getHeight();
maxHeightThisFlight = 0;
iHeight = 0;
}
 
uint8_t HC_isSwitchOn() {
return (dynamicParams.heightSetting >= 255/3);
}
 
void HC_periodicTask(void) {
int32_t height = analog_getHeight();
static uint8_t setHeightLatch = 0;
39,17 → 43,15
// debugOut.analog[25] = dynamicParams.heightSetting;
 
if (staticParams.bitConfig & CFG_SIMPLE_HC_HOLD_SWITCH) {
// If switch is activated in config, the MaxHeight parameter is a switch value: ON in both ends of the range; OFF in the middle.
// if (dynamicParams.heightSetting < 40 || dynamicParams.heightSetting > 255 - 40) {
if (dynamicParams.heightSetting >= 255/3) {
if (HC_isSwitchOn()) {
// Switch is ON
if (setHeightLatch <= LATCH_TIME) {
if (setHeightLatch == LATCH_TIME) {
// Freeze the height as target. We want to do this exactly once each time the switch is thrown ON.
rampedTargetHeight = targetHeight = height;
}
// Time not yet reached.
setHeightLatch++;
if (setHeightLatch == LATCH_TIME) {
// Freeze the height as target. We want to do this exactly once each time the switch is thrown ON.
/* rampedTargetHeight = */ targetHeight = height;
}
// Time not yet reached.
setHeightLatch++;
}
} else {
// Switch is OFF.
60,6 → 62,7
targetHeight = (uint16_t) dynamicParams.heightSetting * 25L - 500L; // should be: 100 (or make a param out of it)
}
/*
if (++heightRampingTimer == INTEGRATION_FREQUENCY / 10) {
heightRampingTimer = 0;
if (rampedTargetHeight < targetHeight) {
78,6 → 81,7
}
}
}
*/
 
// height, in meters (so the division factor is: 100)
// debugOut.analog[24] = (117100 - filteredAirPressure) / 100;
91,7 → 95,7
HC_periodicTask();
int16_t throttle = PRTY[CONTROL_THROTTLE];
int32_t height = analog_getHeight();
int32_t heightError = rampedTargetHeight - height;
int32_t heightError = /*ramped*/ targetHeight - height;
int16_t dHeight = analog_getDHeight();
debugOut.analog[22] = height/10L;
151,8 → 155,7
*/
 
if (staticParams.bitConfig & CFG_SIMPLE_HEIGHT_CONTROL) {
if (!(staticParams.bitConfig & CFG_SIMPLE_HC_HOLD_SWITCH)
|| (dynamicParams.heightSetting < 40 || dynamicParams.heightSetting > 255 - 40)) {
if (!(staticParams.bitConfig & CFG_SIMPLE_HC_HOLD_SWITCH) || HC_isSwitchOn()) {
// If switch is not in use --> Just apply height control.
// If switch is in use --> only apply height control when switch is also ON.
throttle += dThrottle;
/branches/dongfang_FC_rewrite/timer2.c
4,7 → 4,7
#include "rc.h"
#include "attitude.h"
 
//#define COARSERESOLUTION 1
#define COARSERESOLUTION 1
 
#ifdef COARSERESOLUTION
#define NEUTRAL_PULSELENGTH 938
/branches/dongfang_FC_rewrite/uart0.c
108,17 → 108,17
"RC Stick R ",
"RC Stick T ",
"RC Stick Y ",
"Stick P w Emerg.", //20
"Stick R w Emerg.",
"control act wghd", //20
"acc vector wghd ",
"Height[dm] ",
"dHeight ",
"Altitude ",
"acc vector ",
"EFT ", //25
"naviPitch ",
"naviRoll ",
"i part contrib ",
" ",
" ", //30
"Acc Z ",
"Signal Qual ", //30
"var0 "
};
 
511,8 → 511,6
pRxData[0] = 5; // limit to 5
// load requested parameter set
 
debugOut.analog[30] = staticParams.GPSMininumSatellites;
 
paramSet_readFromEEProm(pRxData[0]);
 
tempchar[0] = pRxData[0];