Rev 2309 | Rev 2367 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2309 | Rev 2316 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | volatile int VarioMeter = 0; |
67 | volatile int VarioMeter = 0; |
68 | volatile unsigned int ZaehlMessungen = 0; |
68 | volatile unsigned int ZaehlMessungen = 0; |
69 | unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115; |
69 | unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115; |
70 | volatile unsigned char AdReady = 1; |
70 | volatile unsigned char AdReady = 1; |
71 | volatile long HoehenWertF = 0; |
71 | volatile long HoehenWertF = 0; |
72 | volatile long VerticalVelocity; |
- | |
Line 73... | Line 72... | ||
73 | 72 | ||
74 | //####################################################################################### |
73 | //####################################################################################### |
75 | void ADC_Init(void) |
74 | void ADC_Init(void) |
76 | //####################################################################################### |
75 | //####################################################################################### |
Line 186... | Line 185... | ||
186 | // |
185 | // |
187 | ISR(ADC_vect) |
186 | ISR(ADC_vect) |
188 | //####################################################################################### |
187 | //####################################################################################### |
189 | { |
188 | { |
190 | static unsigned char kanal=0,state = 0; |
189 | static unsigned char kanal=0,state = 0; |
191 | static signed char subcount = 0; |
190 | static signed int subcount = 0; |
192 | static signed int gier1, roll1, nick1, nick_filter, roll_filter; |
191 | static signed int gier1, roll1, nick1, nick_filter, roll_filter; |
193 | static signed int accy, accx; |
192 | static signed int accy, accx; |
194 | static long tmpLuftdruck = 0; |
193 | static long tmpLuftdruck = 0; |
195 | static char messanzahl_Druck = 0; |
194 | static char messanzahl_Druck = 0; |
196 | switch(state++) |
195 | switch(state++) |
Line 233... | Line 232... | ||
233 | UBat = (3 * UBat + ADC / 3) / 4; |
232 | UBat = (3 * UBat + ADC / 3) / 4; |
234 | kanal = AD_ACC_Z; |
233 | kanal = AD_ACC_Z; |
235 | break; |
234 | break; |
236 | case 8: |
235 | case 8: |
237 | Aktuell_az = ADC; |
236 | Aktuell_az = ADC; |
238 | AdWertAccHoch = Aktuell_az - NeutralAccZ; |
237 | AdWertAccHoch = Aktuell_az - NeutralAccZ - (int) NeutralAccZfine; |
239 | if(!ACC_AltitudeControl) // The Offset must be corrected, because of the ACC-Drift from vibrations |
238 | if(!ACC_AltitudeControl) // The Offset must be corrected, because of the ACC-Drift from vibrations |
240 | { |
239 | { |
241 | if(AdWertAccHoch > 1) |
240 | if(AdWertAccHoch > 1) |
242 | { |
241 | { |
243 | if(NeutralAccZ < 750) |
242 | if(NeutralAccZ < 750) |
244 | { |
243 | { |
245 | subcount += 5; |
244 | subcount += 5; |
246 | if(modell_fliegt < 500) subcount += 10; |
245 | if(modell_fliegt < 500) subcount += 10; |
- | 246 | if(subcount > 100) { NeutralAccZ++; subcount -= 100;} |
|
247 | } |
247 | } |
248 | if(subcount > 100) { NeutralAccZ++; subcount -= 100;} |
- | |
249 | } |
248 | } |
250 | else if(AdWertAccHoch < -1) |
249 | else if(AdWertAccHoch < -1) |
251 | { |
250 | { |
252 | if(NeutralAccZ > 550) |
251 | if(NeutralAccZ > 550) |
253 | { |
252 | { |
Line 255... | Line 254... | ||
255 | if(modell_fliegt < 500) subcount -= 10; |
254 | if(modell_fliegt < 500) subcount -= 10; |
256 | if(subcount < -100) { NeutralAccZ--; subcount += 100;} |
255 | if(subcount < -100) { NeutralAccZ--; subcount += 100;} |
257 | } |
256 | } |
258 | } |
257 | } |
259 | } |
258 | } |
- | 259 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
|
- | 260 | else |
|
- | 261 | if(CosAttitude > 8192 - 50) // horizontal leveled within 6° |
|
- | 262 | { |
|
- | 263 | if(AdWertAccHoch > 1) |
|
- | 264 | { |
|
- | 265 | if(++subcount > 5000) |
|
- | 266 | { |
|
- | 267 | if(NeutralAccZfine < 6) NeutralAccZfine++; |
|
- | 268 | subcount -= 5000; |
|
- | 269 | } |
|
- | 270 | } |
|
- | 271 | else |
|
- | 272 | if(AdWertAccHoch < -1) |
|
- | 273 | { |
|
- | 274 | if(--subcount < -5000) |
|
- | 275 | { |
|
- | 276 | if(NeutralAccZfine > -6) NeutralAccZfine--; |
|
- | 277 | subcount += 5000; |
|
- | 278 | } |
|
- | 279 | } |
|
- | 280 | } |
|
- | 281 | #endif |
|
260 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
282 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
261 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
283 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
262 | kanal = AD_DRUCK; |
284 | kanal = AD_DRUCK; |
263 | break; |
285 | break; |
264 | // "case 9:" fehlt hier absichtlich |
286 | // "case 9:" fehlt hier absichtlich |
Line 307... | Line 329... | ||
307 | break; |
329 | break; |
308 | case 17: |
330 | case 17: |
309 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
331 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
310 | if(ACC_AltitudeControl) |
332 | if(ACC_AltitudeControl) |
311 | { |
333 | { |
312 | HoehenWertF = (ACC_AltitudeFusion() + SA_FILTER/2)/SA_FILTER; // cm |
334 | HoehenWertF = (ACC_AltitudeFusion(0) + SA_FILTER/2)/SA_FILTER; // cm |
313 | } |
335 | } |
314 | else HoehenWertF = HoehenWert; |
336 | else HoehenWertF = HoehenWert; |
315 | #else |
337 | #else |
316 | HoehenWertF = HoehenWert; |
338 | HoehenWertF = HoehenWert; |
317 | #endif |
339 | #endif |
Line 327... | Line 349... | ||
327 | { |
349 | { |
328 | tmpLuftdruck = MessLuftdruck - 523 * (long)ExpandBaro; // -523 counts per offset step |
350 | tmpLuftdruck = MessLuftdruck - 523 * (long)ExpandBaro; // -523 counts per offset step |
329 | Luftdruck -= Luftdruck/16; |
351 | Luftdruck -= Luftdruck/16; |
330 | Luftdruck += tmpLuftdruck; |
352 | Luftdruck += tmpLuftdruck; |
331 | HoehenWert = StartLuftdruck - Luftdruck; // cm |
353 | HoehenWert = StartLuftdruck - Luftdruck; // cm |
332 | HoehenWert = HoehenWert + AdWertAccHoch * 41 / 256; // Weight-compsensation <------- |
- | |
333 | } |
354 | } |
334 | else |
355 | else |
335 | #endif |
356 | #endif |
336 | { // old version (until FC V2.1) |
357 | { // old version (until FC V2.1) |
337 | tmpLuftdruck += MessLuftdruck; |
358 | tmpLuftdruck += MessLuftdruck; |