56,6 → 56,7 |
#include "main.h" |
#include "eeprom.c" |
#include "mymath.h" |
#include "isqrt.h" |
|
unsigned char h,m,s,BaroExpandActive = 0; |
volatile unsigned int I2CTimeout = 100; |
542,7 → 543,7 |
void MotorRegler(void) |
//############################################################################ |
{ |
int pd_ergebnis_nick,pd_ergebnis_roll,tmp_int; |
int pd_ergebnis_nick,pd_ergebnis_roll,tmp_int, tmp_int2; |
int GierMischanteil,GasMischanteil; |
static long SummeNick=0,SummeRoll=0; |
static long sollGier = 0,tmp_long,tmp_long2; |
766,8 → 767,8 |
if(StickGas < 0) StickGas = 0; |
|
if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor = 0; |
if(GyroFaktor < 0) GyroFaktor = 0; |
if(IntegralFaktor < 0) IntegralFaktor = 0; |
//if(GyroFaktor < 0) GyroFaktor = 0; |
//if(IntegralFaktor < 0) IntegralFaktor = 0; |
|
if(abs(StickNick/STICK_GAIN) > MaxStickNick) |
{ |
1234,8 → 1235,7 |
static unsigned long HooverGasFilter = 0; |
static unsigned char delay = 100, BaroAtUpperLimit = 0, BaroAtLowerLimit = 0; |
int CosAttitude; // for projection of hoover gas |
long tmp_long3; |
// const unsigned char GAS_TAB[31] = {128,128,128,129,129,130,131,132,133,135,136,138,140,142,145,148,151,154,158,162,167,172,178,184,191,199,208,218,229,241,255}; |
|
// get the current hooverpoint |
if(LoadHandler == 1) |
{ |
1316,11 → 1316,9 |
|
// calculate cos of nick and roll angle used for projection of the vertical hoover gas |
J4Low; |
tmp_long = IntegralNick/GIER_GRAD_FAKTOR; // nick angle in deg |
tmp_long *= tmp_long; |
tmp_long2 = IntegralRoll/GIER_GRAD_FAKTOR; // roll angle in deg |
tmp_long2 *= tmp_long2; |
CosAttitude = (int16_t)c_sqrt(tmp_long + tmp_long2); // phytagoras gives effective attitude angle in deg |
tmp_int = (int)(IntegralNick/GIER_GRAD_FAKTOR); // nick angle in deg |
tmp_int2 = (int)(IntegralRoll/GIER_GRAD_FAKTOR); // roll angle in deg |
CosAttitude = (int16_t)ihypot(tmp_int, tmp_int2); // phytagoras gives effective attitude angle in deg |
DebugOut.Analog[16] = CosAttitude; |
LIMIT_MAX(CosAttitude, 60); // limit effective attitude angle |
CosAttitude = c_cos_8192(CosAttitude); // cos of actual attitude |
1435,10 → 1433,10 |
|
// strech control output by inverse attitude projection 1/cos |
// + 1/cos(angle) ++++++++++++++++++++++++++ |
tmp_long3 = (int32_t)HCGas; |
tmp_long3 *= 8192L; |
tmp_long3 /= CosAttitude; |
HCGas = (int16_t)tmp_long3; |
tmp_long2 = (int32_t)HCGas; |
tmp_long2 *= 8192L; |
tmp_long2 /= CosAttitude; |
HCGas = (int16_t)tmp_long2; |
// update height control gas averaging |
FilterHCGas = (FilterHCGas * (HC_GAS_AVERAGE - 1) + HCGas) / HC_GAS_AVERAGE; |
// limit height control gas pd-control output |
1472,30 → 1470,30 |
if(HooverGasFilter == 0) HooverGasFilter = HOOVER_GAS_AVERAGE * (unsigned long)(GasMischanteil); // init estimation |
if(abs(VarioMeter) < 100) // only on small vertical speed |
{ |
tmp_long3 = (int32_t)GasMischanteil; // take current thrust |
tmp_long3 *= CosAttitude; // apply attitude projection |
tmp_long3 /= 8192; |
tmp_long2 = (int32_t)GasMischanteil; // take current thrust |
tmp_long2 *= CosAttitude; // apply attitude projection |
tmp_long2 /= 8192; |
|
// average vertical projected thrust |
if(modell_fliegt < 2000) // the first 4 seconds |
{ // reduce the time constant of averaging by factor of 8 to get much faster a stable value |
HooverGasFilter -= HooverGasFilter/(HOOVER_GAS_AVERAGE/8L); |
HooverGasFilter += 8L * tmp_long3; |
HooverGasFilter += 8L * tmp_long2; |
} |
else if(modell_fliegt < 4000) // the first 8 seconds |
{ // reduce the time constant of averaging by factor of 4 to get much faster a stable value |
HooverGasFilter -= HooverGasFilter/(HOOVER_GAS_AVERAGE/4L); |
HooverGasFilter += 4L * tmp_long3; |
HooverGasFilter += 4L * tmp_long2; |
} |
else if(modell_fliegt < 8000) // the first 16 seconds |
{ // reduce the time constant of averaging by factor of 2 to get much faster a stable value |
HooverGasFilter -= HooverGasFilter/(HOOVER_GAS_AVERAGE/2L); |
HooverGasFilter += 2L * tmp_long3; |
HooverGasFilter += 2L * tmp_long2; |
} |
else //later |
{ |
HooverGasFilter -= HooverGasFilter/HOOVER_GAS_AVERAGE; |
HooverGasFilter += tmp_long3; |
HooverGasFilter += tmp_long2; |
} |
HooverGas = (int16_t)(HooverGasFilter/HOOVER_GAS_AVERAGE); |
if(EE_Parameter.Hoehe_HoverBand) |