Subversion Repositories FlightCtrl

Rev

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

Rev 701 Rev 703
Line 64... Line 64...
64
#include "uart.h"
64
#include "uart.h"
65
#include "rc.h"
65
#include "rc.h"
66
#include "twimaster.h"
66
#include "twimaster.h"
67
#include "mm3.h"
67
#include "mm3.h"
Line 68... Line -...
68
 
-
 
-
 
68
 
69
unsigned char h,m,s;
69
 
-
 
70
volatile unsigned int I2CTimeout = 100;
70
volatile unsigned int I2CTimeout = 100;
71
// gyro readings
-
 
72
volatile int16_t ReadingPitch, ReadingRoll, ReadingYaw;
71
volatile int ReadingPitch, ReadingRoll, ReadingYaw;
73
// gyro neutral readings
-
 
74
volatile int16_t AdNeutralPitch = 0, AdNeutralRoll = 0, AdNeutralYaw = 0;
-
 
75
volatile int16_t StartNeutralRoll = 0, StartNeutralPitch = 0;
72
volatile int AdNeutralPitch = 0,AdNeutralRoll = 0,AdNeutralYaw = 0, StartNeutralRoll = 0, StartNeutralPitch = 0;
76
// mean accelerations
-
 
77
volatile int16_t Mean_AccPitch, Mean_AccRoll, Mean_AccTop;
-
 
78
 
-
 
79
// neutral acceleration readings
73
volatile int Mean_AccPitch, Mean_AccRoll, Mean_AccTop, NeutralAccX=0, NeutralAccY=0;
80
volatile int16_t NeutralAccX=0, NeutralAccY=0;
-
 
81
volatile float NeutralAccZ = 0;
74
volatile float NeutralAccZ = 0;
82
 
75
volatile long IntegralPitch = 0,IntegralPitch2 = 0;
83
// attitude gyro integrals
76
volatile long IntegralRoll = 0,IntegralRoll2 = 0;
84
volatile int32_t IntegralPitch = 0,IntegralPitch2 = 0;
77
volatile long IntegralAccPitch = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
85
volatile int32_t IntegralRoll = 0,IntegralRoll2 = 0;
78
volatile long Integral_Yaw = 0;
86
volatile int32_t IntegralYaw = 0;
79
volatile long Reading_IntegralPitch = 0,Reading_IntegralPitch2 = 0;
87
volatile int32_t Reading_IntegralPitch = 0, Reading_IntegralPitch2 = 0;
80
volatile long Reading_IntegralRoll = 0,Reading_IntegralRoll2 = 0;
88
volatile int32_t Reading_IntegralRoll = 0,  Reading_IntegralRoll2 = 0;
-
 
89
volatile int32_t Reading_IntegralYaw = 0,   Reading_IntegralYaw2 = 0;
81
volatile long Reading_Integral_Yaw = 0,Reading_Integral_Yaw2 = 0;
90
volatile int32_t MeanIntegralPitch, MeanIntegralPitch2;
-
 
91
volatile int32_t MeanIntegralRoll, MeanIntegralRoll2;
-
 
92
 
-
 
93
// attitude acceleration integrals
82
volatile long MeanIntegralPitch, MeanIntegralRoll, MeanIntegralPitch2, MeanIntegralRoll2;
94
volatile int32_t IntegralAccPitch = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
-
 
95
volatile int32_t Reading_Integral_Top = 0;
-
 
96
 
83
volatile long Reading_Integral_Top = 0;
97
// compass course
84
volatile int  CompassHeading = 0;
98
volatile int16_t CompassHeading = 0;
85
volatile int  CompassCourse = 0;
99
volatile int16_t CompassCourse = 0;
-
 
100
volatile int16_t CompassOffCourse = 0;
86
volatile int  CompassOffCourse = 0;
101
 
87
unsigned char MAX_GAS,MIN_GAS;
102
// flags
88
unsigned char EmergencyLanding = 0;
103
uint8_t EmergencyLanding = 0;
-
 
104
uint8_t HightControlActive = 0;
-
 
105
uint8_t MotorsOn = 0;
89
unsigned char HightControlActive = 0;
106
 
Line 90... Line 107...
90
long TurnOver180Pitch = 250000L, TurnOver180Roll = 250000L;
107
int32_t TurnOver180Pitch = 250000L, TurnOver180Roll = 250000L;
91
 
108
 
-
 
109
float GyroFactor;
92
float GyroFactor;
110
float IntegralFactor;
-
 
111
 
93
float IntegralFactor;
112
volatile int16_t  DiffPitch, DiffRoll;
-
 
113
 
-
 
114
int16_t  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
94
volatile int  DiffPitch,DiffRoll;
115
 
-
 
116
// setpoints for motors
95
int  Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
117
volatile uint8_t Motor_Front, Motor_Rear, Motor_Right, Motor_Left;
96
volatile unsigned char Motor_Front, Motor_Rear, Motor_Right, Motor_Left, Count;
118
 
97
unsigned char MotorValue[5];
-
 
98
int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickGas = 0;
-
 
99
char MotorsOn = 0;
-
 
100
int ReadingHight = 0;
-
 
101
int SetPointHight = 0;
-
 
102
int AttitudeCorrectionRoll = 0, AttitudeCorrectionPitch = 0;
119
// stick values derived by rc channels readings
103
float Ki =  FAKTOR_I;
120
int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickGas = 0;
104
unsigned char Looping_Pitch = 0, Looping_Roll = 0;
-
 
105
unsigned char Looping_Left = 0, Looping_Right = 0, Looping_Down = 0, Looping_Top = 0;
-
 
106
 
-
 
107
unsigned char Parameter_Luftdruck_D  = 48;      // Wert : 0-250
-
 
108
unsigned char Parameter_MaxHoehe     = 251;     // Wert : 0-250
-
 
109
unsigned char Parameter_Hoehe_P      = 16;      // Wert : 0-32
-
 
110
unsigned char Parameter_Hoehe_ACC_Wirkung = 58; // Wert : 0-250
-
 
111
unsigned char Parameter_CompassYawEffect = 64;  // Wert : 0-250
-
 
112
unsigned char Parameter_Gyro_P = 150;           // Wert : 10-250
-
 
113
unsigned char Parameter_Gyro_I = 150;           // Wert : 0-250
-
 
114
unsigned char Parameter_Gier_P = 2;             // Wert : 1-20
-
 
115
unsigned char Parameter_I_Factor = 10;          // Wert : 1-20
-
 
116
unsigned char Parameter_UserParam1 = 0;
-
 
117
unsigned char Parameter_UserParam2 = 0;
-
 
118
unsigned char Parameter_UserParam3 = 0;
-
 
119
unsigned char Parameter_UserParam4 = 0;
-
 
120
unsigned char Parameter_UserParam5 = 0;
-
 
121
unsigned char Parameter_UserParam6 = 0;
-
 
122
unsigned char Parameter_UserParam7 = 0;
-
 
123
unsigned char Parameter_UserParam8 = 0;
-
 
124
unsigned char Parameter_ServoPitchControl = 100;
-
 
125
unsigned char Parameter_LoopGasLimit = 70;
-
 
126
unsigned char Parameter_AchsKopplung1 = 0;
-
 
Line 127... Line -...
127
unsigned char Parameter_AchsGegenKopplung1 = 0;
-
 
128
unsigned char Parameter_DynamicStability = 100;
121
// stick values derived by uart inputs
Line -... Line 122...
-
 
122
int16_t ExternStickPitch = 0, ExternStickRoll = 0, ExternStickYaw = 0, ExternHightValue = -20;
-
 
123
 
-
 
124
int MaxStickPitch = 0, MaxStickRoll = 0;
-
 
125
 
-
 
126
 
-
 
127
int16_t ReadingHight = 0;
-
 
128
int16_t SetPointHight = 0;
-
 
129
 
-
 
130
int16_t AttitudeCorrectionRoll = 0, AttitudeCorrectionPitch = 0;
-
 
131
 
-
 
132
float Ki =  FACTOR_I;
-
 
133
 
-
 
134
uint8_t Looping_Pitch = 0, Looping_Roll = 0;
-
 
135
uint8_t Looping_Left = 0, Looping_Right = 0, Looping_Down = 0, Looping_Top = 0;
-
 
136
 
-
 
137
 
-
 
138
fc_param_t FCParam = {48,251,16,58,64,150,150,2,10,0,0,0,0,0,0,0,0,100,70,0,0,100};
-
 
139
 
129
 
140
 
130
signed int ExternStickPitch = 0, ExternStickRoll = 0,ExternStickYaw = 0, ExternHightValue = -20;
141
/************************************************************************/
131
int MaxStickPitch = 0, MaxStickRoll = 0;
142
/*  Creates numbeeps beeps at the speaker                               */
132
 
143
/************************************************************************/
133
void Piep(unsigned char Anzahl)
144
void Beep(uint8_t numbeeps)
134
{
145
{
135
 while(Anzahl--)
146
        while(numbeeps--)
-
 
147
        {
-
 
148
                if(MotorsOn) return; //auf keinen Fall im Flug!
136
 {
149
                BeepTime = 100; // 0.1 second
137
  if(MotorsOn) return; //auf keinen Fall im Flug!
150
                Delay_ms(250); // blocks 250 ms as pause to next beep,
Line 138... Line 151...
138
  BeepTime = 100;
151
                // this will block the flight control loop,
139
  Delay_ms(250);
152
                // therefore do not use this funktion if motors are running
-
 
153
        }
140
 }
154
}
141
}
-
 
142
 
155
 
143
//############################################################################
156
/************************************************************************/
144
//  Nullwerte ermitteln
157
/*  Neutral Readings                                                    */
145
void SetNeutral(void)
158
/************************************************************************/
146
//############################################################################
159
void SetNeutral(void)
147
{
160
{
148
        NeutralAccX = 0;
161
        NeutralAccX = 0;
149
        NeutralAccY = 0;
162
        NeutralAccY = 0;
150
        NeutralAccZ = 0;
163
        NeutralAccZ = 0;
151
    AdNeutralPitch = 0;
164
    AdNeutralPitch = 0;
152
        AdNeutralRoll = 0;
165
        AdNeutralRoll = 0;
153
        AdNeutralYaw = 0;
166
        AdNeutralYaw = 0;
154
    Parameter_AchsKopplung1 = 0;
167
    FCParam.AchsKopplung1 = 0;
155
    Parameter_AchsGegenKopplung1 = 0;
168
    FCParam.AchsGegenKopplung1 = 0;
156
    CalibMean();
169
    CalibMean();
157
    Delay_ms_Mess(100);
170
    Delay_ms_Mess(100);
158
        CalibMean();
-
 
159
    if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL))  // Höhenregelung aktiviert?
171
        CalibMean();
160
     {
172
    if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL))  // Hight Control activated?
161
      if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset();
173
    {
162
     }
174
                if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset();
163
 
175
    }
164
     AdNeutralPitch= AdValueGyrPitch;
176
        AdNeutralPitch = AdValueGyrPitch;
165
         AdNeutralRoll= AdValueGyrRoll;
177
        AdNeutralRoll  = AdValueGyrRoll;
166
         AdNeutralYaw= AdValueGyrYaw;
178
        AdNeutralYaw   = AdValueGyrYaw;
167
     StartNeutralRoll = AdNeutralRoll;
179
        StartNeutralRoll  = AdNeutralRoll;
168
     StartNeutralPitch = AdNeutralPitch;
180
        StartNeutralPitch = AdNeutralPitch;
169
    if(GetParamByte(PID_ACC_PITCH) > 4)
181
    if(GetParamByte(PID_ACC_PITCH) > 4)
170
    {
182
    {
171
      NeutralAccY = abs(Mean_AccRoll) / ACC_AMPLIFY;
183
                NeutralAccY = abs(Mean_AccRoll) / ACC_AMPLIFY;
172
          NeutralAccX = abs(Mean_AccPitch) / ACC_AMPLIFY;
184
                NeutralAccX = abs(Mean_AccPitch) / ACC_AMPLIFY;
173
          NeutralAccZ = Current_AccZ;
185
                NeutralAccZ = Current_AccZ;
174
    }
186
    }
175
    else
187
    else
176
    { // why not GetParamWord()?
-
 
177
      NeutralAccX = (int)GetParamByte(PID_ACC_PITCH) * 256 + (int)GetParamByte(PID_ACC_PITCH+1);
188
    {
178
          NeutralAccY = (int)GetParamByte(PID_ACC_ROLL) * 256 + (int)GetParamByte(PID_ACC_ROLL+1);
189
                NeutralAccX = (int16_t)GetParamWord(PID_ACC_PITCH);
179
          NeutralAccZ = (int)GetParamByte(PID_ACC_Z) * 256 + (int)GetParamByte(PID_ACC_Z+1);
190
            NeutralAccY = (int16_t)GetParamWord(PID_ACC_ROLL);
180
    }
191
            NeutralAccZ = (int16_t)GetParamWord(PID_ACC_Z);
181
 
192
    }
182
        Reading_IntegralPitch = 0;
193
        Reading_IntegralPitch = 0;
183
    Reading_IntegralPitch2 = 0;
194
    Reading_IntegralPitch2 = 0;
184
    Reading_IntegralRoll = 0;
195
    Reading_IntegralRoll = 0;
185
    Reading_IntegralRoll2 = 0;
196
    Reading_IntegralRoll2 = 0;
186
    Reading_Integral_Yaw = 0;
197
    Reading_IntegralYaw = 0;
187
    ReadingPitch = 0;
198
    ReadingPitch = 0;
188
    ReadingRoll = 0;
199
    ReadingRoll = 0;
189
    ReadingYaw = 0;
200
    ReadingYaw = 0;
190
    StartAirPressure = AirPressure;
201
    StartAirPressure = AirPressure;
191
    HoeheD = 0;
202
    HightD = 0;
192
    Reading_Integral_Top = 0;
203
    Reading_Integral_Top = 0;
193
    CompassCourse = CompassHeading;
204
    CompassCourse = CompassHeading;
194
    GPS_Neutral();
205
    GPS_Neutral();
Line 195... Line 206...
195
    BeepTime = 50;
206
    BeepTime = 50;
196
        TurnOver180Pitch = (long) ParamSet.AngleTurnOverPitch * 2500L;
207
        TurnOver180Pitch = (int32_t) ParamSet.AngleTurnOverPitch * 2500L;
-
 
208
        TurnOver180Roll = (int32_t) ParamSet.AngleTurnOverRoll * 2500L;
197
        TurnOver180Roll = (long) ParamSet.AngleTurnOverRoll * 2500L;
209
    ExternHightValue = 0;
198
    ExternHightValue = 0;
-
 
199
}
210
}
200
 
211
 
201
//############################################################################
-
 
202
// Bearbeitet die Messwerte
-
 
203
void Mean(void)
-
 
Line -... Line 212...
-
 
212
/************************************************************************/
-
 
213
/*  Averaging Measurement Readings                                      */
-
 
214
/************************************************************************/
-
 
215
void Mean(void)
-
 
216
{
204
//############################################################################
217
    static int32_t tmpl,tmpl2;
205
{
218
 
-
 
219
 // Get offset corrected gyro readings
-
 
220
    ReadingYaw   = AdNeutralYaw    - AdValueGyrYaw;
-
 
221
    ReadingRoll  = AdValueGyrRoll  - AdNeutralRoll;
-
 
222
    ReadingPitch = AdValueGyrPitch - AdNeutralPitch;
-
 
223
 
Line 206... Line -...
206
    static int32_t tmpl,tmpl2;
-
 
207
    ReadingYaw = (int16_t) AdNeutralYaw - AdValueGyrYaw;
-
 
208
    ReadingRoll = (int16_t) AdValueGyrRoll - AdNeutralRoll;
-
 
209
    ReadingPitch = (int16_t) AdValueGyrPitch - AdNeutralPitch;
-
 
210
 
224
        DebugOut.Analog[26] = ReadingPitch;
211
//DebugOut.Analog[26] = ReadingPitch;
225
        DebugOut.Analog[28] = ReadingRoll;
212
DebugOut.Analog[28] = ReadingRoll;
226
 
-
 
227
// Acceleration Sensor
213
 
228
        Mean_AccPitch = ((int32_t)Mean_AccPitch * 1 + ((ACC_AMPLIFY * (int32_t)AdValueAccPitch))) / 2L;
214
// Beschleunigungssensor  ++++++++++++++++++++++++++++++++++++++++++++++++
229
        Mean_AccRoll  = ((int32_t)Mean_AccRoll * 1 + ((ACC_AMPLIFY * (int32_t)AdValueAccRoll))) / 2L;
215
        Mean_AccPitch = ((long)Mean_AccPitch * 1 + ((ACC_AMPLIFY * (long)AdValueAccPitch))) / 2L;
230
        Mean_AccTop   = ((int32_t)Mean_AccTop * 1 + ((int32_t)AdValueAccTop)) / 2L;
-
 
231
 
216
        Mean_AccRoll = ((long)Mean_AccRoll * 1 + ((ACC_AMPLIFY * (long)AdValueAccRoll))) / 2L;
232
    IntegralAccPitch += ACC_AMPLIFY * AdValueAccPitch;
217
        Mean_AccTop = ((long)Mean_AccTop * 1 + ((long)AdValueAccTop)) / 2L;
233
    IntegralAccRoll  += ACC_AMPLIFY * AdValueAccRoll;
218
    IntegralAccPitch += ACC_AMPLIFY * AdValueAccPitch;
234
    IntegralAccZ     += Current_AccZ - NeutralAccZ;
219
    IntegralAccRoll += ACC_AMPLIFY * AdValueAccRoll;
235
 
220
    IntegralAccZ    += Current_AccZ - NeutralAccZ;
236
// Yaw
221
// Yaw  ++++++++++++++++++++++++++++++++++++++++++++++++
237
    Reading_IntegralYaw +=  ReadingYaw;
222
            Reading_Integral_Yaw +=  ReadingYaw;
238
    Reading_IntegralYaw2 += ReadingYaw;
223
            Reading_Integral_Yaw2 += ReadingYaw;
239
 
224
// Kopplungsanteil  +++++++++++++++++++++++++++++++++++++
240
// Coupling fraction
225
      if(!Looping_Pitch && !Looping_Roll && (ParamSet.GlobalConfig & CFG_AXIS_COUPLING_ACTIVE))
241
        if(!Looping_Pitch && !Looping_Roll && (ParamSet.GlobalConfig & CFG_AXIS_COUPLING_ACTIVE))
226
         {
242
        {
227
            tmpl = Reading_IntegralPitch / 4096L;
243
                tmpl = Reading_IntegralPitch / 4096L;
228
            tmpl *= ReadingYaw;
244
                tmpl *= ReadingYaw;
229
            tmpl *= Parameter_AchsKopplung1;  //125
245
                tmpl *= FCParam.AchsKopplung1;  //125
230
            tmpl /= 2048L;
246
                tmpl /= 2048L;
231
            tmpl2 = Reading_IntegralRoll / 4096L;
247
                tmpl2 = Reading_IntegralRoll / 4096L;
232
            tmpl2 *= ReadingYaw;
248
                tmpl2 *= ReadingYaw;
233
            tmpl2 *= Parameter_AchsKopplung1;
249
                tmpl2 *= FCParam.AchsKopplung1;
234
            tmpl2 /= 2048L;
250
                tmpl2 /= 2048L;
235
         }
251
        }
236
      else  tmpl = tmpl2 = 0;
252
        else  tmpl = tmpl2 = 0;
237
// Roll  ++++++++++++++++++++++++++++++++++++++++++++++++
253
// Roll
238
            ReadingRoll += tmpl;
254
        ReadingRoll += tmpl;
239
            ReadingRoll += (tmpl2*Parameter_AchsGegenKopplung1)/512L; //109
255
        ReadingRoll += (tmpl2 * FCParam.AchsGegenKopplung1) / 512L; //109
240
            Reading_IntegralRoll2 += ReadingRoll;
256
        Reading_IntegralRoll2 += ReadingRoll;
241
            Reading_IntegralRoll +=  ReadingRoll - AttitudeCorrectionRoll;
257
        Reading_IntegralRoll +=  ReadingRoll - AttitudeCorrectionRoll;
242
            if(Reading_IntegralRoll > TurnOver180Roll)
258
        if(Reading_IntegralRoll > TurnOver180Roll)
243
            {
259
        {
244
             Reading_IntegralRoll  = -(TurnOver180Roll - 10000L);
260
                Reading_IntegralRoll  = -(TurnOver180Roll - 10000L);
245
             Reading_IntegralRoll2 = Reading_IntegralRoll;
261
                Reading_IntegralRoll2 = Reading_IntegralRoll;
246
            }
262
        }
247
            if(Reading_IntegralRoll <-TurnOver180Roll)
263
        if(Reading_IntegralRoll < -TurnOver180Roll)
248
            {
264
        {
249
             Reading_IntegralRoll =  (TurnOver180Roll - 10000L);
265
                Reading_IntegralRoll =  (TurnOver180Roll - 10000L);
250
             Reading_IntegralRoll2 = Reading_IntegralRoll;
266
                Reading_IntegralRoll2 = Reading_IntegralRoll;
251
            }
267
        }
252
            if(AdValueGyrRoll < 15)   ReadingRoll = -1000;
268
        if(AdValueGyrRoll < 15)   ReadingRoll = -1000;
253
            if(AdValueGyrRoll <  7)   ReadingRoll = -2000;
269
        if(AdValueGyrRoll <  7)   ReadingRoll = -2000;
254
            if(BoardRelease == 10)
270
        if(BoardRelease == 10)
255
                         {
271
         {
256
              if(AdValueGyrRoll > 1010) ReadingRoll = +1000;
272
                if(AdValueGyrRoll > 1010) ReadingRoll = +1000;
257
              if(AdValueGyrRoll > 1017) ReadingRoll = +2000;
273
                if(AdValueGyrRoll > 1017) ReadingRoll = +2000;
258
                         }
274
         }
259
                         else
275
         else
260
                         {
276
         {
261
              if(AdValueGyrRoll > 2020) ReadingRoll = +1000;
277
                if(AdValueGyrRoll > 2020) ReadingRoll = +1000;
262
              if(AdValueGyrRoll > 2034) ReadingRoll = +2000;
278
                if(AdValueGyrRoll > 2034) ReadingRoll = +2000;
263
                         }
279
         }
264
// Pitch  ++++++++++++++++++++++++++++++++++++++++++++++++
280
// Pitch
265
            ReadingPitch -= tmpl2;
281
        ReadingPitch -= tmpl2;
266
            ReadingPitch -= (tmpl*Parameter_AchsGegenKopplung1)/512L;
282
        ReadingPitch -= (tmpl*FCParam.AchsGegenKopplung1) / 512L;
267
            Reading_IntegralPitch2 += ReadingPitch;
283
        Reading_IntegralPitch2 += ReadingPitch;
268
            Reading_IntegralPitch  += ReadingPitch - AttitudeCorrectionPitch;
284
        Reading_IntegralPitch  += ReadingPitch - AttitudeCorrectionPitch;
269
            if(Reading_IntegralPitch > TurnOver180Pitch)
285
        if(Reading_IntegralPitch > TurnOver180Pitch)
270
            {
286
        {
271
             Reading_IntegralPitch = -(TurnOver180Pitch - 10000L);
287
         Reading_IntegralPitch = -(TurnOver180Pitch - 10000L);
272
             Reading_IntegralPitch2 = Reading_IntegralPitch;
288
         Reading_IntegralPitch2 = Reading_IntegralPitch;
273
            }
289
        }
274
            if(Reading_IntegralPitch <-TurnOver180Pitch)
290
        if(Reading_IntegralPitch < -TurnOver180Pitch)
275
            {
291
        {
276
             Reading_IntegralPitch =  (TurnOver180Pitch - 10000L);
292
         Reading_IntegralPitch =  (TurnOver180Pitch - 10000L);
277
             Reading_IntegralPitch2 = Reading_IntegralPitch;
293
         Reading_IntegralPitch2 = Reading_IntegralPitch;
278
            }
294
        }
279
            if(AdValueGyrPitch < 15)   ReadingPitch = -1000;
295
        if(AdValueGyrPitch < 15)   ReadingPitch = -1000;
280
            if(AdValueGyrPitch <  7)   ReadingPitch = -2000;
296
        if(AdValueGyrPitch <  7)   ReadingPitch = -2000;
281
            if(BoardRelease == 10)
297
        if(BoardRelease == 10)
282
                         {
298
         {
283
              if(AdValueGyrPitch > 1010) ReadingPitch = +1000;
-
 
-
 
299
                if(AdValueGyrPitch > 1010) ReadingPitch = +1000;
284
              if(AdValueGyrPitch > 1017) ReadingPitch = +2000;
300
                if(AdValueGyrPitch > 1017) ReadingPitch = +2000;
285
                         }
301
         }
286
                         else
-
 
Line 287... Line 302...
287
                         {
302
         else
288
              if(AdValueGyrPitch > 2020) ReadingPitch = +1000;
303
         {
289
              if(AdValueGyrPitch > 2034) ReadingPitch = +2000;
304
                if(AdValueGyrPitch > 2020) ReadingPitch = +1000;
290
                         }
305
                if(AdValueGyrPitch > 2034) ReadingPitch = +2000;
291
//++++++++++++++++++++++++++++++++++++++++++++++++
306
         }
Line 292... Line 307...
292
// ADC einschalten
307
 
293
    ADC_Enable();
308
// start ADC
294
//++++++++++++++++++++++++++++++++++++++++++++++++
309
    ADC_Enable();
295
 
310
 
296
    Integral_Yaw  = Reading_Integral_Yaw;
311
    IntegralYaw  = Reading_IntegralYaw;
297
    IntegralPitch = Reading_IntegralPitch;
312
    IntegralPitch = Reading_IntegralPitch;
298
    IntegralRoll = Reading_IntegralRoll;
313
    IntegralRoll = Reading_IntegralRoll;
-
 
314
    IntegralPitch2 = Reading_IntegralPitch2;
299
    IntegralPitch2 = Reading_IntegralPitch2;
315
    IntegralRoll2 = Reading_IntegralRoll2;
300
    IntegralRoll2 = Reading_IntegralRoll2;
316
 
301
 
317
        if(ParamSet.GlobalConfig & CFG_ROTARY_RATE_LIMITER && !Looping_Pitch && !Looping_Roll)
302
  if(ParamSet.GlobalConfig & CFG_ROTARY_RATE_LIMITER && !Looping_Pitch && !Looping_Roll)
318
        {
-
 
319
        if(ReadingPitch > 200)       ReadingPitch += 4 * (ReadingPitch - 200);
303
  {
320
        else if(ReadingPitch < -200) ReadingPitch += 4 * (ReadingPitch + 200);
304
    if(ReadingPitch > 200)       ReadingPitch += 4 * (ReadingPitch - 200);
321
        if(ReadingRoll > 200)        ReadingRoll  += 4 * (ReadingRoll - 200);
305
    else if(ReadingPitch < -200) ReadingPitch += 4 * (ReadingPitch + 200);
322
        else if(ReadingRoll < -200)  ReadingRoll  += 4 * (ReadingRoll + 200);
306
    if(ReadingRoll > 200)       ReadingRoll += 4 * (ReadingRoll - 200);
323
        }
307
    else if(ReadingRoll < -200) ReadingRoll += 4 * (ReadingRoll + 200);
324
        //update poti values by rc-signals (why not +127?)
Line 308... Line 325...
308
  }
325
    if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--;
309
    if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--;
326
    if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--;
-
 
327
    if(Poti3 < PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110 && Poti3) Poti3--;
310
    if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--;
328
    if(Poti4 < PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110 && Poti4) Poti4--;
311
    if(Poti3 < PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110 && Poti3) Poti3--;
-
 
312
    if(Poti4 < PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110 && Poti4) Poti4--;
329
        //limit poti values
313
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
330
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
314
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
331
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
-
 
332
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
315
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
333
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
316
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
334
}
317
}
335
 
-
 
336
/************************************************************************/
318
 
337
/*  Averaging Measurement Readings  for Calibration                     */
319
//############################################################################
338
/************************************************************************/
320
// Messwerte beim Ermitteln der Nullage
339
void CalibMean(void)
321
void CalibMean(void)
340
{
322
//############################################################################
341
    // stop ADC to avoid changing values during calculation
-
 
342
        ADC_Disable();
323
{
343
 
324
    // ADC auschalten, damit die Werte sich nicht während der Berechnung ändern
344
        ReadingPitch = AdValueGyrPitch;
325
        ADC_Disable();
345
        ReadingRoll = AdValueGyrRoll;
326
        ReadingPitch = AdValueGyrPitch;
346
        ReadingYaw = AdValueGyrYaw;
-
 
347
 
327
        ReadingRoll = AdValueGyrRoll;
348
        Mean_AccPitch = ACC_AMPLIFY * (int32_t)AdValueAccPitch;
328
        ReadingYaw = AdValueGyrYaw;
349
        Mean_AccRoll = ACC_AMPLIFY * (int32_t)AdValueAccRoll;
329
        Mean_AccPitch = ACC_AMPLIFY * (long)AdValueAccPitch;
350
        Mean_AccTop = (int32_t)AdValueAccTop;
330
        Mean_AccRoll = ACC_AMPLIFY * (long)AdValueAccRoll;
351
   // start ADC
Line 331... Line 352...
331
        Mean_AccTop = (long)AdValueAccTop;
352
    ADC_Enable();
332
   // ADC einschalten
353
    //update poti values by rc-signals (why not +127?)
333
    ADC_Enable();
354
    if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--;
Line 334... Line 355...
334
    if(Poti1 < PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110) Poti1++; else if(Poti1 > PPM_in[ParamSet.ChannelAssignment[CH_POTI1]] + 110 && Poti1) Poti1--;
355
    if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--;
335
    if(Poti2 < PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110) Poti2++; else if(Poti2 > PPM_in[ParamSet.ChannelAssignment[CH_POTI2]] + 110 && Poti2) Poti2--;
356
    if(Poti3 < PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110 && Poti3) Poti3--;
-
 
357
    if(Poti4 < PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110 && Poti4) Poti4--;
336
    if(Poti3 < PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110) Poti3++; else if(Poti3 > PPM_in[ParamSet.ChannelAssignment[CH_POTI3]] + 110 && Poti3) Poti3--;
358
        //limit poti values
337
    if(Poti4 < PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110) Poti4++; else if(Poti4 > PPM_in[ParamSet.ChannelAssignment[CH_POTI4]] + 110 && Poti4) Poti4--;
-
 
338
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
359
    if(Poti1 < 0) Poti1 = 0; else if(Poti1 > 255) Poti1 = 255;
339
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
360
    if(Poti2 < 0) Poti2 = 0; else if(Poti2 > 255) Poti2 = 255;
340
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
361
    if(Poti3 < 0) Poti3 = 0; else if(Poti3 > 255) Poti3 = 255;
341
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
362
    if(Poti4 < 0) Poti4 = 0; else if(Poti4 > 255) Poti4 = 255;
342
 
363
 
343
        TurnOver180Pitch = (long) ParamSet.AngleTurnOverPitch * 2500L;
364
        TurnOver180Pitch = (int32_t) ParamSet.AngleTurnOverPitch * 2500L;
344
        TurnOver180Roll = (long) ParamSet.AngleTurnOverRoll * 2500L;
365
        TurnOver180Roll = (int32_t) ParamSet.AngleTurnOverRoll * 2500L;
345
}
366
}
346
 
367
 
347
//############################################################################
368
/************************************************************************/
348
// Senden der Motorwerte per I2C-Bus
369
/*  Transmit Motor Data via I2C                                         */
349
void SendMotorData(void)
370
/************************************************************************/
Line 350... Line 371...
350
//############################################################################
371
void SendMotorData(void)
351
{
372
{
352
    if(MOTOR_OFF || !MotorsOn)
373
    if(MOTOR_OFF || !MotorsOn)
353
        {
374
    {
Line 372... Line 393...
372
    i2c_start();
393
    i2c_start();
373
}
394
}
Line 374... Line 395...
374
 
395
 
375
 
396
 
-
 
397
 
376
 
398
/************************************************************************/
377
//############################################################################
-
 
378
// Trägt ggf. das Poti als Parameter ein
399
/*  Maps the parameter to poti values                                   */
Line 379... Line 400...
379
void ParameterZuordnung(void)
400
/************************************************************************/
380
//############################################################################
401
void ParameterMapping(void)
381
{
402
{
382
 
403
 
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;}
404
 #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,ParamSet.MaxHight,0,255);
405
 CHK_POTI(FCParam.MaxHight,ParamSet.MaxHight,0,255);
385
 CHK_POTI(Parameter_Luftdruck_D,ParamSet.AirPressure_D,0,100);
406
 CHK_POTI(FCParam.AirPressure_D,ParamSet.AirPressure_D,0,100);
386
 CHK_POTI(Parameter_Hoehe_P,ParamSet.Hight_P,0,100);
407
 CHK_POTI(FCParam.Hight_P,ParamSet.Hight_P,0,100);
387
 CHK_POTI(Parameter_Hoehe_ACC_Wirkung,ParamSet.Hight_ACC_Effect,0,255);
408
 CHK_POTI(FCParam.Hight_ACC_Effect,ParamSet.Hight_ACC_Effect,0,255);
388
 CHK_POTI(Parameter_CompassYawEffect,ParamSet.CompassYawEffect,0,255);
409
 CHK_POTI(FCParam.CompassYawEffect,ParamSet.CompassYawEffect,0,255);
389
 CHK_POTI(Parameter_Gyro_P,ParamSet.Gyro_P,10,255);
410
 CHK_POTI(FCParam.Gyro_P,ParamSet.Gyro_P,10,255);
390
 CHK_POTI(Parameter_Gyro_I,ParamSet.Gyro_I,0,255);
411
 CHK_POTI(FCParam.Gyro_I,ParamSet.Gyro_I,0,255);
391
 CHK_POTI(Parameter_I_Factor,ParamSet.I_Factor,0,255);
412
 CHK_POTI(FCParam.I_Factor,ParamSet.I_Factor,0,255);
392
 CHK_POTI(Parameter_UserParam1,ParamSet.UserParam1,0,255);
413
 CHK_POTI(FCParam.UserParam1,ParamSet.UserParam1,0,255);
393
 CHK_POTI(Parameter_UserParam2,ParamSet.UserParam2,0,255);
414
 CHK_POTI(FCParam.UserParam2,ParamSet.UserParam2,0,255);
394
 CHK_POTI(Parameter_UserParam3,ParamSet.UserParam3,0,255);
415
 CHK_POTI(FCParam.UserParam3,ParamSet.UserParam3,0,255);
395
 CHK_POTI(Parameter_UserParam4,ParamSet.UserParam4,0,255);
416
 CHK_POTI(FCParam.UserParam4,ParamSet.UserParam4,0,255);
396
 CHK_POTI(Parameter_UserParam5,ParamSet.UserParam5,0,255);
417
 CHK_POTI(FCParam.UserParam5,ParamSet.UserParam5,0,255);
397
 CHK_POTI(Parameter_UserParam6,ParamSet.UserParam6,0,255);
418
 CHK_POTI(FCParam.UserParam6,ParamSet.UserParam6,0,255);
398
 CHK_POTI(Parameter_UserParam7,ParamSet.UserParam7,0,255);
419
 CHK_POTI(FCParam.UserParam7,ParamSet.UserParam7,0,255);
399
 CHK_POTI(Parameter_UserParam8,ParamSet.UserParam8,0,255);
420
 CHK_POTI(FCParam.UserParam8,ParamSet.UserParam8,0,255);
400
 CHK_POTI(Parameter_ServoPitchControl,ParamSet.ServoPitchControl,0,255);
421
 CHK_POTI(FCParam.ServoPitchControl,ParamSet.ServoPitchControl,0,255);
401
 CHK_POTI(Parameter_LoopGasLimit,ParamSet.LoopGasLimit,0,255);
422
 CHK_POTI(FCParam.LoopGasLimit,ParamSet.LoopGasLimit,0,255);
402
 CHK_POTI(Parameter_AchsKopplung1,    ParamSet.AchsKopplung1,0,255);
423
 CHK_POTI(FCParam.AchsKopplung1,    ParamSet.AchsKopplung1,0,255);
403
 CHK_POTI(Parameter_AchsGegenKopplung1,ParamSet.AchsGegenKopplung1,0,255);
-
 
404
 CHK_POTI(Parameter_DynamicStability,ParamSet.DynamicStability,0,255);
-
 
405
 
424
 CHK_POTI(FCParam.AchsGegenKopplung1,ParamSet.AchsGegenKopplung1,0,255);
Line 406... Line 425...
406
 Ki = (float) Parameter_I_Factor * 0.0001;
425
 CHK_POTI(FCParam.DynamicStability,ParamSet.DynamicStability,0,255);
407
 MAX_GAS = ParamSet.Gas_Max;
426
 
Line 481... Line 500...
481
                }
500
                }
482
            if((modell_fliegt < 200) || (GasMixingFraction < 40))
501
            if((modell_fliegt < 200) || (GasMixingFraction < 40))
483
                {
502
                {
484
                SumPitch = 0;
503
                SumPitch = 0;
485
                SumRoll = 0;
504
                SumRoll = 0;
486
                Reading_Integral_Yaw = 0;
505
                Reading_IntegralYaw = 0;
487
                Reading_Integral_Yaw2 = 0;
506
                Reading_IntegralYaw2 = 0;
488
                }
507
                }
489
            if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && MotorsOn == 0)
508
            if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && MotorsOn == 0)
490
                {
509
                {
491
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
510
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
492
// auf Nullwerte kalibrieren
511
// auf Nullwerte kalibrieren
Line 513... Line 532...
513
                          {
532
                          {
514
                             if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset();
533
                             if((ReadingAirPressure > 950) || (ReadingAirPressure < 750)) SearchAirPressureOffset();
515
                          }
534
                          }
516
                            ParamSet_ReadFromEEProm(GetActiveParamSet());
535
                            ParamSet_ReadFromEEProm(GetActiveParamSet());
517
                        SetNeutral();
536
                        SetNeutral();
518
                        Piep(GetActiveParamSet());
537
                        Beep(GetActiveParamSet());
519
                        }
538
                        }
520
                    }
539
                    }
521
                 else
540
                 else
522
                if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] < -75)  // ACC Neutralwerte speichern
541
                if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] < -75)  // ACC Neutralwerte speichern
523
                    {
542
                    {
524
                    if(++delay_neutral > 200)  // nicht sofort
543
                    if(++delay_neutral > 200)  // nicht sofort
525
                        {
544
                        {
526
                        GRN_OFF;
545
                        GRN_OFF;
527
                        SetParamByte(PID_ACC_PITCH,0xFF); // Werte löschen
546
                        SetParamWord(PID_ACC_PITCH,0xFFFF); // Werte löschen
528
                        MotorsOn = 0;
547
                        MotorsOn = 0;
529
                        delay_neutral = 0;
548
                        delay_neutral = 0;
530
                        modell_fliegt = 0;
549
                        modell_fliegt = 0;
531
                        SetNeutral();
550
                        SetNeutral();
532
                        SetParamByte(PID_ACC_PITCH, NeutralAccX / 256); // ACC-NeutralWerte speichern
-
 
533
                        SetParamByte(PID_ACC_PITCH+1,NeutralAccX % 256); // ACC-NeutralWerte speichern
-
 
534
                        SetParamByte(PID_ACC_ROLL,NeutralAccY / 256);
551
                        // ACC-NeutralWerte speichern
535
                        SetParamByte(PID_ACC_ROLL+1,NeutralAccY % 256);
552
                        SetParamWord(PID_ACC_PITCH, (uint16_t)NeutralAccX);
536
                        SetParamByte(PID_ACC_Z,(int)NeutralAccZ / 256);
553
                        SetParamWord(PID_ACC_ROLL,  (uint16_t)NeutralAccY);
537
                        SetParamByte(PID_ACC_Z+1,(int)NeutralAccZ % 256);
554
                        SetParamWord(PID_ACC_Z,     (uint16_t)NeutralAccZ);
538
                        Piep(GetActiveParamSet());
555
                        Beep(GetActiveParamSet());
539
                        }
556
                        }
540
                    }
557
                    }
541
                 else delay_neutral = 0;
558
                 else delay_neutral = 0;
542
                }
559
                }
543
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
560
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 555... Line 572...
555
                        {
572
                        {
556
                        delay_einschalten = 200;
573
                        delay_einschalten = 200;
557
                        modell_fliegt = 1;
574
                        modell_fliegt = 1;
558
                        MotorsOn = 1;
575
                        MotorsOn = 1;
559
                        SetPointYaw = 0;
576
                        SetPointYaw = 0;
560
                        Reading_Integral_Yaw = 0;
577
                        Reading_IntegralYaw = 0;
561
                        Reading_Integral_Yaw2 = 0;
578
                        Reading_IntegralYaw2 = 0;
562
                        Reading_IntegralPitch = 0;
579
                        Reading_IntegralPitch = 0;
563
                        Reading_IntegralRoll = 0;
580
                        Reading_IntegralRoll = 0;
564
                        Reading_IntegralPitch2 = IntegralPitch;
581
                        Reading_IntegralPitch2 = IntegralPitch;
565
                        Reading_IntegralRoll2 = IntegralRoll;
582
                        Reading_IntegralRoll2 = IntegralRoll;
566
                        SumPitch = 0;
583
                        SumPitch = 0;
Line 589... Line 606...
589
// neue Werte von der Funke
606
// neue Werte von der Funke
590
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
607
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
591
 if(!NewPpmData-- || EmergencyLanding)
608
 if(!NewPpmData-- || EmergencyLanding)
592
  {
609
  {
593
    int tmp_int;
610
    int tmp_int;
594
    ParameterZuordnung();
611
    ParameterMapping();
595
    StickPitch = (StickPitch * 3 + PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_P) / 4;
612
    StickPitch = (StickPitch * 3 + PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_P) / 4;
596
    StickPitch += PPM_diff[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_D;
613
    StickPitch += PPM_diff[ParamSet.ChannelAssignment[CH_PITCH]] * ParamSet.Stick_D;
597
    StickRoll = (StickRoll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_P) / 4;
614
    StickRoll = (StickRoll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_P) / 4;
598
    StickRoll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_D;
615
    StickRoll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_D;
Line 604... Line 621...
604
     MaxStickPitch = abs(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]]); else MaxStickPitch--;
621
     MaxStickPitch = abs(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]]); else MaxStickPitch--;
605
   if(abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > MaxStickRoll)
622
   if(abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]) > MaxStickRoll)
606
     MaxStickRoll = abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]); else MaxStickRoll--;
623
     MaxStickRoll = abs(PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]); else MaxStickRoll--;
607
   if(EmergencyLanding)  {MaxStickPitch = 0; MaxStickRoll = 0;}
624
   if(EmergencyLanding)  {MaxStickPitch = 0; MaxStickRoll = 0;}
Line 608... Line 625...
608
 
625
 
609
    GyroFactor     = ((float)Parameter_Gyro_P + 10.0) / 256.0;
626
    GyroFactor     = ((float)FCParam.Gyro_P + 10.0) / 256.0;
Line 610... Line 627...
610
    IntegralFactor = ((float) Parameter_Gyro_I) / 44000;
627
    IntegralFactor = ((float) FCParam.Gyro_I) / 44000;
611
 
628
 
612
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
629
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
613
//+ Digitale Steuerung per DubWise
630
//+ Digitale Steuerung per DubWise
614
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
631
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
615
#define KEY_VALUE (Parameter_UserParam1 * 4)  //(Poti3 * 8)
632
#define KEY_VALUE (FCParam.UserParam1 * 4)  //(Poti3 * 8)
616
if(DubWiseKeys[1]) BeepTime = 10;
633
if(DubWiseKeys[1]) BeepTime = 10;
617
    if(DubWiseKeys[1] & DUB_KEY_UP)    tmp_int = KEY_VALUE;   else
634
    if(DubWiseKeys[1] & DUB_KEY_UP)    tmp_int = KEY_VALUE;   else
618
    if(DubWiseKeys[1] & DUB_KEY_DOWN)  tmp_int = -KEY_VALUE;  else   tmp_int = 0;
635
    if(DubWiseKeys[1] & DUB_KEY_DOWN)  tmp_int = -KEY_VALUE;  else   tmp_int = 0;
Line 630... Line 647...
630
    StickRoll += ExternStickRoll / 8;
647
    StickRoll += ExternStickRoll / 8;
631
    StickYaw += ExternStickYaw;
648
    StickYaw += ExternStickYaw;
632
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
649
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
633
//+ Analoge Steuerung per Seriell
650
//+ Analoge Steuerung per Seriell
634
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
651
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
635
   if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128)
652
   if(ExternControl.Config & 0x01 && FCParam.UserParam1 > 128)
636
    {
653
    {
637
         StickPitch += (int) ExternControl.Pitch * (int) ParamSet.Stick_P;
654
         StickPitch += (int) ExternControl.Pitch * (int) ParamSet.Stick_P;
638
         StickRoll += (int) ExternControl.Roll * (int) ParamSet.Stick_P;
655
         StickRoll += (int) ExternControl.Roll * (int) ParamSet.Stick_P;
639
         StickYaw += ExternControl.Yaw;
656
         StickYaw += ExternControl.Yaw;
640
     ExternHightValue =  (int) ExternControl.Hight * (int)ParamSet.Hight_Gain;
657
     ExternHightValue =  (int) ExternControl.Hight * (int)ParamSet.Hight_Gain;
Line 922... Line 939...
922
      if(!(ParamSet.GlobalConfig & CFG_COMPASS_FIX)) StoreNewCompassCourse = 1;
939
      if(!(ParamSet.GlobalConfig & CFG_COMPASS_FIX)) StoreNewCompassCourse = 1;
923
     }
940
     }
924
    tmp_int  = (long) ParamSet.Yaw_P * ((long)StickYaw * abs(StickYaw)) / 512L; // expo  y = ax + bx²
941
    tmp_int  = (long) ParamSet.Yaw_P * ((long)StickYaw * abs(StickYaw)) / 512L; // expo  y = ax + bx²
925
    tmp_int += (ParamSet.Yaw_P * StickYaw) / 4;
942
    tmp_int += (ParamSet.Yaw_P * StickYaw) / 4;
926
    SetPointYaw = tmp_int;
943
    SetPointYaw = tmp_int;
927
    Reading_Integral_Yaw -= tmp_int;
944
    Reading_IntegralYaw -= tmp_int;
928
    if(Reading_Integral_Yaw > 50000) Reading_Integral_Yaw = 50000;  // begrenzen
945
    if(Reading_IntegralYaw > 50000) Reading_IntegralYaw = 50000;  // begrenzen
929
    if(Reading_Integral_Yaw <-50000) Reading_Integral_Yaw =-50000;
946
    if(Reading_IntegralYaw <-50000) Reading_IntegralYaw =-50000;
Line 930... Line 947...
930
 
947
 
931
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
948
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
932
//  Kompass
949
//  Kompass
933
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
950
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 949... Line 966...
949
        if(w < 35 && StoreNewCompassCourse)
966
        if(w < 35 && StoreNewCompassCourse)
950
         {
967
         {
951
          CompassCourse = CompassHeading;
968
          CompassCourse = CompassHeading;
952
          StoreNewCompassCourse = 0;
969
          StoreNewCompassCourse = 0;
953
         }
970
         }
954
        w = (w * Parameter_CompassYawEffect) / 64;           // auf die Wirkung normieren
971
        w = (w * FCParam.CompassYawEffect) / 64;           // auf die Wirkung normieren
955
        w = Parameter_CompassYawEffect - w;                  // Wirkung ggf drosseln
972
        w = FCParam.CompassYawEffect - w;                  // Wirkung ggf drosseln
956
        if(w > 0)
973
        if(w > 0)
957
        {
974
        {
958
                        Reading_Integral_Yaw -= (CompassOffCourse * w) / 32;  // nach Kompass ausrichten
975
                        Reading_IntegralYaw -= (CompassOffCourse * w) / 32;  // nach Kompass ausrichten
959
           }
976
           }
960
     }
977
     }
961
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
978
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 962... Line 979...
962
 
979
 
Line 990... Line 1007...
990
    DebugOut.Analog[24] = motor_rx[7];
1007
    DebugOut.Analog[24] = motor_rx[7];
991
    DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1008
    DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
992
*/
1009
*/
993
//    DebugOut.Analog[9] = ReadingPitch;
1010
//    DebugOut.Analog[9] = ReadingPitch;
994
//    DebugOut.Analog[9] = SetPointHight;
1011
//    DebugOut.Analog[9] = SetPointHight;
995
//    DebugOut.Analog[10] = Reading_Integral_Yaw / 128;
1012
//    DebugOut.Analog[10] = Reading_IntegralYaw / 128;
996
//    DebugOut.Analog[11] = CompassCourse;
1013
//    DebugOut.Analog[11] = CompassCourse;
997
//    DebugOut.Analog[10] = Parameter_Gyro_I;
1014
//    DebugOut.Analog[10] = FCParam.Gyro_I;
998
//    DebugOut.Analog[10] = ParamSet.Gyro_I;
1015
//    DebugOut.Analog[10] = ParamSet.Gyro_I;
999
//    DebugOut.Analog[9] = CompassOffCourse;
1016
//    DebugOut.Analog[9] = CompassOffCourse;
1000
//    DebugOut.Analog[10] = GasMixingFraction;
1017
//    DebugOut.Analog[10] = GasMixingFraction;
1001
//    DebugOut.Analog[3] = HoeheD * 32;
1018
//    DebugOut.Analog[3] = HightD * 32;
1002
//    DebugOut.Analog[4] = hoehenregler;
1019
//    DebugOut.Analog[4] = hoehenregler;
1003
  }
1020
  }
Line 1004... Line 1021...
1004
 
1021
 
1005
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1022
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 1010... Line 1027...
1010
 
1027
 
1011
    if(Looping_Pitch) ReadingPitch = ReadingPitch * GyroFactor;
1028
    if(Looping_Pitch) ReadingPitch = ReadingPitch * GyroFactor;
1012
    else             ReadingPitch = IntegralPitch * IntegralFactor + ReadingPitch * GyroFactor;
1029
    else             ReadingPitch = IntegralPitch * IntegralFactor + ReadingPitch * GyroFactor;
1013
    if(Looping_Roll) ReadingRoll = ReadingRoll * GyroFactor;
1030
    if(Looping_Roll) ReadingRoll = ReadingRoll * GyroFactor;
1014
    else             ReadingRoll = IntegralRoll * IntegralFactor + ReadingRoll * GyroFactor;
1031
    else             ReadingRoll = IntegralRoll * IntegralFactor + ReadingRoll * GyroFactor;
Line 1015... Line 1032...
1015
    ReadingYaw = ReadingYaw * (2 * GyroFactor) + Integral_Yaw * IntegralFactor / 2;
1032
    ReadingYaw = ReadingYaw * (2 * GyroFactor) + IntegralYaw * IntegralFactor / 2;
1016
 
1033
 
1017
DebugOut.Analog[25] = IntegralRoll * IntegralFactor;
1034
DebugOut.Analog[25] = IntegralRoll * IntegralFactor;
Line 1036... Line 1053...
1036
 if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL))  // Höhenregelung
1053
 if((ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL))  // Höhenregelung
1037
  {
1054
  {
1038
    int tmp_int;
1055
    int tmp_int;
1039
    if(ParamSet.GlobalConfig & CFG_HEIGHT_SWITCH)  // Regler wird über Schalter gesteuert
1056
    if(ParamSet.GlobalConfig & CFG_HEIGHT_SWITCH)  // Regler wird über Schalter gesteuert
1040
    {
1057
    {
1041
     if(Parameter_MaxHoehe < 50)
1058
     if(FCParam.MaxHight < 50)
1042
      {
1059
      {
1043
       SetPointHight = ReadingHight - 20;  // Parameter_MaxHoehe ist der PPM-Wert des Schalters
1060
       SetPointHight = ReadingHight - 20;  // FCParam.MaxHight ist der PPM-Wert des Schalters
1044
       HightControlActive = 0;
1061
       HightControlActive = 0;
1045
      }
1062
      }
1046
      else
1063
      else
1047
        HightControlActive = 1;
1064
        HightControlActive = 1;
1048
    }
1065
    }
1049
    else
1066
    else
1050
    {
1067
    {
1051
     SetPointHight = ((int) ExternHightValue + (int) Parameter_MaxHoehe) * (int)ParamSet.Hight_Gain - 20;
1068
     SetPointHight = ((int) ExternHightValue + (int) FCParam.MaxHight) * (int)ParamSet.Hight_Gain - 20;
1052
     HightControlActive = 1;
1069
     HightControlActive = 1;
1053
    }
1070
    }
Line 1054... Line 1071...
1054
 
1071
 
1055
    if(EmergencyLanding) SetPointHight = 0;
1072
    if(EmergencyLanding) SetPointHight = 0;
1056
    h = ReadingHight;
1073
    h = ReadingHight;
1057
    if((h > SetPointHight) && HightControlActive)      // zu hoch --> drosseln
1074
    if((h > SetPointHight) && HightControlActive)      // zu hoch --> drosseln
1058
     {      h = ((h - SetPointHight) * (int) Parameter_Hoehe_P) / 16; // Differenz bestimmen --> P-Anteil
1075
     {      h = ((h - SetPointHight) * (int) FCParam.Hight_P) / 16; // Differenz bestimmen --> P-Anteil
1059
      h = GasMixingFraction - h;         // vom Gas abziehen
1076
      h = GasMixingFraction - h;         // vom Gas abziehen
1060
      h -= (HoeheD * Parameter_Luftdruck_D)/8;    // D-Anteil
1077
      h -= (HightD * FCParam.AirPressure_D)/8;    // D-Anteil
1061
      tmp_int = ((Reading_Integral_Top / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / 32;
1078
      tmp_int = ((Reading_Integral_Top / 512) * (signed long) FCParam.Hight_ACC_Effect) / 32;
1062
      if(tmp_int > 50) tmp_int = 50;
1079
      if(tmp_int > 50) tmp_int = 50;
1063
      else if(tmp_int < -50) tmp_int = -50;
1080
      else if(tmp_int < -50) tmp_int = -50;
1064
      h -= tmp_int;
1081
      h -= tmp_int;
1065
      hoehenregler = (hoehenregler*15 + h) / 16;
1082
      hoehenregler = (hoehenregler*15 + h) / 16;
Line 1070... Line 1087...
1070
       }
1087
       }
1071
      if(hoehenregler > GasMixingFraction) hoehenregler = GasMixingFraction; // nicht mehr als Gas
1088
      if(hoehenregler > GasMixingFraction) hoehenregler = GasMixingFraction; // nicht mehr als Gas
1072
      GasMixingFraction = hoehenregler;
1089
      GasMixingFraction = hoehenregler;
1073
     }
1090
     }
1074
  }
1091
  }
1075
  if(GasMixingFraction > MAX_GAS - 20) GasMixingFraction = MAX_GAS - 20;
1092
  if(GasMixingFraction > ParamSet.Gas_Max - 20) GasMixingFraction = ParamSet.Gas_Max - 20;
1076
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1093
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1077
// + Mischer und PI-Regler
1094
// + Mischer und PI-Regler
1078
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1095
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1079
  DebugOut.Analog[7] = GasMixingFraction;
1096
  DebugOut.Analog[7] = GasMixingFraction;
1080
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1097
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 1084... Line 1101...
1084
    YawMixingFraction = ReadingYaw - SetPointYaw;     // Regler für Gier
1101
    YawMixingFraction = ReadingYaw - SetPointYaw;     // Regler für Gier
1085
// YawMixingFraction = 0;
1102
// YawMixingFraction = 0;
Line 1086... Line 1103...
1086
 
1103
 
1087
    if(YawMixingFraction > (GasMixingFraction / 2)) YawMixingFraction = GasMixingFraction / 2;
1104
    if(YawMixingFraction > (GasMixingFraction / 2)) YawMixingFraction = GasMixingFraction / 2;
1088
    if(YawMixingFraction < -(GasMixingFraction / 2)) YawMixingFraction = -(GasMixingFraction / 2);
1105
    if(YawMixingFraction < -(GasMixingFraction / 2)) YawMixingFraction = -(GasMixingFraction / 2);
1089
    if(YawMixingFraction > ((MAX_GAS - GasMixingFraction))) YawMixingFraction = ((MAX_GAS - GasMixingFraction));
1106
    if(YawMixingFraction > ((ParamSet.Gas_Max - GasMixingFraction))) YawMixingFraction = ((ParamSet.Gas_Max - GasMixingFraction));
Line 1090... Line 1107...
1090
    if(YawMixingFraction < -((MAX_GAS - GasMixingFraction))) YawMixingFraction = -((MAX_GAS - GasMixingFraction));
1107
    if(YawMixingFraction < -((ParamSet.Gas_Max - GasMixingFraction))) YawMixingFraction = -((ParamSet.Gas_Max - GasMixingFraction));
1091
 
1108
 
1092
    if(GasMixingFraction < 20) YawMixingFraction = 0;
1109
    if(GasMixingFraction < 20) YawMixingFraction = 0;
1093
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1110
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Line 1098... Line 1115...
1098
    else  SumPitch += DiffPitch; // I-Anteil bei HH
1115
    else  SumPitch += DiffPitch; // I-Anteil bei HH
1099
    if(SumPitch >  16000) SumPitch =  16000;
1116
    if(SumPitch >  16000) SumPitch =  16000;
1100
    if(SumPitch < -16000) SumPitch = -16000;
1117
    if(SumPitch < -16000) SumPitch = -16000;
1101
    pd_ergebnis = DiffPitch + Ki * SumPitch; // PI-Regler für Pitch
1118
    pd_ergebnis = DiffPitch + Ki * SumPitch; // PI-Regler für Pitch
1102
    // Motor Vorn
1119
    // Motor Vorn
1103
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
1120
    tmp_int = (long)((long)FCParam.DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
1104
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1121
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1105
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1122
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
Line 1106... Line 1123...
1106
 
1123
 
1107
    MotorValue = GasMixingFraction + pd_ergebnis + YawMixingFraction;     // Mischer
1124
    MotorValue = GasMixingFraction + pd_ergebnis + YawMixingFraction;     // Mischer
1108
        if ((MotorValue < 0)) MotorValue = 0;
1125
        if ((MotorValue < 0)) MotorValue = 0;
1109
        else if(MotorValue > MAX_GAS)       MotorValue = MAX_GAS;
1126
        else if(MotorValue > ParamSet.Gas_Max)              MotorValue = ParamSet.Gas_Max;
1110
        if (MotorValue < MIN_GAS)            MotorValue = MIN_GAS;
1127
        if (MotorValue < ParamSet.Gas_Min)            MotorValue = ParamSet.Gas_Min;
1111
        Motor_Front = MotorValue;
1128
        Motor_Front = MotorValue;
1112
    // Motor Heck
1129
    // Motor Heck
1113
        MotorValue = GasMixingFraction - pd_ergebnis + YawMixingFraction;
1130
        MotorValue = GasMixingFraction - pd_ergebnis + YawMixingFraction;
1114
        if ((MotorValue < 0)) MotorValue = 0;
1131
        if ((MotorValue < 0)) MotorValue = 0;
1115
        else if(MotorValue > MAX_GAS)       MotorValue = MAX_GAS;
1132
        else if(MotorValue > ParamSet.Gas_Max)      MotorValue = ParamSet.Gas_Max;
1116
        if (MotorValue < MIN_GAS)            MotorValue = MIN_GAS;
1133
        if (MotorValue < ParamSet.Gas_Min)            MotorValue = ParamSet.Gas_Min;
1117
        Motor_Rear = MotorValue;
1134
        Motor_Rear = MotorValue;
1118
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1135
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1119
// Roll-Achse
1136
// Roll-Achse
1120
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1137
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1121
        DiffRoll = ReadingRoll - (StickRoll  - GPS_Roll);       // Differenz bestimmen
1138
        DiffRoll = ReadingRoll - (StickRoll  - GPS_Roll);       // Differenz bestimmen
1122
    if(IntegralFactor) SumRoll += IntegralRoll * IntegralFactor - (StickRoll  - GPS_Roll);// I-Anteil bei Winkelregelung
1139
    if(IntegralFactor) SumRoll += IntegralRoll * IntegralFactor - (StickRoll  - GPS_Roll);// I-Anteil bei Winkelregelung
1123
    else                 SumRoll += DiffRoll;  // I-Anteil bei HH
1140
    else                 SumRoll += DiffRoll;  // I-Anteil bei HH
1124
    if(SumRoll >  16000) SumRoll =  16000;
1141
    if(SumRoll >  16000) SumRoll =  16000;
1125
    if(SumRoll < -16000) SumRoll = -16000;
1142
    if(SumRoll < -16000) SumRoll = -16000;
1126
    pd_ergebnis = DiffRoll + Ki * SumRoll;      // PI-Regler für Roll
1143
    pd_ergebnis = DiffRoll + Ki * SumRoll;      // PI-Regler für Roll
1127
    tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
1144
    tmp_int = (long)((long)FCParam.DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
1128
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1145
    if(pd_ergebnis >  tmp_int) pd_ergebnis =  tmp_int;
1129
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1146
    if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
1130
    // Motor Links
1147
    // Motor Links
1131
    MotorValue = GasMixingFraction + pd_ergebnis - YawMixingFraction;
1148
    MotorValue = GasMixingFraction + pd_ergebnis - YawMixingFraction;
Line 1132... Line 1149...
1132
#define GRENZE Poti1
1149
#define GRENZE Poti1
1133
 
1150
 
1134
        if ((MotorValue < 0)) MotorValue = 0;
1151
        if ((MotorValue < 0)) MotorValue = 0;
1135
        else if(MotorValue > MAX_GAS)           MotorValue = MAX_GAS;
1152
        else if(MotorValue > ParamSet.Gas_Max)          MotorValue = ParamSet.Gas_Max;
1136
        if (MotorValue < MIN_GAS)            MotorValue = MIN_GAS;
1153
        if (MotorValue < ParamSet.Gas_Min)            MotorValue = ParamSet.Gas_Min;
1137
    Motor_Left = MotorValue;
1154
    Motor_Left = MotorValue;
Line 1138... Line 1155...
1138
    // Motor Rechts
1155
    // Motor Rechts
1139
        MotorValue = GasMixingFraction - pd_ergebnis - YawMixingFraction;
1156
        MotorValue = GasMixingFraction - pd_ergebnis - YawMixingFraction;
1140
 
1157
 
1141
        if ((MotorValue < 0)) MotorValue = 0;
1158
        if ((MotorValue < 0)) MotorValue = 0;
1142
        else if(MotorValue > MAX_GAS)           MotorValue = MAX_GAS;
1159
        else if(MotorValue > ParamSet.Gas_Max)          MotorValue = ParamSet.Gas_Max;
1143
        if (MotorValue < MIN_GAS)            MotorValue = MIN_GAS;
1160
        if (MotorValue < ParamSet.Gas_Min)            MotorValue = ParamSet.Gas_Min;