Rev 420 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 420 | Rev 446 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | volatile unsigned char UpdateMotor = 0; |
5 | volatile unsigned char UpdateMotor = 0; |
6 | volatile unsigned int cntKompass = 0; |
6 | volatile unsigned int cntKompass = 0; |
7 | volatile unsigned int beeptime = 0; |
7 | volatile unsigned int beeptime = 0; |
8 | unsigned int BeepMuster = 0xffff; |
8 | unsigned int BeepMuster = 0xffff; |
9 | int ServoValue = 0; |
9 | int ServoValue = 0; |
- | 10 | //Salvo 8.9.2007 |
|
- | 11 | volatile uint8_t Kompass_Neuer_Wert= 0; |
|
- | 12 | volatile unsigned int Kompass_Value_Old = 0; |
|
- | 13 | // Salvo End |
|
- | 14 | //Salvo 21.9.2007 |
|
- | 15 | short unsigned int Kompass_present= 0; //>0 bedeutet dass der Kompass vorhanden ist |
|
10 | 16 | // Salvo End |
|
11 | enum { |
17 | enum { |
12 | STOP = 0, |
18 | STOP = 0, |
13 | CK = 1, |
19 | CK = 1, |
14 | CK8 = 2, |
20 | CK8 = 2, |
15 | CK64 = 3, |
21 | CK64 = 3, |
Line 17... | Line 23... | ||
17 | CK1024 = 5, |
23 | CK1024 = 5, |
18 | T0_FALLING_EDGE = 6, |
24 | T0_FALLING_EDGE = 6, |
19 | T0_RISING_EDGE = 7 |
25 | T0_RISING_EDGE = 7 |
20 | }; |
26 | }; |
Line -... | Line 27... | ||
- | 27 | ||
- | 28 | // Aenderungen von Peter Muehlenbrock ("Salvo") Stand 21.9.2007 |
|
- | 29 | /* |
|
- | 30 | Driftkompensation fuer Gyros verbessert |
|
- | 31 | Linearsensor mit fixem Neutralwert |
|
21 | 32 | Ersatzkompass abgeleitet aus Magnetkompass und Giergyro fuer nahezu neigungsubhaengige Kompassfunktion |
|
22 | 33 | */ |
|
23 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
34 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
24 | { |
35 | { |
25 | static unsigned char cnt_1ms = 1,cnt = 0; |
36 | static unsigned char cnt_1ms = 1,cnt = 0; |
26 | unsigned char pieper_ein = 0; |
37 | unsigned char pieper_ein = 0; |
Line 27... | Line 38... | ||
27 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
38 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
28 | 39 | ||
- | 40 | if(!cnt--) |
|
29 | if(!cnt--) |
41 | { |
30 | { |
42 | if (Kompass_present > 0) Kompass_present--; //Runterzaehlen. Wenn 0 ist der Kompass nicht vorhanden |
31 | cnt = 9; |
43 | cnt = 9; |
32 | cnt_1ms++; |
44 | cnt_1ms++; |
33 | cnt_1ms %= 2; |
45 | cnt_1ms %= 2; |
Line 60... | Line 72... | ||
60 | { |
72 | { |
61 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
73 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
62 | else PORTC &= ~(1<<7); |
74 | else PORTC &= ~(1<<7); |
63 | } |
75 | } |
Line 64... | Line 76... | ||
64 | 76 | ||
65 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
77 | // if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
66 | { |
78 | { |
67 | if(PINC & 0x10) |
79 | if(PINC & 0x10) |
68 | { |
80 | { |
69 | cntKompass++; |
81 | cntKompass++; |
70 | } |
82 | } |
71 | else |
83 | else |
72 | { |
84 | { |
73 | if((cntKompass) && (cntKompass < 4000)) |
85 | if((cntKompass) && (cntKompass < 4000)) |
- | 86 | { |
|
- | 87 | // Salvo Kompassoffset 30.8.2007 und 21.9.2007 *********** |
|
- | 88 | Kompass_present = 255; |
|
74 | { |
89 | Kompass_Value_Old = KompassValue; |
- | 90 | KompassValue = cntKompass -KOMPASS_OFFSET; |
|
- | 91 | ||
- | 92 | if (KompassValue < 0) |
|
- | 93 | { |
|
- | 94 | KompassValue += 360; |
|
- | 95 | } |
|
- | 96 | if (KompassValue >= 360) |
|
- | 97 | { |
|
- | 98 | KompassValue -= 360; |
|
- | 99 | } |
|
75 | KompassValue = cntKompass; |
100 | // Salvo End |
76 | } |
101 | } |
77 | // if(cntKompass < 10) cntKompass = 10; |
102 | // if(cntKompass < 10) cntKompass = 10; |
78 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
103 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
- | 104 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
|
- | 105 | //Salvo 13.9.2007 Ok Erkennung des Magnetkompasses |
|
- | 106 | Kompass_Neuer_Wert = 1; |
|
79 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
107 | // Salvo End |
80 | cntKompass = 0; |
108 | cntKompass = 0; |
81 | } |
109 | } |
82 | } |
110 | } |