Rev 1638 | Rev 1643 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1338 | ingob | 2 | // + Copyright (c) Holger Buss, Ingo Busker |
1 | ingob | 3 | // + only for non-profit use |
4 | // + www.MikroKopter.com |
||
1356 | hbuss | 5 | // + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
1 | ingob | 6 | // + see the File "License.txt" for further Informations |
7 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
8 | |||
9 | #include "main.h" |
||
1622 | killagreg | 10 | #include "eeprom.h" |
1 | ingob | 11 | volatile int Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100; |
1166 | hbuss | 12 | volatile int AdWertNickFilter = 0, AdWertRollFilter = 0, AdWertGierFilter = 0; |
13 | volatile int HiResNick = 2500, HiResRoll = 2500; |
||
380 | hbuss | 14 | volatile int AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0; |
15 | volatile int AdWertAccRoll = 0,AdWertAccNick = 0,AdWertAccHoch = 0; |
||
1166 | hbuss | 16 | volatile char messanzahl_AccHoch = 0; |
1 | ingob | 17 | volatile long Luftdruck = 32000; |
1322 | hbuss | 18 | volatile long SummenHoehe = 0; |
1 | ingob | 19 | volatile int StartLuftdruck; |
20 | volatile unsigned int MessLuftdruck = 1023; |
||
21 | unsigned char DruckOffsetSetting; |
||
1036 | hbuss | 22 | signed char ExpandBaro = 0; |
1253 | killagreg | 23 | volatile int VarioMeter = 0; |
1 | ingob | 24 | volatile unsigned int ZaehlMessungen = 0; |
918 | hbuss | 25 | unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115; |
26 | unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0; |
||
1168 | hbuss | 27 | volatile unsigned char AdReady = 1; |
1 | ingob | 28 | //####################################################################################### |
29 | // |
||
30 | void ADC_Init(void) |
||
31 | //####################################################################################### |
||
1246 | killagreg | 32 | { |
1 | ingob | 33 | ADMUX = 0;//Referenz ist extern |
1155 | hbuss | 34 | ANALOG_ON; |
1 | ingob | 35 | } |
36 | |||
1352 | hbuss | 37 | #define DESIRED_H_ADC 800 |
1322 | hbuss | 38 | |
1 | ingob | 39 | void SucheLuftruckOffset(void) |
40 | { |
||
41 | unsigned int off; |
||
1622 | killagreg | 42 | off = GetParamByte(PID_PRESSURE_OFFSET); |
173 | holgerb | 43 | if(off > 20) off -= 10; |
44 | OCR0A = off; |
||
1036 | hbuss | 45 | ExpandBaro = 0; |
380 | hbuss | 46 | Delay_ms_Mess(100); |
1322 | hbuss | 47 | if(MessLuftdruck < DESIRED_H_ADC) off = 0; |
173 | holgerb | 48 | for(; off < 250;off++) |
1 | ingob | 49 | { |
50 | OCR0A = off; |
||
380 | hbuss | 51 | Delay_ms_Mess(50); |
1246 | killagreg | 52 | printf("."); |
1322 | hbuss | 53 | if(MessLuftdruck < DESIRED_H_ADC) break; |
1 | ingob | 54 | } |
1622 | killagreg | 55 | SetParamByte(PID_PRESSURE_OFFSET, off); |
173 | holgerb | 56 | DruckOffsetSetting = off; |
1638 | holgerb | 57 | OCR0A = off; |
380 | hbuss | 58 | Delay_ms_Mess(300); |
1638 | holgerb | 59 | |
1 | ingob | 60 | } |
61 | |||
918 | hbuss | 62 | void SucheGyroOffset(void) |
63 | { |
||
64 | unsigned char i, ready = 0; |
||
1219 | hbuss | 65 | int timeout; |
918 | hbuss | 66 | GyroDefektN = 0; GyroDefektR = 0; GyroDefektG = 0; |
1219 | hbuss | 67 | timeout = SetDelay(2000); |
918 | hbuss | 68 | for(i=140; i != 0; i--) |
69 | { |
||
921 | hbuss | 70 | if(ready == 3 && i > 10) i = 9; |
918 | hbuss | 71 | ready = 0; |
72 | if(AdWertNick < 1020) AnalogOffsetNick--; else if(AdWertNick > 1030) AnalogOffsetNick++; else ready++; |
||
73 | if(AdWertRoll < 1020) AnalogOffsetRoll--; else if(AdWertRoll > 1030) AnalogOffsetRoll++; else ready++; |
||
74 | if(AdWertGier < 1020) AnalogOffsetGier--; else if(AdWertGier > 1030) AnalogOffsetGier++; else ready++; |
||
1638 | holgerb | 75 | twi_state = 18; |
1639 | holgerb | 76 | I2C_Start(); |
1246 | killagreg | 77 | if(AnalogOffsetNick < 10) { GyroDefektN = 1; AnalogOffsetNick = 10;}; if(AnalogOffsetNick > 245) { GyroDefektN = 1; AnalogOffsetNick = 245;}; |
78 | if(AnalogOffsetRoll < 10) { GyroDefektR = 1; AnalogOffsetRoll = 10;}; if(AnalogOffsetRoll > 245) { GyroDefektR = 1; AnalogOffsetRoll = 245;}; |
||
79 | if(AnalogOffsetGier < 10) { GyroDefektG = 1; AnalogOffsetGier = 10;}; if(AnalogOffsetGier > 245) { GyroDefektG = 1; AnalogOffsetGier = 245;}; |
||
1219 | hbuss | 80 | while(twi_state) if(CheckDelay(timeout)) {printf("\n\r DAC or I2C ERROR! Check I2C, 3Vref, DAC and BL-Ctrl"); break;} |
1253 | killagreg | 81 | AdReady = 0; |
918 | hbuss | 82 | ANALOG_ON; |
1253 | killagreg | 83 | while(!AdReady); |
1246 | killagreg | 84 | if(i<10) Delay_ms_Mess(10); |
918 | hbuss | 85 | } |
1246 | killagreg | 86 | Delay_ms_Mess(70); |
87 | } |
||
1 | ingob | 88 | |
1171 | hbuss | 89 | /* |
90 | |||
91 | 1 r |
||
1246 | killagreg | 92 | 2 g |
1171 | hbuss | 93 | 3 y |
94 | 4 x |
||
95 | 5 n |
||
96 | 6 r |
||
97 | 7 u |
||
98 | 8 z |
||
99 | 9 L |
||
1246 | killagreg | 100 | 10 n |
1171 | hbuss | 101 | 11 r |
102 | 12 g |
||
103 | 13 y |
||
104 | 14 x |
||
105 | 15 n |
||
106 | 16 r |
||
107 | 17 L |
||
108 | */ |
||
109 | |||
1 | ingob | 110 | //####################################################################################### |
111 | // |
||
1561 | killagreg | 112 | ISR(ADC_vect) |
1 | ingob | 113 | //####################################################################################### |
114 | { |
||
115 | static unsigned char kanal=0,state = 0; |
||
1246 | killagreg | 116 | static signed int gier1, roll1, nick1, nick_filter, roll_filter; |
1639 | holgerb | 117 | static signed int accy, accx,subcount = 0; |
1253 | killagreg | 118 | |
119 | static long tmpLuftdruck = 0; |
||
120 | static char messanzahl_Druck = 0; |
||
1171 | hbuss | 121 | switch(state++) |
122 | { |
||
123 | case 0: |
||
124 | nick1 = ADC; |
||
125 | kanal = AD_ROLL; |
||
126 | break; |
||
127 | case 1: |
||
128 | roll1 = ADC; |
||
129 | kanal = AD_GIER; |
||
130 | break; |
||
131 | case 2: |
||
132 | gier1 = ADC; |
||
133 | kanal = AD_ACC_Y; |
||
134 | break; |
||
135 | case 3: |
||
136 | Aktuell_ay = NeutralAccY - ADC; |
||
137 | accy = Aktuell_ay; |
||
138 | kanal = AD_ACC_X; |
||
139 | break; |
||
140 | case 4: |
||
141 | Aktuell_ax = ADC - NeutralAccX; |
||
142 | accx = Aktuell_ax; |
||
143 | kanal = AD_NICK; |
||
144 | break; |
||
145 | case 5: |
||
146 | nick1 += ADC; |
||
147 | kanal = AD_ROLL; |
||
148 | break; |
||
149 | case 6: |
||
150 | roll1 += ADC; |
||
151 | kanal = AD_UBAT; |
||
152 | break; |
||
153 | case 7: |
||
154 | UBat = (3 * UBat + ADC / 3) / 4; |
||
155 | kanal = AD_ACC_Z; |
||
156 | break; |
||
157 | case 8: |
||
158 | AdWertAccHoch = (signed int) ADC - NeutralAccZ; |
||
1246 | killagreg | 159 | if(AdWertAccHoch > 1) |
1171 | hbuss | 160 | { |
1246 | killagreg | 161 | if(NeutralAccZ < 750) |
1171 | hbuss | 162 | { |
1639 | holgerb | 163 | subcount += 2; |
164 | if(modell_fliegt < 500) subcount += 100; |
||
165 | } |
||
166 | if(subcount > 1000) { NeutralAccZ++; subcount -= 1000;} |
||
167 | } |
||
168 | else if(AdWertAccHoch < -1) |
||
169 | { |
||
170 | if(NeutralAccZ > 550) |
||
171 | { |
||
172 | subcount -= 2; |
||
173 | if(modell_fliegt < 500) subcount -= 100; |
||
174 | if(subcount < -1000) { NeutralAccZ--; subcount += 1000;} |
||
175 | } |
||
176 | } |
||
177 | messanzahl_AccHoch = 1; |
||
178 | Aktuell_az = ADC; |
||
179 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
||
180 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
||
181 | |||
182 | /* |
||
183 | AdWertAccHoch = (signed int) ADC - NeutralAccZ; |
||
184 | if(AdWertAccHoch > 1) |
||
185 | { |
||
186 | if(NeutralAccZ < 750) |
||
187 | { |
||
1246 | killagreg | 188 | NeutralAccZ += 0.02; |
189 | if(modell_fliegt < 500) NeutralAccZ += 0.1; |
||
190 | } |
||
191 | } |
||
1171 | hbuss | 192 | else if(AdWertAccHoch < -1) |
193 | { |
||
1246 | killagreg | 194 | if(NeutralAccZ > 550) |
1171 | hbuss | 195 | { |
196 | NeutralAccZ-= 0.02; |
||
1246 | killagreg | 197 | if(modell_fliegt < 500) NeutralAccZ -= 0.1; |
198 | } |
||
199 | } |
||
1171 | hbuss | 200 | messanzahl_AccHoch = 1; |
201 | Aktuell_az = ADC; |
||
202 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
||
203 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
||
1639 | holgerb | 204 | */ |
1171 | hbuss | 205 | kanal = AD_DRUCK; |
206 | break; |
||
207 | // "case 8:" fehlt hier absichtlich |
||
208 | case 10: |
||
209 | nick1 += ADC; |
||
210 | kanal = AD_ROLL; |
||
211 | break; |
||
212 | case 11: |
||
213 | roll1 += ADC; |
||
214 | kanal = AD_GIER; |
||
215 | break; |
||
216 | case 12: |
||
217 | if(PlatinenVersion == 10) AdWertGier = (ADC + gier1 + 1) / 2; |
||
1246 | killagreg | 218 | else |
1171 | hbuss | 219 | if(PlatinenVersion == 20) AdWertGier = 2047 - (ADC + gier1); |
220 | else AdWertGier = (ADC + gier1); |
||
221 | kanal = AD_ACC_Y; |
||
222 | break; |
||
223 | case 13: |
||
224 | Aktuell_ay = NeutralAccY - ADC; |
||
225 | AdWertAccRoll = (Aktuell_ay + accy); |
||
226 | kanal = AD_ACC_X; |
||
227 | break; |
||
228 | case 14: |
||
229 | Aktuell_ax = ADC - NeutralAccX; |
||
230 | AdWertAccNick = (Aktuell_ax + accx); |
||
231 | kanal = AD_NICK; |
||
232 | break; |
||
233 | case 15: |
||
234 | nick1 += ADC; |
||
1173 | hbuss | 235 | if(PlatinenVersion == 10) nick1 *= 2; else nick1 *= 4; |
236 | AdWertNick = nick1 / 8; |
||
237 | nick_filter = (nick_filter + nick1) / 2; |
||
238 | HiResNick = nick_filter - AdNeutralNick; |
||
1171 | hbuss | 239 | AdWertNickFilter = (AdWertNickFilter + HiResNick) / 2; |
240 | kanal = AD_ROLL; |
||
241 | break; |
||
242 | case 16: |
||
243 | roll1 += ADC; |
||
1173 | hbuss | 244 | if(PlatinenVersion == 10) roll1 *= 2; else roll1 *= 4; |
245 | AdWertRoll = roll1 / 8; |
||
246 | roll_filter = (roll_filter + roll1) / 2; |
||
247 | HiResRoll = roll_filter - AdNeutralRoll; |
||
1171 | hbuss | 248 | AdWertRollFilter = (AdWertRollFilter + HiResRoll) / 2; |
249 | kanal = AD_DRUCK; |
||
250 | break; |
||
251 | case 17: |
||
252 | state = 0; |
||
253 | AdReady = 1; |
||
254 | ZaehlMessungen++; |
||
255 | // "break" fehlt hier absichtlich |
||
256 | case 9: |
||
1253 | killagreg | 257 | MessLuftdruck = ADC; |
258 | tmpLuftdruck += MessLuftdruck; |
||
259 | if(++messanzahl_Druck >= 18) |
||
260 | { |
||
1266 | killagreg | 261 | Luftdruck = (7 * Luftdruck + tmpLuftdruck - (18 * 523) * (long)ExpandBaro + 4) / 8; // -523.19 counts per 10 counts offset step |
1253 | killagreg | 262 | HoehenWert = StartLuftdruck - Luftdruck; |
1272 | hbuss | 263 | SummenHoehe -= SummenHoehe/SM_FILTER; |
1253 | killagreg | 264 | SummenHoehe += HoehenWert; |
1272 | hbuss | 265 | VarioMeter = (15 * VarioMeter + 8 * (int)(HoehenWert - SummenHoehe/SM_FILTER))/16; |
266 | tmpLuftdruck /= 2; |
||
267 | messanzahl_Druck = 18/2; |
||
1253 | killagreg | 268 | } |
1171 | hbuss | 269 | kanal = AD_NICK; |
270 | break; |
||
1246 | killagreg | 271 | default: |
1171 | hbuss | 272 | kanal = 0; state = 0; kanal = AD_NICK; |
273 | break; |
||
1246 | killagreg | 274 | } |
1171 | hbuss | 275 | ADMUX = kanal; |
276 | if(state != 0) ANALOG_ON; |
||
1320 | hbuss | 277 | |
1171 | hbuss | 278 | } |
279 | |||
280 | |||
281 | |||
282 | /* |
||
283 | //####################################################################################### |
||
284 | // |
||
285 | SIGNAL(SIG_ADC) |
||
286 | //####################################################################################### |
||
287 | { |
||
288 | static unsigned char kanal=0,state = 0; |
||
1166 | hbuss | 289 | static signed int gier1, roll1, nick1; |
1246 | killagreg | 290 | static signed long nick_filter, roll_filter; |
1166 | hbuss | 291 | static signed int accy, accx; |
292 | switch(state++) |
||
293 | { |
||
294 | case 0: |
||
295 | nick1 = ADC; |
||
296 | kanal = AD_ROLL; |
||
297 | break; |
||
298 | case 1: |
||
299 | roll1 = ADC; |
||
300 | kanal = AD_GIER; |
||
301 | break; |
||
302 | case 2: |
||
303 | gier1 = ADC; |
||
304 | kanal = AD_ACC_Y; |
||
305 | break; |
||
306 | case 3: |
||
307 | Aktuell_ay = NeutralAccY - ADC; |
||
308 | accy = Aktuell_ay; |
||
309 | kanal = AD_NICK; |
||
310 | break; |
||
311 | case 4: |
||
312 | nick1 += ADC; |
||
313 | kanal = AD_ROLL; |
||
314 | break; |
||
315 | case 5: |
||
316 | roll1 += ADC; |
||
317 | kanal = AD_ACC_Z; |
||
318 | break; |
||
319 | case 6: |
||
320 | AdWertAccHoch = (signed int) ADC - NeutralAccZ; |
||
1246 | killagreg | 321 | if(AdWertAccHoch > 1) |
1166 | hbuss | 322 | { |
1246 | killagreg | 323 | if(NeutralAccZ < 750) |
1166 | hbuss | 324 | { |
1246 | killagreg | 325 | NeutralAccZ += 0.02; |
326 | if(modell_fliegt < 500) NeutralAccZ += 0.1; |
||
327 | } |
||
328 | } |
||
1166 | hbuss | 329 | else if(AdWertAccHoch < -1) |
330 | { |
||
1246 | killagreg | 331 | if(NeutralAccZ > 550) |
1166 | hbuss | 332 | { |
333 | NeutralAccZ-= 0.02; |
||
1246 | killagreg | 334 | if(modell_fliegt < 500) NeutralAccZ -= 0.1; |
335 | } |
||
336 | } |
||
1166 | hbuss | 337 | messanzahl_AccHoch = 1; |
338 | Aktuell_az = ADC; |
||
339 | Mess_Integral_Hoch += AdWertAccHoch; // Integrieren |
||
340 | Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen |
||
341 | kanal = AD_NICK; |
||
342 | break; |
||
343 | case 7: |
||
344 | nick1 += ADC; |
||
345 | kanal = AD_ROLL; |
||
346 | break; |
||
347 | case 8: |
||
348 | roll1 += ADC; |
||
349 | kanal = AD_ACC_X; |
||
350 | break; |
||
351 | case 9: |
||
352 | Aktuell_ax = ADC - NeutralAccX; |
||
353 | accx = Aktuell_ax; |
||
354 | kanal = AD_GIER; |
||
355 | break; |
||
356 | case 10: |
||
357 | gier1 += ADC; |
||
358 | kanal = AD_NICK; |
||
359 | break; |
||
360 | case 11: |
||
361 | nick1 += ADC; |
||
362 | kanal = AD_ROLL; |
||
363 | break; |
||
364 | case 12: |
||
365 | roll1 += ADC; |
||
366 | kanal = AD_UBAT; |
||
367 | break; |
||
368 | case 13: |
||
369 | UBat = (3 * UBat + ADC / 3) / 4;//(UBat + ((ADC * 39) / 256) + 19) / 2; |
||
370 | kanal = AD_ACC_Y; |
||
371 | break; |
||
372 | case 14: |
||
373 | Aktuell_ay = NeutralAccY - ADC; |
||
374 | accy += Aktuell_ay; |
||
375 | kanal = AD_NICK; |
||
376 | break; |
||
377 | case 15: |
||
378 | nick1 += ADC; |
||
379 | kanal = AD_ROLL; |
||
380 | break; |
||
381 | case 16: |
||
382 | roll1 += ADC; |
||
383 | kanal = AD_ACC_X; |
||
384 | break; |
||
385 | case 17: |
||
386 | Aktuell_ax = ADC - NeutralAccX; |
||
387 | accx += Aktuell_ax; |
||
388 | kanal = AD_NICK; |
||
389 | break; |
||
390 | case 18: |
||
391 | nick1 += ADC; |
||
392 | kanal = AD_ROLL; |
||
393 | break; |
||
394 | case 19: |
||
395 | roll1 += ADC; |
||
396 | kanal = AD_GIER; |
||
397 | break; |
||
398 | case 20: |
||
399 | gier1 += ADC; |
||
400 | kanal = AD_ACC_Y; |
||
401 | break; |
||
402 | case 21: |
||
403 | Aktuell_ay = NeutralAccY - ADC; |
||
404 | accy += Aktuell_ay; |
||
405 | kanal = AD_NICK; |
||
406 | break; |
||
407 | case 22: |
||
408 | nick1 += ADC; |
||
409 | kanal = AD_ROLL; |
||
410 | break; |
||
411 | case 23: |
||
412 | roll1 += ADC; |
||
413 | kanal = AD_DRUCK; |
||
414 | break; |
||
415 | case 24: |
||
416 | tmpLuftdruck += ADC; |
||
1246 | killagreg | 417 | if(++messanzahl_Druck >= 5) |
1166 | hbuss | 418 | { |
419 | MessLuftdruck = ADC; |
||
420 | messanzahl_Druck = 0; |
||
1167 | hbuss | 421 | HoeheD = (7 * HoeheD + (int) Parameter_Luftdruck_D * (int)(255 * ExpandBaro + StartLuftdruck - tmpLuftdruck - HoehenWert)) / 8; // D-Anteil = neuerWert - AlterWert |
1166 | hbuss | 422 | Luftdruck = (tmpLuftdruck + 3 * Luftdruck) / 4; |
423 | HoehenWert = 255 * ExpandBaro + StartLuftdruck - Luftdruck; |
||
424 | tmpLuftdruck = 0; |
||
1246 | killagreg | 425 | } |
1166 | hbuss | 426 | kanal = AD_NICK; |
427 | break; |
||
428 | case 25: |
||
429 | nick1 += ADC; |
||
430 | kanal = AD_ROLL; |
||
431 | break; |
||
432 | case 26: |
||
433 | roll1 += ADC; |
||
434 | kanal = AD_ACC_X; |
||
435 | break; |
||
436 | case 27: |
||
437 | Aktuell_ax = ADC - NeutralAccX; |
||
438 | accx += Aktuell_ax; |
||
439 | kanal = AD_GIER; |
||
440 | break; |
||
441 | case 28: |
||
442 | if(PlatinenVersion == 10) AdWertGier = (ADC + gier1 + 2) / 4; |
||
1246 | killagreg | 443 | else |
1166 | hbuss | 444 | if(PlatinenVersion == 20) AdWertGier = 2047 - (ADC + gier1 + 1) / 2; |
445 | else AdWertGier = (ADC + gier1 + 1) / 2; |
||
446 | kanal = AD_NICK; |
||
447 | break; |
||
448 | case 29: |
||
449 | nick1 += ADC; |
||
450 | kanal = AD_ROLL; |
||
451 | break; |
||
452 | case 30: |
||
453 | roll1 += ADC; |
||
454 | kanal = AD_ACC_Y; |
||
455 | break; |
||
456 | case 31: |
||
457 | Aktuell_ay = NeutralAccY - ADC; |
||
458 | AdWertAccRoll = (Aktuell_ay + accy); |
||
459 | kanal = AD_NICK; |
||
460 | break; |
||
461 | case 32: |
||
462 | AdWertNick = (ADC + nick1 + 3) / 5; |
||
463 | nick_filter = (long) (1 * (long) nick_filter + 4 * (long)(ADC + nick1) + 1) / 2; |
||
464 | if(PlatinenVersion == 10) { AdWertNick /= 2;nick_filter /=2;} |
||
465 | HiResNick = nick_filter - 20 * AdNeutralNick; |
||
466 | AdWertNickFilter = (long)(3L * (long)AdWertNickFilter + HiResNick + 2) / 4; |
||
1246 | killagreg | 467 | DebugOut.Analog[21] = AdWertNickFilter / 4; |
1166 | hbuss | 468 | kanal = AD_ROLL; |
469 | break; |
||
470 | case 33: |
||
471 | AdWertRoll = (ADC + roll1 + 3) / 5; |
||
472 | roll_filter = (long)(1 * (long)roll_filter + 4 * (long)(ADC + roll1) + 1) / 2; |
||
473 | if(PlatinenVersion == 10) { AdWertRoll /= 2;roll_filter /=2;} |
||
474 | HiResRoll = roll_filter - 20 * AdNeutralRoll; |
||
475 | AdWertRollFilter = (long)(3L * (long)AdWertRollFilter + HiResRoll + 2) / 4; |
||
476 | DebugOut.Analog[22] = AdWertRollFilter / 4; |
||
477 | kanal = AD_ACC_X; |
||
478 | break; |
||
479 | case 34: |
||
480 | Aktuell_ax = ADC - NeutralAccX; |
||
481 | AdWertAccNick = (Aktuell_ax + accx); |
||
482 | kanal = AD_NICK; |
||
483 | state = 0; |
||
484 | AdReady = 1; |
||
485 | ZaehlMessungen++; |
||
486 | break; |
||
1246 | killagreg | 487 | default: |
1166 | hbuss | 488 | kanal = 0; |
489 | state = 0; |
||
490 | break; |
||
1246 | killagreg | 491 | } |
1166 | hbuss | 492 | ADMUX = kanal; |
493 | if(state != 0) ANALOG_ON; |
||
494 | } |
||
1171 | hbuss | 495 | */ |