Rev 2617 | Rev 2628 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2617 | Rev 2627 | ||
---|---|---|---|
Line 216... | Line 216... | ||
216 | switch_hyterese = 1; |
216 | switch_hyterese = 1; |
217 | } |
217 | } |
218 | } |
218 | } |
219 | // +++++++++++++++++++++++++++++++++++++++++++ |
219 | // +++++++++++++++++++++++++++++++++++++++++++ |
220 | #endif |
220 | #endif |
- | 221 | ||
- | 222 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 223 | // check if ServoControl is serial Poti and if yes: check if there is valid data |
|
- | 224 | void InitSerialPoti(void) |
|
- | 225 | { |
|
- | 226 | unsigned char i; |
|
- | 227 | if(!SerialChannelDataOkay) |
|
- | 228 | { |
|
- | 229 | if(EE_Parameter.ServoNickControl >= 248) // Poti-Value |
|
- | 230 | { |
|
- | 231 | i = 255 - EE_Parameter.ServoNickControl; // Poti-number |
|
- | 232 | i = EE_Parameter.Kanalbelegung[K_POTI1 + i]; |
|
- | 233 | if(i >= SERIAL_POTI_START && i <= SERIAL_POTI_END) // value comes from a serial poti |
|
- | 234 | { |
|
- | 235 | if(EE_Parameter.ServoFS_Pos[0]) PPM_in[i] = EE_Parameter.ServoFS_Pos[0] - 127; // there is a failsafe position |
|
- | 236 | else PPM_in[i] = 0; // middle position |
|
- | 237 | } |
|
- | 238 | } |
|
- | 239 | if(EE_Parameter.ServoRollControl >= 248) // Poti-Value |
|
- | 240 | { |
|
- | 241 | i = 255 - EE_Parameter.ServoRollControl; // Poti-number |
|
- | 242 | i = EE_Parameter.Kanalbelegung[K_POTI1 + i]; |
|
- | 243 | if(i >= SERIAL_POTI_START && i <= SERIAL_POTI_END) // value comes from a serial poti |
|
- | 244 | { |
|
- | 245 | if(EE_Parameter.ServoFS_Pos[1]) PPM_in[i] = EE_Parameter.ServoFS_Pos[1] - 127; |
|
- | 246 | else PPM_in[i] = 0; // middle position |
|
- | 247 | } |
|
- | 248 | } |
|
- | 249 | if(EE_Parameter.Servo3 >= 248) // Poti-Value |
|
- | 250 | { |
|
- | 251 | i = 255 - EE_Parameter.Servo3; // Poti-number |
|
- | 252 | i = EE_Parameter.Kanalbelegung[K_POTI1 + i]; |
|
- | 253 | if(i >= SERIAL_POTI_START && i <= SERIAL_POTI_END) // value comes from a serial poti |
|
- | 254 | { |
|
- | 255 | if(EE_Parameter.ServoFS_Pos[2]) PPM_in[i] = EE_Parameter.ServoFS_Pos[2] - 127; |
|
- | 256 | else PPM_in[i] = 0; // middle position |
|
- | 257 | } |
|
- | 258 | } |
|
- | 259 | if(EE_Parameter.Servo4 >= 248) // Poti-Value |
|
- | 260 | { |
|
- | 261 | i = 255 - EE_Parameter.Servo4; // Poti-number |
|
- | 262 | i = EE_Parameter.Kanalbelegung[K_POTI1 + i]; |
|
- | 263 | if(i >= SERIAL_POTI_START && i <= SERIAL_POTI_END) // value comes from a serial poti |
|
- | 264 | { |
|
- | 265 | if(EE_Parameter.ServoFS_Pos[3]) PPM_in[i] = EE_Parameter.ServoFS_Pos[3] - 127; |
|
- | 266 | else PPM_in[i] = 0; // middle position |
|
- | 267 | } |
|
- | 268 | } |
|
- | 269 | if(EE_Parameter.Servo5 >= 248) // Poti-Value |
|
- | 270 | { |
|
- | 271 | i = 255 - EE_Parameter.Servo5; // Poti-number |
|
- | 272 | i = EE_Parameter.Kanalbelegung[K_POTI1 + i]; |
|
- | 273 | if(i >= SERIAL_POTI_START && i <= SERIAL_POTI_END) // value comes from a serial poti |
|
- | 274 | { |
|
- | 275 | if(EE_Parameter.ServoFS_Pos[4]) PPM_in[i] = EE_Parameter.ServoFS_Pos[4] - 127; |
|
- | 276 | else PPM_in[i] = 0; // middle position |
|
- | 277 | } |
|
- | 278 | } |
|
- | 279 | } |
|
- | 280 | } |
|
- | 281 | ||
221 | //############################################################################ |
282 | //############################################################################ |
222 | //Hauptprogramm |
283 | //Hauptprogramm |
223 | int main (void) |
284 | int main (void) |
224 | //############################################################################ |
285 | //############################################################################ |
225 | { |
286 | { |
Line 369... | Line 430... | ||
369 | 430 | ||
370 | #ifdef REDUNDANT_FC_MASTER |
431 | #ifdef REDUNDANT_FC_MASTER |
371 | printf("\n\r\n\r--> REDUNDANT MASTER <---\n\r"); |
432 | printf("\n\r\n\r--> REDUNDANT MASTER <---\n\r"); |
372 | IamMaster = MASTER; |
433 | IamMaster = MASTER; |
373 | #endif |
- | |
374 | 434 | #endif |
|
375 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
435 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
376 | // Calibrating altitude sensor |
436 | // Calibrating altitude sensor |
377 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
437 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
378 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
438 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
Line 425... | Line 485... | ||
425 | timer = SetDelay(2500); |
485 | timer = SetDelay(2500); |
426 | while(!CheckDelay(timer)); |
486 | while(!CheckDelay(timer)); |
427 | printf("\n\rStart\n\r"); |
487 | printf("\n\rStart\n\r"); |
428 | #endif |
488 | #endif |
429 | // printf("\n\rSize %i\n\r", sizeof(HugeBlockToNavi)); |
489 | // printf("\n\rSize %i\n\r", sizeof(HugeBlockToNavi)); |
430 | - | ||
431 | while(1) |
490 | while(1) |
432 | { |
491 | { |
433 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
492 | EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
434 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
493 | if(ReceiverUpdateModeActive) while (1) PORTC &= ~(1<<7); // Beeper off |
435 | if(UpdateMotor && AdReady) // ReglerIntervall |
494 | if(UpdateMotor && AdReady) // ReglerIntervall |
Line 501... | Line 560... | ||
501 | if(NewMlinkData) ProcessMlinkData(); |
560 | if(NewMlinkData) ProcessMlinkData(); |
502 | else |
561 | else |
503 | #endif |
562 | #endif |
504 | { |
563 | { |
505 | if(BytegapSPI == 0) SPI_TransmitByte(); |
564 | if(BytegapSPI == 0) SPI_TransmitByte(); |
506 | if(CalculateServoSignals) CalculateServo(); |
565 | if(CalculateServoSignals) CalculateServo(0); |
507 | DatenUebertragung(); |
566 | DatenUebertragung(); |
508 | BearbeiteRxDaten(); |
567 | BearbeiteRxDaten(); |
509 | if(!(PINB & 0x04)) VersionInfo.HardwareError[1] |= FC_ERROR1_RC_VOLTAGE; |
568 | if(!(PINB & 0x04)) VersionInfo.HardwareError[1] |= FC_ERROR1_RC_VOLTAGE; |
510 | if(CheckDelay(timer)) |
569 | if(CheckDelay(timer)) |
511 | { |
570 | { |
Line 652... | Line 711... | ||
652 | if(Show_Load_Time) Show_Load_Time--; |
711 | if(Show_Load_Time) Show_Load_Time--; |
653 | if(Show_Store_Time) Show_Store_Time--; |
712 | if(Show_Store_Time) Show_Store_Time--; |
654 | if(ShowCmpsCalibrateTime) ShowCmpsCalibrateTime--; |
713 | if(ShowCmpsCalibrateTime) ShowCmpsCalibrateTime--; |
655 | if(Delete_Stoppflag_Timer) Delete_Stoppflag_Timer--; else FC_StatusFlags3 &= ~FC_STATUS3_MOTORS_STOPPED_BY_RC; |
714 | if(Delete_Stoppflag_Timer) Delete_Stoppflag_Timer--; else FC_StatusFlags3 &= ~FC_STATUS3_MOTORS_STOPPED_BY_RC; |
656 | #endif |
715 | #endif |
- | 716 | if(SerialChannelDataOkay) if(--SerialChannelDataOkay == 0) InitSerialPoti(); |
|
657 | if(NC_To_FC_Flags & NC_TO_FC_FAILSAFE_LANDING) ServoFailsafeActive = SERVO_FS_TIME; |
717 | if(NC_To_FC_Flags & NC_TO_FC_FAILSAFE_LANDING) ServoFailsafeActive = SERVO_FS_TIME; |
658 | else |
718 | else |
659 | if(ServoFailsafeActive) ServoFailsafeActive--; |
719 | if(ServoFailsafeActive) ServoFailsafeActive--; |
Line 660... | Line 720... | ||
660 | 720 | ||
Line 673... | Line 733... | ||
673 | if(!(FC_StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE)) FC_StatusFlags3 |= FC_STATUS3_REDUNDANCE_ERROR; |
733 | if(!(FC_StatusFlags3 & FC_STATUS3_REDUNDANCE_AKTIVE)) FC_StatusFlags3 |= FC_STATUS3_REDUNDANCE_ERROR; |
674 | else FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE_ERROR; |
734 | else FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE_ERROR; |
675 | #endif |
735 | #endif |
676 | } |
736 | } |
677 | if(UBat > BattLowVoltageWarning + 1) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
737 | if(UBat > BattLowVoltageWarning + 1) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
- | 738 | TIMSK2 |= (1<<OCIE2A); // enable Servo-Interrupt now |
|
678 | } |
739 | } |
679 | // +++++++++++++++++++++++++++++++++ |
740 | // +++++++++++++++++++++++++++++++++ |
680 | if(++timer2 == 2930) // eine Minute |
741 | if(++timer2 == 2930) // eine Minute |
681 | { |
742 | { |
682 | timer2 = 0; |
743 | timer2 = 0; |