Subversion Repositories FlightCtrl

Rev

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

Rev 189 Rev 330
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;
-
 
46
     if(!cnt_1ms) UpdateMotor = 1;
34
     if(!cnt_1ms) UpdateMotor = 1;
47
     CountMilliseconds++;
Line 35... Line 48...
35
     CountMilliseconds++;
48
     if(Timeout) Timeout--;
36
     }  
49
     }  
37
 
50
 
Line 60... Line 73...
60
        {
73
        {
61
         if(PlatinenVersion == 10) PORTD &= ~(1<<2);
74
         if(PlatinenVersion == 10) PORTD &= ~(1<<2);
62
         else                      PORTC &= ~(1<<7);
75
         else                      PORTC &= ~(1<<7);
63
        }
76
        }
Line 64... Line 77...
64
 
77
 
65
 if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
78
// if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
66
 {
79
 {
67
  if(PINC & 0x10)
80
  if(PINC & 0x10)
68
   {
81
   {
69
    cntKompass++;
82
    cntKompass++;
70
   }
83
   }
71
  else
84
  else
72
   {
85
   {
73
    if((cntKompass) && (cntKompass < 4000))
86
    if((cntKompass) && (cntKompass < 4000))
-
 
87
    {
-
 
88
// Salvo Kompassoffset 30.8.2007 und 21.9.2007 ***********
-
 
89
         Kompass_present = 255;
74
    {
90
         Kompass_Value_Old      =       KompassValue;
-
 
91
     KompassValue = cntKompass -KOMPASS_OFFSET;
-
 
92
 
-
 
93
         if (KompassValue < 0)
-
 
94
         {
-
 
95
                KompassValue += 360;
-
 
96
         }
-
 
97
         if (KompassValue >= 360)
-
 
98
         {
-
 
99
                KompassValue -= 360;
-
 
100
         }     
75
     KompassValue = cntKompass;
101
 // Salvo End  
76
    }
102
    }
77
//     if(cntKompass < 10) cntKompass = 10;
103
//     if(cntKompass < 10) cntKompass = 10;
78
//     KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L;
104
//     KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L;
-
 
105
     KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
-
 
106
//Salvo 13.9.2007 Ok Erkennung des Magnetkompasses 
-
 
107
         Kompass_Neuer_Wert     = 1;
79
     KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
108
 // Salvo End
80
    cntKompass = 0;
109
     cntKompass = 0;
81
   }
110
   }
82
 }
111
 }