Subversion Repositories FlightCtrl

Rev

Rev 1497 | Rev 1652 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1497 Rev 1622
Line -... Line 1...
-
 
1
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
2
// + Copyright (c) Holger Buss, Ingo Busker
-
 
3
// + Nur für den privaten Gebrauch
-
 
4
// + porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed
-
 
5
// + www.MikroKopter.com
-
 
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
7
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
-
 
8
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
-
 
9
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
-
 
10
// + bzgl. der Nutzungsbedingungen aufzunehmen.
-
 
11
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
-
 
12
// + Verkauf von Luftbildaufnahmen, usw.
-
 
13
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
14
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
-
 
15
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
-
 
16
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
17
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
-
 
18
// + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de"
-
 
19
// + eindeutig als Ursprung verlinkt werden
-
 
20
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
21
// + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion
-
 
22
// + Benutzung auf eigene Gefahr
-
 
23
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
-
 
24
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
25
// + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
-
 
26
// + mit unserer Zustimmung zulässig
-
 
27
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
28
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
-
 
29
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
30
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
-
 
31
// + this list of conditions and the following disclaimer.
-
 
32
// +   * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
-
 
33
// +     from this software without specific prior written permission.
-
 
34
// +   * The use of this project (hardware, software, binary files, sources and documentation) is only permittet
-
 
35
// +     for non-commercial use (directly or indirectly)
-
 
36
// +     Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
-
 
37
// +     with our written permission
-
 
38
// +   * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
-
 
39
// +     clearly linked as origin
-
 
40
// +   * porting to systems other than hardware from www.mikrokopter.de is not allowed
-
 
41
// +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
42
// +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
43
// +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-
 
44
// +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-
 
45
// +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-
 
46
// +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-
 
47
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-
 
48
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-
 
49
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-
 
50
// +  POSSIBILITY OF SUCH DAMAGE.
-
 
51
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
52
 
1
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
// + Konstanten
54
// + Contant Values
3
// + 0-247 -> normale Werte
55
// + 0-250 -> normale Values
4
// + 255 -> Poti1
56
// + 251 -> Poti1
5
// + 254 -> Poti2
57
// + 252 -> Poti2
6
// + 253 -> Poti3
58
// + 253 -> Poti3
7
// + 252 -> Poti4
59
// + 254 -> Poti4
8
// + 251 -> Poti5
-
 
9
// + 247 -> Poti6
-
 
10
// + 249 -> Poti7
-
 
11
// + 248 -> Poti8
-
 
12
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
61
 
-
 
62
#ifndef EEMEM
-
 
63
#define EEMEM __attribute__ ((section (".eeprom")))
-
 
64
#endif
-
 
65
 
-
 
66
 
-
 
67
#include <avr/eeprom.h>
-
 
68
#include <string.h>
-
 
69
#include "eeprom.h"
-
 
70
#include "uart.h"
-
 
71
#include "led.h"
-
 
72
#include "main.h"
-
 
73
#include "fc.h"
-
 
74
 
-
 
75
paramset_t              EE_Parameter;
-
 
76
MixerTable_t    Mixer;
-
 
77
 
-
 
78
 
-
 
79
uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len)
-
 
80
{
-
 
81
        uint8_t crc = 0xAA;
-
 
82
        uint16_t i;
-
 
83
 
-
 
84
        for(i=0; i<len; i++)
-
 
85
        {
-
 
86
                crc += pBuffer[i];
-
 
87
        }
-
 
88
        return crc;
-
 
89
}
-
 
90
 
-
 
91
uint8_t EEProm_Checksum(uint16_t EEAddr, uint16_t len)
-
 
92
{
-
 
93
        uint8_t crc = 0xAA;
-
 
94
        uint16_t off;
-
 
95
 
-
 
96
        for(off=0; off<len; off++)
-
 
97
        {
-
 
98
                crc += eeprom_read_byte((uint8_t*)(EEAddr + off));;
-
 
99
        }
-
 
100
        return crc;
-
 
101
}
-
 
102
 
13
void DefaultStickMapping(void) // mode 2
103
void ParamSet_DefaultStickMapping(void)
-
 
104
{
-
 
105
        EE_Parameter.Kanalbelegung[K_GAS]   = 1;
-
 
106
        EE_Parameter.Kanalbelegung[K_ROLL]  = 2;
-
 
107
        EE_Parameter.Kanalbelegung[K_NICK]  = 3;
-
 
108
        EE_Parameter.Kanalbelegung[K_GIER]  = 4;
-
 
109
        EE_Parameter.Kanalbelegung[K_POTI1] = 5;
-
 
110
        EE_Parameter.Kanalbelegung[K_POTI2] = 6;
-
 
111
        EE_Parameter.Kanalbelegung[K_POTI3] = 7;
-
 
112
        EE_Parameter.Kanalbelegung[K_POTI4] = 8;
-
 
113
        EE_Parameter.Kanalbelegung[K_POTI5] = 9;
-
 
114
        EE_Parameter.Kanalbelegung[K_POTI6] = 10;
-
 
115
        EE_Parameter.Kanalbelegung[K_POTI7] = 11;
-
 
116
        EE_Parameter.Kanalbelegung[K_POTI8] = 12;
-
 
117
}
-
 
118
 
-
 
119
 
-
 
120
/***************************************************/
-
 
121
/*    Default Values for parameter set 1           */
-
 
122
/***************************************************/
-
 
123
void ParamSet_DefaultSet1(void) // sport
-
 
124
{
-
 
125
        EE_Parameter.Revision = EEPARAM_REVISION;
-
 
126
 
-
 
127
        if(PlatinenVersion >= 20)
-
 
128
        {
-
 
129
                EE_Parameter.Gyro_D = 5;
-
 
130
                EE_Parameter.Driftkomp = 0;
-
 
131
                EE_Parameter.GyroAccFaktor = 27;
-
 
132
                EE_Parameter.WinkelUmschlagNick = 78;
-
 
133
                EE_Parameter.WinkelUmschlagRoll = 78;
-
 
134
        }
-
 
135
        else
-
 
136
        {
-
 
137
                EE_Parameter.Gyro_D = 3;
-
 
138
                EE_Parameter.Driftkomp = 32;
-
 
139
                EE_Parameter.GyroAccFaktor = 30;
-
 
140
                EE_Parameter.WinkelUmschlagNick = 85;
-
 
141
                EE_Parameter.WinkelUmschlagRoll = 85;
-
 
142
        }
-
 
143
        EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER;
-
 
144
        EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT;// | CFG2_VARIO_BEEP | CFG_SENSITIVE_RC
-
 
145
        EE_Parameter.Hoehe_MinGas = 30;
-
 
146
        EE_Parameter.MaxHoehe     = 255;      // Wert : 0-247   255 -> Poti1
-
 
147
        EE_Parameter.Hoehe_P      = 10;       // Wert : 0-32
-
 
148
        EE_Parameter.Luftdruck_D  = 30;       // Wert : 0-247
-
 
149
        EE_Parameter.Hoehe_ACC_Wirkung = 30;  // Wert : 0-247
-
 
150
        EE_Parameter.Hoehe_HoverBand = 5;     // Wert : 0-247
-
 
151
        EE_Parameter.Hoehe_GPS_Z = 64;        // Wert : 0-247
-
 
152
        EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation)
-
 
153
        EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50
-
 
154
        EE_Parameter.Stick_P = 14;            // Wert : 1-6
-
 
155
        EE_Parameter.Stick_D = 16;            // Wert : 0-64
-
 
156
        EE_Parameter.Gier_P = 12;             // Wert : 1-20
-
 
157
        EE_Parameter.Gas_Min = 8;             // Wert : 0-32
-
 
158
        EE_Parameter.Gas_Max = 230;           // Wert : 33-247
-
 
159
        EE_Parameter.KompassWirkung = 128;    // Wert : 0-247
-
 
160
        EE_Parameter.Gyro_P = 80;             // Wert : 0-247
-
 
161
        EE_Parameter.Gyro_I = 150;            // Wert : 0-247
-
 
162
        EE_Parameter.Gyro_Gier_P = 80;        // Wert : 0-247
-
 
163
        EE_Parameter.Gyro_Gier_I = 150;       // Wert : 0-247
-
 
164
        EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50)
-
 
165
        EE_Parameter.NotGas = 35;                // Wert : 0-247     // Gaswert bei Empangsverlust
-
 
166
        EE_Parameter.NotGasZeit = 30;            // Wert : 0-247     // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
-
 
167
        EE_Parameter.I_Faktor = 32;
-
 
168
        EE_Parameter.UserParam1 =   0;           // zur freien Verwendung
-
 
169
        EE_Parameter.UserParam2 =   0;           // zur freien Verwendung
-
 
170
        EE_Parameter.UserParam3 =   0;           // zur freien Verwendung
-
 
171
        EE_Parameter.UserParam4 =   0;           // zur freien Verwendung
-
 
172
        EE_Parameter.UserParam5 =   0;           // zur freien Verwendung
-
 
173
        EE_Parameter.UserParam6 =   0;           // zur freien Verwendung
-
 
174
        EE_Parameter.UserParam7 = 0;             // zur freien Verwendung
-
 
175
        EE_Parameter.UserParam8 = 0;             // zur freien Verwendung
-
 
176
        EE_Parameter.ServoNickControl = 100;     // Wert : 0-247     // Stellung des Servos
-
 
177
        EE_Parameter.ServoNickComp = 40;         // Wert : 0-247     // Einfluss Gyro/Servo
-
 
178
        EE_Parameter.ServoCompInvert = 1;        // Wert : 0-247     // Richtung Einfluss Gyro/Servo
-
 
179
        EE_Parameter.ServoNickMin = 0;           // Wert : 0-247     // Anschlag
-
 
180
        EE_Parameter.ServoNickMax = 247;         // Wert : 0-247     // Anschlag
-
 
181
        EE_Parameter.ServoNickRefresh = 6;
-
 
182
        EE_Parameter.Servo3 = 125;
-
 
183
        EE_Parameter.Servo4 = 125;
-
 
184
        EE_Parameter.Servo5 = 125;
-
 
185
        EE_Parameter.ServoRollControl = 100;     // Wert : 0-247     // Stellung des Servos
-
 
186
        EE_Parameter.ServoRollComp = 40;         // Wert : 0-247     // Einfluss Gyro/Servo
-
 
187
        EE_Parameter.ServoRollMin = 0;           // Wert : 0-247     // Anschlag
-
 
188
        EE_Parameter.ServoRollMax = 247;         // Wert : 0-247     // Anschlag
-
 
189
        EE_Parameter.LoopGasLimit = 50;
-
 
190
        EE_Parameter.LoopThreshold = 90;         // Wert: 0-247  Schwelle für Stickausschlag
-
 
191
        EE_Parameter.LoopHysterese = 50;
-
 
192
        EE_Parameter.BitConfig = 0;              // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
-
 
193
        EE_Parameter.AchsKopplung1 = 90;
-
 
194
        EE_Parameter.AchsKopplung2 = 80;
-
 
195
        EE_Parameter.CouplingYawCorrection = 1;
-
 
196
        EE_Parameter.GyroAccAbgleich = 16;        // 1/k;
-
 
197
        EE_Parameter.DynamicStability = 100;
-
 
198
        EE_Parameter.J16Bitmask = 95;
-
 
199
        EE_Parameter.J17Bitmask = 243;
-
 
200
        EE_Parameter.WARN_J16_Bitmask = 0xAA;
-
 
201
        EE_Parameter.WARN_J17_Bitmask = 0xAA;
-
 
202
        EE_Parameter.J16Timing = 15;
-
 
203
        EE_Parameter.J17Timing = 15;
-
 
204
        EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2
-
 
205
        EE_Parameter.NaviGpsGain = 100;
-
 
206
        EE_Parameter.NaviGpsP = 90;
-
 
207
        EE_Parameter.NaviGpsI = 90;
-
 
208
        EE_Parameter.NaviGpsD = 90;
-
 
209
        EE_Parameter.NaviGpsPLimit = 75;
-
 
210
        EE_Parameter.NaviGpsILimit = 75;
-
 
211
        EE_Parameter.NaviGpsDLimit = 75;
-
 
212
        EE_Parameter.NaviGpsACC = 0;
-
 
213
        EE_Parameter.NaviGpsMinSat = 6;
-
 
214
        EE_Parameter.NaviStickThreshold = 8;
-
 
215
        EE_Parameter.NaviWindCorrection = 90;
-
 
216
        EE_Parameter.NaviSpeedCompensation = 30;
-
 
217
        EE_Parameter.NaviOperatingRadius = 100;
-
 
218
        EE_Parameter.NaviAngleLimitation = 100;
-
 
219
        EE_Parameter.NaviPH_LoginTime = 4;
-
 
220
        EE_Parameter.Receiver = RECEIVER_SPEKTRUM;
-
 
221
        memcpy(EE_Parameter.Name, "Sport\0", 12);
-
 
222
        EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1);
-
 
223
}
-
 
224
 
-
 
225
 
-
 
226
/***************************************************/
-
 
227
/*    Default Values for parameter set 2           */
-
 
228
/***************************************************/
-
 
229
void ParamSet_DefaultSet2(void) // normal
14
{
230
{
290
}
705
}