Rev 308 | Rev 313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 308 | Rev 309 | ||
---|---|---|---|
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 cntKompass = 0; |
5 | volatile unsigned char UpdateMotor = 0; |
7 | volatile unsigned int beeptime = 0; |
6 | volatile unsigned int beeptime = 0; |
8 | unsigned int BeepMuster = 0xffff; |
7 | volatile unsigned int cntKompass = 0; |
- | 8 | int ServoValue = 0; |
|
- | 9 | /*Salvo 8.9.2007 |
|
- | 10 | volatile uint8_t Kompass_Neuer_Wert= 0; |
|
9 | int ServoValue = 0; |
11 | volatile unsigned int Kompass_Value_Old = 0; |
- | 12 | // Salvo End |
|
- | 13 | //Salvo 21.9.2007 |
|
- | 14 | short unsigned int Kompass_present= 0; //>0 bedeutet dass der Kompass vorhanden ist |
|
10 | 15 | // Salvo End */ |
|
11 | enum { |
16 | enum { |
12 | STOP = 0, |
17 | STOP = 0, |
13 | CK = 1, |
18 | CK = 1, |
14 | CK8 = 2, |
19 | CK8 = 2, |
Line 21... | Line 26... | ||
21 | 26 | ||
22 | 27 | ||
23 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
28 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
24 | { |
- | |
25 | static unsigned char cnt_1ms = 1,cnt = 0; |
29 | { |
Line 26... | Line 30... | ||
26 | unsigned char pieper_ein = 0; |
30 | static unsigned char cnt_1ms = 1,cnt = 0; |
27 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
31 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
- | 32 | ||
28 | 33 | if(!cnt--) |
|
29 | if(!cnt--) |
34 | { |
30 | { |
35 | // if (Kompass_present > 0) Kompass_present--; //Runterzaehlen. Wenn 0 ist der Kompass nicht vorhanden |
31 | cnt = 9; |
36 | cnt = 9; |
32 | cnt_1ms++; |
37 | cnt_1ms++; |
- | 38 | cnt_1ms %= 2; |
|
33 | cnt_1ms %= 2; |
39 | if(!cnt_1ms) UpdateMotor = 1; |
Line 34... | Line 40... | ||
34 | if(!cnt_1ms) UpdateMotor = 1; |
40 | CountMilliseconds++; |
35 | CountMilliseconds++; |
41 | if(Timeout) Timeout--; |
36 | } |
42 | } |
Line 85... | Line 91... | ||
85 | // { |
91 | // { |
86 | MM3_timer0(); // Kompass auslesen |
92 | MM3_timer0(); // Kompass auslesen |
Line 87... | Line 93... | ||
87 | 93 | ||
88 | if (!cntKompass--) // Aufruf mit 25 Hz |
94 | if (!cntKompass--) // Aufruf mit 25 Hz |
89 | { |
95 | { |
- | 96 | KompassValue = (MM3_heading()); |
|
- | 97 | ||
- | 98 | if (KompassValue < 0 ) { KompassValue = 380+MM3_heading();} |
|
- | 99 | if (KompassValue > 359) { KompassValue = 359;} |
|
- | 100 | ||
90 | KompassValue = MM3_heading(); |
101 | |
- | 102 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360); |
|
- | 103 | ||
91 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
104 | |
92 | cntKompass = 320; |
105 | cntKompass = 320; |
93 | } |
106 | } |
94 | } |
- | |
95 | } |
107 | } |
Line 96... | Line 108... | ||
96 | 108 | ||
Line 97... | Line 109... | ||
97 | 109 | ||
98 | //} |
110 | } |
99 | 111 | ||
Line 160... | Line 172... | ||
160 | else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
172 | else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512; |
Line 161... | Line 173... | ||
161 | 173 | ||
162 | if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin; |
174 | if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin; |
Line -... | Line 175... | ||
- | 175 | else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax; |
|
163 | else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax; |
176 | |
164 | 177 | //DebugOut.Analog[10] = ServoValue; |
|
165 | OCR2A = ServoValue;// + 75; |
178 | OCR2A = ServoValue;// + 75; |
166 | timer = EE_Parameter.ServoNickRefresh; |
179 | timer = EE_Parameter.ServoNickRefresh; |
167 | } |
180 | } |