Rev 677 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 677 | Rev 698 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
15 | von Peter Muehlenbrock alias Salvo |
15 | von Peter Muehlenbrock alias Salvo |
16 | Auswertung der Daten vom GPS im ublox Format |
16 | Auswertung der Daten vom GPS im ublox Format |
17 | Hold Modus mit PID Regler |
17 | Hold Modus mit PID Regler |
18 | Rückstuerz zur Basis Funktion |
18 | Rückstuerz zur Basis Funktion |
19 | Stand 20.1.2008 |
19 | Stand 29.1.2008 |
Line 20... | Line 20... | ||
20 | 20 | ||
21 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
21 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
22 | */ |
22 | */ |
23 | #include "main.h" |
23 | #include "main.h" |
24 | #include "math.h" |
24 | #include "math.h" |
Line 25... | Line 25... | ||
25 | //#include "gps.h" |
25 | //#include "gps.h" |
26 | 26 | ||
27 | // Defines fuer ublox Messageformat um Auswertung zu steuern |
27 | // Defines fuer ublox Messageformat um Auswertung zu steuern |
28 | #define UBLOX_IDLE 0 |
28 | #define UBLOX_IDLE 0 |
29 | #define UBLOX_SYNC1 1 |
29 | #define UBLOX_SYNC1 1 |
30 | #define UBLOX_SYNC2 2 |
30 | #define UBLOX_SYNC2 2 |
31 | #define UBLOX_CLASS 3 |
31 | #define UBLOX_CLASS 3 |
32 | #define UBLOX_ID 4 |
32 | #define UBLOX_ID 4 |
33 | #define UBLOX_LEN1 5 |
33 | #define UBLOX_LEN1 5 |
34 | #define UBLOX_LEN2 6 |
34 | #define UBLOX_LEN2 6 |
35 | #define UBLOX_CKA 7 |
35 | #define UBLOX_CKA 7 |
Line 36... | Line 36... | ||
36 | #define UBLOX_CKB 8 |
36 | #define UBLOX_CKB 8 |
37 | #define UBLOX_PAYLOAD 9 |
37 | #define UBLOX_PAYLOAD 9 |
38 | 38 | ||
39 | // ublox Protokoll Identifier |
39 | // ublox Protokoll Identifier |
40 | #define UBLOX_NAV_POSUTM 0x08 |
40 | #define UBLOX_NAV_POSUTM 0x08 |
41 | #define UBLOX_NAV_STATUS 0x03 |
41 | #define UBLOX_NAV_STATUS 0x03 |
42 | #define UBLOX_NAV_VELED 0x12 |
42 | #define UBLOX_NAV_VELED 0x12 |
43 | #define UBLOX_NAV_CLASS 0x01 |
43 | #define UBLOX_NAV_CLASS 0x01 |
44 | #define UBLOX_SYNCH1_CHAR 0xB5 |
44 | #define UBLOX_SYNCH1_CHAR 0xB5 |
45 | #define UBLOX_SYNCH2_CHAR 0x62 |
45 | #define UBLOX_SYNCH2_CHAR 0x62 |
46 | 46 | ||
47 | signed int GPS_Nick = 0; |
47 | signed int GPS_Nick = 0; |
48 | signed int GPS_Roll = 0; |
48 | signed int GPS_Roll = 0; |
49 | short int ublox_msg_state = UBLOX_IDLE; |
49 | short int ublox_msg_state = UBLOX_IDLE; |
50 | static uint8_t chk_a =0; //Checksum |
50 | static uint8_t chk_a =0; //Checksum |
51 | static uint8_t chk_b =0; |
51 | static uint8_t chk_b =0; |
52 | short int gps_state,gps_sub_state; //Zustaende der Statemachine |
52 | short int gps_state,gps_sub_state; //Zustaende der Statemachine |
53 | short int gps_updte_flag; |
53 | short int gps_updte_flag; |
54 | static long signed gps_reg_x,gps_reg_y; |
54 | static long signed gps_reg_x,gps_reg_y; |
55 | static unsigned int rx_len; |
55 | static unsigned int rx_len; |
56 | static unsigned int ptr_payload_data_end; |
56 | static unsigned int ptr_payload_data_end; |
57 | unsigned int gps_alive_cnt; // Wird bei jedem gueltigen GPS Telegramm hochgezaehlt |
57 | unsigned int gps_alive_cnt; // Wird bei jedem gueltigen GPS Telegramm hochgezaehlt |
58 | static signed int hdng_2home,dist_2home; //Richtung und Entfernung zur home Position |
58 | static signed int hdng_2home,dist_2home; //Richtung und Entfernung zur home Position |
59 | static signed gps_tick; //wird bei jedem Update durch das GPS Modul hochgezaehlt |
59 | static signed gps_tick; //wird bei jedem Update durch das GPS Modul hochgezaehlt |
60 | static short int hold_fast,hold_reset_int; //Flags fuer Hold Regler |
60 | static short int hold_fast,hold_reset_int; //Flags fuer Hold Regler |
61 | static uint8_t *ptr_payload_data; |
61 | static uint8_t *ptr_payload_data; |
62 | static uint8_t *ptr_pac_status; |
62 | static uint8_t *ptr_pac_status; |
Line 63... | Line 63... | ||
63 | static int dist_flown; |
63 | static int dist_flown; |
Line 64... | Line 64... | ||
64 | static unsigned int int_ovfl_cnt; // Zaehler fuer Overflows des Integrators |
64 | //static unsigned int int_ovfl_cnt; // Zaehler fuer Overflows des Integrators |
Line 78... | Line 78... | ||
78 | GPS_REL_POSITION_t gps_rel_start_position; // Die gespeicherte Ausgangsposition fuer GPS_ Home Mode |
78 | GPS_REL_POSITION_t gps_rel_start_position; // Die gespeicherte Ausgangsposition fuer GPS_ Home Mode |
Line 79... | Line 79... | ||
79 | 79 | ||
80 | // Initialisierung |
80 | // Initialisierung |
81 | void GPS_Neutral(void) |
81 | void GPS_Neutral(void) |
82 | { |
82 | { |
83 | ublox_msg_state = UBLOX_IDLE; |
83 | ublox_msg_state = UBLOX_IDLE; |
84 | gps_state = GPS_CRTL_IDLE; |
84 | gps_state = GPS_CRTL_IDLE; |
85 | gps_sub_state = GPS_CRTL_IDLE; |
85 | gps_sub_state = GPS_CRTL_IDLE; |
86 | actual_pos.status = 0; |
86 | actual_pos.status = 0; |
87 | actual_speed.status = 0; |
87 | actual_speed.status = 0; |
88 | actual_status.status = 0; |
88 | actual_status.status = 0; |
89 | gps_home_position.status = 0; // Noch keine gueltige Home Position |
89 | gps_home_position.status = 0; // Noch keine gueltige Home Position |
90 | gps_act_position.status = 0; |
90 | gps_act_position.status = 0; |
91 | gps_rel_act_position.status = 0; |
91 | gps_rel_act_position.status = 0; |
92 | GPS_Nick = 0; |
92 | GPS_Nick = 0; |
93 | GPS_Roll = 0; |
93 | GPS_Roll = 0; |
94 | gps_updte_flag = 0; |
94 | gps_updte_flag = 0; |
95 | gps_alive_cnt = 0; |
95 | gps_alive_cnt = 0; |
Line 96... | Line 96... | ||
96 | } |
96 | } |
97 | 97 | ||
98 | // Home Position sichern falls Daten verfuegbar sind. |
98 | // Home Position sichern falls Daten verfuegbar sind. |
Line 148... | Line 148... | ||
148 | { |
148 | { |
149 | actual_status.status = 0; |
149 | actual_status.status = 0; |
150 | gps_act_position.utm_east = actual_pos.utm_east/10; |
150 | gps_act_position.utm_east = actual_pos.utm_east/10; |
151 | gps_act_position.utm_north = actual_pos.utm_north/10; |
151 | gps_act_position.utm_north = actual_pos.utm_north/10; |
152 | gps_act_position.utm_alt = actual_pos.utm_alt/10; |
152 | gps_act_position.utm_alt = actual_pos.utm_alt/10; |
153 | actual_pos.status = 0; //neue ublox Messages anfordern |
153 | actual_pos.status = 0; //neue ublox Messages anfordern |
154 | gps_act_position.speed_gnd = actual_speed.speed_gnd; |
154 | gps_act_position.speed_gnd = actual_speed.speed_gnd; |
155 | gps_act_position.speed_gnd = actual_speed.speed_gnd; |
155 | gps_act_position.speed_gnd = actual_speed.speed_gnd; |
156 | gps_act_position.heading = actual_speed.heading/100000; |
156 | gps_act_position.heading = actual_speed.heading/100000; |
157 | actual_speed.status = 0; |
157 | actual_speed.status = 0; |
158 | gps_act_position.status = 1; |
158 | gps_act_position.status = 1; |
159 | n = 0; //Daten gueltig |
159 | n = 0; //Daten gueltig |
160 | } |
160 | } |
161 | else |
161 | else |
162 | { |
162 | { |
163 | gps_act_position.status = 0; //Keine gueltigen Daten |
163 | gps_act_position.status = 0; //Keine gueltigen Daten |
164 | actual_speed.status = 0; |
164 | actual_speed.status = 0; |
165 | actual_status.status = 0; |
165 | actual_status.status = 0; |
166 | actual_pos.status = 0; //neue ublox Messages anfordern |
166 | actual_pos.status = 0; //neue ublox Messages anfordern |
167 | n = 2; |
167 | n = 2; |
168 | } |
168 | } |
169 | } |
169 | } |
170 | return (n); |
170 | return (n); |
171 | } |
171 | } |
Line 214... | Line 214... | ||
214 | case UBLOX_NAV_STATUS: |
214 | case UBLOX_NAV_STATUS: |
215 | ptr_pac_status = &actual_status.status; |
215 | ptr_pac_status = &actual_status.status; |
216 | if (*ptr_pac_status > 0) ublox_msg_state = UBLOX_IDLE; |
216 | if (*ptr_pac_status > 0) ublox_msg_state = UBLOX_IDLE; |
217 | else |
217 | else |
218 | { |
218 | { |
219 | ptr_payload_data = &actual_status; |
219 | ptr_payload_data = &actual_status; |
220 | ptr_payload_data_end = &actual_status.status; |
220 | ptr_payload_data_end = &actual_status.status; |
221 | ublox_msg_state = UBLOX_LEN1; |
221 | ublox_msg_state = UBLOX_LEN1; |
222 | } |
222 | } |
223 | break; |
223 | break; |
Line 224... | Line 224... | ||
224 | 224 | ||
225 | case UBLOX_NAV_VELED: |
225 | case UBLOX_NAV_VELED: |
226 | ptr_pac_status = &actual_speed.status; |
226 | ptr_pac_status = &actual_speed.status; |
227 | if (*ptr_pac_status > 0) ublox_msg_state = UBLOX_IDLE; |
227 | if (*ptr_pac_status > 0) ublox_msg_state = UBLOX_IDLE; |
228 | else |
228 | else |
229 | { |
229 | { |
230 | ptr_payload_data = &actual_speed; |
230 | ptr_payload_data = &actual_speed; |
231 | ptr_payload_data_end = &actual_speed.status; |
231 | ptr_payload_data_end = &actual_speed.status; |
232 | ublox_msg_state = UBLOX_LEN1; |
232 | ublox_msg_state = UBLOX_LEN1; |
233 | } |
233 | } |
Line 234... | Line 234... | ||
234 | break; |
234 | break; |
235 | 235 | ||
Line 292... | Line 292... | ||
292 | //Zentrale Statemachine fuer alle GPS relevanten Regelungsablauefe |
292 | //Zentrale Statemachine fuer alle GPS relevanten Regelungsablauefe |
293 | short int GPS_CRTL(short int cmd) |
293 | short int GPS_CRTL(short int cmd) |
294 | { |
294 | { |
295 | static unsigned int cnt; // Zaehler fuer diverse Verzoegerungen |
295 | static unsigned int cnt; // Zaehler fuer diverse Verzoegerungen |
296 | static long int delta_north,delta_east; // Mass fuer Distanz zur Sollposition |
296 | static long int delta_north,delta_east; // Mass fuer Distanz zur Sollposition |
297 | signed int n; |
297 | signed int n; |
298 | static signed int gps_g2t_act_v; // Aktuelle Geschwindigkeitsvorgabe fuer Home Funktion |
298 | static signed int gps_g2t_act_v; // Aktuelle Geschwindigkeitsvorgabe fuer Home Funktion |
299 | signed int dist_frm_start_east,dist_frm_start_north; |
299 | signed int dist_frm_start_east,dist_frm_start_north; |
300 | int amplfy_speed_east,amplfy_speed_north; //Verstaerkungsfaktoren fuer D-Anteil |
300 | int amplfy_speed_east,amplfy_speed_north; //Verstaerkungsfaktoren fuer D-Anteil |
301 | static signed int int_east,int_north; //Integrierer |
301 | static signed int int_east,int_north; //Integrierer |
302 | long int speed_east,speed_north; //Aktuelle Geschwindigkeit |
302 | long int speed_east,speed_north; //Aktuelle Geschwindigkeit |
303 | signed long int_east1,int_north1; |
303 | signed long int_east1,int_north1; |
304 | int dist_east,dist_north; |
304 | int dist_east,dist_north; |
305 | int diff_p; //Vom Modus abhaengige zusaetzliche Verstaerkung |
305 | int diff_p; //Vom Modus abhaengige zusaetzliche Verstaerkung |
306 | long ni,ro; // Nick und Roll Zwischenwerte |
306 | long ni,ro; // Nick und Roll Zwischenwerte |
Line 307... | Line 307... | ||
307 | 307 | ||
308 | 308 | ||
Line 309... | Line 309... | ||
309 | switch (cmd) |
309 | switch (cmd) |
310 | { |
310 | { |
311 | 311 | ||
312 | case GPS_CMD_REQ_HOME: // Es soll zum Startpunkt zurueckgeflogen werden. |
312 | case GPS_CMD_REQ_HOME: // Es soll zum Startpunkt zurueckgeflogen werden. |
313 | if ((gps_state != GPS_CRTL_HOLD_ACTIVE) && (gps_state != GPS_CRTL_HOME_ACTIVE)) |
313 | if ((gps_state != GPS_CRTL_HOLD_ACTIVE) && (gps_state != GPS_CRTL_HOME_ACTIVE)) |
314 | { |
314 | { |
315 | cnt++; |
315 | cnt++; |
316 | if (cnt > 50) // erst nach Verzoegerung |
316 | if (cnt > 100) // erst nach Verzoegerung |
317 | { |
317 | { |
318 | // Erst mal initialisieren |
318 | // Erst mal initialisieren |
319 | cnt = 0; |
319 | cnt = 0; |
320 | gps_tick = 0; |
320 | gps_tick = 0; |
321 | hold_fast = 0; |
321 | hold_fast = 0; |
322 | hold_reset_int = 0; // Integrator enablen |
322 | hold_reset_int = 0; // Integrator enablen |
323 | int_east = 0, int_north = 0; |
323 | int_east = 0, int_north = 0; |
324 | gps_reg_x = 0, gps_reg_y = 0; |
324 | gps_reg_x = 0, gps_reg_y = 0; |
325 | delta_east = 0, delta_north = 0; |
325 | delta_east = 0, delta_north = 0; |
326 | dist_flown = 0; |
326 | dist_flown = 0; |
327 | gps_g2t_act_v = 0; |
327 | gps_g2t_act_v = 0; |
328 | gps_sub_state = GPS_CRTL_IDLE; |
328 | gps_sub_state = GPS_CRTL_IDLE; |
Line 365... | Line 365... | ||
365 | cnt = 0; |
365 | cnt = 0; |
366 | // aktuelle positionsdaten abspeichern |
366 | // aktuelle positionsdaten abspeichern |
367 | if (gps_rel_act_position.status > 0) |
367 | if (gps_rel_act_position.status > 0) |
368 | { |
368 | { |
369 | hold_fast = 0; |
369 | hold_fast = 0; |
370 | hold_reset_int = 0; // Integrator enablen |
370 | hold_reset_int = 0; // Integrator enablen |
371 | int_east = 0, int_north = 0; |
371 | int_east = 0, int_north = 0; |
372 | gps_reg_x = 0, gps_reg_y = 0; |
372 | gps_reg_x = 0, gps_reg_y = 0; |
373 | delta_east = 0, delta_north = 0; |
373 | delta_east = 0, delta_north = 0; |
374 | speed_east = 0; speed_north= 0; |
374 | speed_east = 0; speed_north= 0; |
375 | int_ovfl_cnt = 0; |
375 | // int_ovfl_cnt = 0; |
376 | gps_quiet_cnt = 0; |
376 | gps_quiet_cnt = 0; |
377 | gps_rel_hold_position.utm_east = gps_rel_act_position.utm_east; |
377 | gps_rel_hold_position.utm_east = gps_rel_act_position.utm_east; |
378 | gps_rel_hold_position.utm_north = gps_rel_act_position.utm_north; |
378 | gps_rel_hold_position.utm_north = gps_rel_act_position.utm_north; |
379 | gps_rel_hold_position.status = 1; // gueltige Positionsdaten |
379 | gps_rel_hold_position.status = 1; // gueltige Positionsdaten |
380 | gps_state = GPS_CRTL_HOLD_ACTIVE; |
380 | gps_state = GPS_CRTL_HOLD_ACTIVE; |
381 | return (GPS_STST_OK); |
381 | return (GPS_STST_OK); |
Line 390... | Line 390... | ||
390 | else return(GPS_STST_PEND); // noch warten |
390 | else return(GPS_STST_PEND); // noch warten |
391 | } |
391 | } |
392 | break; |
392 | break; |
Line 393... | Line 393... | ||
393 | 393 | ||
394 | case GPS_CMD_STOP: // Lageregelung beenden |
394 | case GPS_CMD_STOP: // Lageregelung beenden |
395 | cnt = 0; |
395 | cnt = 0; |
396 | GPS_Nick = 0; |
396 | GPS_Nick = 0; |
397 | GPS_Roll = 0; |
397 | GPS_Roll = 0; |
398 | gps_sub_state = GPS_CRTL_IDLE; |
398 | gps_sub_state = GPS_CRTL_IDLE; |
399 | gps_state = GPS_CRTL_IDLE; |
399 | gps_state = GPS_CRTL_IDLE; |
400 | return (GPS_STST_OK); |
400 | return (GPS_STST_OK); |
Line 401... | Line 401... | ||
401 | break; |
401 | break; |
Line 424... | Line 424... | ||
424 | d2 = abs (gps_rel_hold_position.utm_north - gps_rel_act_position.utm_north ); |
424 | d2 = abs (gps_rel_hold_position.utm_north - gps_rel_act_position.utm_north ); |
425 | d3 = (dist_2home - dist_flown); // Restdistanz zum Ziel |
425 | d3 = (dist_2home - dist_flown); // Restdistanz zum Ziel |
Line 426... | Line 426... | ||
426 | 426 | ||
427 | if (d3 > GPS_G2T_DIST_MAX_STOP) // Schneller Rueckflug, noch weit weg vom Ziel |
427 | if (d3 > GPS_G2T_DIST_MAX_STOP) // Schneller Rueckflug, noch weit weg vom Ziel |
428 | { |
428 | { |
429 | if ((d1 < GPS_G2T_FAST_TOL/2) && (d2 < GPS_G2T_FAST_TOL/2)) //voll Stoff weiter wenn Lage gut innerhalb der Toleranz |
429 | if ((d1 < (GPS_G2T_FAST_TOL/2)) && (d2 < (GPS_G2T_FAST_TOL/2))) //voll Stoff weiter wenn Lage gut innerhalb der Toleranz |
430 | { |
430 | { |
431 | if (gps_g2t_act_v < GPS_G2T_V_MAX-3) gps_g2t_act_v += 4; //Geschwindigkeit erhoehen |
431 | if (gps_g2t_act_v < GPS_G2T_V_MAX-3) gps_g2t_act_v += 4; //Geschwindigkeit erhoehen |
432 | dist_flown +=gps_g2t_act_v; // Vorgabe der Strecke anhand der Geschwindigkeit |
432 | dist_flown +=gps_g2t_act_v; // Vorgabe der Strecke anhand der Geschwindigkeit |
433 | gps_sub_state = GPS_HOME_FAST_IN_TOL; |
433 | gps_sub_state = GPS_HOME_FAST_IN_TOL; |
434 | } |
434 | } |
435 | else if ((d1 < GPS_G2T_FAST_TOL) && (d2 < GPS_G2T_FAST_TOL)) //nur weiter wenn Lage innerhalb der Toleranz |
435 | else if ((d1 < GPS_G2T_FAST_TOL) && (d2 < GPS_G2T_FAST_TOL)) //nur weiter wenn Lage innerhalb der Toleranz |
436 | { |
436 | { |
437 | if (gps_g2t_act_v > GPS_G2T_V_MAX/2) gps_g2t_act_v -= 1; //Geschwindigkeit auf Haeflte runter oder rauffahren |
437 | if (gps_g2t_act_v > (GPS_G2T_V_MAX/2)) gps_g2t_act_v -= 1; //Geschwindigkeit auf Haelfte runter oder rauffahren |
438 | else if (gps_g2t_act_v < GPS_G2T_V_MAX/2) gps_g2t_act_v += 1; |
438 | else if (gps_g2t_act_v < (GPS_G2T_V_MAX/2)) gps_g2t_act_v += 1; |
439 | dist_flown +=gps_g2t_act_v; // Vorgabe der Strecke anhand der Geschwindigkeit |
439 | dist_flown +=gps_g2t_act_v; // Vorgabe der Strecke anhand der Geschwindigkeit |
440 | gps_sub_state = GPS_HOME_FAST_IN_TOL; |
440 | gps_sub_state = GPS_HOME_FAST_IN_TOL; |
441 | } |
441 | } |
442 | else //Den Lageregler in Ruhe arbeiten lassen weil ausserhalb der Toleranz |
442 | else //Den Lageregler in Ruhe arbeiten lassen weil ausserhalb der Toleranz |
443 | { |
443 | { |
444 | if (gps_g2t_act_v > 1) gps_g2t_act_v--; // Geschwindigkeit reduzieren |
444 | if (gps_g2t_act_v > 1) gps_g2t_act_v--; // Geschwindigkeit reduzieren |
445 | // dist_flown++; //Auch ausserhalb der Toleranz langsam erhoehen |
445 | // dist_flown++; //Auch ausserhalb der Toleranz langsam erhoehen |
446 | gps_sub_state = GPS_HOME_FAST_OUTOF_TOL; |
446 | gps_sub_state = GPS_HOME_FAST_OUTOF_TOL; |
447 | } |
447 | } |
448 | hold_reset_int = 1; // Integrator aussschalten |
448 | hold_reset_int = 0; // Integrator einsschalten |
449 | hold_fast = 1; // Regler fuer schnellen Flug |
449 | hold_fast = 1; // Regler fuer schnellen Flug |
450 | dist_frm_start_east = (int)(((long)dist_flown * (long)sin_i(hdng_2home))/1000); |
450 | dist_frm_start_east = (int)(((long)dist_flown * (long)sin_i(hdng_2home))/1000); |
451 | dist_frm_start_north = (int)(((long)dist_flown * (long)cos_i(hdng_2home))/1000); |
451 | dist_frm_start_north = (int)(((long)dist_flown * (long)cos_i(hdng_2home))/1000); |
452 | gps_rel_hold_position.utm_east = gps_rel_start_position.utm_east + dist_frm_start_east; //naechster Zielpunkt |
452 | gps_rel_hold_position.utm_east = gps_rel_start_position.utm_east + dist_frm_start_east; //naechster Zielpunkt |
Line 484... | Line 484... | ||
484 | else if (gps_rel_hold_position.utm_north <= - GPS_G2T_V_MIN ) gps_rel_hold_position.utm_north += GPS_G2T_V_MIN; |
484 | else if (gps_rel_hold_position.utm_north <= - GPS_G2T_V_MIN ) gps_rel_hold_position.utm_north += GPS_G2T_V_MIN; |
485 | if ((abs(gps_rel_hold_position.utm_east) <= GPS_G2T_V_MIN) && (abs(gps_rel_hold_position.utm_north) <=GPS_G2T_V_MIN)) |
485 | if ((abs(gps_rel_hold_position.utm_east) <= GPS_G2T_V_MIN) && (abs(gps_rel_hold_position.utm_north) <=GPS_G2T_V_MIN)) |
486 | { |
486 | { |
487 | gps_rel_hold_position.utm_east = 0; |
487 | gps_rel_hold_position.utm_east = 0; |
488 | gps_rel_hold_position.utm_north = 0; |
488 | gps_rel_hold_position.utm_north = 0; |
489 | gps_sub_state = GPS_HOME_FINISHED; |
489 | gps_sub_state = GPS_HOME_FINISHED; |
490 | } |
490 | } |
491 | } |
491 | } |
492 | else gps_sub_state = GPS_HOME_OUTOF_TOL; |
492 | else gps_sub_state = GPS_HOME_OUTOF_TOL; |
493 | } |
493 | } |
494 | } |
494 | } |
Line 521... | Line 521... | ||
521 | 521 | ||
522 | // #define GPSINT_MAX 3000 // Neues Verfahren ab 30.12.2007 bei Integratoroverflow |
522 | // #define GPSINT_MAX 3000 // Neues Verfahren ab 30.12.2007 bei Integratoroverflow |
523 | long int gpsintmax; |
523 | long int gpsintmax; |
524 | if (Parameter_UserParam2 > 0) |
524 | if (Parameter_UserParam2 > 0) |
525 | { |
525 | { |
526 | gpsintmax = (GPS_NICKROLL_MAX * GPS_V * GPS_USR_PAR_FKT * ((32*4)/10))/(long)Parameter_UserParam2; //auf ungefeahren Maximalwert begrenzen |
526 | gpsintmax = (GPS_NICKROLL_MAX * GPS_V * GPS_USR_PAR_FKT * ((32*3)/10))/(long)Parameter_UserParam2; //auf ungefeahren Maximalwert begrenzen |
527 | if ((abs(int_east) > (int)gpsintmax) || (abs(int_north)> (int)gpsintmax)) |
527 | if ((abs(int_east) > (int)gpsintmax) || (abs(int_north)> (int)gpsintmax)) |
528 | { |
528 | { |
529 | int_ovfl_cnt += 1; // Zahl der Overflows zaehlen |
- | |
530 | } |
- | |
531 | if (int_ovfl_cnt > 0) //bei Overflow Wert Integratorwert reduzieren |
- | |
532 | { |
529 | // // = 1; // Zahl der Overflows zaehlen |
533 | int_ovfl_cnt -= 1; |
530 | // int_ovfl_cnt -= 1; |
534 | int_east = (int_east*7)/8; // Wert reduzieren |
531 | int_east = (int_east * 6)/8; // Wert reduzieren |
535 | int_north = (int_north*7)/8; |
532 | int_north = (int_north* 6)/8; |
Line 536... | Line 533... | ||
536 | } |
533 | } |
537 | 534 | ||
538 | if (hold_reset_int > 0) //Im Schnellen Mode Integrator abschalten |
535 | if (hold_reset_int > 0) //Im Schnellen Mode Integrator abschalten |
539 | { |
536 | { |
540 | int_east = 0; |
537 | int_east = 0; |
541 | int_north = 0; |
538 | int_north = 0; |
542 | } |
539 | } |
543 | } |
540 | } |
544 | else // Integrator deaktiviert |
541 | else // Integrator deaktiviert |
545 | { |
542 | { |
546 | int_east = 0; |
543 | int_east = 0; |
Line 547... | Line 544... | ||
547 | int_north = 0; |
544 | int_north = 0; |
548 | } |
545 | } |
Line 549... | Line 546... | ||
549 | 546 | ||
550 | debug_gp_4 = (int)int_east; // zum Debuggen |
547 | debug_gp_4 = (int)int_east; // zum Debuggen |
551 | debug_gp_5 = (int)int_north; // zum Debuggen |
548 | debug_gp_5 = (int)int_north; // zum Debuggen |
Line 596... | Line 593... | ||
596 | 593 | ||
597 | // debug_gp_4 = (int)speed_east; // zum Debuggen |
594 | // debug_gp_4 = (int)speed_east; // zum Debuggen |
Line 598... | Line 595... | ||
598 | // debug_gp_5 = (int)speed_north; // zum Debuggen |
595 | // debug_gp_5 = (int)speed_north; // zum Debuggen |
599 | 596 | ||
600 | //P-Werte verstaerken |
597 | //P-Werte verstaerken |
Line 601... | Line 598... | ||
601 | delta_east = (delta_east * (long)diff_p)/(20); |
598 | delta_east = (delta_east * (long)diff_p)/(40); |
602 | delta_north = (delta_north * (long)diff_p)/(20); |
599 | delta_north = (delta_north * (long)diff_p)/(40); |
603 | 600 | ||
604 | if (hold_fast > 0) //schneller Coming Home Modus |
601 | if (hold_fast > 0) //schneller Coming Home Modus |
605 | { |
602 | { |
606 | // P Werte begrenzen |
603 | // P Werte begrenzen |
607 | #define P1_F_MAX (GPS_NICKROLL_MAX * GPS_V*8)/10 // auf 80 Prozent des Maximalen Nick/Rollwert begrenzen |
604 | #define P1_F_MAX (GPS_NICKROLL_MAX * GPS_V*7)/10 // auf 80 Prozent des Maximalen Nick/Rollwert begrenzen |
608 | if (delta_east > P1_F_MAX) delta_east = P1_F_MAX; |
605 | if (delta_east > P1_F_MAX) delta_east = P1_F_MAX; |
609 | else if (delta_east < -P1_F_MAX) delta_east = -P1_F_MAX; |
606 | else if (delta_east < -P1_F_MAX) delta_east = -P1_F_MAX; |