Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2506 - 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
#define ACC_AMPLIFY    6
12
#define HEIGHT_CONTROL_STICKTHRESHOLD 15
13
 
14
// FC_StatusFlags
15
#define FC_STATUS_MOTOR_RUN                             0x01
16
#define FC_STATUS_FLY                                   0x02
17
#define FC_STATUS_CALIBRATE                             0x04
18
#define FC_STATUS_START                                 0x08
19
#define FC_STATUS_EMERGENCY_LANDING             0x10
20
#define FC_STATUS_LOWBAT                                0x20
21
#define FC_STATUS_VARIO_TRIM_UP                 0x40
22
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
23
 
24
// FC_StatusFlags2 
25
#define FC_STATUS2_CAREFREE                 0x01
26
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
27
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
28
#define FC_STATUS2_OUT1_ACTIVE                  0x08
29
#define FC_STATUS2_OUT2_ACTIVE                  0x10
30
#define FC_STATUS2_WAIT_FOR_TAKEOFF             0x20   // Motor Running, but still on the ground
31
#define FC_STATUS2_AUTO_STARTING                0x40
32
#define FC_STATUS2_AUTO_LANDING                 0x80
33
 
34
// FC_StatusFlags3 
35
#define FC_STATUS3_REDUNDANCE               0x01
36
#define FC_STATUS3_BOAT                         0x02
37
 
38
//NC_To_FC_Flags
39
#define NC_TO_FC_FLYING_RANGE           0x01
40
#define NC_TO_FC_EMERGENCY_LANDING      0x02
41
#define NC_TO_FC_AUTOSTART                      0x04
42
#define NC_TO_FC_AUTOLANDING            0x08 // not used 
43
#define NC_TO_FC_SIMULATION_ACTIVE      0x10 // don't start motors
44
 
45
extern volatile unsigned char FC_StatusFlags, FC_StatusFlags2;
46
extern unsigned char FC_StatusFlags3;
47
extern void ParameterZuordnung(void);
48
extern unsigned char GetChannelValue(unsigned char ch); // gives the unsigned value of the channel
49
 
50
#define Poti1 Poti[0]
51
#define Poti2 Poti[1]
52
#define Poti3 Poti[2]
53
#define Poti4 Poti[3]
54
#define Poti5 Poti[4]
55
#define Poti6 Poti[5]
56
#define Poti7 Poti[6]
57
#define Poti8 Poti[7]
58
 
59
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
60
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
61
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
62
 
63
#define CHK_POTI(b,a) {if(a < 248) b = a; else b = Poti[255 - a];}
64
#define CHK_POTI_OFF(b,a,off) {if(a < 248) b = a; else b = Poti[255 - a] - off;}
65
#define CHK_POTI_MM(b,a,min,max) {CHK_POTI(b,a); LIMIT_MIN_MAX(b, min, max);}
66
#define CHK_POTI_MM_OFF(b,a,min,max,off) {CHK_POTI_OFF(b,a,off); LIMIT_MIN_MAX(b, min, max);}
67
 
68
extern unsigned char Sekunde,Minute;
69
extern unsigned int BaroExpandActive;
70
extern long IntegralNick;//,IntegralNick2;
71
extern long IntegralRoll;//,IntegralRoll2;
72
//extern int IntegralNick,IntegralNick2;
73
//extern int IntegralRoll,IntegralRoll2;
74
extern unsigned char Poti[9];
75
 
76
extern long Mess_IntegralNick;//,Mess_IntegralNick2;
77
extern long Mess_IntegralRoll;//,Mess_IntegralRoll2;
78
extern long IntegralAccNick,IntegralAccRoll;
79
extern long SummeNick,SummeRoll;
80
extern volatile long Mess_Integral_Hoch;
81
extern long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2;
82
extern int  KompassValue;
83
extern int  KompassSollWert;
84
extern int  KompassRichtung;
85
extern char CalculateCompassTimer;
86
extern unsigned char KompassFusion;
87
extern unsigned char ControlHeading;
88
extern int  TrimNick, TrimRoll;
89
extern long  ErsatzKompass;
90
extern int   ErsatzKompassInGrad,CompassCorrected; // Kompasswert in Grad
91
extern long HoehenWert;
92
extern long SollHoehe;
93
extern long FromNC_AltitudeSetpoint;
94
extern unsigned char FromNC_AltitudeSpeed;
95
extern unsigned char Parameter_HoehenSchalter;      // Wert : 0-250
96
extern unsigned char CareFree;
97
extern int MesswertNick,MesswertRoll,MesswertGier;
98
extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll;
99
extern unsigned int NeutralAccX, NeutralAccY;
100
extern unsigned char HoehenReglerAktiv;
101
extern int NeutralAccZ;
102
extern signed char NeutralAccZfine;
103
extern long Umschlag180Nick, Umschlag180Roll;
104
extern signed int ExternStickNick,ExternStickRoll,ExternStickGier;
105
extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8;
106
extern int NaviAccNick,NaviAccRoll,NaviCntAcc;
107
extern unsigned int modell_fliegt;
108
extern void MotorRegler(void);
109
extern void SendMotorData(void);
110
//void CalibrierMittelwert(void);
111
//void Mittelwert(void);
112
extern unsigned char SetNeutral(unsigned char AccAdjustment);  // retuns: "sucess"
113
extern void Piep(unsigned char Anzahl, unsigned int dauer);
114
extern void CopyDebugValues(void);
115
extern unsigned char ACC_AltitudeControl;
116
extern signed int CosAttitude;  // for projection of hoover gas
117
 
118
extern unsigned char h,m,s;
119
extern int StickNick,StickRoll,StickGier,StickGas;
120
extern volatile unsigned char Timeout ;
121
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
122
extern int  DiffNick,DiffRoll;
123
//extern int  Poti1, Poti2, Poti3, Poti4;
124
extern volatile unsigned char SenderOkay;
125
extern int StickNick,StickRoll,StickGier;
126
extern char MotorenEin;
127
extern unsigned char CalibrationDone;
128
extern unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5;
129
extern char VarioCharacter;
130
extern signed int AltitudeSetpointTrimming;
131
extern signed char WaypointTrimming;
132
extern int HoverGas;
133
extern unsigned char Parameter_Luftdruck_D;
134
//extern unsigned char Parameter_MaxHoehe;
135
extern unsigned char Parameter_Hoehe_P;
136
extern unsigned char Parameter_Hoehe_ACC_Wirkung;
137
extern unsigned char Parameter_KompassWirkung;
138
extern unsigned char Parameter_Gyro_P;
139
extern unsigned char Parameter_Gyro_I;
140
extern unsigned char Parameter_Gier_P;
141
extern unsigned char Parameter_ServoNickControl;
142
extern unsigned char Parameter_ServoRollControl;
143
extern unsigned char Parameter_ServoNickComp;
144
extern unsigned char Parameter_ServoRollComp;
145
extern unsigned char Parameter_AchsKopplung1;
146
extern unsigned char Parameter_AchsKopplung2;
147
//extern unsigned char Parameter_AchsGegenKopplung1;
148
extern unsigned char Parameter_J16Bitmask;             // for the J16 Output
149
extern unsigned char Parameter_J16Timing;              // for the J16 Output
150
extern unsigned char Parameter_J17Bitmask;             // for the J17 Output
151
extern unsigned char Parameter_J17Timing;              // for the J17 Output
152
extern unsigned char Parameter_GlobalConfig;
153
extern unsigned char Parameter_ExtraConfig;
154
extern signed char MixerTable[MAX_MOTORS][4];
155
extern const signed char sintab[31];
156
extern unsigned char LowVoltageLandingActive;
157
extern unsigned char LowVoltageHomeActive;
158
extern unsigned char Parameter_MaximumAltitude;
159
#endif //_FC_H
160