Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 159 → Rev 160

/branches/salvo_gps/GPS.c
72,7 → 72,6
// Initialisierung
void GPS_Neutral(void)
{
short int n;
ublox_msg_state = UBLOX_IDLE;
gps_state = GPS_CRTL_IDLE;
actual_pos.status = 0;
285,7 → 284,8
short int GPS_CRTL(short int cmd)
{
static unsigned int cnt; //Zaehler fuer diverse Verzoegerungen
 
int n;
long int dist;
switch (cmd)
{
case GPS_CMD_REQ_HOLD: // Die Lageregelung soll aktiviert werden.
292,7 → 292,7
if (gps_state != GPS_CRTL_HOLD_ACTIVE)
{
cnt++;
if (cnt > 300) // erst nach Verzoegerung
if (cnt > 500) // erst nach Verzoegerung
{
cnt = 0;
// aktuelle positionsdaten abespeichern
345,7 → 345,7
signed int dist_north,dist_east;
dist_east = gps_rel_hold_position.utm_east - gps_rel_act_position.utm_east;
dist_north = gps_rel_hold_position.utm_north - gps_rel_act_position.utm_north;
 
//PI Regler
gps_int_x = gps_int_x + (dist_east * Parameter_UserParam1)/16; // Integrator
gps_int_y = gps_int_y + (dist_north * Parameter_UserParam1)/16;
361,10 → 361,9
GPS_hdng_abs_2trgt = arctan_i((long)gps_reg_x,(long)gps_reg_y);
 
//in Winkel 0..360 grad umrechnen
if ((dist_east >= 0) && (dist_north < 0)) GPS_hdng_abs_2trgt = ( 90-GPS_hdng_abs_2trgt);
else if ((dist_east < 0) ) GPS_hdng_abs_2trgt = (270 - GPS_hdng_abs_2trgt);
if ((gps_reg_x >= 0) && (gps_reg_y < 0)) GPS_hdng_abs_2trgt = ( 90-GPS_hdng_abs_2trgt);
else if ((gps_reg_x < 0) ) GPS_hdng_abs_2trgt = (270 - GPS_hdng_abs_2trgt);
// Relative Richtung in bezug auf Nordachse des Kopters errechen
int n,m;
n= GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT;
GPS_hdng_rel_2trgt = GPS_hdng_abs_2trgt - n;
if ((GPS_hdng_rel_2trgt >180) && (GPS_hdng_abs_2trgt >=180))GPS_hdng_rel_2trgt = GPS_hdng_rel_2trgt-360;
371,8 → 370,31
else if (GPS_hdng_rel_2trgt >180) GPS_hdng_rel_2trgt = 360 - GPS_hdng_rel_2trgt;
else if (GPS_hdng_rel_2trgt <-180) GPS_hdng_rel_2trgt = 360 + GPS_hdng_rel_2trgt;
// Distanz zum Ziel ermitteln
GPS_dist_2trgt = abs(dist_north) + abs(dist_east);//ACHTUNG: Noch Nicht korrekt
// Regelabweichung aus x,y zu Ziel in Distanz umrechnen
if (abs(gps_reg_x) > abs(gps_reg_y) )
{
dist = (long)gps_reg_x; //Groesseren Wert wegen besserer genauigkeit nehmen
dist = abs((dist *1000) / (long) cos_i(GPS_hdng_rel_2trgt));
}
else
{
dist = (long)gps_reg_y;
dist = abs((dist *1000) / (long) sin_i(GPS_hdng_rel_2trgt));
}
if (dist > 30000) dist = 30000;
GPS_dist_2trgt = (int )dist;
 
// Winkel und Distanz in Nick und Roll groessen umrechnen
long int a,b;
GPS_Roll = (int) -((dist * sin_i(GPS_hdng_rel_2trgt))/(1000*4));
GPS_Nick = (int) -((dist * cos_i(GPS_hdng_rel_2trgt))/(1000*4));
 
if (GPS_Roll > GPS_ROLL_MAX) GPS_Roll = GPS_ROLL_MAX; //Auf Maxwerte begrenzen
else if (GPS_Roll < -GPS_ROLL_MAX) GPS_Roll = - GPS_ROLL_MAX;
if (GPS_Nick > GPS_NICK_MAX) GPS_Nick = GPS_NICK_MAX;
else if (GPS_Nick < -GPS_NICK_MAX) GPS_Nick = - GPS_NICK_MAX;
 
return (GPS_STST_OK);
}
else return (GPS_STST_OK);
/branches/salvo_gps/fc.c
819,8 → 819,8
// DebugOut.Analog[2] = MesswertGier;
// DebugOut.Analog[0] = IntegralNick / EE_Parameter.GyroAccFaktor;
// DebugOut.Analog[1] = IntegralRoll / EE_Parameter.GyroAccFaktor;
DebugOut.Analog[2] = Mittelwert_AccNick;
DebugOut.Analog[3] = Mittelwert_AccRoll;
// DebugOut.Analog[2] = Mittelwert_AccNick;
// DebugOut.Analog[3] = Mittelwert_AccRoll;
DebugOut.Analog[4] = MesswertGier;
DebugOut.Analog[5] = HoehenWert;
DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);
829,8 → 829,10
DebugOut.Analog[8] = KompassValue;
*/
DebugOut.Analog[0] = GPS_hdng_rel_2trgt;
DebugOut.Analog[1] = 0;
DebugOut.Analog[7] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT;
DebugOut.Analog[1] = GPS_dist_2trgt;
DebugOut.Analog[2] = GPS_Nick;
DebugOut.Analog[3] = GPS_Roll;
DebugOut.Analog[7] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT;
DebugOut.Analog[8] = KompassValue;
/*
DebugOut.Analog[7] = gps_rel_act_position.utm_east;
/branches/salvo_gps/fc.h
20,7 → 20,7
// Salvo End
//Salvo 16.9.2007 GPS_STICK_HOLDOFF ***************
// Laut Datenblatt sind die Werte ueber Zeit und Temperatur sehr stabil.
#define GPS_STICK_HOLDOFF 35 // Wenn der Nick oder Roll groesser ist, wird GPS_HOLD deaktiviert
#define GPS_STICK_HOLDOFF 30 // Wenn der Nick oder Roll groesser ist, wird GPS_HOLD deaktiviert
 
extern unsigned char Parameter_UserParam1 ;
extern unsigned char Parameter_UserParam2 ;
/branches/salvo_gps/gps.h
77,6 → 77,7
extern signed int GPS_hdng_rel_2trgt;
extern signed int GPS_dist_2trgt;
extern signed int gps_reg_x,gps_reg_y;
extern signed int GPS_dist_2trgt;
 
// Zustaende der zentralen GPS statemachine
#define GPS_CRTL_IDLE 0 //
94,5 → 95,5
#define GPS_STST_ERR 2 // Fehler
 
// GPS Lageregler
#define GPS_NICK_MAX 20
#define GPS_ROLL_MAX 20
#define GPS_NICK_MAX 10
#define GPS_ROLL_MAX 10