Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

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