Subversion Repositories FlightCtrl

Rev

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

Rev 1634 Rev 1645
Line 54... Line 54...
54
#include <avr/io.h>
54
#include <avr/io.h>
55
#include "eeprom.h"
55
#include "eeprom.h"
56
#include "flight.h"
56
#include "flight.h"
Line 57... Line 57...
57
 
57
 
58
// Only for debug. Remove.
58
// Only for debug. Remove.
59
#include "analog.h"
59
//#include "analog.h"
Line 60... Line 60...
60
#include "rc.h"
60
//#include "rc.h"
61
 
61
 
62
// Necessary for external control and motor test
62
// Necessary for external control and motor test
63
#include "uart0.h"
63
#include "uart0.h"
Line 72... Line 72...
72
 
72
 
73
/*
73
/*
74
 * These are no longer maintained, just left at 0. The original implementation just summed the acc.
74
 * These are no longer maintained, just left at 0. The original implementation just summed the acc.
75
 * value to them every 2 ms. No filtering or anything. Just a case for an eventual overflow?? Hey???
75
 * value to them every 2 ms. No filtering or anything. Just a case for an eventual overflow?? Hey???
76
 */
76
 */
Line 77... Line 77...
77
int16_t naviAccPitch = 0, naviAccRoll = 0, naviCntAcc = 0;
77
// int16_t naviAccPitch = 0, naviAccRoll = 0, naviCntAcc = 0;
78
 
78
 
79
// MK flags
79
// MK flags
Line 126... Line 126...
126
  dynamicParams.KalmanK = -1;
126
  dynamicParams.KalmanK = -1;
127
  dynamicParams.KalmanMaxDrift = 0;
127
  dynamicParams.KalmanMaxDrift = 0;
128
  dynamicParams.KalmanMaxFusion = 32;
128
  dynamicParams.KalmanMaxFusion = 32;
Line 129... Line 129...
129
 
129
 
130
  controlMixer_initVariables();
-
 
131
 
-
 
132
  // TODO: Move off.
-
 
133
  // RC_Quality = 100;
130
  controlMixer_initVariables();
Line 134... Line 131...
134
}
131
}
135
 
132
 
136
/************************************************************************/
133
/************************************************************************/
Line 148... Line 145...
148
    }
145
    }
149
    if(motorTestActive) motorTestActive--;
146
    if(motorTestActive) motorTestActive--;
150
  }
147
  }
Line 151... Line 148...
151
 
148
 
152
  /*
149
  /*
153
  DebugOut.Analog[12] = Motor[0].SetPoint; // Front
150
  DebugOut.Analog[] = Motor[0].SetPoint; // Front
154
  DebugOut.Analog[13] = Motor[1].SetPoint; // Rear
151
  DebugOut.Analog[] = Motor[1].SetPoint; // Rear
155
  DebugOut.Analog[14] = Motor[3].SetPoint; // Left
152
  DebugOut.Analog[] = Motor[3].SetPoint; // Left
156
  DebugOut.Analog[15] = Motor[2].SetPoint; // Right
153
  DebugOut.Analog[] = Motor[2].SetPoint; // Right
157
  */
154
  */
158
  // Start I2C Interrupt Mode
155
  // Start I2C Interrupt Mode
159
  I2C_Start(TWI_STATE_MOTOR_TX);
156
  I2C_Start(TWI_STATE_MOTOR_TX);
Line 246... Line 243...
246
/*  Main Flight Control                                                 */
243
/*  Main Flight Control                                                 */
247
/************************************************************************/
244
/************************************************************************/
248
void flight_control(void) {
245
void flight_control(void) {
249
  int16_t tmp_int;
246
  int16_t tmp_int;
250
    // Mixer Fractions that are combined for Motor Control
247
    // Mixer Fractions that are combined for Motor Control
251
  int16_t yawTerm, throttleTerm, pitchTerm, rollTerm;
248
  int16_t yawTerm, throttleTerm, term[2];
Line 252... Line 249...
252
 
249
 
253
  // PID controller variables
250
  // PID controller variables
254
  int16_t PDPartPitch, PDPartRoll, PDPartYaw, PPartPitch, PPartRoll;
251
  int16_t PDPart[2], PDPartYaw, PPart[2];
255
  static int32_t IPartPitch = 0, IPartRoll = 0;
-
 
256
 
252
  static int32_t IPart[2] = {0,0};
Line 257... Line 253...
257
  static int32_t setPointYaw = 0;
253
  static int32_t setPointYaw = 0;
258
 
254
 
259
  // Removed. Too complicated, and apparently not necessary with MEMS gyros anyway.
255
  // Removed. Too complicated, and apparently not necessary with MEMS gyros anyway.
Line 260... Line 256...
260
  // static int32_t IntegralGyroPitchError = 0, IntegralGyroRollError = 0;
256
  // static int32_t IntegralGyroPitchError = 0, IntegralGyroRollError = 0;
261
  // static int32_t CorrectionPitch, CorrectionRoll;
-
 
262
 
-
 
263
  static uint16_t emergencyFlightTime;
-
 
264
 
-
 
265
  // No support for altitude control right now.
-
 
266
  // static uint8_t HeightControlActive = 0;
257
  // static int32_t CorrectionPitch, CorrectionRoll;
Line 267... Line 258...
267
  // static int16_t HeightControlGas = 0;
258
 
268
 
259
  static uint16_t emergencyFlightTime;
Line 269... Line 260...
269
  static int8_t debugDataTimer = 1;
260
  static int8_t debugDataTimer = 1;
Line 270... Line 261...
270
 
261
 
271
  // High resolution motor values for smoothing of PID motor outputs
262
  // High resolution motor values for smoothing of PID motor outputs
272
  static int16_t motorFilters[MAX_MOTORS];
263
  static int16_t motorFilters[MAX_MOTORS];
Line 326... Line 317...
326
    } else
317
    } else
327
      /*
318
      /*
328
       * When standing on the ground, do not apply I controls and zero the yaw stick.
319
       * When standing on the ground, do not apply I controls and zero the yaw stick.
329
       * Probably to avoid integration effects that will cause the copter to spin
320
       * Probably to avoid integration effects that will cause the copter to spin
330
       * or flip when taking off.
321
       * or flip when taking off.
331
       * TODO: What was the value of IPartPitch? At 1st run of this, it's 0 already.
-
 
332
       */
322
       */
333
      if(isFlying < 256) {
323
      if(isFlying < 256) {
334
        IPartPitch = 0;
324
            IPart[PITCH] = IPart[ROLL] = 0;
335
        IPartRoll = 0;
-
 
336
        // TODO: Don't stomp on other modules' variables!!!
325
            // TODO: Don't stomp on other modules' variables!!!
337
        controlYaw = 0;
326
            controlYaw = 0;
338
        if(isFlying == 250) {
327
            if(isFlying == 250) {
339
          updateCompassCourse = 1;
328
              updateCompassCourse = 1;
340
          yawAngle = 0;
329
              yawAngle = 0;
341
          setPointYaw = 0;
330
              setPointYaw = 0;
342
        }
331
        }
343
      } else {
332
      } else {
344
        // DebugOut.Digital[1] = 0;
333
            // DebugOut.Digital[1] = 0;
345
        // Set fly flag. TODO: Hmmm what can we trust - the isFlying counter or the flag? 
334
            // Set fly flag. TODO: Hmmm what can we trust - the isFlying counter or the flag? 
346
        // Answer: The counter. The flag is not read from anywhere anyway... except the NC maybe.
335
            // Answer: The counter. The flag is not read from anywhere anyway... except the NC maybe.
347
        MKFlags |= (MKFLAG_FLY);
336
            MKFlags |= (MKFLAG_FLY);
348
      }
337
      }
Line 349... Line 338...
349
   
338
   
350
    /*
339
    /*
351
     * Get the current command (start/stop motors, calibrate), if any.
340
     * Get the current command (start/stop motors, calibrate), if any.
Line 397... Line 386...
397
      updateCompass();
386
      updateCompass();
398
      }
387
      }
399
    */
388
    */
Line 400... Line 389...
400
 
389
 
401
#if defined (USE_MK3MAG)
-
 
402
      // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
403
 
-
 
404
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
390
#if defined (USE_MK3MAG)
405
    /************************************************************************/
391
    /************************************************************************/
406
    /* GPS is currently not supported.                                      */
392
    /* GPS is currently not supported.                                      */
407
    /************************************************************************/
393
    /************************************************************************/
408
    /*
394
    /*
Line 414... Line 400...
414
      // GPSStickPitch = 0;
400
      // GPSStickPitch = 0;
415
      // GPSStickRoll = 0;
401
      // GPSStickRoll = 0;
416
      }
402
      }
417
    */
403
    */
418
#endif
404
#endif
-
 
405
 
-
 
406
#define SENSOR_LIMIT  (4096 * 4)
Line 419... Line 407...
419
   
407
   
420
    /************************************************************************/
408
    /************************************************************************/
421
    /* Calculate control feedback from angle (gyro integral)                */
409
    /* Calculate control feedback from angle (gyro integral)                */
422
    /* and angular velocity (gyro signal)                                   */
410
    /* and angular velocity (gyro signal)                                   */
423
    /************************************************************************/
411
    /************************************************************************/
-
 
412
    // The P-part is the P of the PID controller. That's the angle integrals (not rates).
424
    // The P-part is the P of the PID controller. That's the angle integrals (not rates).
413
  for (axis=PITCH; axis<=ROLL; axis++) {
425
  if(looping & LOOPING_PITCH_AXIS) {
414
    if(looping & (1<<(4+axis))) {
426
    PPartPitch = 0;
415
      PPart[axis] = 0;
427
  } else { // TODO: Where do the 44000 come from???
416
    } else { // TODO: Where do the 44000 come from???
428
    PPartPitch = pitchAngle * gyroIFactor / (44000 / STICK_GAIN); // P-Part - Proportional to Integral
417
      PPart[axis] = angle[axis] * gyroIFactor / (44000 / CONTROL_SCALING); // P-Part - Proportional to Integral
429
  }
418
    }
-
 
419
 
430
 
420
    /*
-
 
421
     * Now blend in the D-part - proportional to the Differential of the integral = the rate.
-
 
422
     * Read this as: PDPart = PPart + rate_PID * pfactor * CONTROL_SCALING
-
 
423
     * where pfactor is in [0..1].
431
  // Now blend in the D-part - proportional to the Differential of the integral = the rate.
424
     */
432
  PDPartPitch = PPartPitch + (int32_t)((int32_t)pitchRate_PID * gyroPFactor / (256L / STICK_GAIN))
425
    PDPart[axis] = PPart[axis] + (int32_t)((int32_t)rate_PID[axis] * gyroPFactor / (256L / CONTROL_SCALING))
433
    + (pitchDifferential * (int16_t)dynamicParams.GyroD) / 16;
426
      + (differential[axis] * (int16_t)dynamicParams.GyroD) / 16;
434
 
-
 
435
  // The P-part is actually the I-part...
-
 
436
  if(looping & LOOPING_ROLL_AXIS) {
-
 
437
    PPartRoll = 0;
427
 
438
  } else { // TODO: Where do the 44000 come from???
-
 
439
    PPartRoll = (rollAngle * gyroIFactor) / (44000 / STICK_GAIN); // P-Part - Proportional to Integral
428
    CHECK_MIN_MAX(PDPart[axis], -SENSOR_LIMIT, SENSOR_LIMIT);
Line 440... Line -...
440
  }
-
 
441
 
-
 
442
  // Now blend in the P-part - proportional to the Differential of the integral = the rate
-
 
443
  PDPartRoll = PPartRoll + (int32_t)((int32_t)rollRate_PID * gyroPFactor / (256L / STICK_GAIN))
-
 
444
    + (rollDifferential * (int16_t)dynamicParams.GyroD) / 16;
429
  }
445
 
430
 
Line 446... Line 431...
446
  PDPartYaw =  (int32_t)(yawRate * 2 * (int32_t)yawPFactor) / (256L / STICK_GAIN)
431
  PDPartYaw = (int32_t)(yawRate * 2 * (int32_t)yawPFactor) / (256L / CONTROL_SCALING)
447
    + (int32_t)(yawAngle * yawIFactor) / (2 * (44000 / STICK_GAIN));
-
 
448
 
-
 
449
  // limit control feedback
-
 
450
#define SENSOR_LIMIT  (4096 * 4)
432
    + (int32_t)(yawAngle * yawIFactor) / (2 * (44000 / CONTROL_SCALING));
Line 451... Line 433...
451
  CHECK_MIN_MAX(PDPartPitch, -SENSOR_LIMIT, SENSOR_LIMIT);
433
 
452
  CHECK_MIN_MAX(PDPartRoll, -SENSOR_LIMIT, SENSOR_LIMIT);
434
  // limit control feedback
453
  CHECK_MIN_MAX(PDPartYaw,  -SENSOR_LIMIT, SENSOR_LIMIT);
435
  CHECK_MIN_MAX(PDPartYaw,  -SENSOR_LIMIT, SENSOR_LIMIT);
Line 465... Line 447...
465
 
447
 
466
  /*
448
  /*
467
   * Height control was here.
449
   * Height control was here.
468
   */
450
   */
469
  if(throttleTerm > staticParams.MaxThrottle - 20) throttleTerm = (staticParams.MaxThrottle - 20);
451
  if(throttleTerm > staticParams.MaxThrottle - 20) throttleTerm = (staticParams.MaxThrottle - 20);
Line 470... Line 452...
470
  throttleTerm *= STICK_GAIN;
452
  throttleTerm *= CONTROL_SCALING;
471
 
453
 
-
 
454
  /*
-
 
455
   * Compose yaw term.
-
 
456
   * The yaw term is limited: Absolute value is max. = the throttle term / 2.
-
 
457
   * However, at low throttle the yaw term is limited to a fixed value,
472
  /*
458
   * and at high throttle it is limited by the throttle reserve (the difference
473
   * Compose yaw term.
459
   * between current throttle and maximum throttle).
474
   */
460
   */
475
#define MIN_YAWGAS (40 * STICK_GAIN)  // yaw also below this gas value
461
#define MIN_YAWGAS (40 * CONTROL_SCALING)  // yaw also below this gas value
476
  yawTerm = PDPartYaw - setPointYaw * STICK_GAIN;
462
  yawTerm = PDPartYaw - setPointYaw * CONTROL_SCALING;
477
  // limit yawTerm
-
 
478
  if(throttleTerm > MIN_YAWGAS) {
-
 
479
    /*
-
 
480
     * -throttle/2 < -20 <= yawTerm <= 20 < throttle/2
463
  // limit yawTerm
481
     */
464
  if(throttleTerm > MIN_YAWGAS) {
482
    CHECK_MIN_MAX(yawTerm, - (throttleTerm / 2), (throttleTerm / 2));
-
 
483
  } else {
-
 
484
    /*
-
 
485
     * -20 <= yawTerm <= 20
465
    CHECK_MIN_MAX(yawTerm, - (throttleTerm / 2), (throttleTerm / 2));
486
     */
466
  } else {
Line 487... Line 467...
487
    CHECK_MIN_MAX(yawTerm, - (MIN_YAWGAS / 2), (MIN_YAWGAS / 2));
467
    CHECK_MIN_MAX(yawTerm, - (MIN_YAWGAS / 2), (MIN_YAWGAS / 2));
488
  }
-
 
489
 
-
 
490
  tmp_int = staticParams.MaxThrottle * STICK_GAIN;
-
 
491
 
-
 
492
  /*
468
  }
493
   * throttle-MaxThrottle <= yawTerm <= MaxThrottle-throttle
-
 
494
   */
-
 
495
  CHECK_MIN_MAX(yawTerm, -(tmp_int - throttleTerm), (tmp_int - throttleTerm));
-
 
496
 
-
 
497
  /*
-
 
498
   * Compose pitch and roll terms. This is finally where the sticks come into play.
-
 
499
   */
-
 
500
  if(gyroIFactor) {
-
 
501
    // Integration mode: Integrate (angle - stick) = the difference between angle and stick pos.
-
 
502
    // That means: Holding the stick a little forward will, at constant flight attitude, cause this to grow (decline??) over time.
-
 
503
    // TODO: Find out why this seems to be proportional to stick position - not integrating it at all.
-
 
504
    IPartPitch += PPartPitch - controlPitch; // Integrate difference between P part (the angle) and the stick pos.
-
 
505
    IPartRoll += PPartRoll - controlRoll;    // I-part for attitude control OK
-
 
506
  } else {
-
 
507
    // "HH" mode: Integrate (rate - stick) = the difference between rotation rate and stick pos.
-
 
508
    IPartPitch += PDPartPitch - controlPitch; // With gyroIFactor == 0, PDPart is really just a D-part. Integrate D-part (the rot. rate) and the stick pos.
-
 
509
    IPartRoll += PDPartRoll - controlRoll;    // With gyroIFactor == 0, PDPart is really just a D-part. Integrate D-part (the rot. rate) and the stick pos.
-
 
510
  }
-
 
Line 511... Line -...
511
 
-
 
512
  // TODO: From which planet comes the 16000?
-
 
513
  CHECK_MIN_MAX(IPartPitch, -(STICK_GAIN * 16000L), (STICK_GAIN * 16000L));
-
 
514
 
-
 
515
  // Add (P, D) parts minus stick pos. to the scaled-down I part.
-
 
516
  pitchTerm = PDPartPitch - controlPitch + IPartPitch / Ki;    // PID-controller for pitch
-
 
517
 
-
 
518
  CHECK_MIN_MAX(IPartRoll, -(STICK_GAIN * 16000L), (STICK_GAIN * 16000L));
-
 
519
  rollTerm = PDPartRoll - controlRoll + IPartRoll / Ki;  // PID-controller for roll
-
 
520
 
-
 
521
  /*
-
 
522
   * Apply "dynamic stability" - that is: Limit pitch and roll terms to a growing function of throttle and yaw(!).
-
 
523
   * The higher the dynamic stability parameter, the wider the bounds. 64 seems to be a kind of unity
469
 
-
 
470
  tmp_int = staticParams.MaxThrottle * CONTROL_SCALING;
-
 
471
  CHECK_MIN_MAX(yawTerm, -(tmp_int - throttleTerm), (tmp_int - throttleTerm));
-
 
472
 
-
 
473
  tmp_int = (int32_t)((int32_t)dynamicParams.DynamicStability * (int32_t)(throttleTerm + abs(yawTerm) / 2)) / 64;
-
 
474
 
-
 
475
  for (axis=PITCH; axis<=ROLL; axis++) {  
-
 
476
    /*
-
 
477
     * Compose pitch and roll terms. This is finally where the sticks come into play.
-
 
478
     */
-
 
479
    if(gyroIFactor) {
-
 
480
      // Integration mode: Integrate (angle - stick) = the difference between angle and stick pos.
-
 
481
      // That means: Holding the stick a little forward will, at constant flight attitude, cause this to grow (decline??) over time.
-
 
482
      // TODO: Find out why this seems to be proportional to stick position - not integrating it at all.
-
 
483
      IPart[axis] += PPart[axis] - control[axis]; // Integrate difference between P part (the angle) and the stick pos.
-
 
484
    } else {
-
 
485
      // "HH" mode: Integrate (rate - stick) = the difference between rotation rate and stick pos.
-
 
486
      // To keep up with a full stick PDPart should be about 156...
-
 
487
      IPart[axis] += PDPart[axis] - control[axis]; // With gyroIFactor == 0, PDPart is really just a D-part. Integrate D-part (the rot. rate) and the stick pos.
-
 
488
    }
-
 
489
   
-
 
490
    // TODO: From which planet comes the 16000?
-
 
491
    CHECK_MIN_MAX(IPart[axis], -(CONTROL_SCALING * 16000L), (CONTROL_SCALING * 16000L));
-
 
492
    // Add (P, D) parts minus stick pos. to the scaled-down I part.
-
 
493
    term[axis] = PDPart[axis] - control[axis] + IPart[axis] / Ki;    // PID-controller for pitch
524
   * (max. pitch or roll term is the throttle value).
494
   
-
 
495
    /*
-
 
496
     * Apply "dynamic stability" - that is: Limit pitch and roll terms to a growing function of throttle and yaw(!).
525
   * TODO: Why a growing function of yaw?
497
     * The higher the dynamic stability parameter, the wider the bounds. 64 seems to be a kind of unity
-
 
498
     * (max. pitch or roll term is the throttle value).
Line 526... Line 499...
526
   */
499
     * TODO: Why a growing function of yaw?
527
  tmp_int = (int32_t)((int32_t)dynamicParams.DynamicStability * (int32_t)(throttleTerm + abs(yawTerm) / 2)) / 64;
500
     */
-
 
501
    CHECK_MIN_MAX(term[axis], -tmp_int, tmp_int);
528
  CHECK_MIN_MAX(pitchTerm, -tmp_int, tmp_int);
502
  }
529
  CHECK_MIN_MAX(rollTerm, -tmp_int, tmp_int);
503
 
530
 
504
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
531
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
505
  // Universal Mixer
532
  // Universal Mixer
506
  // Each (pitch, roll, throttle, yaw) term is in the range [0..255 * CONTROL_SCALING].
533
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
507
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
534
  for(i = 0; i < MAX_MOTORS; i++) {
508
  for(i = 0; i < MAX_MOTORS; i++) {
535
    int16_t tmp;
509
    int16_t tmp;
536
    if(Mixer.Motor[i][MIX_THROTTLE] > 0) { // If a motor has a zero throttle mix, it is not considered.
510
    if(Mixer.Motor[i][MIX_THROTTLE] > 0) { // If a motor has a zero throttle mix, it is not considered.
537
      tmp =  ((int32_t)throttleTerm * Mixer.Motor[i][MIX_THROTTLE]) / 64L;
511
      tmp =  ((int32_t)throttleTerm * Mixer.Motor[i][MIX_THROTTLE]) / 64L;
538
      tmp += ((int32_t)pitchTerm    * Mixer.Motor[i][MIX_PITCH])    / 64L;
512
      tmp += ((int32_t)term[PITCH]  * Mixer.Motor[i][MIX_PITCH])    / 64L;
539
      tmp += ((int32_t)rollTerm     * Mixer.Motor[i][MIX_ROLL])     / 64L;
513
      tmp += ((int32_t)term[ROLL]   * Mixer.Motor[i][MIX_ROLL])     / 64L;
540
      tmp += ((int32_t)yawTerm      * Mixer.Motor[i][MIX_YAW])      / 64L;
514
      tmp += ((int32_t)yawTerm      * Mixer.Motor[i][MIX_YAW])      / 64L;
541
      motorFilters[i] = motorFilter(tmp, motorFilters[i]);
515
      motorFilters[i] = motorFilter(tmp, motorFilters[i]);
542
      tmp = motorFilters[i] / STICK_GAIN;
516
      tmp = motorFilters[i] / CONTROL_SCALING;
Line 543... Line 517...
543
      CHECK_MIN_MAX(tmp, staticParams.MinThrottle, staticParams.MaxThrottle);
517
      CHECK_MIN_MAX(tmp, staticParams.MinThrottle, staticParams.MaxThrottle);
544
      Motor[i].SetPoint = tmp;
518
      Motor[i].SetPoint = tmp;
545
    }
519
    }
546
    else Motor[i].SetPoint = 0;
520
    else Motor[i].SetPoint = 0;
547
  }
521
  }
548
 
522
 
549
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
523
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
550
  //  Debugwerte zuordnen
524
  // Debugging
Line 551... Line 525...
551
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
525
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
552
  if(!(--debugDataTimer)) {
526
  if(!(--debugDataTimer)) {
553
    debugDataTimer = 24; // update debug outputs at 488 / 24 = 20.3 Hz.
527
    debugDataTimer = 24; // update debug outputs at 488 / 24 = 20.3 Hz.
554
    DebugOut.Analog[0]  = (10 * pitchAngle) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
528
    DebugOut.Analog[0]  = (10 * angle[PITCH]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
555
    DebugOut.Analog[1]  = (10 * rollAngle) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
529
    DebugOut.Analog[1]  = (10 * angle[ROLL]) / GYRO_DEG_FACTOR_PITCHROLL; // in 0.1 deg
556
    DebugOut.Analog[2]  = yawGyroHeading / GYRO_DEG_FACTOR_YAW;
530
    DebugOut.Analog[2]  = yawGyroHeading / GYRO_DEG_FACTOR_YAW;
557
 
531
 
558
    DebugOut.Analog[9]  = setPointYaw;
532
    // DebugOut.Analog[9]  = setPointYaw;
Line 559... Line 533...
559
    DebugOut.Analog[10] = yawIFactor;
533
    // DebugOut.Analog[10] = yawIFactor;
560
    DebugOut.Analog[11] = gyroIFactor;
534
    // DebugOut.Analog[11] = gyroIFactor;
561
    // DebugOut.Analog[12] = RC_getVariable(0);
535
    // DebugOut.Analog[12] = RC_getVariable(0);
562
    // DebugOut.Analog[13] = dynamicParams.UserParams[0];
536
    // DebugOut.Analog[13] = dynamicParams.UserParams[0];
Line 563... Line 537...
563
    DebugOut.Analog[14] = RC_getVariable(4);
537
    // DebugOut.Analog[14] = RC_getVariable(4);
564
    DebugOut.Analog[15] = dynamicParams.UserParams[4];
538
    // DebugOut.Analog[15] = dynamicParams.UserParams[4];
565
    /* DebugOut.Analog[11] = yawGyroHeading / GYRO_DEG_FACTOR_YAW; */
539
    /* DebugOut.Analog[11] = yawGyroHeading / GYRO_DEG_FACTOR_YAW; */
566
 
540
 
567
    // 12..15 are the controls.
-
 
568
    // DebugOut.Analog[16] = pitchAxisAcc;
-
 
569
    // DebugOut.Analog[17] = rollAxisAcc;
-
 
Line -... Line 541...
-
 
541
    // 12..15 are the controls.
-
 
542
    // DebugOut.Analog[16] = pitchAxisAcc;
-
 
543
    // DebugOut.Analog[17] = rollAxisAcc;
-
 
544
    // DebugOut.Analog[18] = ZAxisAcc;
570
    // DebugOut.Analog[18] = ZAxisAcc;
545
 
571
 
546
    DebugOut.Analog[19] = throttleTerm;
Line 572... Line 547...
572
    DebugOut.Analog[19] = throttleTerm;
547
    DebugOut.Analog[20] = term[PITCH];
573
    DebugOut.Analog[20] = pitchTerm;
548
    DebugOut.Analog[21] = term[ROLL];
574
    DebugOut.Analog[21] = rollTerm;
549
    DebugOut.Analog[22] = yawTerm;
575
    DebugOut.Analog[22] = yawTerm;
550