Rev 1316 | Rev 1322 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1316 | Rev 1320 | ||
---|---|---|---|
Line 52... | Line 52... | ||
52 | // + POSSIBILITY OF SUCH DAMAGE. |
52 | // + POSSIBILITY OF SUCH DAMAGE. |
53 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
53 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 54... | Line 54... | ||
54 | 54 | ||
55 | #include "main.h" |
55 | #include "main.h" |
- | 56 | #include "eeprom.c" |
|
Line 56... | Line 57... | ||
56 | #include "eeprom.c" |
57 | #include "mymath.h" |
57 | 58 | ||
58 | unsigned char h,m,s; |
59 | unsigned char h,m,s; |
59 | volatile unsigned int I2CTimeout = 100; |
60 | volatile unsigned int I2CTimeout = 100; |
Line 181... | Line 182... | ||
181 | void SetNeutral(void) |
182 | void SetNeutral(void) |
182 | //############################################################################ |
183 | //############################################################################ |
183 | { |
184 | { |
184 | unsigned char i; |
185 | unsigned char i; |
185 | unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0; |
186 | unsigned int gier_neutral=0, nick_neutral=0, roll_neutral=0; |
186 | ServoActive = 0; HEF4017R_ON; |
187 | HEF4017R_ON; |
187 | NeutralAccX = 0; |
188 | NeutralAccX = 0; |
188 | NeutralAccY = 0; |
189 | NeutralAccY = 0; |
189 | NeutralAccZ = 0; |
190 | NeutralAccZ = 0; |
190 | AdNeutralNick = 0; |
191 | AdNeutralNick = 0; |
191 | AdNeutralRoll = 0; |
192 | AdNeutralRoll = 0; |
Line 258... | Line 259... | ||
258 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
259 | FromNaviCtrl_Value.Kalman_MaxFusion = 32; |
259 | Poti1 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110; |
260 | Poti1 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110; |
260 | Poti2 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110; |
261 | Poti2 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110; |
261 | Poti3 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110; |
262 | Poti3 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110; |
262 | Poti4 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110; |
263 | Poti4 = PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110; |
263 | // ServoActive = 1; |
- | |
264 | SenderOkay = 100; |
264 | SenderOkay = 100; |
- | 265 | if(ServoActive) |
|
- | 266 | { |
|
- | 267 | HEF4017R_ON; |
|
- | 268 | DDRD |=0x80; // enable J7 -> Servo signal |
|
- | 269 | } |
|
265 | } |
270 | } |
Line 266... | Line 271... | ||
266 | 271 | ||
267 | //############################################################################ |
272 | //############################################################################ |
268 | // Bearbeitet die Messwerte |
273 | // Bearbeitet die Messwerte |
Line 643... | Line 648... | ||
643 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
648 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
644 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
649 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung aktiviert? |
645 | { |
650 | { |
646 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
651 | if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset(); |
647 | } |
652 | } |
- | 653 | ServoActive = 0; |
|
648 | SetNeutral(); |
654 | SetNeutral(); |
649 | ServoActive = 1; |
655 | ServoActive = 1; |
650 | DDRD |=0x80; // enable J7 -> Servo signal |
656 | DDRD |=0x80; // enable J7 -> Servo signal |
651 | Piep(GetActiveParamSetNumber(),120); |
657 | Piep(GetActiveParamSetNumber(),120); |
652 | } |
658 | } |
Line 1249... | Line 1255... | ||
1249 | if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR; |
1255 | if(MesswertRoll < -MAX_SENSOR) MesswertRoll = -MAX_SENSOR; |
1250 | if(MesswertGier > MAX_SENSOR) MesswertGier = MAX_SENSOR; |
1256 | if(MesswertGier > MAX_SENSOR) MesswertGier = MAX_SENSOR; |
1251 | if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
1257 | if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
Line 1252... | Line 1258... | ||
1252 | 1258 | ||
1253 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1254 | // all BL-Ctrl connected? |
- | |
1255 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1256 | if(MissingMotor) if(modell_fliegt > 1 && modell_fliegt < 50 && GasMischanteil > 0) |
- | |
1257 | { |
- | |
1258 | modell_fliegt = 1; |
- | |
1259 | GasMischanteil = MIN_GAS; |
- | |
1260 | } |
- | |
1261 | - | ||
1262 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1259 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1263 | // Höhenregelung |
1260 | // Höhenregelung |
1264 | // Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht |
1261 | // Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht |
1265 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1262 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1266 | if(UBat > BattLowVoltageWarning) GasMischanteil = (GasMischanteil * BattLowVoltageWarning) / UBat; // Gas auf das aktuelle Spannungvieveau beziehen |
1263 | if(UBat > BattLowVoltageWarning) GasMischanteil = (GasMischanteil * BattLowVoltageWarning) / UBat; // Gas auf das aktuelle Spannungvieveau beziehen |
Line 1267... | Line -... | ||
1267 | GasMischanteil *= STICK_GAIN; |
- | |
1268 | 1264 | GasMischanteil *= STICK_GAIN; |
|
1269 | 1265 | ||
1270 | // if height control is activated |
1266 | // if height control is activated |
1271 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung |
1267 | if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)) // Höhenregelung |
1272 | { |
1268 | { |
1273 | #define HOOVER_GAS_AVERAGE 4096L // 4096 * 2ms = 8.2s averaging |
1269 | #define HOOVER_GAS_AVERAGE 4096L // 4096 * 2ms = 8.2s averaging |
1274 | #define HC_GAS_AVERAGE 4 // 4 * 2ms= 8 ms averaging |
1270 | #define HC_GAS_AVERAGE 4 // 4 * 2ms= 8 ms averaging |
1275 | #define OPA_OFFSET_STEP 10 |
1271 | #define OPA_OFFSET_STEP 10 |
1276 | int HCGas, HeightDeviation; |
1272 | int HCGas, HeightDeviation; |
1277 | static int HeightTrimming = 0; // rate for change of height setpoint |
1273 | static int HeightTrimming = 0; // rate for change of height setpoint |
1278 | static int FilterHCGas = 0; |
1274 | static int FilterHCGas = 0; |
1279 | static int HooverGas = 0, HooverGasMin = 0, HooverGasMax = 1023; |
1275 | static int StickGasHoover = 110, HooverGas = 0, HooverGasMin = 0, HooverGasMax = 1023; |
- | 1276 | static unsigned long HooverGasFilter = 0; |
|
1280 | static unsigned long HooverGasFilter = 0; |
1277 | static unsigned char delay = 100; |
1281 | static unsigned char delay = 100; |
1278 | int CosAttitude; // for projection of hoover gas |
1282 | long tmp_long3; |
1279 | long tmp_long3; |
1283 | 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}; |
1280 | // 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}; |
1284 | // get the current hooverpoint |
1281 | // get the current hooverpoint |
Line 1285... | Line 1282... | ||
1285 | DebugOut.Analog[25] = HooverGas; |
1282 | DebugOut.Analog[25] = HooverGas; |
Line 1325... | Line 1322... | ||
1325 | else // no switchable height control |
1322 | else // no switchable height control |
1326 | { |
1323 | { |
1327 | SollHoehe = ((int16_t) ExternHoehenValue + (int16_t) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung; |
1324 | SollHoehe = ((int16_t) ExternHoehenValue + (int16_t) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung; |
1328 | HoehenReglerAktiv = 1; |
1325 | HoehenReglerAktiv = 1; |
1329 | } |
1326 | } |
- | 1327 | // calculate cos of nick and roll angle used for projection of the vertical hoover gas |
|
- | 1328 | tmp_long = IntegralNick/GIER_GRAD_FAKTOR; // nick angle in deg |
|
- | 1329 | tmp_long *= tmp_long; |
|
- | 1330 | tmp_long2 = IntegralRoll/GIER_GRAD_FAKTOR; // roll angle in deg |
|
- | 1331 | tmp_long2 *= tmp_long2; |
|
1330 | 1332 | ||
- | 1333 | CosAttitude = (int16_t)c_sqrt(tmp_long + tmp_long2); // phytagoras gives effective attitude angle in deg |
|
- | 1334 | LIMIT_MAX(CosAttitude, 60); // limit effective attitude angle |
|
- | 1335 | CosAttitude = c_cos_8192(CosAttitude); // cos of actual attitude |
|
- | 1336 | ||
1331 | if(HoehenReglerAktiv && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1337 | if(HoehenReglerAktiv && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1332 | { |
1338 | { |
1333 | #define HEIGHT_TRIM_UP 0x01 |
1339 | #define HEIGHT_TRIM_UP 0x01 |
1334 | #define HEIGHT_TRIM_DOWN 0x02 |
1340 | #define HEIGHT_TRIM_DOWN 0x02 |
1335 | static unsigned char HeightTrimmingFlag = 0x00; |
1341 | static unsigned char HeightTrimmingFlag = 0x00; |
Line 1336... | Line 1342... | ||
1336 | 1342 | ||
1337 | #define HEIGHT_CONTROL_STICKTHRESHOLD 15 * STICK_GAIN |
1343 | #define HEIGHT_CONTROL_STICKTHRESHOLD 15 |
1338 | // Holger original version |
1344 | // Holger original version |
1339 | // start of height control algorithm |
1345 | // start of height control algorithm |
1340 | // the height control is only an attenuation of the actual gas stick. |
1346 | // the height control is only an attenuation of the actual gas stick. |
1341 | // I.e. it will work only if the gas stick is higher than the hover gas |
1347 | // I.e. it will work only if the gas stick is higher than the hover gas |
Line 1351... | Line 1357... | ||
1351 | // PD-Control with respect to hoover point |
1357 | // PD-Control with respect to hoover point |
1352 | // the thrust loss out of horizontal attitude is compensated |
1358 | // the thrust loss out of horizontal attitude is compensated |
1353 | // the setpoint will be fine adjusted with the gas stick position |
1359 | // the setpoint will be fine adjusted with the gas stick position |
1354 | if(MikroKopterFlags & FLAG_FLY) // trim setpoint only when flying |
1360 | if(MikroKopterFlags & FLAG_FLY) // trim setpoint only when flying |
1355 | { // gas stick is above hoover point |
1361 | { // gas stick is above hoover point |
1356 | if(GasMischanteil > (HooverGas + HEIGHT_CONTROL_STICKTHRESHOLD) ) |
1362 | if(StickGas > (StickGasHoover + HEIGHT_CONTROL_STICKTHRESHOLD) ) |
1357 | { |
1363 | { |
1358 | if(HeightTrimmingFlag & HEIGHT_TRIM_DOWN) |
1364 | if(HeightTrimmingFlag & HEIGHT_TRIM_DOWN) |
1359 | { |
1365 | { |
1360 | HeightTrimmingFlag &= ~HEIGHT_TRIM_DOWN; |
1366 | HeightTrimmingFlag &= ~HEIGHT_TRIM_DOWN; |
1361 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1367 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1362 | } |
1368 | } |
1363 | HeightTrimmingFlag |= HEIGHT_TRIM_UP; |
1369 | HeightTrimmingFlag |= HEIGHT_TRIM_UP; |
1364 | HeightTrimming += abs(GasMischanteil - (HooverGas + HEIGHT_CONTROL_STICKTHRESHOLD)) / 4; |
1370 | HeightTrimming += abs(StickGas - (StickGasHoover + HEIGHT_CONTROL_STICKTHRESHOLD)); |
1365 | } // gas stick is below hoover point |
1371 | } // gas stick is below hoover point |
1366 | else if(GasMischanteil < (HooverGas - HEIGHT_CONTROL_STICKTHRESHOLD) ) |
1372 | else if(StickGas < (StickGasHoover - HEIGHT_CONTROL_STICKTHRESHOLD) ) |
1367 | { |
1373 | { |
1368 | if(HeightTrimmingFlag & HEIGHT_TRIM_UP) |
1374 | if(HeightTrimmingFlag & HEIGHT_TRIM_UP) |
1369 | { |
1375 | { |
1370 | HeightTrimmingFlag &= ~HEIGHT_TRIM_UP; |
1376 | HeightTrimmingFlag &= ~HEIGHT_TRIM_UP; |
1371 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1377 | SollHoehe = HoehenWert; // update setpoint to current heigth |
1372 | } |
1378 | } |
1373 | HeightTrimmingFlag |= HEIGHT_TRIM_DOWN; |
1379 | HeightTrimmingFlag |= HEIGHT_TRIM_DOWN; |
1374 | HeightTrimming -= abs(GasMischanteil - (HooverGas - HEIGHT_CONTROL_STICKTHRESHOLD)) / 4; |
1380 | HeightTrimming -= abs(StickGas - (StickGasHoover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
1375 | } |
1381 | } |
1376 | else // Gas Stick in Hoover Range |
1382 | else // Gas Stick in Hoover Range |
1377 | { |
1383 | { |
1378 | if(HeightTrimmingFlag & (HEIGHT_TRIM_UP|HEIGHT_TRIM_DOWN)) |
1384 | if(HeightTrimmingFlag & (HEIGHT_TRIM_UP|HEIGHT_TRIM_DOWN)) |
1379 | { |
1385 | { |
Line 1387... | Line 1393... | ||
1387 | if(abs(HeightTrimming) > 512) |
1393 | if(abs(HeightTrimming) > 512) |
1388 | { |
1394 | { |
1389 | SollHoehe += (HeightTrimming * EE_Parameter.Hoehe_Verstaerkung)/(5 * 512 / 2); // move setpoint |
1395 | SollHoehe += (HeightTrimming * EE_Parameter.Hoehe_Verstaerkung)/(5 * 512 / 2); // move setpoint |
1390 | HeightTrimming = 0; |
1396 | HeightTrimming = 0; |
1391 | if(EE_Parameter.ExtraConfig & CFG2_VARIO_BEEP) beeptime = 75; |
1397 | if(EE_Parameter.ExtraConfig & CFG2_VARIO_BEEP) beeptime = 75; |
- | 1398 | //update hoover gas stick value when setpoint is shifted |
|
- | 1399 | StickGasHoover = HooverGas/STICK_GAIN; // rescale back to stick value |
|
- | 1400 | StickGasHoover = (StickGasHoover * UBat) / BattLowVoltageWarning; |
|
- | 1401 | if(StickGasHoover < 70) StickGasHoover = 70; else |
|
- | 1402 | if(StickGasHoover > 150) StickGasHoover = 150; |
|
1392 | } |
1403 | } |
1393 | } //if MikroKopterFlags & MKFLAG_FLY |
1404 | } //if MikroKopterFlags & MKFLAG_FLY |
- | 1405 | else |
|
- | 1406 | { |
|
1394 | else SollHoehe = HoehenWert - 200; |
1407 | SollHoehe = HoehenWert - 200; |
- | 1408 | StickGasHoover = 110; |
|
- | 1409 | } |
|
1395 | HCGas = HooverGas; // take hoover gas (neutral point) |
1410 | HCGas = HooverGas; // take hoover gas (neutral point) |
1396 | } |
1411 | } |
Line 1397... | Line 1412... | ||
1397 | 1412 | ||
1398 | if(HoehenWert > SollHoehe || !(EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT)) |
1413 | if(HoehenWert > SollHoehe || !(EE_Parameter.ExtraConfig & CFG2_HEIGHT_LIMIT)) |
Line 1425... | Line 1440... | ||
1425 | tmp_int = (Parameter_Hoehe_GPS_Z * (long)FromNaviCtrl_Value.GpsZ)/128L; |
1440 | tmp_int = (Parameter_Hoehe_GPS_Z * (long)FromNaviCtrl_Value.GpsZ)/128L; |
1426 | DebugOut.Analog[24] = -tmp_int; |
1441 | DebugOut.Analog[24] = -tmp_int; |
1427 | HCGas -= tmp_int; |
1442 | HCGas -= tmp_int; |
1428 | // strech control output by inverse attitude projection |
1443 | // strech control output by inverse attitude projection |
1429 | // + 1/cos(angle) ++++++++++++++++++++++++++ |
1444 | // + 1/cos(angle) ++++++++++++++++++++++++++ |
- | 1445 | // strech control output by inverse attitude projection 1/cos |
|
- | 1446 | tmp_long3 = (int32_t)HCGas; |
|
- | 1447 | tmp_long3 *= 8192L; |
|
- | 1448 | tmp_long3 /= CosAttitude; |
|
- | 1449 | HCGas = (int16_t)tmp_long3; |
|
- | 1450 | /* |
|
1430 | tmp_long3 = labs(IntegralNick) + labs(IntegralRoll); |
1451 | tmp_long3 = labs(IntegralNick) + labs(IntegralRoll); |
1431 | tmp_long3 /= 1500;//1024 * 2; |
1452 | tmp_long3 /= 1500;//1024 * 2; |
1432 | if(tmp_long3 > 29) tmp_long3 = 29; |
1453 | if(tmp_long3 > 29) tmp_long3 = 29; |
1433 | HCGas = ((long) HCGas * GAS_TAB[tmp_long3]) / 128L; |
1454 | HCGas = ((long) HCGas * GAS_TAB[tmp_long3]) / 128L; |
1434 | 1455 | */ |
|
1435 | // update height control gas averaging |
1456 | // update height control gas averaging |
1436 | FilterHCGas = (FilterHCGas * (HC_GAS_AVERAGE - 1) + HCGas) / HC_GAS_AVERAGE; |
1457 | FilterHCGas = (FilterHCGas * (HC_GAS_AVERAGE - 1) + HCGas) / HC_GAS_AVERAGE; |
1437 | // limit height control gas pd-control output |
1458 | // limit height control gas pd-control output |
1438 | LIMIT_MIN_MAX(FilterHCGas, EE_Parameter.Hoehe_MinGas * STICK_GAIN, (MAX_GAS - 20) * STICK_GAIN); |
1459 | LIMIT_MIN_MAX(FilterHCGas, EE_Parameter.Hoehe_MinGas * STICK_GAIN, (MAX_GAS - 20) * STICK_GAIN); |
1439 | // set GasMischanteil to HeightControlGasFilter |
1460 | // set GasMischanteil to HeightControlGasFilter |
Line 1442... | Line 1463... | ||
1442 | if(FilterHCGas > GasMischanteil) FilterHCGas = GasMischanteil; // nicht mehr als Gas |
1463 | if(FilterHCGas > GasMischanteil) FilterHCGas = GasMischanteil; // nicht mehr als Gas |
1443 | } |
1464 | } |
1444 | GasMischanteil = FilterHCGas; |
1465 | GasMischanteil = FilterHCGas; |
1445 | } |
1466 | } |
1446 | }// EOF height control active |
1467 | }// EOF height control active |
- | 1468 | else // HC not active |
|
- | 1469 | { |
|
- | 1470 | //update hoover gas stick value when HC is not active |
|
- | 1471 | StickGasHoover = HooverGas/STICK_GAIN; // rescale back to stick value |
|
- | 1472 | StickGasHoover = (StickGasHoover * UBat) / BattLowVoltageWarning; |
|
- | 1473 | } |
|
Line 1447... | Line 1474... | ||
1447 | 1474 | ||
1448 | // Hoover gas estimation by averaging gas control output on small z-velocities |
1475 | // Hoover gas estimation by averaging gas control output on small z-velocities |
1449 | // this is done only if height contol option is selected in global config and aircraft is flying |
1476 | // this is done only if height contol option is selected in global config and aircraft is flying |
1450 | if((MikroKopterFlags & FLAG_FLY) && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1477 | if((MikroKopterFlags & FLAG_FLY) && !(MikroKopterFlags & FLAG_NOTLANDUNG)) |
1451 | { |
1478 | { |
1452 | if(HooverGasFilter == 0) HooverGasFilter = HOOVER_GAS_AVERAGE * (unsigned long)(GasMischanteil); // init estimation |
1479 | if(HooverGasFilter == 0) HooverGasFilter = HOOVER_GAS_AVERAGE * (unsigned long)(GasMischanteil); // init estimation |
1453 | if(abs(VarioMeter) < 100) // only on small vertical speed |
1480 | if(abs(VarioMeter) < 100) // only on small vertical speed |
1454 | { |
1481 | { |
1455 | tmp_long3 = (long)GasMischanteil; // take current thrust |
1482 | /* tmp_long3 = (long)GasMischanteil; // take current thrust |
1456 | tmp_long3 = labs(IntegralNick) + labs(IntegralRoll); |
1483 | tmp_long3 = labs(IntegralNick) + labs(IntegralRoll); |
1457 | tmp_long3 /= 1500;//1024 * 2; |
1484 | tmp_long3 /= 1500;//1024 * 2; |
1458 | if(tmp_long3 > 29) tmp_long3 = 29; |
1485 | if(tmp_long3 > 29) tmp_long3 = 29; |
- | 1486 | tmp_long3 = ((long) GasMischanteil * 128L) / (long) GAS_TAB[tmp_long3]; |
|
- | 1487 | */ |
|
- | 1488 | tmp_long3 = (int32_t)GasMischanteil; // take current thrust |
|
- | 1489 | tmp_long3 *= CosAttitude; // apply attitude projection |
|
1459 | tmp_long3 = ((long) GasMischanteil * 128L) / (long) GAS_TAB[tmp_long3]; |
1490 | tmp_long3 /= 8192; |
1460 | 1491 | ||
1461 | // average vertical projected thrust |
1492 | // average vertical projected thrust |
1462 | if(modell_fliegt < 2000) // the first 4 seconds |
1493 | if(modell_fliegt < 2000) // the first 4 seconds |
1463 | { // reduce the time constant of averaging by factor of 8 to get much faster a stable value |
1494 | { // reduce the time constant of averaging by factor of 8 to get much faster a stable value |
1464 | HooverGasFilter -= HooverGasFilter/(HOOVER_GAS_AVERAGE/8L); |
1495 | HooverGasFilter -= HooverGasFilter/(HOOVER_GAS_AVERAGE/8L); |
Line 1499... | Line 1530... | ||
1499 | DebugOut.Analog[28] = HooverGasMin; |
1530 | DebugOut.Analog[28] = HooverGasMin; |
Line 1500... | Line 1531... | ||
1500 | 1531 | ||
Line 1501... | Line 1532... | ||
1501 | }// EOF ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL |
1532 | }// EOF ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL |
1502 | 1533 | ||
1503 | // limit gas to parameter setting |
- | |
1504 | LIMIT_MIN(GasMischanteil, (MIN_GAS + 10) * STICK_GAIN); |
1534 | // limit gas to parameter setting |
Line 1505... | Line 1535... | ||
1505 | 1535 | LIMIT_MIN(GasMischanteil, (MIN_GAS + 10) * STICK_GAIN); |
|
- | 1536 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
|
- | 1537 | ||
- | 1538 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1539 | // all BL-Ctrl connected? |
|
- | 1540 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 1541 | if(MissingMotor) |
|
- | 1542 | if(modell_fliegt > 1 && modell_fliegt < 50 && GasMischanteil > 0) |
|
- | 1543 | { |
|
- | 1544 | modell_fliegt = 1; |
|
1506 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
1545 | GasMischanteil = MIN_GAS; |
1507 | 1546 | } |
|
1508 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1547 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1509 | // + Mischer und PI-Regler |
1548 | // + Mischer und PI-Regler |
1510 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1549 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |