Rev 313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 313 | Rev 316 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "main.h" |
1 | #include "main.h" |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | volatile unsigned int CountMilliseconds = 0; |
3 | volatile unsigned int CountMilliseconds = 0; |
4 | volatile static unsigned int tim_main; |
4 | volatile static unsigned int tim_main; |
5 | volatile unsigned char UpdateMotor = 0; |
- | |
6 | volatile unsigned int beeptime = 0; |
5 | volatile unsigned char UpdateMotor = 0; |
- | 6 | volatile unsigned int cntKompass = 0; |
|
- | 7 | volatile unsigned int beeptime = 0; |
|
7 | volatile unsigned int cntKompass = 0; |
8 | unsigned int BeepMuster = 0xffff; |
8 | int ServoValue = 0; |
- | |
9 | /*Salvo 8.9.2007 |
- | |
10 | volatile uint8_t Kompass_Neuer_Wert= 0; |
- | |
11 | volatile unsigned int Kompass_Value_Old = 0; |
9 | int ServoValue = 0; |
12 | // Salvo End |
- | |
13 | //Salvo 21.9.2007 |
- | |
14 | short unsigned int Kompass_present= 0; //>0 bedeutet dass der Kompass vorhanden ist |
- | |
15 | // Salvo End */ |
10 | |
16 | enum { |
11 | enum { |
17 | STOP = 0, |
12 | STOP = 0, |
18 | CK = 1, |
13 | CK = 1, |
19 | CK8 = 2, |
14 | CK8 = 2, |
Line 26... | Line 21... | ||
26 | 21 | ||
27 | 22 | ||
28 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
23 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
- | 24 | { |
|
29 | { |
25 | static unsigned char cnt_1ms = 1,cnt = 0; |
Line 30... | Line 26... | ||
30 | static unsigned char cnt_1ms = 1,cnt = 0; |
26 | unsigned char pieper_ein = 0; |
31 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
27 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
32 | - | ||
33 | if(!cnt--) |
28 | |
34 | { |
29 | if(!cnt--) |
35 | // if (Kompass_present > 0) Kompass_present--; //Runterzaehlen. Wenn 0 ist der Kompass nicht vorhanden |
30 | { |
36 | cnt = 9; |
31 | cnt = 9; |
37 | cnt_1ms++; |
32 | cnt_1ms++; |
38 | cnt_1ms %= 2; |
- | |
39 | if(!cnt_1ms) UpdateMotor = 1; |
33 | cnt_1ms %= 2; |
Line 40... | Line 34... | ||
40 | CountMilliseconds++; |
34 | if(!cnt_1ms) UpdateMotor = 1; |
41 | if(Timeout) Timeout--; |
35 | CountMilliseconds++; |
42 | } |
36 | } |
Line 66... | Line 60... | ||
66 | { |
60 | { |
67 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
61 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
68 | else PORTC &= ~(1<<7); |
62 | else PORTC &= ~(1<<7); |
69 | } |
63 | } |
Line 70... | Line 64... | ||
70 | 64 | ||
71 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV || EE_Parameter.GlobalConfig & CFG_GPS_AKTIV) //Abfrage um GPS_AKTIV erweitert, damit auch bei nur eingeschaltetem GPS OHNE Kompass der benötigte Kompassvalue berechnet wird (200907Kr) |
65 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
72 | { |
66 | { |
73 | // if(PINC & 0x10) |
67 | if(PINC & 0x10) |
74 | // { |
68 | { |
75 | // cntKompass++; |
69 | cntKompass++; |
76 | // } |
70 | } |
77 | // else |
71 | else |
78 | // { |
- | |
79 | // if((cntKompass) && (cntKompass < 4000)) |
- | |
80 | // { |
- | |
81 | // KompassValue = cntKompass; |
- | |
82 | // } |
- | |
83 | // if(cntKompass < 10) cntKompass = 10; |
- | |
84 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
- | |
85 | // KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
- | |
86 | // cntKompass = 0; |
- | |
87 | // } |
- | |
88 | // } |
72 | { |
89 | // |
- | |
90 | // if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
- | |
91 | // { |
73 | |
Line 92... | Line 74... | ||
92 | MM3_timer0(); // Kompass auslesen |
74 | MM3_timer0(); // Kompass auslesen |
93 | 75 | ||
Line 99... | Line 81... | ||
99 | if (MM3_heading() < 0 ) { KompassValue = MM3_heading()*-1;} |
81 | if (MM3_heading() < 0 ) { KompassValue = MM3_heading()*-1;} |
Line 100... | Line 82... | ||
100 | 82 | ||
101 | - | ||
102 | - | ||
103 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360); |
83 | |
104 | 84 | ||
105 | 85 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360); |
|
106 | cntKompass = 320; |
86 | cntKompass = 640; |
107 | } |
- | |
108 | } |
87 | } |
Line 109... | Line 88... | ||
109 | 88 | } |
|
110 | 89 | } |
|
Line 173... | Line 152... | ||
173 | else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
152 | else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
Line 174... | Line 153... | ||
174 | 153 | ||
175 | if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin; |
154 | if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin; |
Line 176... | Line -... | ||
176 | else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax; |
- | |
177 | 155 | else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax; |
|
178 | //DebugOut.Analog[10] = ServoValue; |
156 | |
179 | OCR2A = ServoValue;// + 75; |
157 | OCR2A = ServoValue;// + 75; |
180 | timer = EE_Parameter.ServoNickRefresh; |
158 | timer = EE_Parameter.ServoNickRefresh; |
181 | } |
159 | } |