Subversion Repositories FlightCtrl

Rev

Rev 2552 | 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
1703 holgerb 11
#define ACC_AMPLIFY    6
2390 holgerb 12
#define HEIGHT_CONTROL_STICKTHRESHOLD 15
2541 holgerb 13
#define SERVO_FS_TIME 10   // in Seconds
921 hbuss 14
 
1916 holgerb 15
// FC_StatusFlags
1765 killagreg 16
#define FC_STATUS_MOTOR_RUN                             0x01
17
#define FC_STATUS_FLY                                   0x02
18
#define FC_STATUS_CALIBRATE                             0x04
19
#define FC_STATUS_START                                 0x08
20
#define FC_STATUS_EMERGENCY_LANDING             0x10
21
#define FC_STATUS_LOWBAT                                0x20
1767 killagreg 22
#define FC_STATUS_VARIO_TRIM_UP                 0x40
23
#define FC_STATUS_VARIO_TRIM_DOWN               0x80
1254 killagreg 24
 
2040 holgerb 25
// FC_StatusFlags2 
1861 holgerb 26
#define FC_STATUS2_CAREFREE                 0x01
27
#define FC_STATUS2_ALTITUDE_CONTROL         0x02
1916 holgerb 28
#define FC_STATUS2_RC_FAILSAVE_ACTIVE       0x04
2040 holgerb 29
#define FC_STATUS2_OUT1_ACTIVE                  0x08
30
#define FC_STATUS2_OUT2_ACTIVE                  0x10
2309 holgerb 31
#define FC_STATUS2_WAIT_FOR_TAKEOFF             0x20   // Motor Running, but still on the ground
2340 holgerb 32
#define FC_STATUS2_AUTO_STARTING                0x40
33
#define FC_STATUS2_AUTO_LANDING                 0x80
1702 holgerb 34
 
2482 holgerb 35
// FC_StatusFlags3 
2530 holgerb 36
#define FC_STATUS3_REDUNDANCE_AKTIVE        0x01
2482 holgerb 37
#define FC_STATUS3_BOAT                         0x02
2530 holgerb 38
#define FC_STATUS3_REDUNDANCE_ERROR         0x04
39
#define FC_STATUS3_REDUNDANCE_TEST                      0x08
2482 holgerb 40
 
2009 holgerb 41
//NC_To_FC_Flags
42
#define NC_TO_FC_FLYING_RANGE           0x01
2552 holgerb 43
#define NC_TO_FC_EMERGENCY_LANDING      0x02 // Forces a landing
2322 holgerb 44
#define NC_TO_FC_AUTOSTART                      0x04
2541 holgerb 45
#define NC_TO_FC_FAILSAFE_LANDING       0x08 // moves Servos into FS-Position
2482 holgerb 46
#define NC_TO_FC_SIMULATION_ACTIVE      0x10 // don't start motors
2009 holgerb 47
 
1861 holgerb 48
extern volatile unsigned char FC_StatusFlags, FC_StatusFlags2;
2482 holgerb 49
extern unsigned char FC_StatusFlags3;
1862 holgerb 50
extern void ParameterZuordnung(void);
2342 holgerb 51
extern unsigned char GetChannelValue(unsigned char ch); // gives the unsigned value of the channel
2499 holgerb 52
extern void ChannelAssingment(void);
2537 holgerb 53
extern void StoreNeutralToEeprom(void);
1861 holgerb 54
 
1377 hbuss 55
#define Poti1 Poti[0]
56
#define Poti2 Poti[1]
57
#define Poti3 Poti[2]
58
#define Poti4 Poti[3]
59
#define Poti5 Poti[4]
60
#define Poti6 Poti[5]
61
#define Poti7 Poti[6]
62
#define Poti8 Poti[7]
1254 killagreg 63
 
2191 holgerb 64
#define LIMIT_MIN(value, min) {if(value <= min) value = min;}
65
#define LIMIT_MAX(value, max) {if(value >= max) value = max;}
66
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;}
67
 
1921 holgerb 68
#define CHK_POTI(b,a) {if(a < 248) b = a; else b = Poti[255 - a];}
1933 holgerb 69
#define CHK_POTI_OFF(b,a,off) {if(a < 248) b = a; else b = Poti[255 - a] - off;}
1921 holgerb 70
#define CHK_POTI_MM(b,a,min,max) {CHK_POTI(b,a); LIMIT_MIN_MAX(b, min, max);}
1933 holgerb 71
#define CHK_POTI_MM_OFF(b,a,min,max,off) {CHK_POTI_OFF(b,a,off); LIMIT_MIN_MAX(b, min, max);}
1921 holgerb 72
 
1 ingob 73
extern unsigned char Sekunde,Minute;
1352 hbuss 74
extern unsigned int BaroExpandActive;
2482 holgerb 75
extern long IntegralNick;//,IntegralNick2;
76
extern long IntegralRoll;//,IntegralRoll2;
1153 hbuss 77
//extern int IntegralNick,IntegralNick2;
78
//extern int IntegralRoll,IntegralRoll2;
1420 killagreg 79
extern unsigned char Poti[9];
1153 hbuss 80
 
2482 holgerb 81
extern long Mess_IntegralNick;//,Mess_IntegralNick2;
82
extern long Mess_IntegralRoll;//,Mess_IntegralRoll2;
693 hbuss 83
extern long IntegralAccNick,IntegralAccRoll;
1685 holgerb 84
extern long SummeNick,SummeRoll;
1 ingob 85
extern volatile long Mess_Integral_Hoch;
693 hbuss 86
extern long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2;
1153 hbuss 87
extern int  KompassValue;
2497 holgerb 88
extern int  KompassSollWert,NC_CompassSetpoint;
1153 hbuss 89
extern int  KompassRichtung;
1839 holgerb 90
extern char CalculateCompassTimer;
91
extern unsigned char KompassFusion;
1664 holgerb 92
extern unsigned char ControlHeading;
1166 hbuss 93
extern int  TrimNick, TrimRoll;
717 hbuss 94
extern long  ErsatzKompass;
2437 holgerb 95
extern int   ErsatzKompassInGrad,CompassCorrected; // Kompasswert in Grad
1246 killagreg 96
extern long HoehenWert;
97
extern long SollHoehe;
1855 holgerb 98
extern long FromNC_AltitudeSetpoint;
99
extern unsigned char FromNC_AltitudeSpeed;
1921 holgerb 100
extern unsigned char Parameter_HoehenSchalter;      // Wert : 0-250
1690 holgerb 101
extern unsigned char CareFree;
1153 hbuss 102
extern int MesswertNick,MesswertRoll,MesswertGier;
1703 holgerb 103
extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll;
2499 holgerb 104
extern int BoatNeutralNick,BoatNeutralRoll,BoatNeutralGier;
1643 holgerb 105
extern unsigned int NeutralAccX, NeutralAccY;
1215 hbuss 106
extern unsigned char HoehenReglerAktiv;
1639 holgerb 107
extern int NeutralAccZ;
2316 holgerb 108
extern signed char NeutralAccZfine;
396 hbuss 109
extern long Umschlag180Nick, Umschlag180Roll;
513 hbuss 110
extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8;
805 hbuss 111
extern int NaviAccNick,NaviAccRoll,NaviCntAcc;
871 hbuss 112
extern unsigned int modell_fliegt;
1639 holgerb 113
extern void MotorRegler(void);
114
extern void SendMotorData(void);
1622 killagreg 115
//void CalibrierMittelwert(void);
116
//void Mittelwert(void);
2316 holgerb 117
extern unsigned char SetNeutral(unsigned char AccAdjustment);  // retuns: "sucess"
1639 holgerb 118
extern void Piep(unsigned char Anzahl, unsigned int dauer);
119
extern void CopyDebugValues(void);
2309 holgerb 120
extern unsigned char ACC_AltitudeControl;
121
extern signed int CosAttitude;  // for projection of hoover gas
1 ingob 122
 
304 ingob 123
extern unsigned char h,m,s;
1943 holgerb 124
extern int StickNick,StickRoll,StickGier,StickGas;
304 ingob 125
extern volatile unsigned char Timeout ;
126
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
1153 hbuss 127
extern int  DiffNick,DiffRoll;
1377 hbuss 128
//extern int  Poti1, Poti2, Poti3, Poti4;
304 ingob 129
extern volatile unsigned char SenderOkay;
130
extern int StickNick,StickRoll,StickGier;
131
extern char MotorenEin;
2009 holgerb 132
extern unsigned char CalibrationDone;
1403 hbuss 133
extern unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5;
1591 holgerb 134
extern char VarioCharacter;
1942 holgerb 135
extern signed int AltitudeSetpointTrimming;
136
extern signed char WaypointTrimming;
1692 holgerb 137
extern int HoverGas;
1 ingob 138
extern unsigned char Parameter_Luftdruck_D;
2342 holgerb 139
//extern unsigned char Parameter_MaxHoehe;
1 ingob 140
extern unsigned char Parameter_Hoehe_P;
141
extern unsigned char Parameter_Hoehe_ACC_Wirkung;
142
extern unsigned char Parameter_KompassWirkung;
143
extern unsigned char Parameter_Gyro_P;
144
extern unsigned char Parameter_Gyro_I;
145
extern unsigned char Parameter_Gier_P;
146
extern unsigned char Parameter_ServoNickControl;
1232 hbuss 147
extern unsigned char Parameter_ServoRollControl;
2296 holgerb 148
extern unsigned char Parameter_ServoNickComp;
149
extern unsigned char Parameter_ServoRollComp;
396 hbuss 150
extern unsigned char Parameter_AchsKopplung1;
1120 hbuss 151
extern unsigned char Parameter_AchsKopplung2;
152
//extern unsigned char Parameter_AchsGegenKopplung1;
921 hbuss 153
extern unsigned char Parameter_J16Bitmask;             // for the J16 Output
154
extern unsigned char Parameter_J16Timing;              // for the J16 Output
155
extern unsigned char Parameter_J17Bitmask;             // for the J17 Output
156
extern unsigned char Parameter_J17Timing;              // for the J17 Output
1916 holgerb 157
extern unsigned char Parameter_GlobalConfig;
158
extern unsigned char Parameter_ExtraConfig;
1243 killagreg 159
extern signed char MixerTable[MAX_MOTORS][4];
1760 holgerb 160
extern const signed char sintab[31];
2390 holgerb 161
extern unsigned char LowVoltageLandingActive;
2408 holgerb 162
extern unsigned char LowVoltageHomeActive;
2447 holgerb 163
extern unsigned char Parameter_MaximumAltitude;
2497 holgerb 164
extern char NeueKompassRichtungMerken;
2541 holgerb 165
extern unsigned char ServoFailsafeActive;
2499 holgerb 166
 
1 ingob 167
#endif //_FC_H
168