Subversion Repositories FlightCtrl

Rev

Rev 515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 515 Rev 525
Line 49... Line 49...
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52
// +  POSSIBILITY OF SUCH DAMAGE. 
52
// +  POSSIBILITY OF SUCH DAMAGE. 
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
54
// Aenderungen von Peter Muehlenbrock ("Salvo") Stand 6.10.2007
-
 
55
/*
-
 
56
Driftkompensation fuer Gyros verbessert
-
 
57
Linearsensor mit fixem Neutralwert
-
 
58
Ersatzkompass abgeleitet aus Magnetkompass und Giergyro fuer nahezu neigungsunabhaengige Kompassfunktion
-
 
59
*/
Line 54... Line 60...
54
 
60
 
55
#include "main.h"
61
#include "main.h"
Line 56... Line 62...
56
#include "eeprom.c"
62
#include "eeprom.c"
Line 77... Line 83...
77
unsigned char MAX_GAS,MIN_GAS;
83
unsigned char MAX_GAS,MIN_GAS;
78
unsigned char Notlandung = 0;
84
unsigned char Notlandung = 0;
79
unsigned char HoehenReglerAktiv = 0;
85
unsigned char HoehenReglerAktiv = 0;
80
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
86
long Umschlag180Nick = 250000L, Umschlag180Roll = 250000L;
Line -... Line 87...
-
 
87
 
-
 
88
 
-
 
89
//Salvo 12.10.2007
-
 
90
uint8_t magkompass_ok=0;
-
 
91
uint8_t gps_cmd = GPS_CMD_STOP;
-
 
92
static int       ubat_cnt =0;
-
 
93
static int gas_actual,gas_mittel; //Parameter fuer Gasreduzierung bei unterspannung
-
 
94
int w,v;
-
 
95
//Salvo End
-
 
96
 
-
 
97
 //Salvo 2.9.2007 Ersatzkompass
-
 
98
volatile long GyroKomp_Int;
-
 
99
volatile int GyroKomp_Value; //  Der ermittelte Kompasswert aus Gyro und Magnetkompass
-
 
100
// Salvo End
81
 
101
 
82
float GyroFaktor;
102
float GyroFaktor;
83
float IntegralFaktor;
103
float IntegralFaktor;
84
volatile int  DiffNick,DiffRoll;
104
volatile int  DiffNick,DiffRoll;
85
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
105
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
Line 184... Line 204...
184
    GPS_Neutral();
204
    GPS_Neutral();
185
    beeptime = 50;  
205
    beeptime = 50;  
186
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
206
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
187
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
207
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
188
    ExternHoehenValue = 0;
208
    ExternHoehenValue = 0;
-
 
209
 
-
 
210
 
-
 
211
//Salvo 13.10.2007 Ersatzkompass und Gas
-
 
212
        GyroKomp_Int =  KompassValue * GYROKOMP_INC_GRAD_DEFAULT; //Neu ab 3.1.2007
-
 
213
        gas_mittel      =       30;
-
 
214
        gas_actual      =       gas_mittel;
-
 
215
// Salvo End
189
}
216
}
Line 190... Line 217...
190
 
217
 
191
//############################################################################
218
//############################################################################
192
// Bearbeitet die Messwerte
219
// Bearbeitet die Messwerte
Line 204... Line 231...
204
        Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdWertAccHoch)) / 2L;
231
        Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdWertAccHoch)) / 2L;
205
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
232
    IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
206
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
233
    IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
207
    IntegralAccZ    += Aktuell_az - NeutralAccZ;
234
    IntegralAccZ    += Aktuell_az - NeutralAccZ;
208
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
235
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
-
 
236
//Salvo 12.11.2007
-
 
237
                        GyroKomp_Int  += MesswertGier;
-
 
238
//Salvo End
209
            Mess_Integral_Gier +=  MesswertGier;
239
            Mess_Integral_Gier +=  MesswertGier;
210
            Mess_Integral_Gier2 += MesswertGier;
240
            Mess_Integral_Gier2 += MesswertGier;
211
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
241
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
212
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
242
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
213
         {
243
         {
Line 415... Line 445...
415
     static char TimerWerteausgabe = 0;
445
     static char TimerWerteausgabe = 0;
416
     static char NeueKompassRichtungMerken = 0;
446
     static char NeueKompassRichtungMerken = 0;
417
     static long ausgleichNick, ausgleichRoll;
447
     static long ausgleichNick, ausgleichRoll;
Line 418... Line 448...
418
     
448
     
-
 
449
        Mittelwert();
-
 
450
//****** GPS Daten holen ***************
-
 
451
        short int n;
-
 
452
        if (gps_alive_cnt > 0) gps_alive_cnt--; //Dekrementieren. Wenn 0 kommen keine ausreichenden GPS Meldungen (Timeout)
-
 
453
        n = Get_Rel_Position();
-
 
454
        if (n == 0)    
-
 
455
        {
-
 
456
                ROT_ON; //led blitzen lassen
-
 
457
        }
-
 
458
//******PROVISORISCH***************
Line 419... Line 459...
419
        Mittelwert();
459
    GRN_ON;
420
 
460
 
421
    GRN_ON;
461
    GRN_ON;
422
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
462
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
423
// Gaswert ermitteln
463
// Gaswert ermitteln
424
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
464
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
465
        GasMischanteil = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
-
 
466
    if(GasMischanteil > MAX_GAS - 20) GasMischanteil = MAX_GAS - 20;
-
 
467
//Salvo 13.10.2007 langsame Gasreduktion bei Unterspannung. Als Ausgangswert wird der bei UBAT=k gemessen Mittelwert genommen
-
 
468
// und dieser dann langsam zwangsweise reduziert
-
 
469
        if (UBat <= EE_Parameter.UnterspannungsWarnung - 2)     //Unterhalb der Piepser Schwelle aktivieren
-
 
470
        {
-
 
471
                if (ubat_cnt > 700)
-
 
472
                {
-
 
473
                        ubat_cnt = 0;
-
 
474
                        if (gas_actual > ((gas_mittel*12)/15)) gas_actual--;
-
 
475
                }
-
 
476
                else ubat_cnt++;
-
 
477
                if (GasMischanteil > gas_actual) GasMischanteil = gas_actual;
-
 
478
        }
-
 
479
        else   //Falls UBAT wieder ok ist
-
 
480
        {
-
 
481
                if (ubat_cnt > 1000)
-
 
482
                {
-
 
483
                        gas_mittel = ((gas_mittel*9) + GasMischanteil)/10; //Filtern
-
 
484
                        gas_actual = GasMischanteil;
-
 
485
                }
-
 
486
                else
-
 
487
                {
-
 
488
                        ubat_cnt++;
-
 
489
                        if ((ubat_cnt % 10) == 0)
-
 
490
                        {
-
 
491
                                if (gas_actual < GasMischanteil) gas_actual++;
-
 
492
                                else gas_actual = GasMischanteil;
-
 
493
                }
-
 
494
                }
-
 
495
                GasMischanteil = gas_actual;
425
        GasMischanteil = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
496
        }      
-
 
497
// Salvo End
-
 
498
    if(GasMischanteil < 0) GasMischanteil = 0;
426
    if(GasMischanteil > MAX_GAS - 20) GasMischanteil = MAX_GAS - 20;
499
 
427
    if(GasMischanteil < 0) GasMischanteil = 0;
500
 
428
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
501
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
429
// Emfang schlecht
502
// Empfang schlecht
430
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
503
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
431
   if(SenderOkay < 100)
504
   if(SenderOkay < 100)
432
        {
505
        {
Line 482... Line 555...
482
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
555
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
483
                    {
556
                    {
484
                    if(++delay_neutral > 200)  // nicht sofort
557
                    if(++delay_neutral > 200)  // nicht sofort
485
                        {
558
                        {
486
                        GRN_OFF;
559
                        GRN_OFF;
-
 
560
                        SetNeutral();
487
                        MotorenEin = 0;
561
                        MotorenEin = 0;
488
                        delay_neutral = 0;
562
                        delay_neutral = 0;
489
                        modell_fliegt = 0;
563
                        modell_fliegt = 0;
490
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
564
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
491
                        {
565
                        {
Line 495... Line 569...
495
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
569
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
496
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
570
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
497
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
571
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
498
                         eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], setting);  // aktiven Datensatz merken
572
                         eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], setting);  // aktiven Datensatz merken
499
                        }
573
                        }
500
                        if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
-
 
501
                          {
-
 
502
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
-
 
503
                          }  
-
 
-
 
574
 
-
 
575
 
504
                            ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
576
                            ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
505
                        SetNeutral();
-
 
-
 
577
 
506
                        Piep(GetActiveParamSetNumber());
578
                        Piep(GetActiveParamSetNumber());
-
 
579
                        if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
-
 
580
                        {
-
 
581
                          if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
507
                        }
582
                        }  
-
 
583
                                                GPS_Save_Home(); //Daten sind jetzt hoffentlich verfuegbar
-
 
584
                                                if (gps_home_position.status > 0 )
-
 
585
                                                {
-
 
586
                                                        Delay_ms(1000);  //akustisch verkuenden dass GPS Home Daten da sind
-
 
587
                                                        beeptime = 2000;
-
 
588
                                                        Delay_ms(500);
-
 
589
                                                }
-
 
590
                       }
508
                    }
591
                    }
509
                 else
592
                 else
510
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
593
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
511
                    {
594
                    {
512
                    if(++delay_neutral > 200)  // nicht sofort
595
                    if(++delay_neutral > 200)  // nicht sofort
Line 524... Line 607...
524
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
607
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
525
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
608
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
526
                        Piep(GetActiveParamSetNumber());
609
                        Piep(GetActiveParamSetNumber());
527
                        }
610
                        }
528
                    }
611
                    }
-
 
612
 
529
                 else delay_neutral = 0;
613
                 else delay_neutral = 0;
530
                }
614
                }
531
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
615
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
532
// Gas ist unten
616
// Gas ist unten
533
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
617
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
Line 782... Line 866...
782
    Mess_IntegralRoll2 -= IntegralFehlerRoll;
866
    Mess_IntegralRoll2 -= IntegralFehlerRoll;
Line 783... Line 867...
783
 
867
 
784
//    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
868
//    IntegralFehlerNick = (IntegralFehlerNick * 1 + tmp_long) / 2;
Line -... Line 869...
-
 
869
//    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
-
 
870
 
-
 
871
//Salvo Ersatzkompass Ueberlauf korrigieren
-
 
872
                if (GyroKomp_Int >= ((long)360 * GYROKOMP_INC_GRAD_DEFAULT)) GyroKomp_Int = GyroKomp_Int - (GYROKOMP_INC_GRAD_DEFAULT *(long)360); //neu ab 3.11.2007
-
 
873
                if (GyroKomp_Int < 0) GyroKomp_Int = GyroKomp_Int + (GYROKOMP_INC_GRAD_DEFAULT *(long)360); //neu ab 3.11.2007
Line 785... Line 874...
785
//    IntegralFehlerRoll = (IntegralFehlerRoll * 1 + tmp_long2) / 2;
874
                ROT_OFF;
786
 
875
// Salvo End
787
 
876
 
788
DebugOut.Analog[17] = IntegralAccNick / 26;
877
/*DebugOut.Analog[17] = IntegralAccNick / 26;
789
DebugOut.Analog[18] = IntegralAccRoll / 26;
878
DebugOut.Analog[18] = IntegralAccRoll / 26;
790
DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
879
DebugOut.Analog[19] = IntegralFehlerNick;// / 26;
791
DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
880
DebugOut.Analog[20] = IntegralFehlerRoll;// / 26;
792
DebugOut.Analog[21] = MittelIntegralNick / 26;
881
DebugOut.Analog[21] = MittelIntegralNick / 26;
793
DebugOut.Analog[22] = MittelIntegralRoll / 26;
882
DebugOut.Analog[22] = MittelIntegralRoll / 26;
-
 
883
DebugOut.Analog[28] = ausgleichNick;
Line 794... Line 884...
794
//DebugOut.Analog[28] = ausgleichNick;
884
DebugOut.Analog[29] = ausgleichRoll;
795
DebugOut.Analog[29] = ausgleichRoll;
885
DebugOut.Analog[30] = LageKorrekturRoll * 10;
796
DebugOut.Analog[30] = LageKorrekturRoll * 10;
886
*/
797
 
887
 
Line 859... Line 949...
859
         } else  last_r_n = 0;
949
         } else  last_r_n = 0;
860
        } else
950
        } else
861
        {
951
        {
862
         cnt = 0;
952
         cnt = 0;
863
        }
953
        }
864
DebugOut.Analog[27] = ausgleichRoll;
954
//DebugOut.Analog[27] = ausgleichRoll;
865
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
955
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
866
//if(cnt > 1) beeptime = 50;
956
//if(cnt > 1) beeptime = 50;
867
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
957
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
868
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
958
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
869
DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick);
959
//DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick);
870
DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll);
960
//DebugOut.Analog[24] = 10*(AdNeutralRoll - StartNeutralRoll);
871
  }
961
  }
872
  else
962
  else
873
  {
963
  {
874
   LageKorrekturRoll = 0;
964
   LageKorrekturRoll = 0;
875
   LageKorrekturNick = 0;
965
   LageKorrekturNick = 0;
Line 886... Line 976...
886
    MittelIntegralRoll = 0;
976
    MittelIntegralRoll = 0;
887
    MittelIntegralNick2 = 0;
977
    MittelIntegralNick2 = 0;
888
    MittelIntegralRoll2 = 0;
978
    MittelIntegralRoll2 = 0;
889
    ZaehlMessungen = 0;
979
    ZaehlMessungen = 0;
890
 }
980
 }
891
//DebugOut.Analog[31] = StickRoll / (26*IntegralFaktor);
-
 
Line 892... Line 981...
892
 
981
 
893
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
982
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
894
//  Gieren
983
//  Gieren
895
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
984
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
Line 902... Line 991...
902
    sollGier = tmp_int;
991
    sollGier = tmp_int;
903
    Mess_Integral_Gier -= tmp_int;  
992
    Mess_Integral_Gier -= tmp_int;  
904
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
993
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
905
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
994
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
Line -... Line 995...
-
 
995
 
-
 
996
// Salvo Ersatzkompass  26.9.2007 **********************
-
 
997
        if ((Kompass_Neuer_Wert > 0))
-
 
998
        {
-
 
999
           Kompass_Neuer_Wert = 0;
-
 
1000
           w = (abs(Mittelwert_AccNick));
-
 
1001
           v = (abs(Mittelwert_AccRoll));
-
 
1002
           if  ((w  < ACC_WAAGRECHT_LIMIT) && (v < ACC_WAAGRECHT_LIMIT)) //Ersatzkompass nur mit Magnetkompass aktualisieren wenn alles ok
-
 
1003
           {
-
 
1004
                if  ((abs(KompassValue - Kompass_Value_Old)) <= 5) // Aufeinanderfolgende Werte duerfen nur minimal abweichen
-
 
1005
                 {
-
 
1006
                  magkompass_ok = 1; // Flag dass Magnetkompass stabil arbeitet 
-
 
1007
                  GyroKomp_Int = (GyroKomp_Int )/GYROKOMP_INC_GRAD_DEFAULT;
-
 
1008
                  w = KompassValue - GyroKomp_Int;
-
 
1009
                  if ((w > 0) && (w < 180))
-
 
1010
                  {
-
 
1011
                   ++GyroKomp_Int;
-
 
1012
                  }
-
 
1013
                  else if ((w > 0) && (w >= 180))
-
 
1014
                  {
-
 
1015
                   --GyroKomp_Int;
-
 
1016
                  }
-
 
1017
                  else if ((w < 0) && (w >= -180))
-
 
1018
                  {
-
 
1019
                   --GyroKomp_Int;
-
 
1020
                  }
-
 
1021
                  else if ((w < 0) && (w < -180))
-
 
1022
                  {
-
 
1023
                   ++GyroKomp_Int;
-
 
1024
                  }
-
 
1025
                  if (GyroKomp_Int < 0)  GyroKomp_Int = GyroKomp_Int + 360;
-
 
1026
                  GyroKomp_Int = (GyroKomp_Int%360) * GYROKOMP_INC_GRAD_DEFAULT; // An Magnetkompasswert annaehern
-
 
1027
                 }
-
 
1028
           }
-
 
1029
           else magkompass_ok = 0;
-
 
1030
        }
-
 
1031
// Salvo End *************************
-
 
1032
 
-
 
1033
// Salvo 6.10.2007 
-
 
1034
        // GPS Home aktivieren wenn Knueppel in Ruhelage und Hoehenschalter aktiviert ist
-
 
1035
        //GPS Hold Aktiveren wenn Knueppel in Ruhelage sind
-
 
1036
        if ((EE_Parameter.GlobalConfig & CFG_GPS_AKTIV) && (abs(StickRoll) < GPS_STICK_HOLDOFF) && (abs(StickNick) < GPS_STICK_HOLDOFF) && (gps_alive_cnt > 0))
-
 
1037
        {
-
 
1038
                if (Parameter_MaxHoehe > 200)  
-
 
1039
                {      
-
 
1040
                        if ( gps_cmd == GPS_CMD_REQ_HOLD) gps_cmd = GPS_CMD_STOP; // erst mal stoppen, denn altes Kommando wurde noch nicht beendet
-
 
1041
                        else gps_cmd = GPS_CMD_REQ_HOME;
-
 
1042
                        n = GPS_CRTL(gps_cmd);
-
 
1043
                }
-
 
1044
                else
-
 
1045
                {
-
 
1046
                        if ( gps_cmd == GPS_CMD_REQ_HOME) gps_cmd = GPS_CMD_STOP; // erst mal stoppen, denn altes Kommando wurde noch nicht beendet
-
 
1047
                        else gps_cmd = GPS_CMD_REQ_HOLD;
-
 
1048
                        n= GPS_CRTL(gps_cmd);
-
 
1049
                }
-
 
1050
        }
-
 
1051
        else
-
 
1052
        {
-
 
1053
                if (gps_cmd != GPS_CMD_STOP)
-
 
1054
                {
-
 
1055
                        gps_cmd = GPS_CMD_STOP;
-
 
1056
                        n= GPS_CRTL(gps_cmd); //GPS Lageregelung beenden
-
 
1057
                }
-
 
1058
        }
906
 
1059
 
907
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
1060
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
908
//  Kompass
1061
//  Kompass
909
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
1062
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
910
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV))
1063
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) && (Kompass_present > 0))
911
     {
-
 
912
       int w,v;
-
 
913
       static int SignalSchlecht = 0;
-
 
914
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
-
 
915
       v = abs(IntegralRoll /512);
1064
     {
-
 
1065
           if(v > w) w = v; // grösste Neigung ermitteln
-
 
1066
 
916
       if(v > w) w = v; // grösste Neigung ermitteln
1067
// Salvo 13.9.2007 Nur wenn Magnetkompass ordentliche Werte liefert
917
       if(w < 25 && NeueKompassRichtungMerken && !SignalSchlecht)    
1068
                if ((magkompass_ok > 0)  &&  NeueKompassRichtungMerken)  
918
        {
1069
        {
919
         KompassStartwert = KompassValue;
1070
                 KompassStartwert = KompassValue;
920
         NeueKompassRichtungMerken = 0;
1071
         NeueKompassRichtungMerken = 0;
-
 
1072
        }
-
 
1073
// Salvo 13.9.2007
-
 
1074
       w=0;
921
        }
1075
// Salvo End
922
       w = (w * Parameter_KompassWirkung) / 64;           // auf die Wirkung normieren
1076
       w = (w * Parameter_KompassWirkung) / 64;           // auf die Wirkung normieren
923
       w = Parameter_KompassWirkung - w;                  // Wirkung ggf drosseln
1077
       w = Parameter_KompassWirkung - w;                  // Wirkung ggf drosseln
924
       if(w > 0)
1078
       if(w > 0)
-
 
1079
        {
925
        {
1080
// Salvo Kompasssteuerung **********************        
926
          if(!SignalSchlecht) Mess_Integral_Gier += (KompassRichtung * w) / 32;  // nach Kompass ausrichten
1081
                 if (magkompass_ok > 0) Mess_Integral_Gier += (KompassRichtung * w) / 32;  // nach Kompass ausrichten
927
          if(SignalSchlecht) SignalSchlecht--;
1082
// Salvo End
928
        }  
-
 
-
 
1083
        }  
929
        else SignalSchlecht = 500; // so lange das Signal taub stellen --> ca. 1 sek
1084
 
930
     }
1085
     }
Line 931... Line 1086...
931
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
1086
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
932
 
1087
 
Line 942... Line 1097...
942
    DebugOut.Analog[3] = Mittelwert_AccRoll;
1097
    DebugOut.Analog[3] = Mittelwert_AccRoll;
943
    DebugOut.Analog[4] = MesswertGier;
1098
    DebugOut.Analog[4] = MesswertGier;
944
    DebugOut.Analog[5] = HoehenWert;
1099
    DebugOut.Analog[5] = HoehenWert;
945
    DebugOut.Analog[6] =(Mess_Integral_Hoch / 512);
1100
    DebugOut.Analog[6] =(Mess_Integral_Hoch / 512);
946
    DebugOut.Analog[8] = KompassValue;
1101
    DebugOut.Analog[8] = KompassValue;
-
 
1102
        DebugOut.Analog[9] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT;
-
 
1103
 
-
 
1104
// Diverse parameter Debugging
-
 
1105
        DebugOut.Analog[16] =  dataset_cnt;
947
    DebugOut.Analog[9] = UBat;
1106
        DebugOut.Analog[17] =  UBat;
948
    DebugOut.Analog[10] = SenderOkay;
1107
        DebugOut.Analog[18] =  MesswertNick;
949
    DebugOut.Analog[16] = Mittelwert_AccHoch;
1108
        DebugOut.Analog[19] =  MesswertRoll;
-
 
1109
        DebugOut.Analog[20] =  MesswertGier;
-
 
1110
        DebugOut.Analog[21] =  StickNick;
-
 
1111
        DebugOut.Analog[22] =  StickRoll;
-
 
1112
        DebugOut.Analog[23] =  StickGier;
-
 
1113
 
-
 
1114
 
-
 
1115
// GPS Debugging
-
 
1116
        DebugOut.Analog[26] =  gps_rel_act_position.utm_east;
-
 
1117
        DebugOut.Analog[27] =  gps_rel_act_position.utm_north;
-
 
1118
        DebugOut.Analog[28] =  gps_rel_act_position.utm_alt;
-
 
1119
        DebugOut.Analog[29] =  gps_sub_state+(20*gps_cmd);
Line 950... Line 1120...
950
 
1120
 
951
/*    DebugOut.Analog[16] = motor_rx[0];
1121
/*    DebugOut.Analog[16] = motor_rx[0];
952
    DebugOut.Analog[17] = motor_rx[1];
1122
    DebugOut.Analog[17] = motor_rx[1];
953
    DebugOut.Analog[18] = motor_rx[2];
1123
    DebugOut.Analog[18] = motor_rx[2];
Line 980... Line 1150...
980
    if(Looping_Roll) MesswertRoll = MesswertRoll * GyroFaktor;
1150
    if(Looping_Roll) MesswertRoll = MesswertRoll * GyroFaktor;
981
    else             MesswertRoll = IntegralRoll * IntegralFaktor + MesswertRoll * GyroFaktor;
1151
    else             MesswertRoll = IntegralRoll * IntegralFaktor + MesswertRoll * GyroFaktor;
982
//    MesswertGier = MesswertGier * (GyroFaktor/2) + Integral_Gier * IntegralFaktor;
1152
//    MesswertGier = MesswertGier * (GyroFaktor/2) + Integral_Gier * IntegralFaktor;
983
    MesswertGier = MesswertGier * (GyroFaktor) + Integral_Gier * IntegralFaktor/2;
1153
    MesswertGier = MesswertGier * (GyroFaktor) + Integral_Gier * IntegralFaktor/2;
Line 984... Line 1154...
984
 
1154
 
985
DebugOut.Analog[28] = MesswertRoll;
1155
//DebugOut.Analog[28] = MesswertRoll;
986
DebugOut.Analog[25] = IntegralRoll * IntegralFaktor;
1156
DebugOut.Analog[25] = IntegralRoll * IntegralFaktor;
Line 987... Line 1157...
987
DebugOut.Analog[31] = StickRoll;// / (26*IntegralFaktor);
1157
DebugOut.Analog[31] = StickRoll;// / (26*IntegralFaktor);
988
 
1158