Rev 2386 | Rev 2402 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2386 | Rev 2390 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | 86 | ||
87 | 87 | ||
88 | void LipoDetection(unsigned char print) |
88 | void LipoDetection(unsigned char print) |
89 | { |
89 | { |
90 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
90 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
- | 91 | unsigned char cells; |
|
- | 92 | if(print) printf("\n\rBatt:"); |
|
- | 93 | // timer = SetDelay(100); |
|
- | 94 | // if(print) while (!CheckDelay(timer)); |
|
- | 95 | // up to 6s LiPo, less than 2s is technical impossible |
|
91 | unsigned int timer, cells; |
96 | // for(cells = 2; cells < 7; cells++) if(UBat < cells * MAX_CELL_VOLTAGE) break; |
92 | if(print) printf("\n\rBatt:"); |
97 | cells = 1 + UBat / MAX_CELL_VOLTAGE; |
93 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
- | |
94 | { |
- | |
95 | timer = SetDelay(500); |
- | |
96 | if(print) while (!CheckDelay(timer)); |
- | |
97 | // up to 6s LiPo, less than 2s is technical impossible |
- | |
98 | for(cells = 2; cells < 7; cells++) |
- | |
99 | { |
- | |
100 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
- | |
101 | } |
98 | if(EE_Parameter.UnterspannungsWarnung < 50) |
102 | 99 | { |
|
103 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
100 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
104 | if(print) |
101 | if(print) |
105 | { |
102 | { |
106 | Piep(cells, 200); |
103 | Piep(cells, 200); |
107 | printf(" %d Cells ", cells); |
104 | printf(" %d Cells ", cells); |
108 | } |
105 | } |
- | 106 | } |
|
- | 107 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
|
- | 108 | ||
- | 109 | // automatische Zellenerkennung |
|
- | 110 | if(EE_Parameter.AutoLandingVoltage < 50) EE_Parameter.AutoLandingVoltage = cells * EE_Parameter.AutoLandingVoltage; |
|
- | 111 | ||
- | 112 | if(EE_Parameter.AutoLandingVoltage > BattLowVoltageWarning) EE_Parameter.AutoLandingVoltage = BattLowVoltageWarning - 1; |
|
- | 113 | ||
109 | } |
114 | if(print) |
- | 115 | { |
|
- | 116 | printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
|
110 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
117 | if(EE_Parameter.AutoLandingVoltage) printf(" Autolanding: %d.%d",EE_Parameter.AutoLandingVoltage/10,EE_Parameter.AutoLandingVoltage%10); |
Line 111... | Line 118... | ||
111 | if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
118 | } |
112 | } |
119 | } |
113 | 120 | ||
Line 348... | Line 355... | ||
348 | } |
355 | } |
349 | } |
356 | } |
350 | else AccZ_ErrorCnt = 0; |
357 | else AccZ_ErrorCnt = 0; |
351 | // ++++++++++++++++++++++++++++ |
358 | // ++++++++++++++++++++++++++++ |
352 | #endif |
359 | #endif |
353 | if(MissingMotor) |
360 | if(MissingMotor || Capacity.MinOfMaxPWM < 30) |
354 | { |
361 | { |
355 | VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
362 | if(MissingMotor) VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
356 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
363 | DebugOut.Status[1] |= 0x02; // BL-Error-Status |
357 | } |
364 | } |
358 | else |
365 | else |
359 | { |
366 | { |
360 | if(!beeptime) |
367 | if(!beeptime) |
Line 409... | Line 416... | ||
409 | FromNC_AltitudeSpeed = 0; |
416 | FromNC_AltitudeSpeed = 0; |
410 | FromNC_AltitudeSetpoint = 0; |
417 | FromNC_AltitudeSetpoint = 0; |
411 | VersionInfo.Flags &= ~FC_VERSION_FLAG_NC_PRESENT; |
418 | VersionInfo.Flags &= ~FC_VERSION_FLAG_NC_PRESENT; |
412 | NaviDataOkay = 0; |
419 | NaviDataOkay = 0; |
413 | } |
420 | } |
414 | if(UBat < BattLowVoltageWarning) |
421 | if(UBat <= BattLowVoltageWarning) |
415 | { |
422 | { |
416 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
423 | FC_StatusFlags |= FC_STATUS_LOWBAT; |
417 | if(BeepMuster == 0xffff && UBat > 10) // Do not beep, if the voltage reading is below 1V (Supplied via MKUSB) |
424 | if(BeepMuster == 0xffff && UBat > 10) // Do not beep, if the voltage reading is below 1V (Supplied via MKUSB) |
418 | { |
425 | { |
419 | beeptime = 6000; |
426 | beeptime = 6000; |
420 | BeepMuster = 0x0300; |
427 | BeepMuster = 0x0300; |
421 | } |
428 | } |
422 | } |
429 | } |
423 | else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
- | |
424 | // SendSPI = SPI_BYTEGAP; |
430 | // SendSPI = SPI_BYTEGAP; |
425 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
431 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
426 | // +++++++++++++++++++++++++++++++++ |
432 | // +++++++++++++++++++++++++++++++++ |
427 | // Sekundentakt |
433 | // Sekundentakt |
428 | if(++second == 49) |
434 | if(++second == 49) |
Line 437... | Line 443... | ||
437 | { |
443 | { |
438 | if(StartLuftdruck < Luftdruck) StartLuftdruck += 5; |
444 | if(StartLuftdruck < Luftdruck) StartLuftdruck += 5; |
439 | else |
445 | else |
440 | if(StartLuftdruck > Luftdruck) StartLuftdruck -= 5; |
446 | if(StartLuftdruck > Luftdruck) StartLuftdruck -= 5; |
441 | } |
447 | } |
- | 448 | if(UBat > BattLowVoltageWarning + 1) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
|
442 | } |
449 | } |
443 | // +++++++++++++++++++++++++++++++++ |
450 | // +++++++++++++++++++++++++++++++++ |
444 | if(++timer2 == 2930) // eine Minute |
451 | if(++timer2 == 2930) // eine Minute |
445 | { |
452 | { |
446 | timer2 = 0; |
453 | timer2 = 0; |