xudeyu 发表于 2011-5-15 19:45:21

请教mk代码

if(SenderOkay > 140)
            {
                        MikroKopterFlags &= ~FLAG_NOTLANDUNG;
            RcLostTimer = EE_Parameter.NotGasZeit * 50;
            if(GasMischanteil > 40 && MotorenEin)
                {
                if(modell_fliegt < 0xffff) modell_fliegt++;
                }
            if((modell_fliegt < 256))
                {
                SummeNick = 0;
                SummeRoll = 0;
                if(modell_fliegt == 250)
               {
                  NeueKompassRichtungMerken = 1;
                  sollGier = 0;
                  Mess_Integral_Gier = 0;
//                  Mess_Integral_Gier2 = 0;
               }
                } else MikroKopterFlags |= FLAG_FLY;

            if((PPM_in] > 80) && MotorenEin == 0)
                {
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// auf Nullwerte kalibrieren
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                if(PPM_in] > 75)// Neutralwerte
                  {
                  if(++delay_neutral > 200)// nicht sofort
                        {
                        GRN_OFF;
                        MotorenEin = 0;
                        delay_neutral = 0;
                        modell_fliegt = 0;
                        if(PPM_in] > 70 || abs(PPM_in]) > 70)
                        {
                         unsigned char setting=1;
                         if(PPM_in] > 70 && PPM_in] < 70) setting = 1;
                         if(PPM_in] > 70 && PPM_in] > 70) setting = 2;
                         if(PPM_in] < 70 && PPM_in] > 70) setting = 3;
                         if(PPM_in] <-70 && PPM_in] > 70) setting = 4;
                         if(PPM_in] <-70 && PPM_in] < 70) setting = 5;
                         SetActiveParamSetNumber(setting);// aktiven Datensatz merken
                        }
//                        else
                         if(abs(PPM_in]) < 30 && PPM_in] < -70)
                        {
                           WinkelOut.CalcState = 1;
                           beeptime = 1000;
                        }
                        else
                        {
                               ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung, STRUCT_PARAM_LAENGE);
                           if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG))// H鰄enregelung aktiviert?
                            {
                           if((MessLuftdruck > 950) || (MessLuftdruck < 750)) SucheLuftruckOffset();
                            }
                                                   ServoActive = 0;
                           SetNeutral();
                                                   ServoActive = 1;
                                                   DDRD|=0x80; // enable J7 -> Servo signal
                           Piep(GetActiveParamSetNumber(),120);
                         }
                        }
                  }
               else
                if(PPM_in] < -75)// ACC Neutralwerte speichern
                  {
                  if(++delay_neutral > 200)// nicht sofort
                        {
                        GRN_OFF;
                        eeprom_write_byte(&EEPromArray,0xff); // Werte l鰏chen
                        MotorenEin = 0;
                        delay_neutral = 0;
                        modell_fliegt = 0;
                        SetNeutral();
                        eeprom_write_byte(&EEPromArray,NeutralAccX / 256); // ACC-NeutralWerte speichern
                        eeprom_write_byte(&EEPromArray,NeutralAccX % 256); // ACC-NeutralWerte speichern
                        eeprom_write_byte(&EEPromArray,NeutralAccY / 256);
                        eeprom_write_byte(&EEPromArray,NeutralAccY % 256);
                        eeprom_write_byte(&EEPromArray,(int)NeutralAccZ / 256);
                        eeprom_write_byte(&EEPromArray,(int)NeutralAccZ % 256);
                        Piep(GetActiveParamSetNumber(),120);
                        }
                  }
               else delay_neutral = 0;
                }
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Gas ist unten
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            if(PPM_in] < 35-120)
                {
                // Starten
                if(PPM_in] < -75)
                  {
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Einschalten
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                  if(++delay_einschalten > 200)
                        {
                        delay_einschalten = 200;
                        modell_fliegt = 1;
                        MotorenEin = 1;
                        sollGier = 0;
                        Mess_Integral_Gier = 0;
                        Mess_Integral_Gier2 = 0;
                        Mess_IntegralNick = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccNick;
                        Mess_IntegralRoll = EE_Parameter.GyroAccFaktor * (long)Mittelwert_AccRoll;
                        Mess_IntegralNick2 = IntegralNick;
                        Mess_IntegralRoll2 = IntegralRoll;
                        SummeNick = 0;
                        SummeRoll = 0;
                        MikroKopterFlags |= FLAG_START;
                        }
                  }
                  else delay_einschalten = 0;
                //Auf Neutralwerte setzen
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Auschalten
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                if(PPM_in] > 75)
                  {
                  if(++delay_ausschalten > 200)// nicht sofort
                        {
                         MotorenEin = 0;
                         delay_ausschalten = 200;
                         modell_fliegt = 0;
                        }
                  }
                else delay_ausschalten = 0;
                }
            }


这句话起到了什么作用啊!有点看不懂啊,请指教谢谢!

jmp2002911 发表于 2011-5-15 23:03:08

好大一句啊

59hang 发表于 2011-5-16 06:42:55

都是用遥控器置各种状态吧,有的是总清0,有的是打开气压控制,有的是关闭电机,我也外行,猜的,呵呵

yuxuanqq 发表于 2011-5-16 12:08:33

这些都不难:

判断是否起飞

在你做陀螺和加表校准的时候选哪种参数配置,可以用俯仰和滚转通道选择!就是当把油门达到最大,yaw最左时,读取俯仰和滚转遥控杆,看看你用哪种配置飞行,可以选5个!

这5个配置都是用MK tools配置的存在eepROM里。呵呵

大概功能就是这个。

对了,还能保存数据到eeprom里。
页: [1]
查看完整版本: 请教mk代码