Subversion Repositories FlightCtrl

Rev

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

Rev 162 Rev 167
Line 283... Line 283...
283
//Zentrale Statemachine fuer alle GPS relevanten Regelungsablauefe
283
//Zentrale Statemachine fuer alle GPS relevanten Regelungsablauefe
284
short int GPS_CRTL(short int cmd)
284
short int GPS_CRTL(short int cmd)
285
{
285
{
286
        static unsigned int cnt;        //Zaehler fuer diverse Verzoegerungen 
286
        static unsigned int cnt;                //Zaehler fuer diverse Verzoegerungen 
287
        static int int_east,int_north;  //Integrierer 
287
        static int int_east,int_north;  //Integrierer 
-
 
288
        static signed int dist_north,dist_east;
-
 
289
        int diff_east,diff_north;               // Differenzierer  (Differenz zum  vorhergehenden x bzw. y  Wert)
288
        int n;
290
        int n;
289
        long int dist;
291
        long int dist;
290
        switch (cmd)
292
        switch (cmd)
291
        {
293
        {
Line 352... Line 354...
352
                case GPS_CRTL_HOLD_ACTIVE: // Hier werden die Daten fuer Nick und Roll errechnet
354
                case GPS_CRTL_HOLD_ACTIVE:     // Hier werden die Daten fuer Nick und Roll errechnet
353
                        if (gps_updte_flag == 1)  //nur wenn neue GPS Daten vorliegen
355
                        if (gps_updte_flag == 1)  //nur wenn neue GPS Daten vorliegen
354
                        {
356
                        {
355
                                gps_updte_flag = 0;
357
                                gps_updte_flag = 0;
356
                                // ab hier wird geregelt
358
                                // ab hier wird geregelt
-
 
359
 
-
 
360
                                diff_east  = -dist_east;         //Alten Wert schon mal abziehen
357
                                signed int dist_north,dist_east;
361
                                diff_north = -dist_north;      
358
                                dist_east = gps_rel_hold_position.utm_east - gps_rel_act_position.utm_east;
362
                                dist_east = gps_rel_hold_position.utm_east - gps_rel_act_position.utm_east;
359
                                dist_north = gps_rel_hold_position.utm_north - gps_rel_act_position.utm_north;
363
                                dist_north = gps_rel_hold_position.utm_north - gps_rel_act_position.utm_north;
360
                                int_east        += dist_east;
364
                                int_east        += dist_east;
361
                                int_north   += dist_north;
365
                                int_north   += dist_north;
-
 
366
                                diff_east       += dist_east;   // Differenz zur vorhergehenden East Position
-
 
367
                                diff_north      += dist_north;  // Differenz zur vorhergehenden North Position
Line 362... Line 368...
362
 
368
 
363
                                #define GPSINT_MAX 1000
369
                                #define GPSINT_MAX 2048 //neuer Wert ab 25.9.2007 Begrenzung 
364
                                if ((abs(int_east) > GPSINT_MAX) || (abs(int_north)> GPSINT_MAX)) //Bei zu hohem Wert Integrator auf Wert halten
370
                                if ((abs(int_east) > GPSINT_MAX) || (abs(int_north)> GPSINT_MAX)) //Bei zu hohem Wert Integrator auf Wert halten
365
                                {
371
                                {
366
                                        int_east        -= dist_east;
372
                                        int_east        -= dist_east;
367
                                        int_north   -= dist_north;                                     
373
                                        int_north   -= dist_north;                                     
Line 368... Line 374...
368
                                }
374
                                }
369
       
375
       
370
                                #define DIST_MAX 200 //neu ab 19.9. 1900 Begrenzung 
376
                                #define DIST_MAX 100 //neuer Wert ab 24.9.2007 Begrenzung 
371
                                if (dist_east > DIST_MAX)       dist_east       = DIST_MAX;
377
                                if (dist_east > DIST_MAX)       dist_east       = DIST_MAX;
372
                                if (dist_east <-DIST_MAX)       dist_east       = -DIST_MAX;
378
                                if (dist_east <-DIST_MAX)       dist_east       = -DIST_MAX;
Line 373... Line 379...
373
                                if (dist_north > DIST_MAX)  dist_north  = DIST_MAX;
379
                                if (dist_north > DIST_MAX)  dist_north  = DIST_MAX;
374
                                if (dist_north <-DIST_MAX)  dist_north  = -DIST_MAX;
380
                                if (dist_north <-DIST_MAX)  dist_north  = -DIST_MAX;
375
 
381
 
Line 376... Line 382...
376
                                //PI Regler
382
                                //PID Regler
377
                                gps_reg_x       =       ((int_east  * Parameter_UserParam1)/16) + ((dist_east   * Parameter_UserParam2)/8);  // P+I Anteil 
383
                                gps_reg_x = ((int_east  * Parameter_UserParam1)/32) + ((dist_east   * Parameter_UserParam2)/2)+ ((diff_east  * Parameter_UserParam3)/2);  // 
Line 378... Line 384...
378
                                gps_reg_y       =       ((int_north * Parameter_UserParam1)/16) + ((dist_north  * Parameter_UserParam2)/8);  // P+I Anteil 
384
                                gps_reg_y = ((int_north * Parameter_UserParam1)/32) + ((dist_north  * Parameter_UserParam2)/2)+ ((diff_north * Parameter_UserParam3)/2);  // I + P +D  Anteil Y Achse