Subversion Repositories FlightCtrl

Rev

Details | 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
886 killagreg 7
 
8
#include <inttypes.h>
9
 
1078 killagreg 10
#define YAW_GYRO_DEG_FACTOR 1291L // Factor between Yaw Gyro Integral and HeadingAngle in deg
855 hbuss 11
#define STICK_GAIN 4
886 killagreg 12
 
13
typedef struct
14
{
15
        uint8_t Height_D;
16
        uint8_t MaxHeight;
17
        uint8_t Height_P;
18
        uint8_t Height_ACC_Effect;
19
        uint8_t CompassYawEffect;
20
        uint8_t Gyro_P;
21
        uint8_t Gyro_I;
936 killagreg 22
        uint8_t Yaw_P;
886 killagreg 23
        uint8_t I_Factor;
24
        uint8_t UserParam1;
25
        uint8_t UserParam2;
26
        uint8_t UserParam3;
27
        uint8_t UserParam4;
28
        uint8_t UserParam5;
29
        uint8_t UserParam6;
30
        uint8_t UserParam7;
31
        uint8_t UserParam8;
911 killagreg 32
        uint8_t ServoNickControl;
33
        uint8_t LoopGasLimit;
886 killagreg 34
        uint8_t Yaw_PosFeedback;
35
        uint8_t Yaw_NegFeedback;
36
        uint8_t DynamicStability;
936 killagreg 37
        uint8_t ExternalControl;
38
        uint8_t J16Timing;
39
        uint8_t J17Timing;
1078 killagreg 40
        #if (defined (USE_KILLAGREG) || defined (USE_MK3MAG))
936 killagreg 41
        uint8_t NaviGpsModeControl;
42
        uint8_t NaviGpsGain;
43
        uint8_t NaviGpsP;
44
        uint8_t NaviGpsI;
45
        uint8_t NaviGpsD;
46
        uint8_t NaviGpsACC;
1080 killagreg 47
        uint8_t NaviOperatingRadius;
1078 killagreg 48
        uint8_t NaviWindCorrection;
49
        uint8_t NaviSpeedCompensation;
50
        #endif
1080 killagreg 51
        int8_t Kalman_K;
52
        int8_t Kalman_MaxDrift;
53
        int8_t Kalman_MaxFusion;
886 killagreg 54
} fc_param_t;
55
 
56
extern fc_param_t FCParam;
57
 
58
// attitude
936 killagreg 59
extern  int32_t IntegralNick, IntegralRoll, IntegralYaw;
60
extern  int16_t Reading_GyroNick, Reading_GyroRoll, Reading_GyroYaw;
886 killagreg 61
 
62
// offsets
936 killagreg 63
extern  int16_t AdNeutralNick, AdNeutralRoll, AdNeutralYaw;
886 killagreg 64
extern volatile int16_t NeutralAccX, NeutralAccY;
1 ingob 65
extern volatile float NeutralAccZ;
886 killagreg 66
 
67
 
68
extern volatile int32_t Reading_Integral_Top; // calculated in analog.c
69
 
70
// compass navigation
71
extern volatile int16_t CompassHeading;
72
extern volatile int16_t CompassCourse;
73
extern volatile int16_t CompassOffCourse;
74
extern volatile uint8_t CompassCalState;
75
extern int32_t YawGyroHeading;
76
extern int16_t YawGyroHeadingInDeg;
77
 
78
// hight control
79
extern int ReadingHeight;
80
extern int SetPointHeight;
81
 
82
// mean accelerations
936 killagreg 83
extern  int16_t Mean_AccNick, Mean_AccRoll, Mean_AccTop;
886 killagreg 84
 
85
// acceleration send to navi board
911 killagreg 86
extern int16_t NaviAccNick, NaviAccRoll, NaviCntAcc;
886 killagreg 87
 
88
 
89
// looping params
911 killagreg 90
extern long TurnOver180Nick, TurnOver180Roll;
886 killagreg 91
 
92
// external control
911 killagreg 93
extern int16_t ExternStickNick, ExternStickRoll, ExternStickYaw;
886 killagreg 94
 
95
 
96
void MotorControl(void);
1 ingob 97
void SendMotorData(void);
886 killagreg 98
void CalibMean(void);
99
void Mean(void);
1 ingob 100
void SetNeutral(void);
886 killagreg 101
void Beep(uint8_t numbeeps);
1 ingob 102
 
103
 
886 killagreg 104
extern int16_t  Poti1, Poti2, Poti3, Poti4, Poti5, Poti6, Poti7, Poti8;
499 hbuss 105
 
886 killagreg 106
// setpoints for motors
107
extern volatile uint8_t Motor_Front, Motor_Rear, Motor_Right, Motor_Left; //used by twimaster isr
1 ingob 108
 
886 killagreg 109
// current stick values
911 killagreg 110
extern int16_t StickNick;
886 killagreg 111
extern int16_t StickRoll;
112
extern int16_t StickYaw;
911 killagreg 113
extern int16_t GPS_Nick;
886 killagreg 114
extern int16_t GPS_Roll;
396 hbuss 115
 
886 killagreg 116
// current stick elongations
911 killagreg 117
extern int16_t MaxStickNick, MaxStickRoll, MaxStickYaw;
936 killagreg 118
 
119
 
886 killagreg 120
extern uint16_t Model_Is_Flying;
1 ingob 121
 
122
 
936 killagreg 123
// MKFlags
124
#define MKFLAG_MOTOR_RUN                                0x01
125
#define MKFLAG_FLY                                      0x02
126
#define MKFLAG_CALIBRATE                                0x04
127
#define MKFLAG_START                                    0x08
128
#define MKFLAG_EMERGENCY_LANDING        0x10
129
#define MKFLAG_RESERVE1                         0x20
130
#define MKFLAG_RESERVE2                         0x40
131
#define MKFLAG_RESERVE3                         0x80
132
 
133
volatile extern uint8_t MKFlags;
134
 
1 ingob 135
#endif //_FC_H
136