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