Subversion Repositories FlightCtrl

Rev

Rev 685 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 685 Rev 687
Line 49... Line 49...
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49
// +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52
// +  POSSIBILITY OF SUCH DAMAGE.
52
// +  POSSIBILITY OF SUCH DAMAGE.
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54
 
-
 
-
 
54
#include <stdlib.h>
-
 
55
#include <avr/io.h>
Line 55... Line 56...
55
 
56
 
56
#include "main.h"
57
#include "main.h"
57
#include "eeprom.h"
58
#include "eeprom.h"
58
#include "timer0.h"
59
#include "timer0.h"
Line 124... Line 125...
124
unsigned char Parameter_ServoNickControl = 100;
125
unsigned char Parameter_ServoNickControl = 100;
125
unsigned char Parameter_LoopGasLimit = 70;
126
unsigned char Parameter_LoopGasLimit = 70;
126
unsigned char Parameter_AchsKopplung1 = 0;
127
unsigned char Parameter_AchsKopplung1 = 0;
127
unsigned char Parameter_AchsGegenKopplung1 = 0;
128
unsigned char Parameter_AchsGegenKopplung1 = 0;
128
unsigned char Parameter_DynamicStability = 100;
129
unsigned char Parameter_DynamicStability = 100;
129
struct mk_param_struct EE_Parameter;
-
 
-
 
130
 
130
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
131
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
131
int MaxStickNick = 0,MaxStickRoll = 0;
132
int MaxStickNick = 0,MaxStickRoll = 0;
Line 132... Line 133...
132
 
133
 
133
void Piep(unsigned char Anzahl)
134
void Piep(unsigned char Anzahl)
Line 154... Line 155...
154
    Parameter_AchsKopplung1 = 0;
155
    Parameter_AchsKopplung1 = 0;
155
    Parameter_AchsGegenKopplung1 = 0;
156
    Parameter_AchsGegenKopplung1 = 0;
156
    CalibrierMittelwert();
157
    CalibrierMittelwert();
157
    Delay_ms_Mess(100);
158
    Delay_ms_Mess(100);
158
        CalibrierMittelwert();
159
        CalibrierMittelwert();
159
    if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
160
    if((ParamSet.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
160
     {
161
     {
161
      if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
162
      if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
162
     }
163
     }
Line 163... Line 164...
163
 
164
 
164
     AdNeutralNick= AdValueGyrNick;
165
     AdNeutralNick= AdValueGyrNick;
165
         AdNeutralRoll= AdValueGyrRoll;
166
         AdNeutralRoll= AdValueGyrRoll;
166
         AdNeutralGier= AdValueGyrGier;
167
         AdNeutralGier= AdValueGyrGier;
167
     StartNeutralRoll = AdNeutralRoll;
168
     StartNeutralRoll = AdNeutralRoll;
168
     StartNeutralNick = AdNeutralNick;
169
     StartNeutralNick = AdNeutralNick;
169
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
170
    if(GetParamByte(PID_ACC_NICK) > 4)
170
    {
171
    {
171
      NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
172
      NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
172
          NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
173
          NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
173
          NeutralAccZ = Current_AccZ;
174
          NeutralAccZ = Current_AccZ;
174
    }
175
    }
175
    else
176
    else
176
    {
177
    {
177
      NeutralAccX = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1]);
178
      NeutralAccX = (int)GetParamByte(PID_ACC_NICK) * 256 + (int)GetParamByte(PID_ACC_NICK+1);
178
          NeutralAccY = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1]);
179
          NeutralAccY = (int)GetParamByte(PID_ACC_ROLL) * 256 + (int)GetParamByte(PID_ACC_ROLL+1);
179
          NeutralAccZ = (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z]) * 256 + (int)eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1]);
180
          NeutralAccZ = (int)GetParamByte(PID_ACC_Z) * 256 + (int)GetParamByte(PID_ACC_Z+1);
Line 180... Line 181...
180
    }
181
    }
181
 
182
 
182
        Mess_IntegralNick = 0;
183
        Mess_IntegralNick = 0;
Line 191... Line 192...
191
    HoeheD = 0;
192
    HoeheD = 0;
192
    Mess_Integral_Hoch = 0;
193
    Mess_Integral_Hoch = 0;
193
    KompassStartwert = KompassValue;
194
    KompassStartwert = KompassValue;
194
    GPS_Neutral();
195
    GPS_Neutral();
195
    BeepTime = 50;
196
    BeepTime = 50;
196
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
197
        Umschlag180Nick = (long) ParamSet.WinkelUmschlagNick * 2500L;
197
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L;
198
        Umschlag180Roll = (long) ParamSet.WinkelUmschlagRoll * 2500L;
198
    ExternHoehenValue = 0;
199
    ExternHoehenValue = 0;
199
}
200
}
Line 200... Line 201...
200
 
201
 
201
//############################################################################
202
//############################################################################
Line 220... Line 221...
220
    IntegralAccZ    += Current_AccZ - NeutralAccZ;
221
    IntegralAccZ    += Current_AccZ - NeutralAccZ;
221
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
222
// Gier  ++++++++++++++++++++++++++++++++++++++++++++++++
222
            Mess_Integral_Gier +=  MesswertGier;
223
            Mess_Integral_Gier +=  MesswertGier;
223
            Mess_Integral_Gier2 += MesswertGier;
224
            Mess_Integral_Gier2 += MesswertGier;
224
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
225
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
225
      if(!Looping_Nick && !Looping_Roll && (EE_Parameter.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
226
      if(!Looping_Nick && !Looping_Roll && (ParamSet.GlobalConfig & CFG_ACHSENKOPPLUNG_AKTIV))
226
         {
227
         {
227
            tmpl = Mess_IntegralNick / 4096L;
228
            tmpl = Mess_IntegralNick / 4096L;
228
            tmpl *= MesswertGier;
229
            tmpl *= MesswertGier;
229
            tmpl *= Parameter_AchsKopplung1;  //125
230
            tmpl *= Parameter_AchsKopplung1;  //125
230
            tmpl /= 2048L;
231
            tmpl /= 2048L;
Line 297... Line 298...
297
    IntegralNick = Mess_IntegralNick;
298
    IntegralNick = Mess_IntegralNick;
298
    IntegralRoll = Mess_IntegralRoll;
299
    IntegralRoll = Mess_IntegralRoll;
299
    IntegralNick2 = Mess_IntegralNick2;
300
    IntegralNick2 = Mess_IntegralNick2;
300
    IntegralRoll2 = Mess_IntegralRoll2;
301
    IntegralRoll2 = Mess_IntegralRoll2;
Line 301... Line 302...
301
 
302
 
302
  if(EE_Parameter.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll)
303
  if(ParamSet.GlobalConfig & CFG_DREHRATEN_BEGRENZER && !Looping_Nick && !Looping_Roll)
303
  {
304
  {
304
    if(MesswertNick > 200)       MesswertNick += 4 * (MesswertNick - 200);
305
    if(MesswertNick > 200)       MesswertNick += 4 * (MesswertNick - 200);
305
    else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200);
306
    else if(MesswertNick < -200) MesswertNick += 4 * (MesswertNick + 200);
306
    if(MesswertRoll > 200)       MesswertRoll += 4 * (MesswertRoll - 200);
307
    if(MesswertRoll > 200)       MesswertRoll += 4 * (MesswertRoll - 200);
307
    else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200);
308
    else if(MesswertRoll < -200) MesswertRoll += 4 * (MesswertRoll + 200);
308
  }
309
  }
309
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
310
    if(Poti1 < PPM_in[ParamSet.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
310
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
311
    if(Poti2 < PPM_in[ParamSet.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
311
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
312
    if(Poti3 < PPM_in[ParamSet.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
312
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
313
    if(Poti4 < PPM_in[ParamSet.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
313
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
314
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
314
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
315
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
315
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
316
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
316
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
317
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
Line 329... Line 330...
329
        Mittelwert_AccNick = ACC_AMPLIFY * (long)AdValueAccNick;
330
        Mittelwert_AccNick = ACC_AMPLIFY * (long)AdValueAccNick;
330
        Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll;
331
        Mittelwert_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll;
331
        Mittelwert_AccHoch = (long)AdValueAccTop;
332
        Mittelwert_AccHoch = (long)AdValueAccTop;
332
   // ADC einschalten
333
   // ADC einschalten
333
    ADC_Enable();
334
    ADC_Enable();
334
    if(Poti1 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
335
    if(Poti1 < PPM_in[ParamSet.Kanalbelegung[K_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.Kanalbelegung[K_POTI1]] + 110 && Poti1) Poti1--;
335
    if(Poti2 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
336
    if(Poti2 < PPM_in[ParamSet.Kanalbelegung[K_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.Kanalbelegung[K_POTI2]] + 110 && Poti2) Poti2--;
336
    if(Poti3 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
337
    if(Poti3 < PPM_in[ParamSet.Kanalbelegung[K_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.Kanalbelegung[K_POTI3]] + 110 && Poti3) Poti3--;
337
    if(Poti4 < PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[EE_Parameter.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
338
    if(Poti4 < PPM_in[ParamSet.Kanalbelegung[K_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.Kanalbelegung[K_POTI4]] + 110 && Poti4) Poti4--;
338
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
339
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
339
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
340
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
340
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
341
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
341
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
342
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
Line 342... Line 343...
342
 
343
 
343
        Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
344
        Umschlag180Nick = (long) ParamSet.WinkelUmschlagNick * 2500L;
344
        Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagNick * 2500L;
345
        Umschlag180Roll = (long) ParamSet.WinkelUmschlagNick * 2500L;
Line 345... Line 346...
345
}
346
}
346
 
347
 
347
//############################################################################
348
//############################################################################
Line 379... Line 380...
379
void ParameterZuordnung(void)
380
void ParameterZuordnung(void)
380
//############################################################################
381
//############################################################################
381
{
382
{
Line 382... Line 383...
382
 
383
 
383
 #define CHK_POTI(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; if(b <= min) b = min; else if(b >= max) b = max;}
384
 #define CHK_POTI(b,a,min,max) { if(a > 250) { if(a == 251) b = Poti1; else if(a == 252) b = Poti2; else if(a == 253) b = Poti3; else if(a == 254) b = Poti4;} else b = a; if(b <= min) b = min; else if(b >= max) b = max;}
384
 CHK_POTI(Parameter_MaxHoehe,EE_Parameter.MaxHoehe,0,255);
385
 CHK_POTI(Parameter_MaxHoehe,ParamSet.MaxHoehe,0,255);
385
 CHK_POTI(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100);
386
 CHK_POTI(Parameter_Luftdruck_D,ParamSet.Luftdruck_D,0,100);
386
 CHK_POTI(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100);
387
 CHK_POTI(Parameter_Hoehe_P,ParamSet.Hoehe_P,0,100);
387
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung,0,255);
388
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,ParamSet.Hoehe_ACC_Wirkung,0,255);
388
 CHK_POTI(Parameter_KompassWirkung,EE_Parameter.KompassWirkung,0,255);
389
 CHK_POTI(Parameter_KompassWirkung,ParamSet.KompassWirkung,0,255);
389
 CHK_POTI(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255);
390
 CHK_POTI(Parameter_Gyro_P,ParamSet.Gyro_P,10,255);
390
 CHK_POTI(Parameter_Gyro_I,EE_Parameter.Gyro_I,0,255);
391
 CHK_POTI(Parameter_Gyro_I,ParamSet.Gyro_I,0,255);
391
 CHK_POTI(Parameter_I_Faktor,EE_Parameter.I_Faktor,0,255);
392
 CHK_POTI(Parameter_I_Faktor,ParamSet.I_Faktor,0,255);
392
 CHK_POTI(Parameter_UserParam1,EE_Parameter.UserParam1,0,255);
393
 CHK_POTI(Parameter_UserParam1,ParamSet.UserParam1,0,255);
393
 CHK_POTI(Parameter_UserParam2,EE_Parameter.UserParam2,0,255);
394
 CHK_POTI(Parameter_UserParam2,ParamSet.UserParam2,0,255);
394
 CHK_POTI(Parameter_UserParam3,EE_Parameter.UserParam3,0,255);
395
 CHK_POTI(Parameter_UserParam3,ParamSet.UserParam3,0,255);
395
 CHK_POTI(Parameter_UserParam4,EE_Parameter.UserParam4,0,255);
396
 CHK_POTI(Parameter_UserParam4,ParamSet.UserParam4,0,255);
396
 CHK_POTI(Parameter_UserParam5,EE_Parameter.UserParam5,0,255);
397
 CHK_POTI(Parameter_UserParam5,ParamSet.UserParam5,0,255);
397
 CHK_POTI(Parameter_UserParam6,EE_Parameter.UserParam6,0,255);
398
 CHK_POTI(Parameter_UserParam6,ParamSet.UserParam6,0,255);
398
 CHK_POTI(Parameter_UserParam7,EE_Parameter.UserParam7,0,255);
399
 CHK_POTI(Parameter_UserParam7,ParamSet.UserParam7,0,255);
399
 CHK_POTI(Parameter_UserParam8,EE_Parameter.UserParam8,0,255);
400
 CHK_POTI(Parameter_UserParam8,ParamSet.UserParam8,0,255);
400
 CHK_POTI(Parameter_ServoNickControl,EE_Parameter.ServoNickControl,0,255);
401
 CHK_POTI(Parameter_ServoNickControl,ParamSet.ServoNickControl,0,255);
401
 CHK_POTI(Parameter_LoopGasLimit,EE_Parameter.LoopGasLimit,0,255);
402
 CHK_POTI(Parameter_LoopGasLimit,ParamSet.LoopGasLimit,0,255);
402
 CHK_POTI(Parameter_AchsKopplung1,    EE_Parameter.AchsKopplung1,0,255);
403
 CHK_POTI(Parameter_AchsKopplung1,    ParamSet.AchsKopplung1,0,255);
403
 CHK_POTI(Parameter_AchsGegenKopplung1,EE_Parameter.AchsGegenKopplung1,0,255);
404
 CHK_POTI(Parameter_AchsGegenKopplung1,ParamSet.AchsGegenKopplung1,0,255);
Line 404... Line 405...
404
 CHK_POTI(Parameter_DynamicStability,EE_Parameter.DynamicStability,0,255);
405
 CHK_POTI(Parameter_DynamicStability,ParamSet.DynamicStability,0,255);
405
 
406
 
406
 Ki = (float) Parameter_I_Faktor * 0.0001;
407
 Ki = (float) Parameter_I_Faktor * 0.0001;
407
 MAX_GAS = EE_Parameter.Gas_Max;
408
 MAX_GAS = ParamSet.Gas_Max;
Line 408... Line 409...
408
 MIN_GAS = EE_Parameter.Gas_Min;
409
 MIN_GAS = ParamSet.Gas_Min;
409
}
410
}
Line 457... Line 458...
457
          Notlandung = 0;
458
          Notlandung = 0;
458
         }
459
         }
459
        ROT_ON;
460
        ROT_ON;
460
        if(modell_fliegt > 2000)  // wahrscheinlich in der Luft --> langsam absenken
461
        if(modell_fliegt > 2000)  // wahrscheinlich in der Luft --> langsam absenken
461
            {
462
            {
462
            GasMischanteil = EE_Parameter.NotGas;
463
            GasMischanteil = ParamSet.NotGas;
463
            Notlandung = 1;
464
            Notlandung = 1;
464
            PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] = 0;
465
            PPM_in[ParamSet.Kanalbelegung[K_NICK]] = 0;
465
            PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] = 0;
466
            PPM_in[ParamSet.Kanalbelegung[K_ROLL]] = 0;
466
            PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] = 0;
467
            PPM_in[ParamSet.Kanalbelegung[K_GIER]] = 0;
467
            }
468
            }
468
         else MotorenEin = 0;
469
         else MotorenEin = 0;
469
        }
470
        }
470
        else
471
        else
471
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
472
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
472
// Emfang gut
473
// Emfang gut
473
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
474
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
474
        if(SenderOkay > 140)
475
        if(SenderOkay > 140)
475
            {
476
            {
476
            Notlandung = 0;
477
            Notlandung = 0;
477
            RcLostTimer = EE_Parameter.NotGasZeit * 50;
478
            RcLostTimer = ParamSet.NotGasZeit * 50;
478
            if(GasMischanteil > 40)
479
            if(GasMischanteil > 40)
479
                {
480
                {
480
                if(modell_fliegt < 0xffff) modell_fliegt++;
481
                if(modell_fliegt < 0xffff) modell_fliegt++;
481
                }
482
                }
482
            if((modell_fliegt < 200) || (GasMischanteil < 40))
483
            if((modell_fliegt < 200) || (GasMischanteil < 40))
Line 484... Line 485...
484
                SummeNick = 0;
485
                SummeNick = 0;
485
                SummeRoll = 0;
486
                SummeRoll = 0;
486
                Mess_Integral_Gier = 0;
487
                Mess_Integral_Gier = 0;
487
                Mess_Integral_Gier2 = 0;
488
                Mess_Integral_Gier2 = 0;
488
                }
489
                }
489
            if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0)
490
            if((PPM_in[ParamSet.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0)
490
                {
491
                {
491
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
492
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
492
// auf Nullwerte kalibrieren
493
// auf Nullwerte kalibrieren
493
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
495
                if(PPM_in[ParamSet.Kanalbelegung[K_GIER]] > 75)  // Neutralwerte
495
                    {
496
                    {
496
                    if(++delay_neutral > 200)  // nicht sofort
497
                    if(++delay_neutral > 200)  // nicht sofort
497
                        {
498
                        {
498
                        GRN_OFF;
499
                        GRN_OFF;
499
                        MotorenEin = 0;
500
                        MotorenEin = 0;
500
                        delay_neutral = 0;
501
                        delay_neutral = 0;
501
                        modell_fliegt = 0;
502
                        modell_fliegt = 0;
502
                        if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > 70)
503
                        if(PPM_in[ParamSet.Kanalbelegung[K_NICK]] > 70 || abs(PPM_in[ParamSet.Kanalbelegung[K_ROLL]]) > 70)
503
                        {
504
                        {
504
                         unsigned char setting=1;
505
                         unsigned char setting=1;
505
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 1;
506
                         if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] > 70 && PPM_in[ParamSet.Kanalbelegung[K_NICK]] < 70) setting = 1;
506
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 2;
507
                         if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] > 70 && PPM_in[ParamSet.Kanalbelegung[K_NICK]] > 70) setting = 2;
507
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < 70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 3;
508
                         if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] < 70 && PPM_in[ParamSet.Kanalbelegung[K_NICK]] > 70) setting = 3;
508
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > 70) setting = 4;
509
                         if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] <-70 && PPM_in[ParamSet.Kanalbelegung[K_NICK]] > 70) setting = 4;
509
                         if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] <-70 && PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < 70) setting = 5;
510
                         if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] <-70 && PPM_in[ParamSet.Kanalbelegung[K_NICK]] < 70) setting = 5;
510
                         eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], setting);  // aktiven Datensatz merken
511
                         SetActiveParamSet(setting);  // aktiven Datensatz merken
511
                        }
512
                        }
512
                        if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
513
                        if((ParamSet.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung aktiviert?
513
                          {
514
                          {
514
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
515
                             if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
515
                          }
516
                          }
516
                            ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
517
                            ParamSet_ReadFromEEProm(GetActiveParamSet());
517
                        SetNeutral();
518
                        SetNeutral();
518
                        Piep(GetActiveParamSetNumber());
519
                        Piep(GetActiveParamSet());
519
                        }
520
                        }
520
                    }
521
                    }
521
                 else
522
                 else
522
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
523
                if(PPM_in[ParamSet.Kanalbelegung[K_GIER]] < -75)  // ACC Neutralwerte speichern
523
                    {
524
                    {
524
                    if(++delay_neutral > 200)  // nicht sofort
525
                    if(++delay_neutral > 200)  // nicht sofort
525
                        {
526
                        {
526
                        GRN_OFF;
527
                        GRN_OFF;
527
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],0xff); // Werte löschen
528
                        SetParamByte(PID_ACC_NICK,0xFF); // Werte löschen
528
                        MotorenEin = 0;
529
                        MotorenEin = 0;
529
                        delay_neutral = 0;
530
                        delay_neutral = 0;
530
                        modell_fliegt = 0;
531
                        modell_fliegt = 0;
531
                        SetNeutral();
532
                        SetNeutral();
532
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK],NeutralAccX / 256); // ACC-NeutralWerte speichern
533
                        SetParamByte(PID_ACC_NICK, NeutralAccX / 256); // ACC-NeutralWerte speichern
533
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_NICK+1],NeutralAccX % 256); // ACC-NeutralWerte speichern
534
                        SetParamByte(PID_ACC_NICK+1,NeutralAccX % 256); // ACC-NeutralWerte speichern
534
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL],NeutralAccY / 256);
535
                        SetParamByte(PID_ACC_ROLL,NeutralAccY / 256);
535
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_ROLL+1],NeutralAccY % 256);
536
                        SetParamByte(PID_ACC_ROLL+1,NeutralAccY % 256);
536
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z],(int)NeutralAccZ / 256);
537
                        SetParamByte(PID_ACC_Z,(int)NeutralAccZ / 256);
537
                        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACC_Z+1],(int)NeutralAccZ % 256);
538
                        SetParamByte(PID_ACC_Z+1,(int)NeutralAccZ % 256);
538
                        Piep(GetActiveParamSetNumber());
539
                        Piep(GetActiveParamSet());
539
                        }
540
                        }
540
                    }
541
                    }
541
                 else delay_neutral = 0;
542
                 else delay_neutral = 0;
542
                }
543
                }
543
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
544
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
544
// Gas ist unten
545
// Gas ist unten
545
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
546
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
546
            if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120)
547
            if(PPM_in[ParamSet.Kanalbelegung[K_GAS]] < 35-120)
547
                {
548
                {
548
                // Starten
549
                // Starten
549
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)
550
                if(PPM_in[ParamSet.Kanalbelegung[K_GIER]] < -75)
550
                    {
551
                    {
551
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
552
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
552
// Einschalten
553
// Einschalten
553
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
554
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
554
                    if(++delay_einschalten > 200)
555
                    if(++delay_einschalten > 200)
Line 570... Line 571...
570
                    else delay_einschalten = 0;
571
                    else delay_einschalten = 0;
571
                //Auf Neutralwerte setzen
572
                //Auf Neutralwerte setzen
572
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
573
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
573
// Auschalten
574
// Auschalten
574
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
575
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
575
                if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)
576
                if(PPM_in[ParamSet.Kanalbelegung[K_GIER]] > 75)
576
                    {
577
                    {
577
                    if(++delay_ausschalten > 200)  // nicht sofort
578
                    if(++delay_ausschalten > 200)  // nicht sofort
578
                        {
579
                        {
579
                        MotorenEin = 0;
580
                        MotorenEin = 0;
580
                        delay_ausschalten = 200;
581
                        delay_ausschalten = 200;
Line 591... Line 592...
591
 if(!NewPpmData-- || Notlandung)
592
 if(!NewPpmData-- || Notlandung)
592
  {
593
  {
593
    int tmp_int;
594
    int tmp_int;
594
        static int stick_nick,stick_roll;
595
        static int stick_nick,stick_roll;
595
    ParameterZuordnung();
596
    ParameterZuordnung();
596
    StickNick = (StickNick * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_P) / 4;
597
    StickNick = (StickNick * 3 + PPM_in[ParamSet.Kanalbelegung[K_NICK]] * ParamSet.Stick_P) / 4;
597
    StickNick += PPM_diff[EE_Parameter.Kanalbelegung[K_NICK]] * EE_Parameter.Stick_D;
598
    StickNick += PPM_diff[ParamSet.Kanalbelegung[K_NICK]] * ParamSet.Stick_D;
598
    StickRoll = (StickRoll * 3 + PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_P) / 4;
599
    StickRoll = (StickRoll * 3 + PPM_in[ParamSet.Kanalbelegung[K_ROLL]] * ParamSet.Stick_P) / 4;
599
    StickRoll += PPM_diff[EE_Parameter.Kanalbelegung[K_ROLL]] * EE_Parameter.Stick_D;
600
    StickRoll += PPM_diff[ParamSet.Kanalbelegung[K_ROLL]] * ParamSet.Stick_D;
600
 
601
 
601
    StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
602
    StickGier = -PPM_in[ParamSet.Kanalbelegung[K_GIER]];
602
        StickGas  = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] + 120;
603
        StickGas  = PPM_in[ParamSet.Kanalbelegung[K_GAS]] + 120;
603
 
604
 
604
   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]) > MaxStickNick)
605
   if(abs(PPM_in[ParamSet.Kanalbelegung[K_NICK]]) > MaxStickNick)
605
     MaxStickNick = abs(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]); else MaxStickNick--;
606
     MaxStickNick = abs(PPM_in[ParamSet.Kanalbelegung[K_NICK]]); else MaxStickNick--;
606
   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]) > MaxStickRoll)
607
   if(abs(PPM_in[ParamSet.Kanalbelegung[K_ROLL]]) > MaxStickRoll)
607
     MaxStickRoll = abs(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]); else MaxStickRoll--;
608
     MaxStickRoll = abs(PPM_in[ParamSet.Kanalbelegung[K_ROLL]]); else MaxStickRoll--;
608
   if(Notlandung)  {MaxStickNick = 0; MaxStickRoll = 0;}
609
   if(Notlandung)  {MaxStickNick = 0; MaxStickRoll = 0;}
Line 609... Line 610...
609
 
610
 
610
    GyroFaktor     = ((float)Parameter_Gyro_P + 10.0) / 256.0;
611
    GyroFaktor     = ((float)Parameter_Gyro_P + 10.0) / 256.0;
Line 633... Line 634...
633
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
634
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
634
//+ Analoge Steuerung per Seriell
635
//+ Analoge Steuerung per Seriell
635
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
636
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
636
   if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128)
637
   if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128)
637
    {
638
    {
638
         StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P;
639
         StickNick += (int) ExternControl.Nick * (int) ParamSet.Stick_P;
639
         StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P;
640
         StickRoll += (int) ExternControl.Roll * (int) ParamSet.Stick_P;
640
         StickGier += ExternControl.Gier;
641
         StickGier += ExternControl.Gier;
641
     ExternHoehenValue =  (int) ExternControl.Hight * (int)EE_Parameter.Hoehe_Verstaerkung;
642
     ExternHoehenValue =  (int) ExternControl.Hight * (int)ParamSet.Hoehe_Verstaerkung;
642
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
643
     if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
643
    }
644
    }
Line 644... Line 645...
644
 
645
 
645
    if(EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
646
    if(ParamSet.GlobalConfig & CFG_HEADING_HOLD) IntegralFaktor =  0;
646
    if(GyroFaktor < 0) GyroFaktor = 0;
647
    if(GyroFaktor < 0) GyroFaktor = 0;
647
    if(IntegralFaktor < 0) IntegralFaktor = 0;
648
    if(IntegralFaktor < 0) IntegralFaktor = 0;
648
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
649
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
649
// Looping?
650
// Looping?
650
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
651
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
651
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_LINKS)  Looping_Links = 1;
652
  if((PPM_in[ParamSet.Kanalbelegung[K_ROLL]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_LINKS)  Looping_Links = 1;
652
  else
653
  else
653
   {
654
   {
654
     {
655
     {
655
      if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Links = 0;
656
      if((PPM_in[ParamSet.Kanalbelegung[K_ROLL]] < (ParamSet.LoopThreshold - ParamSet.LoopHysterese))) Looping_Links = 0;
656
     }
657
     }
657
   }
658
   }
658
  if((PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
659
  if((PPM_in[ParamSet.Kanalbelegung[K_ROLL]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_RECHTS) Looping_Rechts = 1;
659
   else
660
   else
660
   {
661
   {
661
   if(Looping_Rechts) // Hysterese
662
   if(Looping_Rechts) // Hysterese
662
     {
663
     {
663
      if(PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Rechts = 0;
664
      if(PPM_in[ParamSet.Kanalbelegung[K_ROLL]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysterese)) Looping_Rechts = 0;
664
     }
665
     }
Line 665... Line 666...
665
   }
666
   }
666
 
667
 
667
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
668
  if((PPM_in[ParamSet.Kanalbelegung[K_NICK]] > ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_OBEN) Looping_Oben = 1;
668
  else
669
  else
669
   {
670
   {
670
    if(Looping_Oben)  // Hysterese
671
    if(Looping_Oben)  // Hysterese
671
     {
672
     {
672
      if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < (EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese))) Looping_Oben = 0;
673
      if((PPM_in[ParamSet.Kanalbelegung[K_NICK]] < (ParamSet.LoopThreshold - ParamSet.LoopHysterese))) Looping_Oben = 0;
673
     }
674
     }
674
   }
675
   }
675
  if((PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] < -EE_Parameter.LoopThreshold) && EE_Parameter.LoopConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
676
  if((PPM_in[ParamSet.Kanalbelegung[K_NICK]] < -ParamSet.LoopThreshold) && ParamSet.LoopConfig & CFG_LOOP_UNTEN) Looping_Unten = 1;
676
   else
677
   else
677
   {
678
   {
678
    if(Looping_Unten) // Hysterese
679
    if(Looping_Unten) // Hysterese
679
     {
680
     {
680
      if(PPM_in[EE_Parameter.Kanalbelegung[K_NICK]] > -(EE_Parameter.LoopThreshold - EE_Parameter.LoopHysterese)) Looping_Unten = 0;
681
      if(PPM_in[ParamSet.Kanalbelegung[K_NICK]] > -(ParamSet.LoopThreshold - ParamSet.LoopHysterese)) Looping_Unten = 0;
Line 681... Line 682...
681
     }
682
     }
682
   }
683
   }
683
 
684
 
Line 684... Line 685...
684
   if(Looping_Links || Looping_Rechts)   Looping_Roll = 1; else Looping_Roll = 0;
685
   if(Looping_Links || Looping_Rechts)   Looping_Roll = 1; else Looping_Roll = 0;
685
   if(Looping_Oben  || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0;
686
   if(Looping_Oben  || Looping_Unten) {Looping_Nick = 1; Looping_Roll = 0; Looping_Links = 0; Looping_Rechts = 0;} else Looping_Nick = 0;
686
  } // Ende neue Funken-Werte
687
  } // Ende neue Funken-Werte
687
 
688
 
688
  if(Looping_Roll) BeepTime = 100;
689
  if(Looping_Roll) BeepTime = 100;
Line 689... Line 690...
689
  if(Looping_Roll || Looping_Nick)
690
  if(Looping_Roll || Looping_Nick)
690
   {
691
   {
Line 734... Line 735...
734
 
735
 
735
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
736
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
736
  if(!Looping_Nick && !Looping_Roll)
737
  if(!Looping_Nick && !Looping_Roll)
737
  {
738
  {
738
   long tmp_long, tmp_long2;
739
   long tmp_long, tmp_long2;
739
    tmp_long = (long)(IntegralNick / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccNick);
740
    tmp_long = (long)(IntegralNick / ParamSet.GyroAccFaktor - (long)Mittelwert_AccNick);
740
    tmp_long2 = (long)(IntegralRoll / EE_Parameter.GyroAccFaktor - (long)Mittelwert_AccRoll);
741
    tmp_long2 = (long)(IntegralRoll / ParamSet.GyroAccFaktor - (long)Mittelwert_AccRoll);
741
    tmp_long /= 16;
742
    tmp_long /= 16;
742
    tmp_long2 /= 16;
743
    tmp_long2 /= 16;
743
   if((MaxStickNick > 15) || (MaxStickRoll > 15))
744
   if((MaxStickNick > 15) || (MaxStickRoll > 15))
744
    {
745
    {
745
    tmp_long  /= 3;
746
    tmp_long  /= 3;
746
    tmp_long2 /= 3;
747
    tmp_long2 /= 3;
747
    }
748
    }
748
   if(abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25)
749
   if(abs(PPM_in[ParamSet.Kanalbelegung[K_GIER]]) > 25)
749
    {
750
    {
750
    tmp_long  /= 3;
751
    tmp_long  /= 3;
751
    tmp_long2 /= 3;
752
    tmp_long2 /= 3;
Line 769... Line 770...
769
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
770
  static long MittelIntegralNick_Alt,MittelIntegralRoll_Alt;
770
  if(!Looping_Nick && !Looping_Roll)
771
  if(!Looping_Nick && !Looping_Roll)
771
  {
772
  {
772
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
773
    MittelIntegralNick  /= ABGLEICH_ANZAHL;
773
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
774
    MittelIntegralRoll  /= ABGLEICH_ANZAHL;
774
        IntegralAccNick = (EE_Parameter.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
775
        IntegralAccNick = (ParamSet.GyroAccFaktor * IntegralAccNick) / ABGLEICH_ANZAHL;
775
        IntegralAccRoll = (EE_Parameter.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
776
        IntegralAccRoll = (ParamSet.GyroAccFaktor * IntegralAccRoll) / ABGLEICH_ANZAHL;
776
    IntegralAccZ    = IntegralAccZ / ABGLEICH_ANZAHL;
777
    IntegralAccZ    = IntegralAccZ / ABGLEICH_ANZAHL;
777
#define MAX_I 0//(Poti2/10)
778
#define MAX_I 0//(Poti2/10)
778
// Nick ++++++++++++++++++++++++++++++++++++++++++++++++
779
// Nick ++++++++++++++++++++++++++++++++++++++++++++++++
779
    IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick);
780
    IntegralFehlerNick = (long)(MittelIntegralNick - (long)IntegralAccNick);
780
    ausgleichNick = IntegralFehlerNick / EE_Parameter.GyroAccAbgleich;
781
    ausgleichNick = IntegralFehlerNick / ParamSet.GyroAccAbgleich;
781
// Roll ++++++++++++++++++++++++++++++++++++++++++++++++
782
// Roll ++++++++++++++++++++++++++++++++++++++++++++++++
782
    IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll);
783
    IntegralFehlerRoll = (long)(MittelIntegralRoll - (long)IntegralAccRoll);
783
    ausgleichRoll = IntegralFehlerRoll / EE_Parameter.GyroAccAbgleich;
784
    ausgleichRoll = IntegralFehlerRoll / ParamSet.GyroAccAbgleich;
Line 784... Line 785...
784
 
785
 
785
    LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
786
    LageKorrekturNick = ausgleichNick / ABGLEICH_ANZAHL;
Line 786... Line 787...
786
    LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
787
    LageKorrekturRoll = ausgleichRoll / ABGLEICH_ANZAHL;
787
 
788
 
788
   if((MaxStickNick > 15) || (MaxStickRoll > 15) || (abs(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]) > 25))
789
   if((MaxStickNick > 15) || (MaxStickRoll > 15) || (abs(PPM_in[ParamSet.Kanalbelegung[K_GIER]]) > 25))
789
    {
790
    {
790
     LageKorrekturNick /= 2;
791
     LageKorrekturNick /= 2;
Line 847... Line 848...
847
             LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
848
             LageKorrekturNick += ausgleichNick / ABGLEICH_ANZAHL;
848
            }
849
            }
849
           else last_n_n = 1;
850
           else last_n_n = 1;
850
         } else  last_n_n = 0;
851
         } else  last_n_n = 0;
851
        } else cnt = 0;
852
        } else cnt = 0;
852
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
853
        if(cnt > ParamSet.Driftkomp) cnt = ParamSet.Driftkomp;
853
        if(IntegralFehlerNick >  FEHLER_LIMIT)   AdNeutralNick += cnt;
854
        if(IntegralFehlerNick >  FEHLER_LIMIT)   AdNeutralNick += cnt;
854
        if(IntegralFehlerNick < -FEHLER_LIMIT)   AdNeutralNick -= cnt;
855
        if(IntegralFehlerNick < -FEHLER_LIMIT)   AdNeutralNick -= cnt;
Line 855... Line 856...
855
 
856
 
856
// Roll +++++++++++++++++++++++++++++++++++++++++++++++++
857
// Roll +++++++++++++++++++++++++++++++++++++++++++++++++
Line 884... Line 885...
884
        } else
885
        } else
885
        {
886
        {
886
         cnt = 0;
887
         cnt = 0;
887
        }
888
        }
Line 888... Line 889...
888
 
889
 
889
        if(cnt > EE_Parameter.Driftkomp) cnt = EE_Parameter.Driftkomp;
890
        if(cnt > ParamSet.Driftkomp) cnt = ParamSet.Driftkomp;
890
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
891
        if(IntegralFehlerRoll >  FEHLER_LIMIT)   AdNeutralRoll += cnt;
891
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
892
        if(IntegralFehlerRoll < -FEHLER_LIMIT)   AdNeutralRoll -= cnt;
892
DebugOut.Analog[27] = ausgleichRoll;
893
DebugOut.Analog[27] = ausgleichRoll;
893
DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick);
894
DebugOut.Analog[23] = AdNeutralNick;//10*(AdNeutralNick - StartNeutralNick);
Line 918... Line 919...
918
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
919
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
919
//  Gieren
920
//  Gieren
920
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
921
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
921
    if(abs(StickGier) > 20) // war 35
922
    if(abs(StickGier) > 20) // war 35
922
     {
923
     {
923
      if(!(EE_Parameter.GlobalConfig & CFG_KOMPASS_FIX)) NeueKompassRichtungMerken = 1;
924
      if(!(ParamSet.GlobalConfig & CFG_KOMPASS_FIX)) NeueKompassRichtungMerken = 1;
924
     }
925
     }
925
    tmp_int  = (long) EE_Parameter.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
926
    tmp_int  = (long) ParamSet.Gier_P * ((long)StickGier * abs(StickGier)) / 512L; // expo  y = ax + bx²
926
    tmp_int += (EE_Parameter.Gier_P * StickGier) / 4;
927
    tmp_int += (ParamSet.Gier_P * StickGier) / 4;
927
    sollGier = tmp_int;
928
    sollGier = tmp_int;
928
    Mess_Integral_Gier -= tmp_int;
929
    Mess_Integral_Gier -= tmp_int;
929
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
930
    if(Mess_Integral_Gier > 50000) Mess_Integral_Gier = 50000;  // begrenzen
930
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
931
    if(Mess_Integral_Gier <-50000) Mess_Integral_Gier =-50000;
Line 931... Line 932...
931
 
932
 
932
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
933
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
933
//  Kompass
934
//  Kompass
934
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
935
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
935
    if(KompassValue && (EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV))
936
    if(KompassValue && (ParamSet.GlobalConfig & CFG_KOMPASS_AKTIV))
936
     {
937
     {
937
       int w,v;
938
       int w,v;
938
       static int SignalSchlecht = 0;
939
       static int SignalSchlecht = 0;
939
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
940
       w = abs(IntegralNick /512); // mit zunehmender Neigung den Einfluss drosseln
Line 959... Line 960...
959
//  Debugwerte zuordnen
960
//  Debugwerte zuordnen
960
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
961
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
961
  if(!TimerWerteausgabe--)
962
  if(!TimerWerteausgabe--)
962
   {
963
   {
963
    TimerWerteausgabe = 24;
964
    TimerWerteausgabe = 24;
964
    DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
965
    DebugOut.Analog[0] = IntegralNick / ParamSet.GyroAccFaktor;
965
    DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
966
    DebugOut.Analog[1] = IntegralRoll / ParamSet.GyroAccFaktor;
966
    DebugOut.Analog[2] = Mittelwert_AccNick;
967
    DebugOut.Analog[2] = Mittelwert_AccNick;
967
    DebugOut.Analog[3] = Mittelwert_AccRoll;
968
    DebugOut.Analog[3] = Mittelwert_AccRoll;
968
    DebugOut.Analog[4] = MesswertGier;
969
    DebugOut.Analog[4] = MesswertGier;
969
    DebugOut.Analog[5] = HoehenWert;
970
    DebugOut.Analog[5] = HoehenWert;
970
    DebugOut.Analog[6] =(Mess_Integral_Hoch / 512);
971
    DebugOut.Analog[6] =(Mess_Integral_Hoch / 512);
Line 988... Line 989...
988
//    DebugOut.Analog[9] = MesswertNick;
989
//    DebugOut.Analog[9] = MesswertNick;
989
//    DebugOut.Analog[9] = SollHoehe;
990
//    DebugOut.Analog[9] = SollHoehe;
990
//    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
991
//    DebugOut.Analog[10] = Mess_Integral_Gier / 128;
991
//    DebugOut.Analog[11] = KompassStartwert;
992
//    DebugOut.Analog[11] = KompassStartwert;
992
//    DebugOut.Analog[10] = Parameter_Gyro_I;
993
//    DebugOut.Analog[10] = Parameter_Gyro_I;
993
//    DebugOut.Analog[10] = EE_Parameter.Gyro_I;
994
//    DebugOut.Analog[10] = ParamSet.Gyro_I;
994
//    DebugOut.Analog[9] = KompassRichtung;
995
//    DebugOut.Analog[9] = KompassRichtung;
995
//    DebugOut.Analog[10] = GasMischanteil;
996
//    DebugOut.Analog[10] = GasMischanteil;
996
//    DebugOut.Analog[3] = HoeheD * 32;
997
//    DebugOut.Analog[3] = HoeheD * 32;
997
//    DebugOut.Analog[4] = hoehenregler;
998
//    DebugOut.Analog[4] = hoehenregler;
998
  }
999
  }
Line 1026... Line 1027...
1026
// Höhenregelung
1027
// Höhenregelung
1027
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1028
// Die Höhenregelung schwächt lediglich das Gas ab, erhöht es allerdings nicht
1028
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1029
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1029
//OCR0B = 180 - (Poti1 + 120) / 4;
1030
//OCR0B = 180 - (Poti1 + 120) / 4;
1030
//DruckOffsetSetting = OCR0B;
1031
//DruckOffsetSetting = OCR0B;
1031
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1032
 if((ParamSet.GlobalConfig & CFG_HOEHENREGELUNG))  // Höhenregelung
1032
  {
1033
  {
1033
    int tmp_int;
1034
    int tmp_int;
1034
    if(EE_Parameter.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
1035
    if(ParamSet.GlobalConfig & CFG_HOEHEN_SCHALTER)  // Regler wird über Schalter gesteuert
1035
    {
1036
    {
1036
     if(Parameter_MaxHoehe < 50)
1037
     if(Parameter_MaxHoehe < 50)
1037
      {
1038
      {
1038
       SollHoehe = HoehenWert - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters
1039
       SollHoehe = HoehenWert - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters
1039
       HoehenReglerAktiv = 0;
1040
       HoehenReglerAktiv = 0;
Line 1041... Line 1042...
1041
      else
1042
      else
1042
        HoehenReglerAktiv = 1;
1043
        HoehenReglerAktiv = 1;
1043
    }
1044
    }
1044
    else
1045
    else
1045
    {
1046
    {
1046
     SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)EE_Parameter.Hoehe_Verstaerkung - 20;
1047
     SollHoehe = ((int) ExternHoehenValue + (int) Parameter_MaxHoehe) * (int)ParamSet.Hoehe_Verstaerkung - 20;
1047
     HoehenReglerAktiv = 1;
1048
     HoehenReglerAktiv = 1;
1048
    }
1049
    }
Line 1049... Line 1050...
1049
 
1050
 
1050
    if(Notlandung) SollHoehe = 0;
1051
    if(Notlandung) SollHoehe = 0;
Line 1056... Line 1057...
1056
      tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32;
1057
      tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32;
1057
      if(tmp_int > 50) tmp_int = 50;
1058
      if(tmp_int > 50) tmp_int = 50;
1058
      else if(tmp_int < -50) tmp_int = -50;
1059
      else if(tmp_int < -50) tmp_int = -50;
1059
      h -= tmp_int;
1060
      h -= tmp_int;
1060
      hoehenregler = (hoehenregler*15 + h) / 16;
1061
      hoehenregler = (hoehenregler*15 + h) / 16;
1061
      if(hoehenregler < EE_Parameter.Hoehe_MinGas) // nicht unter MIN
1062
      if(hoehenregler < ParamSet.Hoehe_MinGas) // nicht unter MIN
1062
       {
1063
       {
1063
         if(GasMischanteil >= EE_Parameter.Hoehe_MinGas) hoehenregler = EE_Parameter.Hoehe_MinGas;
1064
         if(GasMischanteil >= ParamSet.Hoehe_MinGas) hoehenregler = ParamSet.Hoehe_MinGas;
1064
         if(GasMischanteil < EE_Parameter.Hoehe_MinGas) hoehenregler = GasMischanteil;
1065
         if(GasMischanteil < ParamSet.Hoehe_MinGas) hoehenregler = GasMischanteil;
1065
       }
1066
       }
1066
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1067
      if(hoehenregler > GasMischanteil) hoehenregler = GasMischanteil; // nicht mehr als Gas
1067
      GasMischanteil = hoehenregler;
1068
      GasMischanteil = hoehenregler;
1068
     }
1069
     }
1069
  }
1070
  }