Subversion Repositories FlightCtrl

Rev

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