Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 938 → Rev 937

/branches/V0.70d Code Redesign killagreg/Hex-Files/Readme.txt
48,8 → 48,13
- Unter Sonstiges: Kompass-Wirkung etwa auf 50 bis 70.
 
- User Parameters:
Parameter 2 --> I-Factor for GPS PD controller (start with small values below 10)
Parameter 3 --> Calibration factor for transforming Gyro Integrals to angular degrees (~170)
Parameter 4 --> Angle between the MM3 Board (Arrow) and the MK head (typical ~180)
Parameter 5 --> P-Factor for GPS PD controller (~70)
Parameter 6 --> D-Factor for GPS PD controller (~140)
Parameter 7 --> LED1Time for J16
Parameter 8 --> LED2Time for J17
 
- Zusätzliche akustische Signale:
/branches/V0.70d Code Redesign killagreg/gps.c
4,7 → 4,7
#include "ubx.h"
#include "mymath.h"
#include "timer0.h"
#include "uart.h"
//#include "uart.h"
#include "rc.h"
#include "eeprom.h"
 
16,9 → 16,9
GPS_FLIGHT_MODE_HOME,
} FlightMode_t;
 
#define GPS_STICK_LIMIT 500 // limit of gps stick control to avoid critical flight attitudes
#define GPS_STICK_LIMIT 200 // limit of gps stick control to avoid critical flight attitudes
#define GPS_POSDEV_INTEGRAL_LIMIT 32000 // limit for the position error integral
#define GPS_P_LIMIT 250
#define GPS_P_LIMIT 100
 
 
typedef struct
149,7 → 149,7
// then the P part of the controller is deactivated.
void GPS_PIDController(GPS_Pos_t *pTargetPos)
{
static int32_t PID_Nick, PID_Roll;
int32_t PID_Nick, PID_Roll;
int32_t coscompass, sincompass;
int32_t GPSPosDev_North, GPSPosDev_East; // Position deviation in cm
int32_t P_North = 0, D_North = 0, P_East = 0, D_East = 0, I_North = 0, I_East = 0;
206,15 → 206,15
GPSPosDevIntegral_East = 0;
}
 
//Calculate PID-components of the controller
//Calculate PID-components of the controller (negative sign for compensation)
 
// P-Part
P_North = ((int32_t)FCParam.NaviGpsP * GPSPosDev_North)/512;
P_East = ((int32_t)FCParam.NaviGpsP * GPSPosDev_East)/512;
P_North = -((int32_t)FCParam.NaviGpsP * GPSPosDev_North)/512;
P_East = -((int32_t)FCParam.NaviGpsP * GPSPosDev_East)/512;
 
// I-Part
I_North = ((int32_t)FCParam.NaviGpsI * GPSPosDevIntegral_North)/2048;
I_East = ((int32_t)FCParam.NaviGpsI * GPSPosDevIntegral_East)/2048;
I_North = -((int32_t)FCParam.NaviGpsI * GPSPosDevIntegral_North)/2048;
I_East = -((int32_t)FCParam.NaviGpsI * GPSPosDevIntegral_East)/2048;
 
// combine P- & I-Part
PID_North = P_North + I_North;
234,8 → 234,8
}
 
// D-Part
D_North = ((int32_t)FCParam.NaviGpsD * GPSInfo.velnorth)/ 128;
D_East = ((int32_t)FCParam.NaviGpsD * GPSInfo.veleast) / 128;
D_North = -((int32_t)FCParam.NaviGpsD * GPSInfo.velnorth)/ 128;
D_East = -((int32_t)FCParam.NaviGpsD * GPSInfo.veleast) / 128;
 
// combine PI- and D-Part
PID_North += D_North;
261,10 → 261,9
 
coscompass = (int32_t)c_cos_8192(YawGyroHeading / YAW_GYRO_DEG_FACTOR);
sincompass = (int32_t)c_sin_8192(YawGyroHeading / YAW_GYRO_DEG_FACTOR);
PID_Nick = (PID_Nick + (coscompass * PID_North + sincompass * PID_East) / 8192)/2;
PID_Roll = (PID_Roll + (sincompass * PID_North - coscompass * PID_East) / 8192)/2;
PID_Roll = (coscompass * PID_East - sincompass * PID_North) / 8192;
PID_Nick = -1*((sincompass * PID_East + coscompass * PID_North) / 8192);
 
 
// limit resulting GPS control vector
GPS_LimitXY(&PID_Nick, &PID_Roll, GPS_STICK_LIMIT);
 
286,7 → 285,7
void GPS_Main(void)
{
static uint8_t GPS_P_Delay = 0;
static uint16_t beep_rythm = 0;
uint16_t beep_rythm = 0;
 
GPS_UpdateParameter();
 
293,7 → 292,7
// store home position if start of flight flag is set
if(MKFlags & MKFLAG_CALIBRATE)
{
if(GPS_SetCurrPosition(&HomePosition)) BeepTime = 700;
GPS_SetCurrPosition(&HomePosition);
}
 
switch(GPSInfo.status)
/branches/V0.70d Code Redesign killagreg/makefile
1,7 → 1,7
#--------------------------------------------------------------------
# MCU name
#MCU = atmega644
MCU = atmega644p
MCU = atmega644
#MCU = atmega644p
F_CPU = 20000000
#-------------------------------------------------------------------
VERSION_MAJOR = 0
/branches/V0.70d Code Redesign killagreg/menu.c
54,7 → 54,7
void LCD_PrintMenu(void)
{
 
#if (!defined (USE_KILLAGREG) && !defined (USE_MK3MAG))
#if !defined (USE_MK3MAG) & !defined (USE_MK3MAG)
static uint8_t MaxMenuItem = 11;
#else
#ifdef USE_MK3MAG
196,7 → 196,7
LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Height, ExternControl.Config);
break;
 
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG))
#if defined (USE_KILLAGREG) || defined (USE_MK3MAG)
case 12://GPS Lat/Lon coords
if (GPSInfo.status == INVALID)
{