Rev 1908 | Rev 1961 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1908 | Rev 1960 | ||
---|---|---|---|
1 | #ifndef _CONFIGURATION_H |
1 | #ifndef _CONFIGURATION_H |
2 | #define _CONFIGURATION_H |
2 | #define _CONFIGURATION_H |
3 | 3 | ||
4 | #include <inttypes.h> |
4 | #include <inttypes.h> |
5 | #include <avr/io.h> |
5 | #include <avr/io.h> |
- | 6 | ||
- | 7 | ||
- | 8 | #define MAX_CHANNELS 10 |
|
- | 9 | #define MAX_MOTORS 12 |
|
6 | 10 | ||
7 | typedef struct { |
11 | typedef struct { |
8 | /*PMM*/uint8_t HeightD; |
- | |
9 | /* P */uint8_t MaxHeight; |
12 | // IMU |
10 | /*PMM*/uint8_t HeightP; |
- | |
11 | /* P */uint8_t Height_ACC_Effect; |
- | |
12 | /* P */uint8_t CompassYawEffect; |
13 | /*PMM*/uint8_t gyroP; |
13 | /* P */uint8_t GyroD; |
- | |
14 | /*PMM*/uint8_t GyroP; |
14 | /* P */uint8_t gyroD; |
15 | /* P */uint8_t GyroI; |
- | |
16 | /* Never used */uint8_t StickYawP; |
15 | /* P */uint8_t gyroI; |
17 | /* P */uint8_t IFactor; |
16 | /* P */uint8_t IFactor; |
18 | /* P */uint8_t UserParams[8]; |
17 | uint8_t yawIFactor; |
- | 18 | /* P */uint8_t compassYawEffect; |
|
- | 19 | ||
19 | /* P */uint8_t ServoPitchControl; |
20 | // Control |
- | 21 | /* P */uint8_t externalControl; |
|
20 | /* P */uint8_t LoopGasLimit; |
22 | |
21 | /* P */uint8_t AxisCoupling1; |
23 | /* P */uint8_t axisCoupling1; |
22 | /* P */uint8_t AxisCoupling2; |
24 | /* P */uint8_t axisCoupling2; |
23 | /* P */uint8_t AxisCouplingYawCorrection; |
25 | /* P */uint8_t axisCouplingYawCorrection; |
24 | /* P */uint8_t DynamicStability; |
26 | /* P */uint8_t dynamicStability; |
- | 27 | uint8_t maxControlActivityForAcc; |
|
25 | /* P */uint8_t ExternalControl; |
28 | |
26 | /*PMM*/uint8_t J16Timing; |
29 | // Height control |
27 | /*PMM*/uint8_t J17Timing; |
30 | /*PMM*/uint8_t heightP; |
28 | /* P */uint8_t NaviGpsModeControl; |
31 | /*PMM*/uint8_t heightD; |
29 | /* P */uint8_t NaviGpsGain; |
32 | /* P */uint8_t heightSetting; |
- | 33 | /* P */uint8_t heightACCEffect; |
|
30 | /* P */uint8_t NaviGpsP; |
34 | |
- | 35 | uint8_t attitudeControl; |
|
31 | /* P */uint8_t NaviGpsI; |
36 | |
32 | /* P */uint8_t NaviGpsD; |
37 | // The rest... |
33 | /* P */uint8_t NaviGpsACC; |
38 | /* P */uint8_t userParams[8]; |
34 | /*PMM*/uint8_t NaviOperatingRadius; |
39 | /*PMM*/uint8_t output0Timing; |
35 | /* P */uint8_t NaviWindCorrection; |
- | |
36 | /* P */uint8_t NaviSpeedCompensation; |
- | |
- | 40 | /*PMM*/uint8_t output1Timing; |
|
37 | int8_t KalmanK; |
41 | |
- | 42 | uint8_t servoManualControl[2]; |
|
38 | int8_t KalmanMaxDrift; |
43 | |
39 | int8_t KalmanMaxFusion; |
44 | uint8_t motorSmoothing; |
- | 45 | } dynamicParam_t; |
|
40 | } dynamicParam_t; |
46 | |
41 | extern dynamicParam_t dynamicParams; |
47 | extern dynamicParam_t dynamicParams; |
42 | 48 | ||
43 | typedef struct { |
49 | typedef struct { |
44 | uint8_t sourceIdx, targetIdx; |
50 | uint8_t sourceIdx, targetIdx; |
45 | uint8_t min, max; |
51 | uint8_t min, max; |
46 | } MMXLATION; |
52 | } MMXLATION; |
47 | 53 | ||
48 | typedef struct { |
54 | typedef struct { |
49 | uint8_t sourceIdx, targetIdx; |
55 | uint8_t sourceIdx, targetIdx; |
50 | } XLATION; |
56 | } XLATION; |
51 | - | ||
52 | // values above 250 representing poti1 to poti4 |
57 | |
53 | typedef struct { |
- | |
54 | uint8_t ChannelAssignment[8]; // see upper defines for details |
- | |
55 | uint8_t GlobalConfig; // see upper defines for bitcoding |
- | |
56 | uint8_t HeightMinGas; // Value : 0-100 |
- | |
57 | uint8_t HeightD; // Value : 0-250 |
- | |
58 | uint8_t MaxHeight; // Value : 0-32 |
- | |
59 | uint8_t HeightP; // Value : 0-32 |
- | |
60 | uint8_t Height_Gain; // Value : 0-50 |
- | |
61 | uint8_t Height_ACC_Effect; // Value : 0-250 |
- | |
62 | uint8_t StickP; // Value : 1-6 |
- | |
63 | uint8_t StickD; // Value : 0-64 |
- | |
64 | uint8_t StickYawP; // Value : 1-20 |
- | |
65 | uint8_t MinThrottle; // Value : 0-32 |
- | |
66 | uint8_t MaxThrottle; // Value : 33-250 |
- | |
67 | uint8_t GyroAccFactor; // Value : 1-64 |
- | |
68 | uint8_t CompassYawEffect; // Value : 0-32 |
- | |
69 | uint8_t GyroP; // Value : 10-250 |
- | |
70 | uint8_t GyroI; // Value : 0-250 |
- | |
71 | uint8_t GyroD; // Value : 0-250 |
- | |
72 | uint8_t LowVoltageWarning; // Value : 0-250 |
- | |
73 | uint8_t EmergencyGas; // Value : 0-250 //Gaswert bei Empüngsverlust |
- | |
74 | uint8_t EmergencyGasDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
58 | typedef struct { |
75 | uint8_t Unused0; // |
- | |
76 | uint8_t IFactor; // Value : 0-250 |
- | |
77 | uint8_t UserParams1[4]; // Value : 0-250 |
- | |
78 | /* |
- | |
79 | uint8_t UserParam2; // Value : 0-250 |
- | |
80 | uint8_t UserParam3; // Value : 0-250 |
- | |
81 | uint8_t UserParam4; // Value : 0-250 |
- | |
82 | */ |
- | |
83 | uint8_t ServoPitchControl; |
59 | uint8_t checksum; |
84 | uint8_t ServoPitchComp; |
60 | uint8_t revisionNumber; |
85 | uint8_t ServoPitchMin; |
- | |
86 | uint8_t ServoPitchMax; // Value : 0-250 // Anschlag |
- | |
87 | uint8_t ServoRefresh; // Value: 0-250 // Refreshrate of servo pwm output |
- | |
88 | uint8_t LoopGasLimit; // Value: 0-250 max. Gas wührend Looping |
- | |
89 | uint8_t LoopThreshold; // Value: 0-250 Schwelle für Stickausschlag |
- | |
90 | uint8_t LoopHysteresis; // Value: 0-250 Hysterese für Stickausschlag |
- | |
91 | uint8_t AxisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
- | |
92 | uint8_t AxisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
- | |
93 | uint8_t AxisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
- | |
94 | uint8_t unused0; |
61 | uint8_t channels[MAX_CHANNELS]; |
95 | uint8_t unused1; |
- | |
96 | uint8_t GyroAccTrim; // 1/k (Koppel_ACC_Wirkung) |
- | |
97 | uint8_t DriftComp; // limit for gyrodrift compensation |
- | |
98 | uint8_t DynamicStability; // PID limit for Attitude controller |
- | |
99 | uint8_t UserParams2[4]; // Value : 0-250 |
- | |
100 | /* |
- | |
101 | uint8_t UserParam6; // Value : 0-250 |
- | |
102 | uint8_t UserParam7; // Value : 0-250 |
- | |
103 | uint8_t UserParam8; // Value : 0-250 |
- | |
104 | */ |
- | |
105 | uint8_t J16Bitmask; // for the J16 Output |
- | |
106 | uint8_t J16Timing; // for the J16 Output |
- | |
107 | uint8_t J17Bitmask; // for the J17 Output |
- | |
108 | uint8_t J17Timing; // for the J17 Output |
- | |
109 | uint8_t NaviGpsModeControl; // Parameters for the Naviboard |
- | |
110 | uint8_t NaviGpsGain; // overall gain for GPS-PID controller |
- | |
111 | uint8_t NaviGpsP; // P gain for GPS-PID controller |
- | |
112 | uint8_t NaviGpsI; // I gain for GPS-PID controller |
- | |
113 | uint8_t NaviGpsD; // D gain for GPS-PID controller |
- | |
114 | uint8_t NaviGpsPLimit; // P limit for GPS-PID controller |
- | |
115 | uint8_t NaviGpsILimit; // I limit for GPS-PID controller |
- | |
116 | uint8_t NaviGpsDLimit; // D limit for GPS-PID controller |
- | |
117 | uint8_t NaviGpsACC; // ACC gain for GPS-PID controller |
- | |
118 | uint8_t NaviGpsMinSat; // number of sattelites neccesary for GPS functions |
- | |
119 | uint8_t NaviStickThreshold; // activation threshild for detection of manual stick movements |
- | |
120 | uint8_t NaviWindCorrection; // streng of wind course correction |
- | |
121 | uint8_t NaviSpeedCompensation; // D gain fefore position hold login |
- | |
122 | uint8_t NaviOperatingRadius; // Radius limit in m around start position for GPS flights |
- | |
123 | uint8_t NaviAngleLimitation; // limitation of attitude angle controlled by the gps algorithm |
- | |
124 | uint8_t NaviPHLoginTime; // position hold logintimeout |
- | |
125 | uint8_t ExternalControl; // for serial Control |
- | |
126 | uint8_t BitConfig; // see upper defines for bitcoding |
- | |
127 | uint8_t ServoPitchCompInvert; // Value : 0-250 0 oder 1 // WICHTIG!!! am Ende lassen |
- | |
128 | uint8_t Reserved[4]; |
62 | } channelMap_t; |
129 | int8_t Name[12]; |
- | |
- | 63 | extern channelMap_t channelMap; |
|
- | 64 | ||
- | 65 | typedef struct { |
|
- | 66 | uint8_t checksum; |
|
- | 67 | uint8_t revision; |
|
130 | } paramset_t; |
68 | int8_t name[12]; |
- | 69 | int8_t motor[MAX_MOTORS][4]; |
|
- | 70 | }__attribute__((packed)) mixerMatrix_t; |
|
- | 71 | extern mixerMatrix_t mixerMatrix; |
|
131 | 72 | ||
- | 73 | typedef struct { |
|
- | 74 | uint8_t manualControl; |
|
- | 75 | uint8_t compensationFactor; |
|
- | 76 | uint8_t minValue; |
|
- | 77 | uint8_t maxValue; |
|
- | 78 | uint8_t flags; |
|
- | 79 | } servo_t; |
|
- | 80 | ||
- | 81 | typedef struct { |
|
- | 82 | uint8_t bitmask; |
|
132 | #define PARAMSET_STRUCT_LEN sizeof(paramset_t) |
83 | uint8_t timing; |
- | 84 | } output_flash_t; |
|
- | 85 | ||
- | 86 | // values above 250 representing poti1 to poti4 |
|
- | 87 | typedef struct { |
|
- | 88 | // Global bitflags |
|
- | 89 | uint8_t bitConfig; // see upper defines for bitcoding |
|
- | 90 | uint8_t bitConfig2; // see upper defines for bitcoding |
|
- | 91 | ||
- | 92 | // Height Control |
|
- | 93 | uint8_t heightP; // Value : 0-32 |
|
- | 94 | uint8_t heightD; // Value : 0-250 |
|
- | 95 | uint8_t heightSetting; // Value : 0-32 |
|
- | 96 | uint8_t heightMaxThrottleChange; // Value : 0-100 |
|
133 | 97 | uint8_t heightSlewRate; // Value : 0-50 |
|
- | 98 | uint8_t heightACCEffect; // Value : 0-250 |
|
- | 99 | ||
- | 100 | // Attitude Control |
|
- | 101 | uint8_t attitudeControl; |
|
- | 102 | ||
134 | extern paramset_t staticParams; |
103 | // Control |
- | 104 | uint8_t stickP; // Value : 1-6 |
|
- | 105 | uint8_t stickD; // Value : 0-64 |
|
- | 106 | uint8_t stickYawP; // Value : 1-20 |
|
- | 107 | uint8_t stickThrottleD; |
|
- | 108 | uint8_t minThrottle; // Value : 0-32 |
|
- | 109 | uint8_t maxThrottle; // Value : 33-250 |
|
- | 110 | uint8_t externalControl; // for serial Control |
|
- | 111 | uint8_t maxControlActivityForAcc; |
|
135 | 112 | ||
136 | typedef struct { |
113 | // IMU |
- | 114 | uint8_t gyroPIDFilterConstant; |
|
- | 115 | uint8_t gyroATTFilterConstant; |
|
- | 116 | uint8_t gyroDFilterConstant; |
|
- | 117 | uint8_t accFilterConstant; |
|
- | 118 | ||
- | 119 | uint8_t gyroP; // Value : 10-250 |
|
- | 120 | uint8_t gyroI; // Value : 0-250 |
|
- | 121 | uint8_t gyroD; // Value : 0-250 |
|
- | 122 | ||
- | 123 | uint8_t zerothOrderCorrection; // Value : 1-64 |
|
- | 124 | uint8_t driftCompDivider; // 1/k (Koppel_ACC_Wirkung) |
|
- | 125 | uint8_t driftCompLimit; // limit for gyrodrift compensation |
|
- | 126 | ||
- | 127 | uint8_t axisCoupling1; // Value: 0-250 Faktor, mit dem Yaw die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
|
- | 128 | uint8_t axisCoupling2; // Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
|
- | 129 | uint8_t axisCouplingYawCorrection;// Value: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
|
- | 130 | ||
- | 131 | uint8_t dynamicStability; // PID limit for Attitude controller |
|
- | 132 | uint8_t IFactor; // Value : 0-250 |
|
- | 133 | uint8_t yawIFactor; |
|
- | 134 | uint8_t compassYawEffect; // Value : 0-32 |
|
- | 135 | ||
- | 136 | // Servos |
|
- | 137 | servo_t servoConfigurations[2]; // [PITCH, ROLL] |
|
- | 138 | uint8_t servoCount; |
|
- | 139 | ||
- | 140 | // Battery warning and emergency flight |
|
- | 141 | uint8_t batteryVoltageWarning; // Value : 0-250 |
|
- | 142 | uint8_t emergencyThrottle; // Value : 0-250 //Gaswert bei Empüngsverlust /* |
|
- | 143 | uint8_t emergencyFlightDuration; // Value : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
|
- | 144 | ||
- | 145 | // Outputs |
|
- | 146 | output_flash_t outputFlash[2]; |
|
- | 147 | uint8_t outputDebugMask; |
|
- | 148 | // bit0: Test all OFF |
|
- | 149 | // bit1: Test all ON |
|
- | 150 | // bit2: flash when beeping |
|
- | 151 | uint8_t outputFlags; |
|
- | 152 | ||
- | 153 | // User params |
|
137 | uint8_t Revision; |
154 | uint8_t userParams[8]; // Value : 0-250 |
138 | int8_t Name[12]; |
155 | |
139 | int8_t Motor[16][4]; |
156 | // Name |
140 | }__attribute__((packed)) MixerTable_t; |
157 | uint8_t name[12]; |
141 | 158 | } paramset_t; |
|
142 | extern MixerTable_t Mixer; |
159 | extern paramset_t staticParams; |
143 | 160 | ||
144 | // MKFlags |
161 | // MKFlags |
145 | #define MKFLAG_MOTOR_RUN (1<<0) |
162 | #define MKFLAG_MOTOR_RUN (1<<0) |
146 | #define MKFLAG_FLY (1<<1) |
163 | #define MKFLAG_FLY (1<<1) |
147 | #define MKFLAG_CALIBRATE (1<<2) |
164 | #define MKFLAG_CALIBRATE (1<<2) |
148 | #define MKFLAG_START (1<<3) |
165 | #define MKFLAG_START (1<<3) |
149 | #define MKFLAG_EMERGENCY_LANDING (1<<4) |
166 | #define MKFLAG_EMERGENCY_FLIGHT (1<<4) |
150 | #define MKFLAG_RESERVE1 (1<<5) |
167 | #define MKFLAG_RESERVE1 (1<<5) |
151 | #define MKFLAG_RESERVE2 (1<<6) |
168 | #define MKFLAG_RESERVE2 (1<<6) |
152 | #define MKFLAG_RESERVE3 (1<<7) |
169 | #define MKFLAG_RESERVE3 (1<<7) |
153 | 170 | ||
154 | // bit mask for staticParams.GlobalConfig |
171 | // bit mask for staticParams.bitConfig |
155 | #define CFG_HEIGHT_CONTROL (1<<0) |
172 | #define CFG_HEIGHT_CONTROL (1<<0) |
156 | #define CFG_HEIGHT_SWITCH (1<<1) |
173 | #define CFG_HEIGHT_SWITCH (1<<1) |
157 | #define CFG_HEADING_HOLD (1<<2) |
174 | #define CFG_HEADING_HOLD (1<<2) |
158 | #define CFG_COMPASS_ACTIVE (1<<3) |
175 | #define CFG_COMPASS_ACTIVE (1<<3) |
159 | #define CFG_COMPASS_FIX (1<<4) |
176 | #define CFG_COMPASS_FIX (1<<4) |
160 | #define CFG_GPS_ACTIVE (1<<5) |
177 | #define CFG_GPS_ACTIVE (1<<5) |
161 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
178 | #define CFG_AXIS_COUPLING_ACTIVE (1<<6) |
162 | #define CFG_ROTARY_RATE_LIMITER (1<<7) |
179 | #define CFG_GYRO_SATURATION_PREVENTION (1<<7) |
163 | 180 | ||
164 | // bit mask for staticParams.BitConfig |
181 | // bit mask for staticParams.bitConfig2 |
165 | #define CFG_LOOP_UP (1<<0) |
182 | #define CFG_LOOP_UP (1<<0) |
166 | #define CFG_LOOP_DOWN (1<<1) |
183 | #define CFG_LOOP_DOWN (1<<1) |
167 | #define CFG_LOOP_LEFT (1<<2) |
184 | #define CFG_LOOP_LEFT (1<<2) |
168 | #define CFG_LOOP_RIGHT (1<<3) |
185 | #define CFG_LOOP_RIGHT (1<<3) |
169 | #define CFG_HEIGHT_3SWITCH (1<<4) |
186 | #define CFG_HEIGHT_3SWITCH (1<<4) |
170 | 187 | ||
171 | #define ATMEGA644 0 |
188 | #define ATMEGA644 0 |
172 | #define ATMEGA644P 1 |
189 | #define ATMEGA644P 1 |
173 | #define SYSCLK F_CPU |
190 | #define SYSCLK F_CPU |
174 | 191 | ||
175 | // Not really a part of configuration, but LEDs and HW version test are the same. |
192 | // Not really a part of configuration, but LEDs and HW version test are the same. |
176 | #define RED_OFF {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
193 | #define RED_OFF {if((boardRelease == 10) || (boardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
177 | #define RED_ON {if((BoardRelease == 10) || (BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
194 | #define RED_ON {if((boardRelease == 10) || (boardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
178 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
195 | #define RED_FLASH PORTB ^= (1<<PORTB0) |
179 | #define GRN_OFF {if(BoardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
196 | #define GRN_OFF {if(boardRelease < 12) PORTB &=~(1<<PORTB1); else PORTB |= (1<<PORTB1);} |
180 | #define GRN_ON {if(BoardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
197 | #define GRN_ON {if(boardRelease < 12) PORTB |= (1<<PORTB1); else PORTB &=~(1<<PORTB1);} |
181 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
198 | #define GRN_FLASH PORTB ^= (1<<PORTB1) |
182 | 199 | ||
183 | // Mixer table |
200 | // Mixer table |
184 | #define MIX_THROTTLE 0 |
201 | #define MIX_THROTTLE 0 |
185 | #define MIX_PITCH 1 |
202 | #define MIX_PITCH 1 |
186 | #define MIX_ROLL 2 |
203 | #define MIX_ROLL 2 |
187 | #define MIX_YAW 3 |
204 | #define MIX_YAW 3 |
188 | 205 | ||
189 | extern volatile uint8_t MKFlags; |
206 | extern volatile uint8_t MKFlags; |
- | 207 | extern uint8_t requiredMotors; |
|
190 | extern int16_t variables[8]; // The "Poti"s. |
208 | extern int16_t variables[8]; // The "Poti"s. |
191 | extern uint8_t BoardRelease; |
209 | extern uint8_t boardRelease; |
192 | extern uint8_t CPUType; |
210 | extern uint8_t CPUType; |
- | 211 | ||
- | 212 | void channelMap_default(void); |
|
- | 213 | void paramSet_default(uint8_t setnumber); |
|
- | 214 | void mixerMatrix_default(void); |
|
193 | 215 | ||
194 | void configuration_applyVariablesToParams(void); |
216 | void configuration_applyVariablesToParams(void); |
195 | uint8_t getCPUType(void); |
217 | uint8_t getCPUType(void); |
196 | uint8_t getBoardRelease(void); |
218 | uint8_t getBoardRelease(void); |
197 | 219 | ||
198 | #endif // _CONFIGURATION_H |
220 | #endif // _CONFIGURATION_H |
199 | 221 |