Rev 1403 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /*####################################################################################### |
2 | Flight Control |
||
3 | #######################################################################################*/ |
||
4 | |||
5 | #ifndef _FC_H |
||
6 | #define _FC_H |
||
1111 | hbuss | 7 | //#define GIER_GRAD_FAKTOR 1291L // Abhängigkeit zwischen GyroIntegral und Winkel |
1243 | killagreg | 8 | //#define GIER_GRAD_FAKTOR 1160L |
1121 | hbuss | 9 | extern long GIER_GRAD_FAKTOR; // Abhängigkeit zwischen GyroIntegral und Winkel |
855 | hbuss | 10 | #define STICK_GAIN 4 |
921 | hbuss | 11 | |
1420 | killagreg | 12 | #define FCFLAG_MOTOR_RUN 0x01 |
13 | #define FCFLAG_FLY 0x02 |
||
14 | #define FCFLAG_CALIBRATE 0x04 |
||
15 | #define FCFLAG_START 0x08 |
||
16 | #define FCFLAG_NOTLANDUNG 0x10 |
||
17 | #define FCFLAG_LOWBAT 0x20 |
||
18 | #define FCFLAG_SPI_RX_ERR 0x40 |
||
19 | #define FCFLAG_RESERVE1 0x80 |
||
1254 | killagreg | 20 | |
1420 | killagreg | 21 | |
1377 | hbuss | 22 | #define Poti1 Poti[0] |
23 | #define Poti2 Poti[1] |
||
24 | #define Poti3 Poti[2] |
||
25 | #define Poti4 Poti[3] |
||
26 | #define Poti5 Poti[4] |
||
27 | #define Poti6 Poti[5] |
||
28 | #define Poti7 Poti[6] |
||
29 | #define Poti8 Poti[7] |
||
1254 | killagreg | 30 | |
1209 | hbuss | 31 | #define MAX_MOTORS 12 |
1155 | hbuss | 32 | |
33 | #define CHECK_MIN_MAX(wert,min,max) {if(wert < min) wert = min; else if(wert > max) wert = max;} |
||
34 | |||
1420 | killagreg | 35 | extern volatile unsigned char FCFlags; |
173 | holgerb | 36 | extern volatile unsigned int I2CTimeout; |
1 | ingob | 37 | extern unsigned char Sekunde,Minute; |
1352 | hbuss | 38 | extern unsigned int BaroExpandActive; |
693 | hbuss | 39 | extern long IntegralNick,IntegralNick2; |
40 | extern long IntegralRoll,IntegralRoll2; |
||
1153 | hbuss | 41 | //extern int IntegralNick,IntegralNick2; |
42 | //extern int IntegralRoll,IntegralRoll2; |
||
1420 | killagreg | 43 | extern unsigned char Poti[9]; |
1153 | hbuss | 44 | |
693 | hbuss | 45 | extern long Mess_IntegralNick,Mess_IntegralNick2; |
46 | extern long Mess_IntegralRoll,Mess_IntegralRoll2; |
||
47 | extern long IntegralAccNick,IntegralAccRoll; |
||
1 | ingob | 48 | extern volatile long Mess_Integral_Hoch; |
693 | hbuss | 49 | extern long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2; |
1153 | hbuss | 50 | extern int KompassValue; |
51 | extern int KompassStartwert; |
||
52 | extern int KompassRichtung; |
||
1166 | hbuss | 53 | extern int TrimNick, TrimRoll; |
717 | hbuss | 54 | extern long ErsatzKompass; |
55 | extern int ErsatzKompassInGrad; // Kompasswert in Grad |
||
1246 | killagreg | 56 | extern long HoehenWert; |
57 | extern long SollHoehe; |
||
1153 | hbuss | 58 | extern int MesswertNick,MesswertRoll,MesswertGier; |
927 | hbuss | 59 | extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll; |
60 | extern int NeutralAccX, NeutralAccY,Mittelwert_AccHoch; |
||
1215 | hbuss | 61 | extern unsigned char HoehenReglerAktiv; |
1 | ingob | 62 | extern volatile float NeutralAccZ; |
396 | hbuss | 63 | extern long Umschlag180Nick, Umschlag180Roll; |
492 | hbuss | 64 | extern signed int ExternStickNick,ExternStickRoll,ExternStickGier; |
513 | hbuss | 65 | extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8; |
805 | hbuss | 66 | extern int NaviAccNick,NaviAccRoll,NaviCntAcc; |
871 | hbuss | 67 | extern unsigned int modell_fliegt; |
1 | ingob | 68 | void MotorRegler(void); |
69 | void SendMotorData(void); |
||
70 | void CalibrierMittelwert(void); |
||
71 | void Mittelwert(void); |
||
72 | void SetNeutral(void); |
||
1232 | hbuss | 73 | void Piep(unsigned char Anzahl, unsigned int dauer); |
1 | ingob | 74 | |
304 | ingob | 75 | extern unsigned char h,m,s; |
76 | extern volatile unsigned char Timeout ; |
||
77 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
||
1153 | hbuss | 78 | extern int DiffNick,DiffRoll; |
1377 | hbuss | 79 | //extern int Poti1, Poti2, Poti3, Poti4; |
304 | ingob | 80 | extern volatile unsigned char SenderOkay; |
1243 | killagreg | 81 | extern volatile unsigned char SenderRSSI; |
1209 | hbuss | 82 | extern unsigned char RequiredMotors; |
304 | ingob | 83 | extern int StickNick,StickRoll,StickGier; |
84 | extern char MotorenEin; |
||
396 | hbuss | 85 | extern void DefaultKonstanten1(void); |
86 | extern void DefaultKonstanten2(void); |
||
1211 | hbuss | 87 | extern void DefaultKonstanten3(void); |
88 | extern void DefaultStickMapping(void); |
||
1403 | hbuss | 89 | extern unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5; |
1 | ingob | 90 | |
1243 | killagreg | 91 | #define STRUCT_PARAM_LAENGE sizeof(EE_Parameter) |
1 | ingob | 92 | struct mk_param_struct |
93 | { |
||
1377 | hbuss | 94 | unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
921 | hbuss | 95 | unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
96 | unsigned char Hoehe_MinGas; // Wert : 0-100 |
||
97 | unsigned char Luftdruck_D; // Wert : 0-250 |
||
98 | unsigned char MaxHoehe; // Wert : 0-32 |
||
99 | unsigned char Hoehe_P; // Wert : 0-32 |
||
100 | unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
||
1 | ingob | 101 | unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
1283 | hbuss | 102 | unsigned char Hoehe_HoverBand; // Wert : 0-250 |
103 | unsigned char Hoehe_GPS_Z; // Wert : 0-250 |
||
1322 | hbuss | 104 | unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250 |
1 | ingob | 105 | unsigned char Stick_P; // Wert : 1-6 |
106 | unsigned char Stick_D; // Wert : 0-64 |
||
107 | unsigned char Gier_P; // Wert : 1-20 |
||
108 | unsigned char Gas_Min; // Wert : 0-32 |
||
109 | unsigned char Gas_Max; // Wert : 33-250 |
||
110 | unsigned char GyroAccFaktor; // Wert : 1-64 |
||
111 | unsigned char KompassWirkung; // Wert : 0-32 |
||
112 | unsigned char Gyro_P; // Wert : 10-250 |
||
113 | unsigned char Gyro_I; // Wert : 0-250 |
||
1120 | hbuss | 114 | unsigned char Gyro_D; // Wert : 0-250 |
1322 | hbuss | 115 | unsigned char Gyro_Gier_P; // Wert : 10-250 |
116 | unsigned char Gyro_Gier_I; // Wert : 0-250 |
||
1 | ingob | 117 | unsigned char UnterspannungsWarnung; // Wert : 0-250 |
118 | unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
||
119 | unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
||
120 | unsigned char UfoAusrichtung; // X oder + Formation |
||
121 | unsigned char I_Faktor; // Wert : 0-250 |
||
122 | unsigned char UserParam1; // Wert : 0-250 |
||
123 | unsigned char UserParam2; // Wert : 0-250 |
||
124 | unsigned char UserParam3; // Wert : 0-250 |
||
125 | unsigned char UserParam4; // Wert : 0-250 |
||
126 | unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
||
127 | unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
||
128 | unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
||
129 | unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
||
1232 | hbuss | 130 | //--- Seit V0.75 |
131 | unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
||
132 | unsigned char ServoRollComp; // Wert : 0-250 |
||
133 | unsigned char ServoRollMin; // Wert : 0-250 |
||
134 | unsigned char ServoRollMax; // Wert : 0-250 |
||
135 | //--- |
||
1403 | hbuss | 136 | unsigned char ServoNickRefresh; // Speed of the Servo |
137 | unsigned char Servo3; // Value or mapping of the Servo Output |
||
138 | unsigned char Servo4; // Value or mapping of the Servo Output |
||
139 | unsigned char Servo5; // Value or mapping of the Servo Output |
||
173 | holgerb | 140 | unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
141 | unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
||
396 | hbuss | 142 | unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
143 | unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
||
1120 | hbuss | 144 | unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
145 | unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
||
396 | hbuss | 146 | unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
147 | unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
||
148 | unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
||
1243 | killagreg | 149 | unsigned char Driftkomp; |
499 | hbuss | 150 | unsigned char DynamicStability; |
151 | unsigned char UserParam5; // Wert : 0-250 |
||
152 | unsigned char UserParam6; // Wert : 0-250 |
||
153 | unsigned char UserParam7; // Wert : 0-250 |
||
154 | unsigned char UserParam8; // Wert : 0-250 |
||
921 | hbuss | 155 | //---Output --------------------------------------------- |
156 | unsigned char J16Bitmask; // for the J16 Output |
||
157 | unsigned char J16Timing; // for the J16 Output |
||
158 | unsigned char J17Bitmask; // for the J17 Output |
||
159 | unsigned char J17Timing; // for the J17 Output |
||
1254 | killagreg | 160 | // seit version V0.75c |
161 | unsigned char WARN_J16_Bitmask; // for the J16 Output |
||
162 | unsigned char WARN_J17_Bitmask; // for the J17 Output |
||
921 | hbuss | 163 | //---NaviCtrl--------------------------------------------- |
164 | unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
||
1243 | killagreg | 165 | unsigned char NaviGpsGain; |
166 | unsigned char NaviGpsP; |
||
167 | unsigned char NaviGpsI; |
||
168 | unsigned char NaviGpsD; |
||
169 | unsigned char NaviGpsPLimit; |
||
170 | unsigned char NaviGpsILimit; |
||
171 | unsigned char NaviGpsDLimit; |
||
172 | unsigned char NaviGpsACC; |
||
173 | unsigned char NaviGpsMinSat; |
||
174 | unsigned char NaviStickThreshold; |
||
175 | unsigned char NaviWindCorrection; |
||
176 | unsigned char NaviSpeedCompensation; |
||
177 | unsigned char NaviOperatingRadius; |
||
1064 | hbuss | 178 | unsigned char NaviAngleLimitation; |
1120 | hbuss | 179 | unsigned char NaviPH_LoginTime; |
921 | hbuss | 180 | //---Ext.Ctrl--------------------------------------------- |
181 | unsigned char ExternalControl; // for serial Control |
||
173 | holgerb | 182 | //------------------------------------------------ |
1309 | hbuss | 183 | unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
1232 | hbuss | 184 | unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen |
1309 | hbuss | 185 | unsigned char ExtraConfig; // bitcodiert |
1 | ingob | 186 | char Name[12]; |
1243 | killagreg | 187 | }; |
1309 | hbuss | 188 | |
1209 | hbuss | 189 | struct |
190 | { |
||
1211 | hbuss | 191 | char Revision; |
1209 | hbuss | 192 | char Name[12]; |
193 | signed char Motor[16][4]; |
||
194 | } Mixer; |
||
1243 | killagreg | 195 | |
1 | ingob | 196 | extern struct mk_param_struct EE_Parameter; |
197 | extern unsigned char Parameter_Luftdruck_D; |
||
198 | extern unsigned char Parameter_MaxHoehe; |
||
199 | extern unsigned char Parameter_Hoehe_P; |
||
200 | extern unsigned char Parameter_Hoehe_ACC_Wirkung; |
||
201 | extern unsigned char Parameter_KompassWirkung; |
||
202 | extern unsigned char Parameter_Gyro_P; |
||
203 | extern unsigned char Parameter_Gyro_I; |
||
204 | extern unsigned char Parameter_Gier_P; |
||
205 | extern unsigned char Parameter_ServoNickControl; |
||
1232 | hbuss | 206 | extern unsigned char Parameter_ServoRollControl; |
396 | hbuss | 207 | extern unsigned char Parameter_AchsKopplung1; |
1120 | hbuss | 208 | extern unsigned char Parameter_AchsKopplung2; |
209 | //extern unsigned char Parameter_AchsGegenKopplung1; |
||
921 | hbuss | 210 | extern unsigned char Parameter_J16Bitmask; // for the J16 Output |
211 | extern unsigned char Parameter_J16Timing; // for the J16 Output |
||
212 | extern unsigned char Parameter_J17Bitmask; // for the J17 Output |
||
213 | extern unsigned char Parameter_J17Timing; // for the J17 Output |
||
1243 | killagreg | 214 | extern signed char MixerTable[MAX_MOTORS][4]; |
1209 | hbuss | 215 | extern unsigned char Motor[MAX_MOTORS]; |
1 | ingob | 216 | #endif //_FC_H |
217 |