Rev 885 | Rev 911 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 885 | Rev 886 | ||
---|---|---|---|
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Konstanten |
2 | // + Konstanten |
3 | // + 0-250 -> normale Werte |
3 | // + 0-250 -> normale Werte |
4 | // + 251 -> Poti1 |
4 | // + 251 -> Poti1 |
5 | // + 252 -> Poti2 |
5 | // + 252 -> Poti2 |
6 | // + 253 -> Poti3 |
6 | // + 253 -> Poti3 |
7 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
- | 8 | ||
- | 9 | #ifndef EEMEM |
|
- | 10 | #define EEMEM __attribute__ ((section (".eeprom"))) |
|
- | 11 | #endif |
|
- | 12 | ||
- | 13 | ||
- | 14 | #include <avr/eeprom.h> |
|
- | 15 | #include <string.h> |
|
- | 16 | #include "eeprom.h" |
|
- | 17 | #include "printf_P.h" |
|
- | 18 | ||
- | 19 | ||
- | 20 | // byte array in eeprom |
|
- | 21 | uint8_t EEPromArray[E2END+1] EEMEM; |
|
- | 22 | ||
- | 23 | paramset_t ParamSet; |
|
- | 24 | ||
- | 25 | ||
- | 26 | ||
- | 27 | /***************************************************/ |
|
- | 28 | /* Default Values for parameter set 1 */ |
|
- | 29 | /***************************************************/ |
|
- | 30 | void ParamSet_DefaultSet1(void) // sport |
|
- | 31 | { |
|
- | 32 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 33 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 34 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 35 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 36 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 37 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 38 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 39 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 40 | ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 41 | ParamSet.Height_MinThrust = 30; |
|
- | 42 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 43 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 44 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 45 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 46 | ParamSet.Height_Gain = 4; // Wert : 0-50 |
|
- | 47 | ParamSet.Stick_P = 15; // Wert : 1-24 |
|
- | 48 | ParamSet.Stick_D = 30; // Wert : 0-250 |
|
- | 49 | ParamSet.Yaw_P = 12; // Wert : 1-20 |
|
- | 50 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 51 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 52 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 53 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 54 | ParamSet.Gyro_P = 80; // Wert : 0-250 |
|
- | 55 | ParamSet.Gyro_I = 150; // Wert : 0-250 |
|
- | 56 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 57 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 58 | ParamSet.EmergencyThrustDuration = 30; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 59 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 60 | ParamSet.I_Factor = 32; |
|
- | 61 | ParamSet.UserParam1 = 253; //zur freien Verwendung |
|
- | 62 | ParamSet.UserParam2 = 100; //zur freien Verwendung |
|
- | 63 | ParamSet.UserParam3 = 90; //zur freien Verwendung |
|
- | 64 | ParamSet.UserParam4 = 90; //zur freien Verwendung |
|
- | 65 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 66 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 67 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 68 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 69 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 70 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 71 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 72 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 73 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 74 | ParamSet.ServoPitchRefresh = 5; |
|
- | 75 | ParamSet.LoopThrustLimit = 50; |
|
- | 76 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 77 | ParamSet.LoopHysteresis = 50; |
|
- | 78 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
|
- | 79 | ParamSet.Yaw_PosFeedback = 90; |
|
- | 80 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 81 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 82 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 83 | ParamSet.GyroAccTrim = 16; // 1/k |
|
- | 84 | ParamSet.DriftComp = 4; |
|
- | 85 | ParamSet.DynamicStability = 100; |
|
- | 86 | memcpy(ParamSet.Name, "Sport\0",6); |
|
- | 87 | } |
|
- | 88 | ||
- | 89 | ||
- | 90 | /***************************************************/ |
|
- | 91 | /* Default Values for parameter set 2 */ |
|
- | 92 | /***************************************************/ |
|
- | 93 | void ParamSet_DefaultSet2(void) // normal |
|
- | 94 | { |
|
- | 95 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 96 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 97 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 98 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 99 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 100 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 101 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 102 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 103 | ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 104 | ParamSet.Height_MinThrust = 30; |
|
- | 105 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 106 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 107 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 108 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 109 | ParamSet.Height_Gain = 3; // Wert : 0-50 |
|
- | 110 | ParamSet.Stick_P = 12; // Wert : 1-24 |
|
- | 111 | ParamSet.Stick_D = 16; // Wert : 0-250 |
|
- | 112 | ParamSet.Yaw_P = 6; // Wert : 1-20 |
|
- | 113 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 114 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 115 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 116 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 117 | ParamSet.Gyro_P = 80; // Wert : 0-250 |
|
- | 118 | ParamSet.Gyro_I = 120; // Wert : 0-250 |
|
- | 119 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 120 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 121 | ParamSet.EmergencyThrustDuration = 30; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 122 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 123 | ParamSet.I_Factor = 32; |
|
- | 124 | ParamSet.UserParam1 = 253; // zur freien Verwendung |
|
- | 125 | ParamSet.UserParam2 = 100; // zur freien Verwendung |
|
- | 126 | ParamSet.UserParam3 = 90; // zur freien Verwendung |
|
- | 127 | ParamSet.UserParam4 = 90; // zur freien Verwendung |
|
- | 128 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 129 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 130 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 131 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 132 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 133 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 134 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 135 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 136 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 137 | ParamSet.ServoPitchRefresh = 5; |
|
- | 138 | ParamSet.LoopThrustLimit = 50; |
|
- | 139 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 140 | ParamSet.LoopHysteresis = 50; |
|
- | 141 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
|
- | 142 | ParamSet.Yaw_PosFeedback = 90; // Faktor, mit dem Yaw die Achsen Roll und Pitch verkoppelt |
|
- | 143 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 144 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 145 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 146 | ParamSet.GyroAccTrim = 32; // 1/k |
|
- | 147 | ParamSet.DriftComp = 4; |
|
- | 148 | ParamSet.DynamicStability = 75; |
|
- | 149 | memcpy(ParamSet.Name, "Normal\0", 7); |
|
- | 150 | } |
|
- | 151 | ||
- | 152 | ||
- | 153 | /***************************************************/ |
|
- | 154 | /* Default Values for parameter set 3 */ |
|
- | 155 | /***************************************************/ |
|
- | 156 | void ParamSet_DefaultSet3(void) // beginner |
|
- | 157 | { |
|
- | 158 | ParamSet.ChannelAssignment[CH_PITCH] = 1; |
|
- | 159 | ParamSet.ChannelAssignment[CH_ROLL] = 2; |
|
- | 160 | ParamSet.ChannelAssignment[CH_THRUST] = 3; |
|
- | 161 | ParamSet.ChannelAssignment[CH_YAW] = 4; |
|
- | 162 | ParamSet.ChannelAssignment[CH_POTI1] = 5; |
|
- | 163 | ParamSet.ChannelAssignment[CH_POTI2] = 6; |
|
- | 164 | ParamSet.ChannelAssignment[CH_POTI3] = 7; |
|
- | 165 | ParamSet.ChannelAssignment[CH_POTI4] = 8; |
|
- | 166 | ParamSet.GlobalConfig = CFG_ROTARY_RATE_LIMITER | CFG_AXIS_COUPLING_ACTIVE | CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE;//CFG_HEIGHT_CONTROL | CFG_HEIGHT_SWITCH | CFG_COMPASS_FIX;//0x01; |
|
- | 167 | ParamSet.Height_MinThrust = 30; |
|
- | 168 | ParamSet.MaxHeight = 251; // Wert : 0-250 251 -> Poti1 |
|
- | 169 | ParamSet.Height_P = 10; // Wert : 0-32 |
|
- | 170 | ParamSet.Height_D = 30; // Wert : 0-250 |
|
- | 171 | ParamSet.Height_ACC_Effect = 30; // Wert : 0-250 |
|
- | 172 | ParamSet.Height_Gain = 3; // Wert : 0-50 |
|
- | 173 | ParamSet.Stick_P = 8; // Wert : 1-24 |
|
- | 174 | ParamSet.Stick_D = 16; // Wert : 0-250 |
|
- | 175 | ParamSet.Yaw_P = 6; // Wert : 1-20 |
|
- | 176 | ParamSet.Trust_Min = 8; // Wert : 0-32 |
|
- | 177 | ParamSet.Trust_Max = 230; // Wert : 33-250 |
|
- | 178 | ParamSet.GyroAccFactor = 30; // Wert : 1-64 |
|
- | 179 | ParamSet.CompassYawEffect = 128; // Wert : 0-250 |
|
- | 180 | ParamSet.Gyro_P = 100; // Wert : 0-250 |
|
- | 181 | ParamSet.Gyro_I = 120; // Wert : 0-250 |
|
- | 182 | ParamSet.LowVoltageWarning = 94; // Wert : 0-250 |
|
- | 183 | ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
|
- | 184 | ParamSet.EmergencyThrustDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen |
|
- | 185 | ParamSet.UfoArrangement = 0; // X oder + Formation |
|
- | 186 | ParamSet.I_Factor = 16; |
|
- | 187 | ParamSet.UserParam1 = 253; // zur freien Verwendung |
|
- | 188 | ParamSet.UserParam2 = 100; // zur freien Verwendung |
|
- | 189 | ParamSet.UserParam3 = 90; // zur freien Verwendung |
|
- | 190 | ParamSet.UserParam4 = 90; // zur freien Verwendung |
|
- | 191 | ParamSet.UserParam5 = 90; // zur freien Verwendung |
|
- | 192 | ParamSet.UserParam6 = 90; // zur freien Verwendung |
|
- | 193 | ParamSet.UserParam7 = 0; // zur freien Verwendung |
|
- | 194 | ParamSet.UserParam8 = 0; // zur freien Verwendung |
|
- | 195 | ParamSet.ServoPitchControl = 100; // Wert : 0-250 // Stellung des Servos |
|
- | 196 | ParamSet.ServoPitchComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
|
- | 197 | ParamSet.ServoPitchCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
|
- | 198 | ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag |
|
- | 199 | ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag |
|
- | 200 | ParamSet.ServoPitchRefresh = 5; |
|
- | 201 | ParamSet.LoopThrustLimit = 50; |
|
- | 202 | ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
|
- | 203 | ParamSet.LoopHysteresis = 50; |
|
- | 204 | ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
|
- | 205 | ParamSet.Yaw_PosFeedback = 90; // Faktor, mit dem Yaw die Achsen Roll und Pitch verkoppelt |
|
- | 206 | ParamSet.Yaw_NegFeedback = 5; |
|
- | 207 | ParamSet.AngleTurnOverPitch = 100; |
|
- | 208 | ParamSet.AngleTurnOverRoll = 100; |
|
- | 209 | ParamSet.GyroAccTrim = 32; // 1/k |
|
- | 210 | ParamSet.DriftComp = 4; |
|
- | 211 | ParamSet.DynamicStability = 50; |
|
- | 212 | memcpy(ParamSet.Name, "Beginner\0", 9); |
|
- | 213 | } |
|
- | 214 | ||
- | 215 | /***************************************************/ |
|
- | 216 | /* Read Parameter from EEPROM as byte */ |
|
- | 217 | /***************************************************/ |
|
- | 218 | uint8_t GetParamByte(uint8_t param_id) |
|
- | 219 | { |
|
- | 220 | return eeprom_read_byte(&EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id]); |
|
- | 221 | } |
|
- | 222 | ||
- | 223 | /***************************************************/ |
|
- | 224 | /* Write Parameter to EEPROM as byte */ |
|
- | 225 | /***************************************************/ |
|
- | 226 | void SetParamByte(uint8_t param_id, uint8_t value) |
|
- | 227 | { |
|
- | 228 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id], value); |
|
- | 229 | } |
|
- | 230 | ||
- | 231 | /***************************************************/ |
|
- | 232 | /* Read Parameter from EEPROM as word */ |
|
- | 233 | /***************************************************/ |
|
- | 234 | uint16_t GetParamWord(uint8_t param_id) |
|
- | 235 | { |
|
- | 236 | return eeprom_read_word((uint16_t *) &EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id]); |
|
- | 237 | } |
|
- | 238 | ||
- | 239 | /***************************************************/ |
|
- | 240 | /* Write Parameter to EEPROM as word */ |
|
- | 241 | /***************************************************/ |
|
- | 242 | void SetParamWord(uint8_t param_id, uint16_t value) |
|
- | 243 | { |
|
- | 244 | eeprom_write_word((uint16_t *) &EEPromArray[EEPROM_ADR_PARAM_BEGIN + param_id], value); |
|
- | 245 | } |
|
- | 246 | ||
- | 247 | ||
- | 248 | /***************************************************/ |
|
- | 249 | /* Read Parameter Set from EEPROM */ |
|
- | 250 | /***************************************************/ |
|
- | 251 | // number [0..5] |
|
- | 252 | void ParamSet_ReadFromEEProm(uint8_t setnumber) |
|
- | 253 | { |
|
- | 254 | if (setnumber > 5) setnumber = 5; |
|
- | 255 | eeprom_read_block((uint8_t *) &ParamSet.ChannelAssignment[0], &EEPromArray[EEPROM_ADR_PARAMSET_BEGIN + PARAMSET_STRUCT_LEN * setnumber], PARAMSET_STRUCT_LEN); |
|
- | 256 | } |
|
- | 257 | ||
- | 258 | /***************************************************/ |
|
- | 259 | /* Write Parameter Set to EEPROM */ |
|
- | 260 | /***************************************************/ |
|
- | 261 | // number [0..5] |
|
- | 262 | void ParamSet_WriteToEEProm(uint8_t setnumber) |
|
- | 263 | { |
|
- | 264 | if(setnumber > 5) setnumber = 5; |
|
- | 265 | eeprom_write_block((uint8_t *) &ParamSet.ChannelAssignment[0], &EEPromArray[EEPROM_ADR_PARAMSET_BEGIN + PARAMSET_STRUCT_LEN * setnumber], PARAMSET_STRUCT_LEN); |
|
- | 266 | // set this parameter set to active set |
|
- | 267 | eeprom_write_byte(&EEPromArray[PID_ACTIVE_SET], setnumber); |
|
- | 268 | } |
|
- | 269 | ||
- | 270 | /***************************************************/ |
|
- | 271 | /* Get active parameter set */ |
|
- | 272 | /***************************************************/ |
|
- | 273 | uint8_t GetActiveParamSet(void) |
|
- | 274 | { |
|
- | 275 | uint8_t setnumber; |
|
- | 276 | setnumber = eeprom_read_byte(&EEPromArray[PID_ACTIVE_SET]); |
|
- | 277 | if(setnumber > 5) |
|
- | 278 | { |
|
- | 279 | setnumber = 2; |
|
- | 280 | eeprom_write_byte(&EEPromArray[PID_ACTIVE_SET], setnumber); |
|
- | 281 | } |
|
- | 282 | return(setnumber); |
|
- | 283 | } |
|
- | 284 | ||
- | 285 | /***************************************************/ |
|
- | 286 | /* Set active parameter set */ |
|
- | 287 | /***************************************************/ |
|
- | 288 | void SetActiveParamSet(uint8_t setnumber) |
|
- | 289 | { |
|
- | 290 | if(setnumber > 5) setnumber = 5; |
|
- | 291 | eeprom_write_byte(&EEPromArray[PID_ACTIVE_SET], setnumber); |
|
- | 292 | } |
|
- | 293 | ||
- | 294 | /***************************************************/ |
|
- | 295 | /* Initialize EEPROM Parameter Sets */ |
|
- | 296 | /***************************************************/ |
|
8 | void DefaultKonstanten1(void) |
297 | void ParamSet_Init(void) |
9 | { |
298 | { |
10 | EE_Parameter.Kanalbelegung[K_NICK] = 1; |
- | |
11 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
- | |
12 | EE_Parameter.Kanalbelegung[K_GAS] = 3; |
- | |
13 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
- | |
14 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
- | |
15 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
- | |
16 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
- | |
17 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
- | |
18 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV;///*CFG_HOEHEN_SCHALTER |*/ CFG_KOMPASS_AKTIV;//0x01; |
- | |
19 | EE_Parameter.Hoehe_MinGas = 30; |
299 | // version check |
20 | EE_Parameter.MaxHoehe = 251; // Wert : 0-250 251 -> Poti1 |
- | |
21 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
- | |
22 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-250 |
- | |
23 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-250 |
- | |
24 | EE_Parameter.Hoehe_Verstaerkung = 4; // Wert : 0-50 |
- | |
25 | EE_Parameter.Stick_P = 15; // Wert : 1-6 |
- | |
26 | EE_Parameter.Stick_D = 30; // Wert : 0-64 |
- | |
27 | EE_Parameter.Gier_P = 12; // Wert : 1-20 |
- | |
28 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
- | |
29 | EE_Parameter.Gas_Max = 230; // Wert : 33-250 |
- | |
30 | EE_Parameter.GyroAccFaktor = 30; // Wert : 1-64 |
- | |
31 | EE_Parameter.KompassWirkung = 128; // Wert : 0-250 |
- | |
32 | EE_Parameter.Gyro_P = 80; // Wert : 0-250 |
- | |
33 | EE_Parameter.Gyro_I = 150; // Wert : 0-250 |
300 | if(eeprom_read_byte(&EEPromArray[PID_VERSION]) != EEPARAM_VERSION) |
34 | EE_Parameter.UnterspannungsWarnung = 94; // Wert : 0-250 |
- | |
35 | EE_Parameter.NotGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
- | |
36 | EE_Parameter.NotGasZeit = 30; // Wert : 0-250 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
- | |
37 | EE_Parameter.UfoAusrichtung = 0; // X oder + Formation |
- | |
- | 301 | { |
|
38 | EE_Parameter.I_Faktor = 32; |
302 | // if version check faild |
39 | EE_Parameter.UserParam1 = 253; // zur freien Verwendung |
- | |
40 | EE_Parameter.UserParam2 = 100; // zur freien Verwendung |
- | |
41 | EE_Parameter.UserParam3 = 90; // zur freien Verwendung |
- | |
42 | EE_Parameter.UserParam4 = 90; // zur freien Verwendung |
- | |
43 | EE_Parameter.UserParam5 = 90; // zur freien Verwendung |
- | |
44 | EE_Parameter.UserParam6 = 90; // zur freien Verwendung |
303 | printf("\n\rInit. EEPROM: Generating Default-Parameter..."); |
45 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
304 | ParamSet_DefaultSet1(); // Fill ParamSet Structure to default parameter set 1 (Sport) |
46 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
305 | // fill all 5 parameter settings with set 1 except otherwise defined |
47 | EE_Parameter.ServoNickControl = 100; // Wert : 0-250 // Stellung des Servos |
- | |
48 | EE_Parameter.ServoNickComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
- | |
49 | EE_Parameter.ServoNickCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
- | |
50 | EE_Parameter.ServoNickMin = 50; // Wert : 0-250 // Anschlag |
- | |
51 | EE_Parameter.ServoNickMax = 150; // Wert : 0-250 // Anschlag |
- | |
52 | EE_Parameter.ServoNickRefresh = 5; |
- | |
53 | EE_Parameter.LoopGasLimit = 50; |
306 | for (unsigned char i=0;i<6;i++) |
54 | EE_Parameter.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
- | |
55 | EE_Parameter.LoopHysterese = 50; |
- | |
56 | EE_Parameter.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
- | |
- | 307 | { |
|
57 | EE_Parameter.AchsKopplung1 = 90; |
308 | if(i==2) ParamSet_DefaultSet2(); // Kamera |
58 | EE_Parameter.AchsGegenKopplung1 = 5; |
309 | if(i==3) ParamSet_DefaultSet3(); // Beginner |
59 | EE_Parameter.WinkelUmschlagNick = 100; |
- | |
60 | EE_Parameter.WinkelUmschlagRoll = 100; |
310 | if(i>3) ParamSet_DefaultSet2(); // Kamera |
61 | EE_Parameter.GyroAccAbgleich = 16; // 1/k |
- | |
62 | EE_Parameter.Driftkomp = 4; |
311 | ParamSet_WriteToEEProm(i); |
63 | EE_Parameter.DynamicStability = 100; |
- | |
64 | memcpy(EE_Parameter.Name, "Sport\0", 12); |
- | |
65 | } |
312 | } |
66 | void DefaultKonstanten2(void) |
313 | // default-Setting is parameter set 3 |
67 | { |
- | |
68 | EE_Parameter.Kanalbelegung[K_NICK] = 1; |
- | |
69 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
- | |
70 | EE_Parameter.Kanalbelegung[K_GAS] = 3; |
- | |
71 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
- | |
72 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
- | |
73 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
- | |
74 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
- | |
75 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
- | |
76 | EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV;///*CFG_HOEHEN_SCHALTER |*/ CFG_KOMPASS_AKTIV;//0x01; |
- | |
77 | EE_Parameter.Hoehe_MinGas = 30; |
- | |
78 | EE_Parameter.MaxHoehe = 251; // Wert : 0-250 251 -> Poti1 |
- | |
79 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
- | |
80 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-250 |
- | |
81 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-250 |
- | |
82 | EE_Parameter.Hoehe_Verstaerkung = 3; // Wert : 0-50 |
- | |
83 | EE_Parameter.Stick_P = 12; // Wert : 1-6 |
- | |
84 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
- | |
85 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
- | |
86 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
- | |
87 | EE_Parameter.Gas_Max = 230; // Wert : 33-250 |
- | |
88 | EE_Parameter.GyroAccFaktor = 30; // Wert : 1-64 |
- | |
89 | EE_Parameter.KompassWirkung = 128; // Wert : 0-250 |
- | |
90 | EE_Parameter.Gyro_P = 80; // Wert : 0-250 |
- | |
91 | EE_Parameter.Gyro_I = 120; // Wert : 0-250 |
- | |
92 | EE_Parameter.UnterspannungsWarnung = 94; // Wert : 0-250 |
- | |
93 | EE_Parameter.NotGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
- | |
94 | EE_Parameter.NotGasZeit = 30; // Wert : 0-250 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
- | |
95 | EE_Parameter.UfoAusrichtung = 0; // X oder + Formation |
- | |
96 | EE_Parameter.I_Faktor = 32; |
314 | SetParamByte(PID_ACTIVE_SET, 3); |
97 | EE_Parameter.UserParam1 = 253; // zur freien Verwendung |
- | |
98 | EE_Parameter.UserParam2 = 100; // zur freien Verwendung |
- | |
99 | EE_Parameter.UserParam3 = 90; // zur freien Verwendung |
- | |
100 | EE_Parameter.UserParam4 = 90; // zur freien Verwendung |
- | |
101 | EE_Parameter.UserParam5 = 90; // zur freien Verwendung |
- | |
102 | EE_Parameter.UserParam6 = 90; // zur freien Verwendung |
- | |
103 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
- | |
104 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
- | |
105 | EE_Parameter.ServoNickControl = 100; // Wert : 0-250 // Stellung des Servos |
- | |
106 | EE_Parameter.ServoNickComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
- | |
107 | EE_Parameter.ServoNickCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
- | |
108 | EE_Parameter.ServoNickMin = 50; // Wert : 0-250 // Anschlag |
- | |
109 | EE_Parameter.ServoNickMax = 150; // Wert : 0-250 // Anschlag |
- | |
110 | EE_Parameter.ServoNickRefresh = 5; |
- | |
111 | EE_Parameter.LoopGasLimit = 50; |
- | |
112 | EE_Parameter.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
- | |
113 | EE_Parameter.LoopHysterese = 50; |
- | |
114 | EE_Parameter.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
- | |
115 | EE_Parameter.AchsKopplung1 = 90; // Faktor, mit dem Gier die Achsen Roll und Nick verkoppelt |
- | |
116 | EE_Parameter.AchsGegenKopplung1 = 5; |
- | |
117 | EE_Parameter.WinkelUmschlagNick = 100; |
- | |
118 | EE_Parameter.WinkelUmschlagRoll = 100; |
- | |
119 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
- | |
120 | EE_Parameter.Driftkomp = 4; |
315 | // update version info |
121 | EE_Parameter.DynamicStability = 75; |
316 | SetParamByte(PID_VERSION, EEPARAM_VERSION); |
122 | memcpy(EE_Parameter.Name, "Normal\0", 12); |
- | |
123 | } |
317 | } |
124 | - | ||
125 | void DefaultKonstanten3(void) |
- | |
126 | { |
- | |
127 | EE_Parameter.Kanalbelegung[K_NICK] = 1; |
- | |
128 | EE_Parameter.Kanalbelegung[K_ROLL] = 2; |
- | |
129 | EE_Parameter.Kanalbelegung[K_GAS] = 3; |
- | |
130 | EE_Parameter.Kanalbelegung[K_GIER] = 4; |
- | |
131 | EE_Parameter.Kanalbelegung[K_POTI1] = 5; |
- | |
132 | EE_Parameter.Kanalbelegung[K_POTI2] = 6; |
- | |
133 | EE_Parameter.Kanalbelegung[K_POTI3] = 7; |
- | |
134 | EE_Parameter.Kanalbelegung[K_POTI4] = 8; |
- | |
135 | EE_Parameter.GlobalConfig = CFG_DREHRATEN_BEGRENZER | CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV;///*CFG_HOEHEN_SCHALTER |*/ CFG_KOMPASS_AKTIV;//0x01; |
- | |
136 | EE_Parameter.Hoehe_MinGas = 30; |
- | |
137 | EE_Parameter.MaxHoehe = 251; // Wert : 0-250 251 -> Poti1 |
- | |
138 | EE_Parameter.Hoehe_P = 10; // Wert : 0-32 |
- | |
139 | EE_Parameter.Luftdruck_D = 30; // Wert : 0-250 |
- | |
140 | EE_Parameter.Hoehe_ACC_Wirkung = 30; // Wert : 0-250 |
- | |
141 | EE_Parameter.Hoehe_Verstaerkung = 3; // Wert : 0-50 |
- | |
142 | EE_Parameter.Stick_P = 8; // Wert : 1-6 |
- | |
143 | EE_Parameter.Stick_D = 16; // Wert : 0-64 |
318 | // read active parameter set to ParamSet stucture |
144 | EE_Parameter.Gier_P = 6; // Wert : 1-20 |
- | |
145 | EE_Parameter.Gas_Min = 8; // Wert : 0-32 |
- | |
146 | EE_Parameter.Gas_Max = 230; // Wert : 33-250 |
- | |
147 | EE_Parameter.GyroAccFaktor = 30; // Wert : 1-64 |
319 | ParamSet_ReadFromEEProm(GetParamByte(PID_ACTIVE_SET)); |
148 | EE_Parameter.KompassWirkung = 128; // Wert : 0-250 |
- | |
149 | EE_Parameter.Gyro_P = 100; // Wert : 0-250 |
- | |
150 | EE_Parameter.Gyro_I = 120; // Wert : 0-250 |
- | |
151 | EE_Parameter.UnterspannungsWarnung = 94; // Wert : 0-250 |
- | |
152 | EE_Parameter.NotGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust |
- | |
153 | EE_Parameter.NotGasZeit = 20; // Wert : 0-250 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
- | |
154 | EE_Parameter.UfoAusrichtung = 0; // X oder + Formation |
- | |
155 | EE_Parameter.I_Faktor = 16; |
- | |
156 | EE_Parameter.UserParam1 = 253; // zur freien Verwendung |
- | |
157 | EE_Parameter.UserParam2 = 100; // zur freien Verwendung |
- | |
158 | EE_Parameter.UserParam3 = 90; // zur freien Verwendung |
- | |
159 | EE_Parameter.UserParam4 = 90; // zur freien Verwendung |
- | |
160 | EE_Parameter.UserParam5 = 90; // zur freien Verwendung |
- | |
161 | EE_Parameter.UserParam6 = 90; // zur freien Verwendung |
- | |
162 | EE_Parameter.UserParam7 = 0; // zur freien Verwendung |
- | |
163 | EE_Parameter.UserParam8 = 0; // zur freien Verwendung |
320 | printf("\n\rUsing Parameter Set %d", GetParamByte(PID_ACTIVE_SET)); |
164 | EE_Parameter.ServoNickControl = 100; // Wert : 0-250 // Stellung des Servos |
- | |
165 | EE_Parameter.ServoNickComp = 40; // Wert : 0-250 // Einfluss Gyro/Servo |
- | |
166 | EE_Parameter.ServoNickCompInvert = 0; // Wert : 0-250 // Richtung Einfluss Gyro/Servo |
- | |
167 | EE_Parameter.ServoNickMin = 50; // Wert : 0-250 // Anschlag |
- | |
168 | EE_Parameter.ServoNickMax = 150; // Wert : 0-250 // Anschlag |
- | |
169 | EE_Parameter.ServoNickRefresh = 5; |
- | |
170 | EE_Parameter.LoopGasLimit = 50; |
- | |
171 | EE_Parameter.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag |
- | |
172 | EE_Parameter.LoopHysterese = 50; |
- | |
173 | EE_Parameter.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts |
- | |
174 | EE_Parameter.AchsKopplung1 = 90; // Faktor, mit dem Gier die Achsen Roll und Nick verkoppelt |
- | |
175 | EE_Parameter.AchsGegenKopplung1 = 5; |
- | |
176 | EE_Parameter.WinkelUmschlagNick = 100; |
- | |
177 | EE_Parameter.WinkelUmschlagRoll = 100; |
- | |
178 | EE_Parameter.GyroAccAbgleich = 32; // 1/k |
- | |
179 | EE_Parameter.Driftkomp = 4; |
- | |
180 | EE_Parameter.DynamicStability = 50; |
- | |
181 | memcpy(EE_Parameter.Name, "Beginner\0", 12); |
- | |
182 | } |
321 | } |
183 | 322 |