Subversion Repositories FlightCtrl

Rev

Blame | Last modification | View Log | RSS feed

## Die Parameterstruktur entspricht der Struktur in der FlightCtrl:


struct
  {
    unsigned char Kanalbelegung[8];       // GAS[0], GIER[1], NICK[2], ROLL[3], POTI1, POTI2, POTI3, POTI4
    unsigned char GlobalConfig;           // Höhenregler aktiv, HR-Schalter, Heading Hold aktiv, Kompass aktiv, Kompass Ausrichtung fest, GPS aktiv,
    unsigned char Hoehe_MinGas;           // Wert : 0-100
    unsigned char Luftdruck_D;            // Wert : 0-250
    unsigned char MaxHoehe;               // Wert : 0-32
    unsigned char Hoehe_P;                // Wert : 0-32
    unsigned char Hoehe_Verstaerkung;     // Wert : 0-50
    unsigned char Hoehe_ACC_Wirkung;      // Wert : 0-250
    unsigned char Stick_P;                // Wert : 1-6
    unsigned char Stick_D;                // Wert : 0-64
    unsigned char Gier_P;                 // Wert : 1-20
    unsigned char Gas_Min;                // Wert : 0-32
    unsigned char Gas_Max;                // Wert : 33-250
    unsigned char GyroAccFaktor;          // Wert : 1-64
    unsigned char KompassWirkung;         // Wert : 0-32
    unsigned char Gyro_P;                 // Wert : 10-250
    unsigned char Gyro_I;                 // Wert : 0-250
    unsigned char UnterspannungsWarnung;  // Wert : 0-250
    unsigned char NotGas;                 // Wert : 0-250     // Gaswert bei Empängsverlust
    unsigned char NotGasZeit;             // Wert : 0-250     // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
    unsigned char UfoAusrichtung;         // X oder + Formation
    unsigned char I_Faktor;               // Wert : 0-250
    unsigned char UserParam1;             // Wert : 0-250
    unsigned char UserParam2;             // Wert : 0-250
    unsigned char UserParam3;             // Wert : 0-250   Default: LED
    unsigned char UserParam4;             // Wert : 0-250   Default: LED
    unsigned char ServoNickControl;       // Wert : 0-250
    unsigned char ServoNickComp;          // Wert : 0-250
    unsigned char ServoNickMin;           // Wert : 0-250
    unsigned char ServoNickMax;           // Wert : 0-250
    unsigned char ServoNickRefresh;       //
    unsigned char ServoNickCompInvert;    // Wert : 0-250   0 oder 1  // WICHTIG!!! am Ende lassen
    unsigned char Reserved[7];
    char Name[12];
  } Param;
  
    
##--------------------------------------------   
## Per Windows wird diese wie folgt geladen:
     TIniFile *iniFile = new TIniFile(OD->FileName);

     strcpy(MK_Parameter[index].Name, (IniReadString(iniFile,"Setup", "Name","<unbenannt>")).c_str() );

     MK_Parameter[index].Kanalbelegung[0] = IniReadInteger(iniFile,"Channels", "Gas", 3);
     MK_Parameter[index].Kanalbelegung[1] = IniReadInteger(iniFile,"Channels", "Gier", 4);
     MK_Parameter[index].Kanalbelegung[2] = IniReadInteger(iniFile,"Channels", "Nick", 1);
     MK_Parameter[index].Kanalbelegung[3] = IniReadInteger(iniFile,"Channels", "Roll", 2);
     MK_Parameter[index].Kanalbelegung[4] = IniReadInteger(iniFile,"Channels", "Poti_1", 5);
     MK_Parameter[index].Kanalbelegung[5] = IniReadInteger(iniFile,"Channels", "Poti_2", 6);
     MK_Parameter[index].Kanalbelegung[6] = IniReadInteger(iniFile,"Channels", "Poti_3", 7);
     MK_Parameter[index].Kanalbelegung[7] = IniReadInteger(iniFile,"Channels", "Poti_3", 8);

     MK_Parameter[index].GlobalConfig = IniReadInteger(iniFile,"Setup", "GlobalConfig", 0);

     MK_Parameter[index].Stick_P = IniReadInteger(iniFile,"Stick", "Nick_Roll-P", 4);
     MK_Parameter[index].Stick_D = IniReadInteger(iniFile,"Stick", "Nick_Roll-D", 8);
     MK_Parameter[index].Gier_P = IniReadInteger(iniFile,"Stick", "Gier-P", 16);

     MK_Parameter[index].MaxHoehe = IniReadInteger(iniFile,"Altitude", "Setpoint", 251);
     MK_Parameter[index].Hoehe_MinGas = IniReadInteger(iniFile,"Altitude", "MinGas", 30);
     MK_Parameter[index].Hoehe_P = IniReadInteger(iniFile,"Altitude", "P", 10);
     MK_Parameter[index].Luftdruck_D = IniReadInteger(iniFile,"Altitude", "Barometric-D", 90);
     MK_Parameter[index].Hoehe_ACC_Wirkung = IniReadInteger(iniFile,"Altitude", "Z-ACC-Effect",15);
     MK_Parameter[index].Hoehe_Verstaerkung = IniReadInteger(iniFile,"Altitude", "Gain", 2);

     MK_Parameter[index].Gyro_P = IniReadInteger(iniFile,"Gyro", "P", 120);
     MK_Parameter[index].Gyro_I = IniReadInteger(iniFile,"Gyro", "I", 150);
     MK_Parameter[index].GyroAccFaktor = IniReadInteger(iniFile,"Gyro", "ACC_Gyro-Factor", 26);

     MK_Parameter[index].I_Faktor = IniReadInteger(iniFile,"Gyro", "Main-I", 5);

     MK_Parameter[index].Gas_Min = IniReadInteger(iniFile,"Others", "MinGas",15);
     MK_Parameter[index].Gas_Max = IniReadInteger(iniFile,"Others", "MaxGas",250);
     MK_Parameter[index].KompassWirkung = IniReadInteger(iniFile,"Others", "Compass-Effect",128);
     MK_Parameter[index].UnterspannungsWarnung = IniReadInteger(iniFile,"Others", "UnderVoltage",90);

     MK_Parameter[index].NotGas = IniReadInteger(iniFile,"Others", "NotGas",35);
     MK_Parameter[index].NotGasZeit = IniReadInteger(iniFile,"Others", "NotGasTime",20);

     MK_Parameter[index].UserParam1 = IniReadInteger(iniFile,"User", "Parameter_1",0);
     MK_Parameter[index].UserParam2 = IniReadInteger(iniFile,"User", "Parameter_2",0);
     MK_Parameter[index].UserParam3 = IniReadInteger(iniFile,"User", "Parameter_3",0);
     MK_Parameter[index].UserParam4 = IniReadInteger(iniFile,"User", "Parameter_4",0);

     MK_Parameter[index].ServoNickControl = IniReadInteger(iniFile,"Camera", "ServoNickControl",252);
     MK_Parameter[index].ServoNickComp = IniReadInteger(iniFile,"Camera", "ServoNickCompensation",100);
     MK_Parameter[index].ServoNickCompInvert = IniReadBool(iniFile,"Camera", "ServoNickInvert",false);
     MK_Parameter[index].ServoNickMin = IniReadInteger(iniFile,"Camera", "ServoNickMin",0);
     MK_Parameter[index].ServoNickMax = IniReadInteger(iniFile,"Camera", "ServoNickMax",250);
     MK_Parameter[index].ServoNickRefresh = IniReadInteger(iniFile,"Camera", "ServoNickRefreshRate",50);
 

 
##--------------------------------------------
 Senden der Daten: (diese Funktionen gibt es entsprechend auch in den FlightCtrl-Quellen

//---------------------------------------------------------------------------
void AddCRC(unsigned int wieviele)
{
 unsigned int tmpCRC = 0,i;
 for(i = 0; i < wieviele;i++)
  {
   tmpCRC += TxBuffer[i];
  }
   tmpCRC %= 4096;
   TxBuffer[i++] = '=' + tmpCRC / 64;
   TxBuffer[i++] = '=' + tmpCRC % 64;
   TxBuffer[i++] = '\r';

   SEND_BYTES(TxBuffer, wieviele+3);
}

// --------------------------------------------------------------------------
void SendOutData(unsigned char cmd,unsigned char modul, unsigned char *buffer, int len)
{
 unsigned int pt = 0,i;

 TxBuffer[pt++] = '#';           // Startzeichen
 TxBuffer[pt++] = modul+'a'; // Adresse (a=0; b=1,...)
 TxBuffer[pt++] = cmd;            // Commando
 if(len)
 for(i = 0;i < len; i+=3)
  {                                                                                                   // Ausgangs-Daten
    TxBuffer[pt++] = '=' + (buffer[i] >> 2);
    TxBuffer[pt++] = '=' + (((buffer[i] & 0x03) << 4) | ((buffer[i+1] & 0xf0) >> 4));
    TxBuffer[pt++] = '=' + ((unsigned char) ((buffer[i+1] & 0x0f) << 2) | ((buffer[i+2] & 0xc0) >> 6));
    TxBuffer[pt++] = '=' + ((unsigned char) buffer[i+2] & 0x3f);
  }
 AddCRC(pt);
}

#########################################

-------------------------------------------- 
 übertragen zum MikroKopter mit dem Befehl
 'l'+Paramterset  (siehe auch Quellen FlightCtrl):
 also m = 1, n = 2, ...

 Beispiel:

 SendOutData('l'+ParameterSet, 1,  MK_Parameter, sizeof(MK_Parameter));