Subversion Repositories FlightCtrl

Rev

Rev 976 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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