Rev 1698 | Rev 1702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1698 | Rev 1701 | ||
---|---|---|---|
Line 181... | Line 181... | ||
181 | DebugOut.Analog[10] = SenderOkay; |
181 | DebugOut.Analog[10] = SenderOkay; |
182 | DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR; |
182 | DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR; |
183 | DebugOut.Analog[20] = ServoNickValue; |
183 | DebugOut.Analog[20] = ServoNickValue; |
184 | DebugOut.Analog[22] = Capacity.ActualCurrent; |
184 | DebugOut.Analog[22] = Capacity.ActualCurrent; |
185 | DebugOut.Analog[23] = Capacity.UsedCapacity; |
185 | DebugOut.Analog[23] = Capacity.UsedCapacity; |
186 | - | ||
187 | DebugOut.Analog[24] = AdWertAccHoch; |
- | |
188 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
186 | // DebugOut.Analog[22] = FromNaviCtrl_Value.GpsZ; |
189 | // DebugOut.Analog[24] = MesswertNick/2; |
- | |
190 | // DebugOut.Analog[25] = MesswertRoll/2; |
- | |
191 | // DebugOut.Analog[27] = (int)FromNaviCtrl_Value.Kalman_MaxDrift; |
- | |
192 | // DebugOut.Analog[28] = (int)FromNaviCtrl_Value.Kalman_MaxFusion; |
- | |
193 | // DebugOut.Analog[29] = (int)FromNaviCtrl_Value.Kalman_K; |
- | |
194 | //DebugOut.Analog[28] = I2CError; |
- | |
195 | // DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
187 | // DebugOut.Analog[29] = FromNaviCtrl_Value.SerialDataOkay; |
196 | DebugOut.Analog[29] = Capacity.MinOfMaxPWM; |
188 | DebugOut.Analog[29] = Capacity.MinOfMaxPWM; |
197 | DebugOut.Analog[30] = GPS_Nick; |
189 | DebugOut.Analog[30] = GPS_Nick; |
198 | DebugOut.Analog[31] = GPS_Roll; |
190 | DebugOut.Analog[31] = GPS_Roll; |
199 | } |
191 | } |
Line 1023... | Line 1015... | ||
1023 | if(tmp_long < -AUSGLEICH) tmp_long =-AUSGLEICH; |
1015 | if(tmp_long < -AUSGLEICH) tmp_long =-AUSGLEICH; |
1024 | if(tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH; |
1016 | if(tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH; |
1025 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
1017 | if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH; |
1026 | } |
1018 | } |
Line 1027... | Line -... | ||
1027 | - | ||
1028 | //if(Poti2 > 20) { tmp_long = 0; tmp_long2 = 0;} |
1019 | |
1029 | Mess_IntegralNick -= tmp_long; |
1020 | Mess_IntegralNick -= tmp_long; |
1030 | Mess_IntegralRoll -= tmp_long2; |
1021 | Mess_IntegralRoll -= tmp_long2; |
1031 | } |
1022 | } |
1032 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1023 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 1183... | Line 1174... | ||
1183 | } // ZaehlMessungen >= ABGLEICH_ANZAHL |
1174 | } // ZaehlMessungen >= ABGLEICH_ANZAHL |
Line 1184... | Line 1175... | ||
1184 | 1175 | ||
1185 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1176 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1186 | // Gieren |
1177 | // Gieren |
1187 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1188 | // if(GasMischanteil < 35) { if(StickGier > 10) StickGier = 10; else if(StickGier < -10) StickGier = -10;}; |
1178 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1189 | if(abs(StickGier) > 15) // war 35 |
1179 | if(abs(StickGier) > 15) // war 35 |
1190 | { |
1180 | { |
1191 | KompassSignalSchlecht = 1000; |
1181 | KompassSignalSchlecht = 1000; |
1192 | if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) |
1182 | if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) |
Line 1202... | Line 1192... | ||
1202 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
1192 | if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000; |
Line 1203... | Line 1193... | ||
1203 | 1193 | ||
1204 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1194 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1205 | // Kompass |
1195 | // Kompass |
1206 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | |
1207 | //DebugOut.Analog[18] = KompassSignalSchlecht; |
- | |
1208 | 1196 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
1209 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
1197 | if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)) |
1210 | { |
1198 | { |
1211 | int w,v,r,fehler,korrektur; |
1199 | int w,v,r,fehler,korrektur; |
1212 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
1200 | w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln |
Line 1224... | Line 1212... | ||
1224 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
1212 | ErsatzKompass = KompassValue * GIER_GRAD_FAKTOR; |
1225 | KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR); |
1213 | KompassStartwert = (ErsatzKompass/GIER_GRAD_FAKTOR); |
1226 | NeueKompassRichtungMerken = 0; |
1214 | NeueKompassRichtungMerken = 0; |
1227 | } |
1215 | } |
1228 | } |
1216 | } |
1229 | //DebugOut.Analog[16] = fehler; |
- | |
1230 | //DebugOut.Analog[17] = korrektur; |
- | |
1231 | ErsatzKompass += (fehler * 16) / korrektur; |
1217 | ErsatzKompass += (fehler * 16) / korrektur; |
1232 | w = (w * Parameter_KompassWirkung) / 32; // auf die Wirkung normieren |
1218 | w = (w * Parameter_KompassWirkung) / 32; // auf die Wirkung normieren |
1233 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
1219 | w = Parameter_KompassWirkung - w; // Wirkung ggf drosseln |
1234 | if(w >= 0) |
1220 | if(w >= 0) |
1235 | { |
1221 | { |
1236 | if(!KompassSignalSchlecht) |
1222 | if(!KompassSignalSchlecht) |
1237 | { |
1223 | { |
1238 | v = 64 + ((MaxStickNick + MaxStickRoll)) / 8; |
1224 | v = 64 + ((MaxStickNick + MaxStickRoll)) / 8; |
1239 | r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180; |
1225 | r = ((540 + (ErsatzKompass/GIER_GRAD_FAKTOR) - KompassStartwert) % 360) - 180; |
1240 | // r = KompassRichtung; |
- | |
1241 | v = (r * w) / v; // nach Kompass ausrichten |
1226 | v = (r * w) / v; // nach Kompass ausrichten |
1242 | w = 3 * Parameter_KompassWirkung; |
1227 | w = 3 * Parameter_KompassWirkung; |
1243 | if(v > w) v = w; // Begrenzen |
1228 | if(v > w) v = w; // Begrenzen |
1244 | else |
1229 | else |
1245 | if(v < -w) v = -w; |
1230 | if(v < -w) v = -w; |
Line 1486... | Line 1471... | ||
1486 | tmp_long = (HoehenWert - SollHoehe); // positive when too high |
1471 | tmp_long = (HoehenWert - SollHoehe); // positive when too high |
1487 | LIMIT_MIN_MAX(tmp_long, -32767L, 32767L); // avoid overflov when casting to int16_t |
1472 | LIMIT_MIN_MAX(tmp_long, -32767L, 32767L); // avoid overflov when casting to int16_t |
1488 | HeightDeviation = (int)(tmp_long); // positive when too high |
1473 | HeightDeviation = (int)(tmp_long); // positive when too high |
1489 | tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 32L; // p-part |
1474 | tmp_long = (tmp_long * (long)Parameter_Hoehe_P) / 32L; // p-part |
1490 | LIMIT_MIN_MAX(tmp_long, -127 * STICK_GAIN, 256 * STICK_GAIN); // more than the full range makes no sense |
1475 | LIMIT_MIN_MAX(tmp_long, -127 * STICK_GAIN, 256 * STICK_GAIN); // more than the full range makes no sense |
1491 | DebugOut.Analog[25] = tmp_long; |
- | |
1492 | GasReduction = tmp_long; |
1476 | GasReduction = tmp_long; |
1493 | // ------------------------- D-Part 1: Vario Meter ---------------------------- |
1477 | // ------------------------- D-Part 1: Vario Meter ---------------------------- |
1494 | tmp_int = VarioMeter / 8; |
1478 | tmp_int = VarioMeter / 8; |
1495 | LIMIT_MIN_MAX(tmp_int, -127, 128); |
1479 | LIMIT_MIN_MAX(tmp_int, -127, 128); |
1496 | DebugOut.Analog[18] = tmp_int; |
- | |
1497 | // tmp_int2 = tmp_int/4; |
- | |
1498 | // LIMIT_MAX(tmp_int2, 64); |
- | |
1499 | // if(tmp_int > 0) tmp_int = tmp_int + (tmp_int2 * tmp_int2); |
- | |
1500 | // else tmp_int = tmp_int - (tmp_int2 * tmp_int2); |
- | |
1501 | - | ||
1502 | if(!HeightTrimmingFlag) |
1480 | if(!HeightTrimmingFlag) |
1503 | { |
1481 | { |
1504 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 4L; // scale to d-gain parameter |
1482 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 4L; // scale to d-gain parameter |
1505 | LIMIT_MIN_MAX(tmp_int,-64 * STICK_GAIN, 64 * STICK_GAIN); |
1483 | LIMIT_MIN_MAX(tmp_int,-64 * STICK_GAIN, 64 * STICK_GAIN); |
1506 | } |
1484 | } |
1507 | 1485 | else |
|
1508 | else { |
1486 | { |
1509 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 16L; // weniger D zum Höhe ändern |
1487 | tmp_int = (tmp_int * (long)Parameter_Luftdruck_D) / 16L; // weniger D zum Höhe ändern |
1510 | LIMIT_MIN_MAX(tmp_int,-16 * STICK_GAIN, 16 * STICK_GAIN); |
1488 | LIMIT_MIN_MAX(tmp_int,-16 * STICK_GAIN, 16 * STICK_GAIN); |
1511 | } |
1489 | } |
1512 | - | ||
1513 | DebugOut.Analog[19] = tmp_int; |
- | |
1514 | GasReduction += tmp_int; |
1490 | GasReduction += tmp_int; |
1515 | } // EOF no baro range expanding |
1491 | } // EOF no baro range expanding |
1516 | // ------------------------ D-Part 2: ACC-Z Integral ------------------------ |
1492 | // ------------------------ D-Part 2: ACC-Z Integral ------------------------ |
1517 | if(Parameter_Hoehe_ACC_Wirkung) |
1493 | if(Parameter_Hoehe_ACC_Wirkung) |
1518 | { |
1494 | { |
Line 1522... | Line 1498... | ||
1522 | } |
1498 | } |
1523 | // ------------------------ D-Part 3: GpsZ ---------------------------------- |
1499 | // ------------------------ D-Part 3: GpsZ ---------------------------------- |
1524 | tmp_int = (Parameter_Hoehe_GPS_Z * (int)FromNaviCtrl_Value.GpsZ)/128L; |
1500 | tmp_int = (Parameter_Hoehe_GPS_Z * (int)FromNaviCtrl_Value.GpsZ)/128L; |
1525 | LIMIT_MIN_MAX(tmp_int, -32 * STICK_GAIN, 64 * STICK_GAIN); |
1501 | LIMIT_MIN_MAX(tmp_int, -32 * STICK_GAIN, 64 * STICK_GAIN); |
1526 | GasReduction += tmp_int; |
1502 | GasReduction += tmp_int; |
- | 1503 | GasReduction = (long)((long)GasReduction * HoverGas) / 512; // scale to the gas value |
|
Line 1527... | Line -... | ||
1527 | - | ||
1528 | //DebugOut.Analog[16] = GasReduction; |
- | |
1529 | GasReduction = (long)((long)GasReduction * HoverGas) / 512; |
1504 | |
1530 | //GasReduction = (long)((long)GasReduction * Poti3) / 64; |
- | |
1531 | DebugOut.Analog[17] = GasReduction; |
- | |
1532 | 1505 | // ------------------------ ---------------------------------- |
|
1533 | HCGas -= GasReduction; |
- | |
1534 | 1506 | HCGas -= GasReduction; |
|
1535 | // limit deviation from hoover point within the target region |
1507 | // limit deviation from hoover point within the target region |
1536 | if(!HeightTrimming && HoverGas > 0) // height setpoint is not changed and hoover gas not zero |
1508 | if(!HeightTrimming && HoverGas > 0) // height setpoint is not changed and hoover gas not zero |
1537 | { |
1509 | { |
1538 | signed int tmp,min,max; |
1510 | signed int tmp,min,max; |
Line 1632... | Line 1604... | ||
1632 | StartTrigger = 0; |
1604 | StartTrigger = 0; |
1633 | HoverGasFilter = 0; |
1605 | HoverGasFilter = 0; |
1634 | HoverGas = 0; |
1606 | HoverGas = 0; |
1635 | } |
1607 | } |
1636 | }// EOF ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL |
1608 | }// EOF ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL |
1637 | DebugOut.Analog[16] = StartTrigger; |
- | |
1638 | // limit gas to parameter setting |
1609 | // limit gas to parameter setting |
1639 | LIMIT_MIN(GasMischanteil, (MIN_GAS + 10) * STICK_GAIN); |
1610 | LIMIT_MIN(GasMischanteil, (MIN_GAS + 10) * STICK_GAIN); |
1640 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
1611 | if(GasMischanteil > (MAX_GAS - 20) * STICK_GAIN) GasMischanteil = (MAX_GAS - 20) * STICK_GAIN; |
Line 1641... | Line 1612... | ||
1641 | 1612 | ||
Line 1719... | Line 1690... | ||
1719 | // Gier |
1690 | // Gier |
1720 | if(Mixer.Motor[i][3] == 64) tmp_int += GierMischanteil; |
1691 | if(Mixer.Motor[i][3] == 64) tmp_int += GierMischanteil; |
1721 | else if(Mixer.Motor[i][3] == -64) tmp_int -= GierMischanteil; |
1692 | else if(Mixer.Motor[i][3] == -64) tmp_int -= GierMischanteil; |
1722 | else tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
1693 | else tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
Line 1723... | Line -... | ||
1723 | - | ||
1724 | //if(Parameter_UserParam4 < 50) |
- | |
1725 | { |
1694 | |
1726 | if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing |
1695 | if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing |
1727 | else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // MotorSmoothing |
- | |
Line 1728... | Line 1696... | ||
1728 | } |
1696 | else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // MotorSmoothing |
1729 | 1697 | ||
1730 | LIMIT_MIN_MAX(tmp_int,MIN_GAS * 4,MAX_GAS * 4); |
1698 | LIMIT_MIN_MAX(tmp_int,MIN_GAS * 4,MAX_GAS * 4); |
1731 | Motor[i].SetPoint = tmp_int / 4; |
1699 | Motor[i].SetPoint = tmp_int / 4; |