Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1588 → Rev 1589

/beta/Code Redesign killagreg/fc.c
1490,7 → 1490,7
#define HC_GAS_AVERAGE 4 // 4 * 2ms= 8 ms averaging
 
int16_t CosAttitude; // for projection of hoover gas
int16_t HCGas, HeightDeviation;
int16_t HCGas, HeightDeviation = 0;
static int16_t FilterHCGas = 0;
static int16_t HeightTrimming = 0; // rate for change of height setpoint
static uint8_t HCActive = 0;
1650,6 → 1650,7
{
SetPointHeight += (HeightTrimming * ParamSet.Height_Gain)/((5 * 512) / 2); // move setpoint
HeightTrimming = 0;
LIMIT_MIN_MAX(SetPointHeight, (ReadingHeight - 1024), (ReadingHeight + 1024)); // max. 10m deviation
if(ParamSet.Config2 & CFG2_VARIO_BEEP) BeepTime = 75;
//update hover gas stick value when setpoint is shifted
if(!ParamSet.Height_StickNeutralPoint)
1683,35 → 1684,38
{
// ------------------------- P-Part ----------------------------
tmp_long1 = ReadingHeight - SetPointHeight; // positive when too high
LIMIT_MIN_MAX(tmp_long1, -32000, 32000); // avoid overflov when casting to int16_t
HeightDeviation = (int16_t)(tmp_long1); // positive when too high
tmp_int1 = (HeightDeviation * (int16_t)FCParam.HeightP) / 16; // p-part
HCGas -= tmp_int1;
LIMIT_MIN_MAX(tmp_long1, -32767L, 32767L); // avoid overflow when casting to int16_t
HeightDeviation = (int16_t)(tmp_long1); // positive when too high
tmp_long1 = (tmp_long1 * (int32_t)FCParam.HeightP) / 16L; // p-part
LIMIT_MIN_MAX(tmp_long1, -255 * STICK_GAIN, 255 * STICK_GAIN); // more than 2 times the full range makes no sense
HCGas -= tmp_long1;
// ------------------------- D-Part 1: Vario Meter ----------------------------
tmp_int1 = ReadingVario / 8;
if(tmp_int1 > 8) tmp_int1 = 8; // limit quadratic part on upward movement to avoid to much gas reduction
if(tmp_int1 > 0) tmp_int1 = ReadingVario + (tmp_int1 * tmp_int1) / 4;
else tmp_int1 = ReadingVario - (tmp_int1 * tmp_int1) / 4;
tmp_int1 = (FCParam.HeightD * (int32_t)(tmp_int1)) / 128L; // scale to d-gain parameter
LIMIT_MIN_MAX(tmp_int1, -127, 255);
LIMIT_MIN_MAX(tmp_int1, -180, 180); // avoid overflow when squared
tmp_int2 = tmp_int1;
LIMIT_MAX(tmp_int2,8); // limit quadratic part on upward movement to avoid to much gas reduction
if(tmp_int1 > 0) tmp_int1 = tmp_int1 + (tmp_int2 * tmp_int2) / 4L;
else tmp_int1 = tmp_int1 - (tmp_int2 * tmp_int2) / 4L;
tmp_int1 = (tmp_int1 * (int32_t)FCParam.HeightD ) / 128L; // scale to d-gain parameter
LIMIT_MIN_MAX(tmp_int1,-32 * STICK_GAIN, 64 * STICK_GAIN);
HCGas -= tmp_int1;
// ------------------------ D-Part 2: ACC-Z Integral ------------------------
tmp_int1 = ((ReadingIntegralTop / 128) * (int32_t) FCParam.Height_ACC_Effect) / (128 / STICK_GAIN);
LIMIT_MIN_MAX(tmp_int1, -127, 255);
HCGas -= tmp_int1;
 
// limit deviation from hover point within the target region
if( (abs(HeightDeviation) < 150) && (!HeightTrimming) && (HoverGas > 0)) // height setpoint is not changed and hover gas not zero
{
LIMIT_MIN_MAX(HCGas, HoverGasMin, HoverGasMax); // limit gas around the hover point
}
tmp_long1 = ((ReadingIntegralTop / 128L) * (int32_t) FCParam.Height_ACC_Effect) / (128L / STICK_GAIN);
LIMIT_MIN_MAX(tmp_long1, -32 * STICK_GAIN, 64 * STICK_GAIN);
HCGas -= tmp_long1;
} // EOF no baro range expanding
 
// ------------------------ D-Part 3: GpsZ ----------------------------------
tmp_int1 = (ParamSet.Height_GPS_Z * (int32_t)NCGpsZ)/128L;
LIMIT_MIN_MAX(tmp_int1, -127, 255);
tmp_int1 = ((int16_t)ParamSet.Height_GPS_Z * (int16_t)NCGpsZ)/128L;
LIMIT_MIN_MAX(tmp_int1, -32 * STICK_GAIN, 64 * STICK_GAIN);
HCGas -= tmp_int1;
 
// limit deviation from hover point within the target region
if( (abs(HeightDeviation) < 150) && (!HeightTrimming) && (HoverGas > 0)) // height setpoint is not changed and hover gas not zero
{
LIMIT_MIN_MAX(HCGas, HoverGasMin, HoverGasMax); // limit gas around the hover point
}
 
// strech control output by inverse attitude projection 1/cos
tmp_long2 = (int32_t)HCGas;
tmp_long2 *= 8192L;
1722,7 → 1726,7
FilterHCGas = (FilterHCGas * (HC_GAS_AVERAGE - 1) + HCGas) / HC_GAS_AVERAGE;
// limit height control gas pd-control output
LIMIT_MIN_MAX(FilterHCGas, ParamSet.HeightMinGas * STICK_GAIN, (ParamSet.GasMax - 20) * STICK_GAIN);
// limit gas to stick position for limiting height version
// limit gas to stick position when limiting height control version active
if(ParamSet.Config2 & CFG2_HEIGHT_LIMIT)
{
LIMIT_MAX(FilterHCGas, GasMixFraction);
1790,7 → 1794,7
else
{ // no limit
HoverGasMin = 0;
HoverGasMax = 1023;
HoverGasMax = 255 * STICK_GAIN;
}
} //EOF only on small vertical speed
}// EOF ----------------- Hover Gas Estimation --------------------------------
/beta/Code Redesign killagreg/jetimenu.c
120,7 → 120,7
// -----------------------------------------------------------
// Update display buffer
// -----------------------------------------------------------
void JetiBox_Update(unsigned char key)
uint8_t JetiBox_Update(uint8_t key)
{
static uint8_t item = 0, last_item = 0; // the menu item
 
129,7 → 129,8
switch(key)
{
case JETIBOX_KEY_LEFT:
item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item
if(item == 0) return(1);
else item = pgm_read_byte(&JetiBox_Menu[item].left);//trigger to left menu item
break;
case JETIBOX_KEY_RIGHT:
item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item
150,5 → 151,7
LIBFC_JetiBox_Clear();
//execute menu item handler
((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key);
 
return(0);
}
 
/beta/Code Redesign killagreg/jetimenu.h
2,6 → 2,6
#define _JETIMENU_H
 
#include <inttypes.h>
extern void JetiBox_Update(uint8_t key);
extern uint8_t JetiBox_Update(uint8_t key);
 
#endif //_JETIMENU_H
/beta/Code Redesign killagreg/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/libfc644.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/makefile
1,7 → 1,7
#--------------------------------------------------------------------
# MCU name
#MCU = atmega644p
MCU = atmega1284p
MCU = atmega644p
#MCU = atmega1284p
F_CPU = 20000000
#-------------------------------------------------------------------
VERSION_MAJOR = 0
/beta/Code Redesign killagreg/version.txt
375,10 → 375,15
- Anzeige des "SPI RX communication error" wenn GPS Option nicht aktiv
- LED-Schwellwerte fürs Blinken waren unterschiedlich
 
0.78e H.Buss + I.Busker 23.3.2010
- Unterstützung für Jeti-Expander
- Begrenzung des Vario-Höhenreglers auf ein 10m-Fenster
 
Anpassungen bzgl. V0.78c
G.Stobrawa 22.2.2010:
 
Anpassungen bzgl. V0.78e
G.Stobrawa 23.3.2010
 
- Code stärker modularisiert und restrukturiert
- viele Kommentare zur Erklärug eingefügt
- konsequent englische Variablennamen