Rev 2341 | Rev 2344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2341 | Rev 2342 | ||
---|---|---|---|
Line 116... | Line 116... | ||
116 | int Ki = 10300 / 33; |
116 | int Ki = 10300 / 33; |
117 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
117 | unsigned char Looping_Nick = 0,Looping_Roll = 0; |
118 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
118 | unsigned char Looping_Links = 0, Looping_Rechts = 0, Looping_Unten = 0, Looping_Oben = 0; |
Line 119... | Line 119... | ||
119 | 119 | ||
120 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
120 | unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
121 | unsigned char Parameter_HoehenSchalter = 251; // Wert : 0-250 |
121 | unsigned char Parameter_HoehenSchalter = 0; // Wert : 0-250 |
122 | unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32 |
122 | unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32 |
123 | unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250 |
123 | unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250 |
124 | unsigned char Parameter_KompassWirkung = 64; // Wert : 0-250 |
124 | unsigned char Parameter_KompassWirkung = 64; // Wert : 0-250 |
125 | unsigned char Parameter_Hoehe_GPS_Z = 64; // Wert : 0-250 |
125 | unsigned char Parameter_Hoehe_GPS_Z = 64; // Wert : 0-250 |
Line 150... | Line 150... | ||
150 | unsigned char Parameter_DynamicStability = 100; |
150 | unsigned char Parameter_DynamicStability = 100; |
151 | unsigned char Parameter_J16Bitmask; // for the J16 Output |
151 | unsigned char Parameter_J16Bitmask; // for the J16 Output |
152 | unsigned char Parameter_J16Timing; // for the J16 Output |
152 | unsigned char Parameter_J16Timing; // for the J16 Output |
153 | unsigned char Parameter_J17Bitmask; // for the J17 Output |
153 | unsigned char Parameter_J17Bitmask; // for the J17 Output |
154 | unsigned char Parameter_J17Timing; // for the J17 Output |
154 | unsigned char Parameter_J17Timing; // for the J17 Output |
155 | unsigned char Parameter_NaviGpsModeControl; // Parameters for the Naviboard |
- | |
156 | unsigned char Parameter_NaviGpsGain; |
155 | unsigned char Parameter_NaviGpsGain; |
157 | unsigned char Parameter_NaviGpsP; |
156 | unsigned char Parameter_NaviGpsP; |
158 | unsigned char Parameter_NaviGpsI; |
157 | unsigned char Parameter_NaviGpsI; |
159 | unsigned char Parameter_NaviGpsD; |
158 | unsigned char Parameter_NaviGpsD; |
160 | unsigned char Parameter_NaviGpsACC; |
159 | unsigned char Parameter_NaviGpsACC; |
Line 600... | Line 599... | ||
600 | motor_write = 0; |
599 | motor_write = 0; |
601 | I2C_Start(TWI_STATE_MOTOR_TX); //Start I2C Interrupt Mode |
600 | I2C_Start(TWI_STATE_MOTOR_TX); //Start I2C Interrupt Mode |
602 | } |
601 | } |
603 | } |
602 | } |
Line -... | Line 603... | ||
- | 603 | ||
604 | 604 | unsigned char GetChannelValue(unsigned char ch) // gives the unsigned value of the channel |
|
- | 605 | { |
|
- | 606 | int tmp2; |
|
- | 607 | if(ch == 0) return(0); |
|
- | 608 | tmp2 = PPM_in[ch] + 127; |
|
- | 609 | if(tmp2 > 255) tmp2 = 255; else if(tmp2 < 0) tmp2 = 0; |
|
- | 610 | return(tmp2); |
|
Line 605... | Line 611... | ||
605 | 611 | } |
|
606 | 612 | ||
607 | //############################################################################ |
613 | //############################################################################ |
608 | // Trägt ggf. das Poti als Parameter ein |
614 | // Trägt ggf. das Poti als Parameter ein |
Line 637... | Line 643... | ||
637 | else CHK_POTI(Parameter_Servo3,EE_Parameter.Servo3); |
643 | else CHK_POTI(Parameter_Servo3,EE_Parameter.Servo3); |
Line 638... | Line 644... | ||
638 | 644 | ||
639 | if(EE_Parameter.Servo4 == 247) { if(PORTC & (1<<PORTC2)) Parameter_Servo4 = 140; else Parameter_Servo4 = 70;} |
645 | if(EE_Parameter.Servo4 == 247) { if(PORTC & (1<<PORTC2)) Parameter_Servo4 = 140; else Parameter_Servo4 = 70;} |
640 | else if(EE_Parameter.Servo4 == 246) { if(PORTC & (1<<PORTC3)) Parameter_Servo4 = 140; else Parameter_Servo4 = 70;} // Out2 (J17) |
646 | else if(EE_Parameter.Servo4 == 246) { if(PORTC & (1<<PORTC3)) Parameter_Servo4 = 140; else Parameter_Servo4 = 70;} // Out2 (J17) |
641 | else CHK_POTI(Parameter_Servo4,EE_Parameter.Servo4); |
- | |
642 | 647 | else CHK_POTI(Parameter_Servo4,EE_Parameter.Servo4); |
|
643 | CHK_POTI(Parameter_Servo5,EE_Parameter.Servo5); |
648 | CHK_POTI(Parameter_Servo5,EE_Parameter.Servo5); |
644 | CHK_POTI(Parameter_HoehenSchalter,EE_Parameter.MaxHoehe); |
649 | Parameter_HoehenSchalter = GetChannelValue(EE_Parameter.HoeheChannel); |
645 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung); |
650 | CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung); |
646 | CHK_POTI(Parameter_Hoehe_GPS_Z,EE_Parameter.Hoehe_GPS_Z); |
651 | CHK_POTI(Parameter_Hoehe_GPS_Z,EE_Parameter.Hoehe_GPS_Z); |
647 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung); |
652 | CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung); |
648 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I); |
653 | CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I); |
Line 675... | Line 680... | ||
675 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl); |
680 | CHK_POTI(Parameter_ExternalControl,EE_Parameter.ExternalControl); |
676 | Ki = 10300 / (Parameter_I_Faktor + 1); |
681 | Ki = 10300 / (Parameter_I_Faktor + 1); |
677 | MAX_GAS = EE_Parameter.Gas_Max; |
682 | MAX_GAS = EE_Parameter.Gas_Max; |
678 | MIN_GAS = EE_Parameter.Gas_Min; |
683 | MIN_GAS = EE_Parameter.Gas_Min; |
Line 679... | Line 684... | ||
679 | 684 | ||
680 | tmp = EE_Parameter.CareFreeModeControl; |
- | |
681 | if(tmp > 50) |
685 | if(EE_Parameter.CareFreeChannel) |
682 | { |
686 | { |
- | 687 | CareFree = 1; |
|
683 | CareFree = 1; |
688 | if(PPM_in[EE_Parameter.CareFreeChannel] < -64) CareFree = 0; |
684 | if(tmp >= 248 && Poti[255 - tmp] < 50) CareFree = 0; |
689 | // if(tmp >= 248 && Poti[255 - tmp] < 50) CareFree = 0; |
685 | if(carefree_old != CareFree) |
690 | if(carefree_old != CareFree) |
686 | { |
691 | { |
687 | if(carefree_old < 3) |
692 | if(carefree_old < 3) |
688 | { |
693 | { |
Line 793... | Line 798... | ||
793 | if(EE_Parameter.StartLandChannel && EE_Parameter.LandingSpeed) |
798 | if(EE_Parameter.StartLandChannel && EE_Parameter.LandingSpeed) |
794 | { |
799 | { |
795 | if(PPM_in[EE_Parameter.StartLandChannel] > 50) |
800 | if(PPM_in[EE_Parameter.StartLandChannel] > 50) |
796 | { |
801 | { |
797 | if(old_switch == 50) if(FC_StatusFlags2 & FC_STATUS2_WAIT_FOR_TAKEOFF) { FC_StatusFlags2 |= FC_STATUS2_AUTO_STARTING; SpeakHoTT = SPEAK_RISING;} |
802 | if(old_switch == 50) if(FC_StatusFlags2 & FC_STATUS2_WAIT_FOR_TAKEOFF) { FC_StatusFlags2 |= FC_STATUS2_AUTO_STARTING; SpeakHoTT = SPEAK_RISING;} |
- | 803 | FC_StatusFlags2 &= ~FC_STATUS2_AUTO_LANDING; |
|
798 | old_switch = 150; |
804 | old_switch = 150; |
799 | } |
805 | } |
800 | else |
806 | else |
801 | if(PPM_in[EE_Parameter.StartLandChannel] < -50) |
807 | if(PPM_in[EE_Parameter.StartLandChannel] < -50) |
802 | { |
808 | { |
803 | if(old_switch == 150) { FC_StatusFlags2 |= FC_STATUS2_AUTO_LANDING; SpeakHoTT = SPEAK_SINKING;} |
809 | if(old_switch == 150) { FC_StatusFlags2 |= FC_STATUS2_AUTO_LANDING; SpeakHoTT = SPEAK_SINKING;} |
- | 810 | FC_StatusFlags2 &= ~FC_STATUS2_AUTO_STARTING; |
|
804 | old_switch = 50; |
811 | old_switch = 50; |
805 | } |
812 | } |
806 | else |
813 | else |
807 | { |
814 | { |
808 | FC_StatusFlags2 &= ~(FC_STATUS2_AUTO_STARTING | FC_STATUS2_AUTO_LANDING); |
815 | FC_StatusFlags2 &= ~(FC_STATUS2_AUTO_STARTING | FC_STATUS2_AUTO_LANDING); |
Line 958... | Line 965... | ||
958 | else delay_neutral = 0; |
965 | else delay_neutral = 0; |
959 | } |
966 | } |
960 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
967 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
961 | // Gas ist unten |
968 | // Gas ist unten |
962 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
969 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
963 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120) |
970 | if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < -100) |
964 | { |
971 | { |
965 | if(PPM_diff[EE_Parameter.MotorSafetySwitch & 127] > 5) move_safety_switch = 100; |
972 | if(PPM_diff[EE_Parameter.MotorSafetySwitch & 127] > 5) move_safety_switch = 100; |
966 | else |
973 | else |
967 | if(PPM_diff[EE_Parameter.MotorSafetySwitch & 127] < -5) move_safety_switch = -100; |
974 | if(PPM_diff[EE_Parameter.MotorSafetySwitch & 127] < -5) move_safety_switch = -100; |
968 | // Motoren Starten |
975 | // Motoren Starten |
969 | if(!MotorenEin) |
976 | if(!MotorenEin) |
970 | { |
977 | { |
971 | if((((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) && ((!(EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -75) || EE_Parameter.MotorSafetySwitch == 0))) |
978 | if((((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -100) && ((!(EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -75) || EE_Parameter.MotorSafetySwitch == 0))) |
972 | || (((EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] > -10 && move_safety_switch == 100))) |
979 | || (((EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] > -10 && move_safety_switch == 100))) |
973 | { |
980 | { |
974 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
981 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
975 | // Einschalten |
982 | // Einschalten |
976 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
983 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
977 | if(CalibrationDone) FC_StatusFlags |= FC_STATUS_START; |
984 | if(CalibrationDone) FC_StatusFlags |= FC_STATUS_START; |
978 | StartLuftdruck = Luftdruck; |
985 | StartLuftdruck = Luftdruck; |
979 | HoehenWertF = 0; |
986 | HoehenWertF = 0; |
980 | HoehenWert = 0; |
987 | HoehenWert = 0; |
981 | SummenHoehe = 0; |
988 | SummenHoehe = 0; |
- | 989 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -100 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 100) && EE_Parameter.MotorSafetySwitch == 0) delay_einschalten = 0; |
|
982 | if(++delay_einschalten > 253) |
990 | if(++delay_einschalten > 253) |
983 | { |
991 | { |
984 | delay_einschalten = 0; |
992 | delay_einschalten = 0; |
985 | if(!VersionInfo.HardwareError[0] && CalibrationDone && !NC_ErrorCode) |
993 | if(!VersionInfo.HardwareError[0] && CalibrationDone && !NC_ErrorCode) |
986 | { |
994 | { |
Line 1016... | Line 1024... | ||
1016 | // Auschalten |
1024 | // Auschalten |
1017 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1025 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1018 | else // only if motors are running |
1026 | else // only if motors are running |
1019 | { |
1027 | { |
1020 | // if((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) && (PPM_in[EE_Parameter.MotorSafetySwitch] < -75 || EE_Parameter.MotorSafetySwitch == 0)) |
1028 | // if((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) && (PPM_in[EE_Parameter.MotorSafetySwitch] < -75 || EE_Parameter.MotorSafetySwitch == 0)) |
1021 | if((((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) && ((!(EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -75) || EE_Parameter.MotorSafetySwitch == 0))) |
1029 | if((((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 100) && ((!(EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -75) || EE_Parameter.MotorSafetySwitch == 0))) |
1022 | || (((EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -50 && move_safety_switch == -100))) |
1030 | || (((EE_Parameter.GlobalConfig3 & CFG3_MOTOR_SWITCH_MODE) && PPM_in[EE_Parameter.MotorSafetySwitch] < -50 && move_safety_switch == -100))) |
1023 | { |
1031 | { |
- | 1032 | if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -100 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) < 100) && EE_Parameter.MotorSafetySwitch == 0) |
|
- | 1033 | { |
|
- | 1034 | delay_ausschalten = 0; |
|
- | 1035 | } |
|
- | 1036 | else |
|
- | 1037 | { |
|
- | 1038 | SummeNick = 0; |
|
- | 1039 | SummeRoll = 0; |
|
- | 1040 | StickNick = 0; |
|
- | 1041 | StickRoll = 0; |
|
- | 1042 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
|
- | 1043 | SpeakHoTT = SPEAK_MK_OFF; |
|
- | 1044 | #endif |
|
- | 1045 | } |
|
1024 | if(++delay_ausschalten > 250) // nicht sofort |
1046 | if(++delay_ausschalten > 250) // nicht sofort |
1025 | { |
1047 | { |
1026 | MotorenEin = 0; |
1048 | MotorenEin = 0; |
1027 | delay_ausschalten = 0; |
1049 | delay_ausschalten = 0; |
1028 | modell_fliegt = 0; |
1050 | modell_fliegt = 0; |
1029 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
1051 | FC_StatusFlags2 &= ~(FC_STATUS2_WAIT_FOR_TAKEOFF | FC_STATUS2_AUTO_STARTING | FC_STATUS2_AUTO_LANDING); |
1030 | SpeakHoTT = SPEAK_MK_OFF; |
- | |
1031 | #endif |
- | |
1032 | } |
1052 | } |
1033 | } |
1053 | } |
1034 | else delay_ausschalten = 0; |
1054 | else delay_ausschalten = 0; |
1035 | } |
1055 | } |
1036 | if(GasIsZeroCnt < 1000) GasIsZeroCnt++; |
1056 | if(GasIsZeroCnt < 1000) GasIsZeroCnt++; |