Rev 528 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 528 | Rev 529 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | #include "main.h" |
8 | #include "main.h" |
9 | 9 | ||
10 | volatile int Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100; |
10 | volatile int Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100; |
11 | volatile int AccumulateNick = 0, AccumulateRoll = 0, AccumulateGier = 0; |
11 | volatile int AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0; |
12 | volatile int accumulate_AccRoll = 0,accumulate_AccNick = 0,accumulate_AccHoch = 0; |
12 | volatile int AdWertAccRoll = 0,AdWertAccNick = 0,AdWertAccHoch = 0; |
13 | volatile char MessanzahlNick = 0, MessanzahlRoll = 0, MessanzahlGier = 0; |
13 | volatile char MessanzahlNick = 0, MessanzahlRoll = 0, MessanzahlGier = 0; |
14 | volatile char messanzahl_AccNick = 0, messanzahl_AccRoll = 0, messanzahl_AccHoch = 0; |
14 | volatile char messanzahl_AccNick = 0, messanzahl_AccRoll = 0, messanzahl_AccHoch = 0; |
15 | volatile long Luftdruck = 32000; |
15 | volatile long Luftdruck = 32000; |
Line 35... | Line 35... | ||
35 | { |
35 | { |
36 | unsigned int off; |
36 | unsigned int off; |
37 | off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]); |
37 | off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]); |
38 | if(off > 20) off -= 10; |
38 | if(off > 20) off -= 10; |
39 | OCR0A = off; |
39 | OCR0A = off; |
40 | Delay_ms(100); |
40 | Delay_ms_Mess(100); |
41 | if(MessLuftdruck < 850) off = 0; |
41 | if(MessLuftdruck < 850) off = 0; |
42 | for(; off < 250;off++) |
42 | for(; off < 250;off++) |
43 | { |
43 | { |
44 | OCR0A = off; |
44 | OCR0A = off; |
45 | Delay_ms(50); |
45 | Delay_ms_Mess(50); |
46 | printf("."); |
46 | printf("."); |
47 | if(MessLuftdruck < 900) break; |
47 | if(MessLuftdruck < 900) break; |
48 | } |
48 | } |
49 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off); |
49 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off); |
50 | DruckOffsetSetting = off; |
50 | DruckOffsetSetting = off; |
51 | Delay_ms(300); |
51 | Delay_ms_Mess(300); |
52 | } |
52 | } |
Line 53... | Line 53... | ||
53 | 53 | ||
54 | 54 | ||
55 | //####################################################################################### |
55 | //####################################################################################### |
56 | // |
56 | // |
57 | SIGNAL(SIG_ADC) |
57 | SIGNAL(SIG_ADC) |
58 | //####################################################################################### |
58 | //####################################################################################### |
59 | { |
59 | { |
60 | static unsigned char kanal=0,state = 0; |
60 | static unsigned char kanal=0,state = 0; |
61 | signed int wert; |
61 | static unsigned int gier1, roll1, nick1; |
62 | ANALOG_OFF; |
62 | ANALOG_OFF; |
63 | switch(state++) |
63 | switch(state++) |
64 | { |
- | |
65 | case 0: |
- | |
66 | wert = (signed int) AdNeutralGier - ADC; |
- | |
67 | if(PlatinenVersion != 10) wert *= 2; |
64 | { |
68 | AccumulateGier += wert; // |
- | |
69 | MessanzahlGier++; |
- | |
70 | Mess_Integral_Gier += wert;// / 16; |
- | |
71 | Mess_Integral_Gier2 += wert; |
65 | case 0: |
72 | GyroKomp_Int += wert; |
66 | gier1 = ADC; |
73 | kanal = 1; |
67 | kanal = 1; |
74 | ZaehlMessungen++; |
68 | ZaehlMessungen++; |
75 | break; |
- | |
76 | case 1: |
- | |
77 | wert = (signed int) ADC - AdNeutralRoll; |
- | |
78 | if(PlatinenVersion != 10) wert *= 2; |
- | |
79 | Mess_IntegralRoll += wert; |
- | |
80 | Mess_IntegralRoll2 += wert; |
- | |
81 | if(Mess_IntegralRoll > 310000L) Mess_IntegralRoll = -290000L; |
- | |
82 | if(Mess_IntegralRoll <-310000L) Mess_IntegralRoll = 290000L; |
- | |
83 | if(ADC < 15) wert = -1000; |
- | |
84 | if(ADC < 7) wert = -2000; |
- | |
85 | if(ADC > 1010) wert = +1000; |
69 | break; |
86 | if(ADC > 1017) wert = +2000; |
- | |
87 | AccumulateRoll += wert; |
70 | case 1: |
88 | MessanzahlRoll++; |
71 | roll1 = ADC; |
89 | kanal = 2; |
72 | kanal = 2; |
90 | break; |
- | |
91 | case 2: |
- | |
92 | wert = (signed int) ADC - AdNeutralNick; |
- | |
93 | if(PlatinenVersion != 10) wert *= 2; |
- | |
94 | Mess_IntegralNick += wert; |
- | |
95 | Mess_IntegralNick2 += wert; |
- | |
96 | if(Mess_IntegralNick > 310000L) Mess_IntegralNick = -290000L; |
- | |
97 | if(Mess_IntegralNick <-310000L) Mess_IntegralNick = 290000L; |
- | |
98 | if(ADC < 15) wert = -1000; |
- | |
99 | if(ADC < 7) wert = -2000; |
- | |
100 | if(ADC > 1010) wert = +1000; |
- | |
101 | if(ADC > 1017) wert = +2000; |
73 | break; |
102 | AccumulateNick += wert; |
74 | case 2: |
103 | MessanzahlNick++; |
75 | nick1 = ADC; |
104 | kanal = 4; |
76 | kanal = 4; |
105 | break; |
77 | break; |
106 | case 3: |
78 | case 3: |
107 | UBat = (3 * UBat + ADC / 3) / 4;//(UBat + ((ADC * 39) / 256) + 19) / 2; |
79 | UBat = (3 * UBat + ADC / 3) / 4;//(UBat + ((ADC * 39) / 256) + 19) / 2; |
108 | kanal = 6; |
80 | kanal = 6; |
109 | break; |
81 | break; |
110 | case 4: |
82 | case 4: |
111 | Aktuell_ay = NeutralAccY - ADC; |
- | |
112 | accumulate_AccRoll += Aktuell_ay; |
83 | Aktuell_ay = NeutralAccY - ADC; |
113 | messanzahl_AccRoll++; |
84 | AdWertAccRoll = Aktuell_ay; |
114 | kanal = 7; |
85 | kanal = 7; |
115 | break; |
86 | break; |
116 | case 5: |
87 | case 5: |
117 | Aktuell_ax = ADC - NeutralAccX; |
- | |
118 | accumulate_AccNick += Aktuell_ax; |
88 | Aktuell_ax = ADC - NeutralAccX; |
119 | messanzahl_AccNick++; |
- | |
120 | kanal = 5; |
89 | AdWertAccNick = Aktuell_ax; |
121 | state = 6; |
90 | kanal = 0; |
- | 91 | break; |
|
- | 92 | case 6: |
|
- | 93 | if(PlatinenVersion == 10) AdWertGier = (ADC + gier1) / 2; |
|
- | 94 | else AdWertGier = ADC + gier1; |
|
- | 95 | kanal = 1; |
|
- | 96 | break; |
|
- | 97 | case 7: |
|
- | 98 | if(PlatinenVersion == 10) AdWertRoll = (ADC + roll1) / 2; |
|
- | 99 | else AdWertRoll = ADC + roll1; |
|
- | 100 | kanal = 2; |
|
- | 101 | break; |
|
- | 102 | case 8: |
|
- | 103 | if(PlatinenVersion == 10) AdWertNick = (ADC + nick1) / 2; |
|
- | 104 | else AdWertNick = ADC + nick1; |
|
- | 105 | kanal = 5; |
|
122 | break; |
106 | break; |
123 | case 6: |
107 | case 9: |
124 | accumulate_AccHoch = (signed int) ADC - NeutralAccZ; |
108 | AdWertAccHoch = (signed int) ADC - NeutralAccZ; |
125 | accumulate_AccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4; |
109 | AdWertAccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4; |
126 | if(accumulate_AccHoch > 1) |
110 | if(AdWertAccHoch > 1) |
127 | { |
111 | { |
128 | if(NeutralAccZ < 800) NeutralAccZ+= 0.02; |
112 | if(NeutralAccZ < 800) NeutralAccZ+= 0.02; |
129 | } |
113 | } |
130 | else if(accumulate_AccHoch < -1) |
114 | else if(AdWertAccHoch < -1) |
131 | { |
115 | { |
132 | if(NeutralAccZ > 600) NeutralAccZ-= 0.02; |
116 | if(NeutralAccZ > 600) NeutralAccZ-= 0.02; |
133 | } |
117 | } |
134 | messanzahl_AccHoch = 1; |
118 | messanzahl_AccHoch = 1; |
135 | Aktuell_az = ADC; |
119 | Aktuell_az = ADC; |
136 | Mess_Integral_Hoch += accumulate_AccHoch; // Integrieren |
- | |
137 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
- | |
138 | // Mess_Integral_Hoch -= Mess_Integral_Hoch / 512; // dämfen |
- | |
139 | /* if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
120 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
140 | { |
- | |
141 | kanal = 3; |
- | |
142 | state = 7; |
- | |
143 | } |
- | |
144 | else |
- | |
145 | { |
- | |
146 | kanal = 0; |
- | |
147 | state = 0; |
- | |
148 | }*/ |
- | |
149 | kanal = 3; |
121 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
150 | state = 7; |
122 | kanal = 3; |
151 | break; |
123 | break; |
152 | case 7: |
124 | case 10: |
153 | tmpLuftdruck += ADC; |
125 | tmpLuftdruck += ADC; |
154 | if(++messanzahl_Druck >= 5) |
126 | if(++messanzahl_Druck >= 5) |
155 | { |
127 | { |
Line 167... | Line 139... | ||
167 | kanal = 0; |
139 | kanal = 0; |
168 | state = 0; |
140 | state = 0; |
169 | break; |
141 | break; |
170 | } |
142 | } |
171 | ADMUX = kanal; |
143 | ADMUX = kanal; |
172 | ANALOG_ON; |
144 | if(state != 0) ANALOG_ON; |
173 | } |
145 | } |