Rev 1212 | Rev 1226 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1212 | Rev 1215 | ||
---|---|---|---|
1 | /*####################################################################################### |
1 | /*####################################################################################### |
2 | Flight Control |
2 | Flight Control |
3 | #######################################################################################*/ |
3 | #######################################################################################*/ |
4 | 4 | ||
5 | #ifndef _FC_H |
5 | #ifndef _FC_H |
6 | #define _FC_H |
6 | #define _FC_H |
7 | //#define GIER_GRAD_FAKTOR 1291L // Abhängigkeit zwischen GyroIntegral und Winkel |
7 | //#define GIER_GRAD_FAKTOR 1291L // Abhängigkeit zwischen GyroIntegral und Winkel |
8 | //#define GIER_GRAD_FAKTOR 1160L |
8 | //#define GIER_GRAD_FAKTOR 1160L |
9 | extern long GIER_GRAD_FAKTOR; // Abhängigkeit zwischen GyroIntegral und Winkel |
9 | extern long GIER_GRAD_FAKTOR; // Abhängigkeit zwischen GyroIntegral und Winkel |
10 | #define STICK_GAIN 4 |
10 | #define STICK_GAIN 4 |
11 | 11 | ||
12 | #define FLAG_MOTOR_RUN 1 |
12 | #define FLAG_MOTOR_RUN 1 |
13 | #define FLAG_FLY 2 |
13 | #define FLAG_FLY 2 |
14 | #define FLAG_CALIBRATE 4 |
14 | #define FLAG_CALIBRATE 4 |
15 | #define FLAG_START 8 |
15 | #define FLAG_START 8 |
16 | #define MAX_MOTORS 12 |
16 | #define MAX_MOTORS 12 |
17 | 17 | ||
18 | #define CHECK_MIN_MAX(wert,min,max) {if(wert < min) wert = min; else if(wert > max) wert = max;} |
18 | #define CHECK_MIN_MAX(wert,min,max) {if(wert < min) wert = min; else if(wert > max) wert = max;} |
19 | 19 | ||
20 | extern volatile unsigned char MikroKopterFlags; |
20 | extern volatile unsigned char MikroKopterFlags; |
21 | extern volatile unsigned int I2CTimeout; |
21 | extern volatile unsigned int I2CTimeout; |
22 | extern unsigned char Sekunde,Minute; |
22 | extern unsigned char Sekunde,Minute; |
23 | 23 | ||
24 | extern long IntegralNick,IntegralNick2; |
24 | extern long IntegralNick,IntegralNick2; |
25 | extern long IntegralRoll,IntegralRoll2; |
25 | extern long IntegralRoll,IntegralRoll2; |
26 | //extern int IntegralNick,IntegralNick2; |
26 | //extern int IntegralNick,IntegralNick2; |
27 | //extern int IntegralRoll,IntegralRoll2; |
27 | //extern int IntegralRoll,IntegralRoll2; |
28 | 28 | ||
29 | extern long Mess_IntegralNick,Mess_IntegralNick2; |
29 | extern long Mess_IntegralNick,Mess_IntegralNick2; |
30 | extern long Mess_IntegralRoll,Mess_IntegralRoll2; |
30 | extern long Mess_IntegralRoll,Mess_IntegralRoll2; |
31 | extern long IntegralAccNick,IntegralAccRoll; |
31 | extern long IntegralAccNick,IntegralAccRoll; |
32 | extern volatile long Mess_Integral_Hoch; |
32 | extern volatile long Mess_Integral_Hoch; |
33 | extern long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2; |
33 | extern long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2; |
34 | extern int KompassValue; |
34 | extern int KompassValue; |
35 | extern int KompassStartwert; |
35 | extern int KompassStartwert; |
36 | extern int KompassRichtung; |
36 | extern int KompassRichtung; |
37 | extern int TrimNick, TrimRoll; |
37 | extern int TrimNick, TrimRoll; |
38 | extern long ErsatzKompass; |
38 | extern long ErsatzKompass; |
39 | extern int ErsatzKompassInGrad; // Kompasswert in Grad |
39 | extern int ErsatzKompassInGrad; // Kompasswert in Grad |
40 | extern int HoehenWert; |
40 | extern int HoehenWert; |
41 | extern int SollHoehe; |
41 | extern int SollHoehe; |
42 | extern int MesswertNick,MesswertRoll,MesswertGier; |
42 | extern int MesswertNick,MesswertRoll,MesswertGier; |
43 | extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll; |
43 | extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll; |
44 | extern int NeutralAccX, NeutralAccY,Mittelwert_AccHoch; |
44 | extern int NeutralAccX, NeutralAccY,Mittelwert_AccHoch; |
- | 45 | extern unsigned char HoehenReglerAktiv; |
|
45 | extern volatile float NeutralAccZ; |
46 | extern volatile float NeutralAccZ; |
46 | extern long Umschlag180Nick, Umschlag180Roll; |
47 | extern long Umschlag180Nick, Umschlag180Roll; |
47 | extern signed int ExternStickNick,ExternStickRoll,ExternStickGier; |
48 | extern signed int ExternStickNick,ExternStickRoll,ExternStickGier; |
48 | extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8; |
49 | extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8; |
49 | extern int NaviAccNick,NaviAccRoll,NaviCntAcc; |
50 | extern int NaviAccNick,NaviAccRoll,NaviCntAcc; |
50 | extern unsigned int modell_fliegt; |
51 | extern unsigned int modell_fliegt; |
51 | void MotorRegler(void); |
52 | void MotorRegler(void); |
52 | void SendMotorData(void); |
53 | void SendMotorData(void); |
53 | void CalibrierMittelwert(void); |
54 | void CalibrierMittelwert(void); |
54 | void Mittelwert(void); |
55 | void Mittelwert(void); |
55 | void SetNeutral(void); |
56 | void SetNeutral(void); |
56 | void Piep(unsigned char Anzahl); |
57 | void Piep(unsigned char Anzahl); |
57 | 58 | ||
58 | extern unsigned char h,m,s; |
59 | extern unsigned char h,m,s; |
59 | extern volatile unsigned char Timeout ; |
60 | extern volatile unsigned char Timeout ; |
60 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
61 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
61 | extern int DiffNick,DiffRoll; |
62 | extern int DiffNick,DiffRoll; |
62 | extern int Poti1, Poti2, Poti3, Poti4; |
63 | extern int Poti1, Poti2, Poti3, Poti4; |
63 | extern volatile unsigned char SenderOkay; |
64 | extern volatile unsigned char SenderOkay; |
64 | extern unsigned char RequiredMotors; |
65 | extern unsigned char RequiredMotors; |
65 | extern int StickNick,StickRoll,StickGier; |
66 | extern int StickNick,StickRoll,StickGier; |
66 | extern char MotorenEin; |
67 | extern char MotorenEin; |
67 | extern void DefaultKonstanten1(void); |
68 | extern void DefaultKonstanten1(void); |
68 | extern void DefaultKonstanten2(void); |
69 | extern void DefaultKonstanten2(void); |
69 | extern void DefaultKonstanten3(void); |
70 | extern void DefaultKonstanten3(void); |
70 | extern void DefaultStickMapping(void); |
71 | extern void DefaultStickMapping(void); |
71 | 72 | ||
72 | #define STRUCT_PARAM_LAENGE sizeof(EE_Parameter) |
73 | #define STRUCT_PARAM_LAENGE sizeof(EE_Parameter) |
73 | struct mk_param_struct |
74 | struct mk_param_struct |
74 | { |
75 | { |
75 | unsigned char Kanalbelegung[8]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
76 | unsigned char Kanalbelegung[8]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
76 | unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
77 | unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
77 | unsigned char Hoehe_MinGas; // Wert : 0-100 |
78 | unsigned char Hoehe_MinGas; // Wert : 0-100 |
78 | unsigned char Luftdruck_D; // Wert : 0-250 |
79 | unsigned char Luftdruck_D; // Wert : 0-250 |
79 | unsigned char MaxHoehe; // Wert : 0-32 |
80 | unsigned char MaxHoehe; // Wert : 0-32 |
80 | unsigned char Hoehe_P; // Wert : 0-32 |
81 | unsigned char Hoehe_P; // Wert : 0-32 |
81 | unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
82 | unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
82 | unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
83 | unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
83 | unsigned char Stick_P; // Wert : 1-6 |
84 | unsigned char Stick_P; // Wert : 1-6 |
84 | unsigned char Stick_D; // Wert : 0-64 |
85 | unsigned char Stick_D; // Wert : 0-64 |
85 | unsigned char Gier_P; // Wert : 1-20 |
86 | unsigned char Gier_P; // Wert : 1-20 |
86 | unsigned char Gas_Min; // Wert : 0-32 |
87 | unsigned char Gas_Min; // Wert : 0-32 |
87 | unsigned char Gas_Max; // Wert : 33-250 |
88 | unsigned char Gas_Max; // Wert : 33-250 |
88 | unsigned char GyroAccFaktor; // Wert : 1-64 |
89 | unsigned char GyroAccFaktor; // Wert : 1-64 |
89 | unsigned char KompassWirkung; // Wert : 0-32 |
90 | unsigned char KompassWirkung; // Wert : 0-32 |
90 | unsigned char Gyro_P; // Wert : 10-250 |
91 | unsigned char Gyro_P; // Wert : 10-250 |
91 | unsigned char Gyro_I; // Wert : 0-250 |
92 | unsigned char Gyro_I; // Wert : 0-250 |
92 | unsigned char Gyro_D; // Wert : 0-250 |
93 | unsigned char Gyro_D; // Wert : 0-250 |
93 | unsigned char UnterspannungsWarnung; // Wert : 0-250 |
94 | unsigned char UnterspannungsWarnung; // Wert : 0-250 |
94 | unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
95 | unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
95 | unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
96 | unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
96 | unsigned char UfoAusrichtung; // X oder + Formation |
97 | unsigned char UfoAusrichtung; // X oder + Formation |
97 | unsigned char I_Faktor; // Wert : 0-250 |
98 | unsigned char I_Faktor; // Wert : 0-250 |
98 | unsigned char UserParam1; // Wert : 0-250 |
99 | unsigned char UserParam1; // Wert : 0-250 |
99 | unsigned char UserParam2; // Wert : 0-250 |
100 | unsigned char UserParam2; // Wert : 0-250 |
100 | unsigned char UserParam3; // Wert : 0-250 |
101 | unsigned char UserParam3; // Wert : 0-250 |
101 | unsigned char UserParam4; // Wert : 0-250 |
102 | unsigned char UserParam4; // Wert : 0-250 |
102 | unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
103 | unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
103 | unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
104 | unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
104 | unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
105 | unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
105 | unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
106 | unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
106 | unsigned char ServoNickRefresh; // |
107 | unsigned char ServoNickRefresh; // |
107 | unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
108 | unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
108 | unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
109 | unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
109 | unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
110 | unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
110 | unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
111 | unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
111 | unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
112 | unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
112 | unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
113 | unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
113 | unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
114 | unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
114 | unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
115 | unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
115 | unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
116 | unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
116 | unsigned char Driftkomp; |
117 | unsigned char Driftkomp; |
117 | unsigned char DynamicStability; |
118 | unsigned char DynamicStability; |
118 | unsigned char UserParam5; // Wert : 0-250 |
119 | unsigned char UserParam5; // Wert : 0-250 |
119 | unsigned char UserParam6; // Wert : 0-250 |
120 | unsigned char UserParam6; // Wert : 0-250 |
120 | unsigned char UserParam7; // Wert : 0-250 |
121 | unsigned char UserParam7; // Wert : 0-250 |
121 | unsigned char UserParam8; // Wert : 0-250 |
122 | unsigned char UserParam8; // Wert : 0-250 |
122 | //---Output --------------------------------------------- |
123 | //---Output --------------------------------------------- |
123 | unsigned char J16Bitmask; // for the J16 Output |
124 | unsigned char J16Bitmask; // for the J16 Output |
124 | unsigned char J16Timing; // for the J16 Output |
125 | unsigned char J16Timing; // for the J16 Output |
125 | unsigned char J17Bitmask; // for the J17 Output |
126 | unsigned char J17Bitmask; // for the J17 Output |
126 | unsigned char J17Timing; // for the J17 Output |
127 | unsigned char J17Timing; // for the J17 Output |
127 | //---NaviCtrl--------------------------------------------- |
128 | //---NaviCtrl--------------------------------------------- |
128 | unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
129 | unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
129 | unsigned char NaviGpsGain; |
130 | unsigned char NaviGpsGain; |
130 | unsigned char NaviGpsP; |
131 | unsigned char NaviGpsP; |
131 | unsigned char NaviGpsI; |
132 | unsigned char NaviGpsI; |
132 | unsigned char NaviGpsD; |
133 | unsigned char NaviGpsD; |
133 | unsigned char NaviGpsPLimit; |
134 | unsigned char NaviGpsPLimit; |
134 | unsigned char NaviGpsILimit; |
135 | unsigned char NaviGpsILimit; |
135 | unsigned char NaviGpsDLimit; |
136 | unsigned char NaviGpsDLimit; |
136 | unsigned char NaviGpsACC; |
137 | unsigned char NaviGpsACC; |
137 | unsigned char NaviGpsMinSat; |
138 | unsigned char NaviGpsMinSat; |
138 | unsigned char NaviStickThreshold; |
139 | unsigned char NaviStickThreshold; |
139 | unsigned char NaviWindCorrection; |
140 | unsigned char NaviWindCorrection; |
140 | unsigned char NaviSpeedCompensation; |
141 | unsigned char NaviSpeedCompensation; |
141 | unsigned char NaviOperatingRadius; |
142 | unsigned char NaviOperatingRadius; |
142 | unsigned char NaviAngleLimitation; |
143 | unsigned char NaviAngleLimitation; |
143 | unsigned char NaviPH_LoginTime; |
144 | unsigned char NaviPH_LoginTime; |
144 | //---Ext.Ctrl--------------------------------------------- |
145 | //---Ext.Ctrl--------------------------------------------- |
145 | unsigned char ExternalControl; // for serial Control |
146 | unsigned char ExternalControl; // for serial Control |
146 | //------------------------------------------------ |
147 | //------------------------------------------------ |
147 | unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
148 | unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
148 | unsigned char ServoNickCompInvert; // Wert : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
149 | unsigned char ServoNickCompInvert; // Wert : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
149 | unsigned char Reserved[4]; |
150 | unsigned char Reserved[4]; |
150 | char Name[12]; |
151 | char Name[12]; |
151 | }; |
152 | }; |
152 | 153 | ||
153 | 154 | ||
154 | struct |
155 | struct |
155 | { |
156 | { |
156 | char Revision; |
157 | char Revision; |
157 | char Name[12]; |
158 | char Name[12]; |
158 | signed char Motor[16][4]; |
159 | signed char Motor[16][4]; |
159 | } Mixer; |
160 | } Mixer; |
160 | 161 | ||
161 | extern struct mk_param_struct EE_Parameter; |
162 | extern struct mk_param_struct EE_Parameter; |
162 | extern unsigned char Parameter_Luftdruck_D; |
163 | extern unsigned char Parameter_Luftdruck_D; |
163 | extern unsigned char Parameter_MaxHoehe; |
164 | extern unsigned char Parameter_MaxHoehe; |
164 | extern unsigned char Parameter_Hoehe_P; |
165 | extern unsigned char Parameter_Hoehe_P; |
165 | extern unsigned char Parameter_Hoehe_ACC_Wirkung; |
166 | extern unsigned char Parameter_Hoehe_ACC_Wirkung; |
166 | extern unsigned char Parameter_KompassWirkung; |
167 | extern unsigned char Parameter_KompassWirkung; |
167 | extern unsigned char Parameter_Gyro_P; |
168 | extern unsigned char Parameter_Gyro_P; |
168 | extern unsigned char Parameter_Gyro_I; |
169 | extern unsigned char Parameter_Gyro_I; |
169 | extern unsigned char Parameter_Gier_P; |
170 | extern unsigned char Parameter_Gier_P; |
170 | extern unsigned char Parameter_ServoNickControl; |
171 | extern unsigned char Parameter_ServoNickControl; |
171 | extern unsigned char Parameter_AchsKopplung1; |
172 | extern unsigned char Parameter_AchsKopplung1; |
172 | extern unsigned char Parameter_AchsKopplung2; |
173 | extern unsigned char Parameter_AchsKopplung2; |
173 | //extern unsigned char Parameter_AchsGegenKopplung1; |
174 | //extern unsigned char Parameter_AchsGegenKopplung1; |
174 | extern unsigned char Parameter_J16Bitmask; // for the J16 Output |
175 | extern unsigned char Parameter_J16Bitmask; // for the J16 Output |
175 | extern unsigned char Parameter_J16Timing; // for the J16 Output |
176 | extern unsigned char Parameter_J16Timing; // for the J16 Output |
176 | extern unsigned char Parameter_J17Bitmask; // for the J17 Output |
177 | extern unsigned char Parameter_J17Bitmask; // for the J17 Output |
177 | extern unsigned char Parameter_J17Timing; // for the J17 Output |
178 | extern unsigned char Parameter_J17Timing; // for the J17 Output |
178 | extern signed char MixerTable[MAX_MOTORS][4]; |
179 | extern signed char MixerTable[MAX_MOTORS][4]; |
179 | extern unsigned char Motor[MAX_MOTORS]; |
180 | extern unsigned char Motor[MAX_MOTORS]; |
180 | #endif //_FC_H |
181 | #endif //_FC_H |
181 | 182 | ||
182 | 183 |