Subversion Repositories FlightCtrl

Rev

Rev 1134 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1134 Rev 1154
Line 4... Line 4...
4
// + www.MikroKopter.com
4
// + www.MikroKopter.com
5
// + see the File "License.txt" for further Informations
5
// + see the File "License.txt" for further Informations
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 7... Line 7...
7
 
7
 
-
 
8
#include "main.h"
Line 8... Line 9...
8
#include "main.h"
9
#include "parameter.h"
9
 
10
 
10
volatile int  Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100;
11
volatile int  Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100;
11
volatile int  AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0;
12
volatile int  AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0;
12
volatile int  AdWertAccRoll = 0,AdWertAccNick = 0,AdWertAccHoch = 0;
13
volatile int  AdWertAccRoll = 0,AdWertAccNick = 0,AdWertAccHoch = 0;
13
volatile char MessanzahlNick = 0, MessanzahlRoll = 0, MessanzahlGier = 0;
14
volatile char MessanzahlNick = 0, MessanzahlRoll = 0, MessanzahlGier = 0;
14
volatile char messanzahl_AccNick = 0, messanzahl_AccRoll = 0, messanzahl_AccHoch = 0;
15
volatile char messanzahl_AccNick = 0, messanzahl_AccRoll = 0, messanzahl_AccHoch = 0;
15
volatile long Luftdruck = 32000;
16
volatile long Luftdruck = 32000;
16
volatile int  StartLuftdruck;
17
volatile int  StartLuftdruck;
17
volatile unsigned int  MessLuftdruck = 1023;
-
 
18
unsigned char DruckOffsetSetting;
18
volatile unsigned int  MessLuftdruck = 1023;
19
signed char ExpandBaro = 0;
19
unsigned char DruckOffsetSetting;
20
volatile int HoeheD = 0;
20
volatile int HoeheD = 0;
21
volatile char messanzahl_Druck;
21
volatile char messanzahl_Druck;
22
volatile int  tmpLuftdruck;
22
volatile int  tmpLuftdruck;
23
volatile unsigned int ZaehlMessungen = 0;
23
volatile unsigned int ZaehlMessungen = 0;
24
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115;
-
 
25
unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0;
-
 
26
 
-
 
27
int airPressure = 0;
-
 
28
 
24
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115;
29
 
25
unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0;
30
//#######################################################################################
26
//#######################################################################################
31
//
27
//
32
void ADC_Init(void)
28
void ADC_Init(void)
Line 41... Line 37...
41
{
37
{
42
 unsigned int off;
38
 unsigned int off;
43
 off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]);
39
 off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]);
44
 if(off > 20) off -= 10;
40
 if(off > 20) off -= 10;
45
 OCR0A = off;
41
 OCR0A = off;
46
 ExpandBaro = 0;
-
 
47
 Delay_ms_Mess(100);
42
 Delay_ms_Mess(100);
48
 if(MessLuftdruck < 850) off = 0;
43
 if(MessLuftdruck < 850) off = 0;
49
 for(; off < 250;off++)
44
 for(; off < 250;off++)
50
  {
45
  {
51
  OCR0A = off;
46
  OCR0A = off;
52
  Delay_ms_Mess(50);
47
  Delay_ms_Mess(50);
53
  printf(".");  
48
  printf(".");  
54
  if(MessLuftdruck < 850) break;
49
  if(MessLuftdruck < 900) break;
55
  }
50
  }
56
 eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off);
51
 eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off);
57
 DruckOffsetSetting = off;
52
 DruckOffsetSetting = off;
58
 Delay_ms_Mess(300);
53
 Delay_ms_Mess(300);
59
}
54
}
Line 121... Line 116...
121
            AdWertAccNick =  Aktuell_ax;
116
            AdWertAccNick =  Aktuell_ax;
122
                    kanal = 0;
117
                    kanal = 0;
123
            break;
118
            break;
124
        case 6:
119
        case 6:
125
            if(PlatinenVersion == 10)  AdWertGier = (ADC + gier1) / 2;
120
            if(PlatinenVersion == 10)  AdWertGier = (ADC + gier1) / 2;
126
            else
-
 
127
            if(PlatinenVersion == 20)  AdWertGier = 1023 - (ADC + gier1);
-
 
128
                        else                                       AdWertGier = ADC + gier1;
121
                        else                                       AdWertGier = ADC + gier1;
129
            kanal = 1;
122
            kanal = 1;
130
            break;
123
            break;
131
        case 7:
124
        case 7:
132
            if(PlatinenVersion == 10)  AdWertRoll = (ADC + roll1) / 2;
125
            if(PlatinenVersion == 10)  AdWertRoll = (ADC + roll1) / 2;
Line 165... Line 158...
165
            Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen
158
            Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen
166
                kanal = 3;
159
                kanal = 3;
167
            break;
160
            break;
168
        case 10:
161
        case 10:
169
            tmpLuftdruck += ADC;
162
            tmpLuftdruck += ADC;
170
            if(++messanzahl_Druck >= 5) {
163
            if(++messanzahl_Druck >= 5)
-
 
164
                {
171
                MessLuftdruck = ADC;
165
                MessLuftdruck = ADC;
172
                messanzahl_Druck = 0;
166
                messanzahl_Druck = 0;
173
               
-
 
-
 
167
                                HoeheD = (7 * HoeheD + (int) PARAM_ALT_D * (int)(StartLuftdruck - tmpLuftdruck - HoehenWert))/8;  // D-Anteil = neuerWert - AlterWert
174
                Luftdruck = (tmpLuftdruck + 3 * Luftdruck) / 4;
168
                Luftdruck = (tmpLuftdruck + 3 * Luftdruck) / 4;
175
                airPressure = StartLuftdruck - Luftdruck;
169
                HoehenWert = StartLuftdruck - Luftdruck;
176
                tmpLuftdruck = 0;
170
                tmpLuftdruck = 0;
177
               
-
 
178
                DebugOut.Analog[5] = airPressure;
-
 
179
            }
171
                }
180
           
-
 
181
            kanal = 0;
172
            kanal = 0;
182
            state = 0;
173
            state = 0;
183
            break;
174
            break;
184
        default:
175
        default:
185
            kanal = 0;
176
            kanal = 0;