forked from multiwii/multiwii-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiWii.h
205 lines (167 loc) · 6.61 KB
/
MultiWii.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef MULTIWII_H_
#define MULTIWII_H_
#define VERSION 230
#include "types.h"
// default POSHOLD control gains
#define POSHOLD_P .11
#define POSHOLD_I 0.0
#define POSHOLD_IMAX 20 // degrees
#define POSHOLD_RATE_P 2.0
#define POSHOLD_RATE_I 0.08 // Wind control
#define POSHOLD_RATE_D 0.045 // try 2 or 3 for POSHOLD_RATE 1
#define POSHOLD_RATE_IMAX 20 // degrees
// default Navigation PID gains
#define NAV_P 1.4
#define NAV_I 0.20 // Wind control
#define NAV_D 0.08 //
#define NAV_IMAX 20 // degrees
#define MINCHECK 1100
#define MAXCHECK 1900
extern volatile unsigned long timer0_overflow_count;
extern const char pidnames[];
extern const char boxnames[];
extern const uint8_t boxids[];
extern uint32_t currentTime;
extern uint16_t previousTime;
extern uint16_t cycleTime;
extern uint16_t calibratingA;
extern uint16_t calibratingB;
extern uint16_t calibratingG;
extern int16_t magHold,headFreeModeHold;
extern uint8_t vbatMin;
extern uint8_t rcOptions[CHECKBOXITEMS];
extern int32_t AltHold;
extern int16_t sonarAlt;
extern int16_t BaroPID;
extern int16_t errorAltitudeI;
extern int16_t i2c_errors_count;
extern uint8_t alarmArray[16];
extern global_conf_t global_conf;
extern imu_t imu;
extern analog_t analog;
extern alt_t alt;
extern att_t att;
#ifdef LOG_PERMANENT
extern plog_t plog;
#endif
extern int16_t debug[4];
extern conf_t conf;
extern int16_t annex650_overrun_count;
extern flags_struct_t f;
extern uint16_t intPowerTrigger1;
extern int16_t gyroZero[3];
extern int16_t angle[2];
#if BARO
extern int32_t baroPressure;
extern int16_t baroTemperature; // temp in 0.01 deg
extern int32_t baroPressureSum;
#endif
extern int16_t axisPID[3];
extern int16_t motor[8];
extern int16_t servo[8];
extern int16_t failsafeEvents;
extern volatile int16_t failsafeCnt;
extern int16_t rcData[RC_CHANS];
extern int16_t rcSerial[8];
extern int16_t rcCommand[4];
extern uint8_t rcSerialCount;
extern int16_t lookupPitchRollRC[5];
extern int16_t lookupThrottleRC[11];
#if defined(POWERMETER) || ( defined(LOG_VALUES) && (LOG_VALUES >= 3) )
#define PMOTOR_SUM 8 // index into pMeter[] for sum
extern uint32_t pMeter[PMOTOR_SUM + 1]; // we use [0:7] for eight motors,one extra for sum
extern uint8_t pMeterV; // dummy to satisfy the paramStruct logic in ConfigurationLoop()
extern uint32_t pAlarm; // we scale the eeprom value from [0:255] to this value we can directly compare to the sum in pMeter[6]
extern uint16_t powerValue; // last known current
#endif
#if defined(LCD_TELEMETRY)
extern uint8_t telemetry;
extern uint8_t telemetry_auto;
#endif
#ifdef LCD_TELEMETRY_STEP
extern char telemetryStepSequence[];
extern uint8_t telemetryStepIndex;
#endif
#if defined(LOG_VALUES) || defined(LCD_TELEMETRY)
extern uint16_t cycleTimeMax; // highest ever cycle timen
extern uint16_t cycleTimeMin; // lowest ever cycle timen
extern int32_t BAROaltMax; // maximum value
extern uint16_t GPS_speedMax; // maximum speed from gps
extern uint16_t powerValueMaxMAH;
extern uint16_t wattsMax;
#endif
#if defined(LOG_VALUES) || defined(LCD_TELEMETRY) || defined(ARMEDTIMEWARNING) || defined(LOG_PERMANENT)
extern uint32_t armedTime;
#endif
// **********************
// GPS common variables
// **********************
extern int16_t GPS_angle[2]; // the angles that must be applied for GPS correction
extern int32_t GPS_coord[2];
extern int32_t GPS_home[2];
extern int32_t GPS_hold[2];
extern uint8_t GPS_numSat;
extern uint16_t GPS_distanceToHome; // distance to home - unit: meter
extern int16_t GPS_directionToHome; // direction to home - unit: degree
extern uint16_t GPS_altitude; // GPS altitude - unit: meter
extern uint16_t GPS_speed; // GPS speed - unit: cm/s
extern uint8_t GPS_update; // a binary toogle to distinct a GPS position update
extern uint16_t GPS_ground_course; // - unit: degree*10
extern uint8_t GPS_Present; // Checksum from Gps serial
extern uint8_t GPS_Enable;
extern uint8_t GPS_Frame; // indicates if a frame is ready to be computed
#define LAT 0
#define LON 1
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serial GPS only variables
//navigation mode
#define NAV_MODE_NONE 0
#define NAV_MODE_POSHOLD 1
#define NAV_MODE_WP 2
extern uint8_t nav_mode; // Navigation mode
extern int16_t nav[2];
extern int16_t nav_rated[2]; //Adding a rate controller to the navigation to make it smoother
// default POSHOLD control gains
#define POSHOLD_P .11
#define POSHOLD_I 0.0
#define POSHOLD_IMAX 20 // degrees
#define POSHOLD_RATE_P 2.0
#define POSHOLD_RATE_I 0.08 // Wind control
#define POSHOLD_RATE_D 0.045 // try 2 or 3 for POSHOLD_RATE 1
#define POSHOLD_RATE_IMAX 20 // degrees
// default Navigation PID gains
#define NAV_P 1.4
#define NAV_I 0.20 // Wind control
#define NAV_D 0.08 //
#define NAV_IMAX 20 // degrees
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serial GPS only variables
//navigation mode
#define NAV_MODE_NONE 0
#define NAV_MODE_POSHOLD 1
#define NAV_MODE_WP 2
extern volatile uint8_t spekFrameFlags;
extern volatile uint32_t spekTimeLast;
extern uint8_t spekFrameDone;
#if defined(OPENLRSv2MULTI)
extern uint8_t pot_P,pot_I; // OpenLRS onboard potentiometers for P and I trim or other usages
#endif
// **********************
//Automatic ACC Offset Calibration
// **********************
#if defined(INFLIGHT_ACC_CALIBRATION)
extern uint16_t InflightcalibratingA;
extern int16_t AccInflightCalibrationArmed;
extern uint16_t AccInflightCalibrationMeasurementDone;
extern uint16_t AccInflightCalibrationSavetoEEProm;
extern uint16_t AccInflightCalibrationActive;
#endif
#if defined(ARMEDTIMEWARNING)
extern uint32_t ArmedTimeWarningMicroSeconds;
#endif
#if defined(THROTTLE_ANGLE_CORRECTION)
extern int16_t throttleAngleCorrection;
extern int8_t cosZ;
#endif
void annexCode();
#endif /* MULTIWII_H_ */