Subversion Repositories FlightCtrl

Rev

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

Rev 793 Rev 800
Line 385... Line 385...
385
/************************************************************************/
385
/************************************************************************/
386
/*  Maps the parameter to poti values                                   */
386
/*  Maps the parameter to poti values                                   */
387
/************************************************************************/
387
/************************************************************************/
388
void ParameterMapping(void)
388
void ParameterMapping(void)
389
{
389
{
390
        if(SenderOkay > 140) // do the mapping of RC-Potis only if the rc-signal is ok
390
        if(RC_Quality > 160) // do the mapping of RC-Potis only if the rc-signal is ok
391
        // else the last updated values are used
391
        // else the last updated values are used
392
        {
392
        {
393
                 //update poti values by rc-signals
393
                 //update poti values by rc-signals
394
                #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;}
394
                #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;}
395
                CHK_POTI(FCParam.MaxHeight,ParamSet.MaxHeight,0,255);
395
                CHK_POTI(FCParam.MaxHeight,ParamSet.MaxHeight,0,255);
Line 447... Line 447...
447
        ThrustMixFraction = StickThrust;
447
        ThrustMixFraction = StickThrust;
448
    if(ThrustMixFraction < 0) ThrustMixFraction = 0;
448
    if(ThrustMixFraction < 0) ThrustMixFraction = 0;
449
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
449
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
450
// RC-signal is bad
450
// RC-signal is bad
451
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
451
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
452
// SenderOkay is incremented at good rc-level, i.e. if the ppm-signal deviation
-
 
453
// of a channel to previous frame is less than 1% the SenderOkay is incremented by 10.
-
 
454
// Typicaly within a frame of 8 channels (22.5ms) the SenderOkay is incremented by 8 * 10 = 80
-
 
455
// The decremtation of 1 in the mainloop is done every 2 ms, i.e. within a time of one rc frame
-
 
456
// the main loop is running 11 times that decrements the SenderOkay by 11.
-
 
457
        if(SenderOkay < 100)  // the rc-frame signal is not reveived or noisy
452
        if(RC_Quality < 120)  // the rc-frame signal is not reveived or noisy
458
        {
453
        {
459
                if(!PcAccess) // if also no PC-Access via UART
454
                if(!PcAccess) // if also no PC-Access via UART
460
                {
455
                {
461
                        if(BeepModulation == 0xFFFF)
456
                        if(BeepModulation == 0xFFFF)
462
                        {
457
                        {
Line 482... Line 477...
482
                        PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] = 0;
477
                        PPM_in[ParamSet.ChannelAssignment[CH_PITCH]] = 0;
483
                        PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] = 0;
478
                        PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] = 0;
484
                        PPM_in[ParamSet.ChannelAssignment[CH_YAW]] = 0;
479
                        PPM_in[ParamSet.ChannelAssignment[CH_YAW]] = 0;
485
                }
480
                }
486
                else MotorsOn = 0; // switch of all motors
481
                else MotorsOn = 0; // switch of all motors
487
        } // eof SenderOkay < 100
482
        } // eof RC_Quality < 120
488
        else
483
        else
489
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
484
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
490
// RC-signal is good
485
// RC-signal is good
491
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
486
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
492
        if(SenderOkay > 140)
487
        if(RC_Quality > 150)
493
        {
488
        {
494
                EmergencyLanding = 0; // switch off emergency landing if RC-signal is okay
489
                EmergencyLanding = 0; // switch off emergency landing if RC-signal is okay
495
                // reset emergency timer
490
                // reset emergency timer
496
                RcLostTimer = ParamSet.EmergencyThrustDuration * 50;
491
                RcLostTimer = ParamSet.EmergencyThrustDuration * 50;
497
                if(ThrustMixFraction > 40)
492
                if(ThrustMixFraction > 40)
Line 637... Line 632...
637
                                }
632
                                }
638
                        }
633
                        }
639
                        else delay_stopmotors = 0; // reset delay timer if sticks are not in this position
634
                        else delay_stopmotors = 0; // reset delay timer if sticks are not in this position
640
                }
635
                }
641
                        // remapping of paameters only if the signal rc-sigbnal conditions are good
636
                        // remapping of paameters only if the signal rc-sigbnal conditions are good
642
        } // eof SenderOkay > 140
637
        } // eof RC_Quality > 150
643
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
638
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
644
// new values from RC
639
// new values from RC
645
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
640
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
646
        if(!NewPpmData-- || EmergencyLanding) // NewData = 0 means new data from RC
641
        if(!NewPpmData-- || EmergencyLanding) // NewData = 0 means new data from RC
647
        {
642
        {
Line 1081... Line 1076...
1081
                DebugOut.Analog[4]  = Reading_GyroYaw;
1076
                DebugOut.Analog[4]  = Reading_GyroYaw;
1082
                DebugOut.Analog[5]  = ReadingHeight;
1077
                DebugOut.Analog[5]  = ReadingHeight;
1083
                DebugOut.Analog[6]  = (Reading_Integral_Top / 512);
1078
                DebugOut.Analog[6]  = (Reading_Integral_Top / 512);
1084
                DebugOut.Analog[8]  = CompassHeading;
1079
                DebugOut.Analog[8]  = CompassHeading;
1085
                DebugOut.Analog[9]  = UBat;
1080
                DebugOut.Analog[9]  = UBat;
1086
                DebugOut.Analog[10] = SenderOkay;
1081
                DebugOut.Analog[10] = RC_Quality;
-
 
1082
                //DebugOut.Analog[11] = RC_Quality;
1087
                DebugOut.Analog[16] = Mean_AccTop;
1083
                DebugOut.Analog[16] = Mean_AccTop;
Line 1088... Line 1084...
1088
 
1084
 
1089
                /*    DebugOut.Analog[16] = motor_rx[0];
1085
                /*    DebugOut.Analog[16] = motor_rx[0];
1090
                DebugOut.Analog[17] = motor_rx[1];
1086
                DebugOut.Analog[17] = motor_rx[1];
Line 1099... Line 1095...
1099
                DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
1095
                DebugOut.Analog[25] = motor_rx[4] + motor_rx[5] + motor_rx[6] + motor_rx[7];
Line 1100... Line 1096...
1100
 
1096
 
1101
                DebugOut.Analog[9]  = Reading_GyroPitch;
1097
                DebugOut.Analog[9]  = Reading_GyroPitch;
1102
                DebugOut.Analog[9]  = SetPointHeight;
1098
                DebugOut.Analog[9]  = SetPointHeight;
1103
                DebugOut.Analog[10] = Reading_IntegralGyroYaw / 128;
-
 
-
 
1099
                DebugOut.Analog[10] = Reading_IntegralGyroYaw / 128;
1104
                DebugOut.Analog[11] = CompassCourse;
1100
 
1105
                DebugOut.Analog[10] = FCParam.Gyro_I;
1101
                DebugOut.Analog[10] = FCParam.Gyro_I;
1106
                DebugOut.Analog[10] = ParamSet.Gyro_I;
1102
                DebugOut.Analog[10] = ParamSet.Gyro_I;
1107
                DebugOut.Analog[9]  = CompassOffCourse;
1103
                DebugOut.Analog[9]  = CompassOffCourse;
1108
                DebugOut.Analog[10] = ThrustMixFraction;
1104
                DebugOut.Analog[10] = ThrustMixFraction;