Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 135 → Rev 136

/branches/salvo_gierkompass/fc.c
78,6 → 78,8
static int SignalSchlecht = 0;
//Salvo 2.9.2007 Ersatzkompass
volatile long GyroKomp_Int,GyroKomp_Int2;
volatile int GyroKomp_Inc_Grad; // Gyroincrements / Grad
volatile int GyroKomp_Value; // Der ermittelte Kompasswert aus Gyro und Magnetkompass
// Salvo End
float GyroFaktor;
float IntegralFaktor;
175,6 → 177,7
//Salvo 2.9.2007 Ersatzkompass
GyroKomp_Int = 0;
GyroKomp_Int2 = 0;
GyroKomp_Inc_Grad = GYROKOMP_INC_GRAD_DEFAULT;
// Salvo End
}
 
605,6 → 608,16
#define DRIFT_FAKTOR 3
if(ZaehlMessungen >= 1000 / DRIFT_FAKTOR)
{
// Salvo 8.9.2007 Ersatzkompass *******
ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern
if (GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT >=360 )
{
// GyroKomp_Int = GyroKomp_Int- (long)(GYROKOMP_INC_GRAD_DEFAULT *360);
GyroKomp_Int = 0;
}
ANALOG_ON; // ADC einschalten
// Salvo End
 
IntegralFehlerNick = IntegralNick2 - IntegralNick;
IntegralFehlerRoll = IntegralRoll2 - IntegralRoll;
ZaehlMessungen = 0;
709,6 → 722,46
// Salvo End *************************
ANALOG_ON; // ADC einschalten
 
// Salvo Ersatzkompass 8.9.2007 **********************
if (Kompass_Neuer_Wert > 0)
{
w = (abs(Mittelwert_AccNick));
v = (abs(Mittelwert_AccRoll));
if ((w < ACC_WAAGRECHT_LIMIT) && (v < ACC_WAAGRECHT_LIMIT)) //Ersatzkompass nur mit Magnetkompass aktualisieren wenn alle sok
{
if ((abs(KompassValue - Kompass_Value_Old)) < 5) // Aufeinanderfolgende Werte duerfen nur minimal abweichen
{
ANALOG_OFF; // ADC ausschalten, damit die Werte sich nicht während der Berechnung ändern
GyroKomp_Int = (GyroKomp_Int )/GYROKOMP_INC_GRAD_DEFAULT;
w = KompassValue - GyroKomp_Int;
if ((w > 0) && (w < 180))
{
++GyroKomp_Int;
}
else if ((w > 0) && (w >= 180))
{
--GyroKomp_Int;
}
else if ((w < 0) && (w >= -180))
{
--GyroKomp_Int;
}
else if ((w < 0) && (w < -180))
{
++GyroKomp_Int;
}
if (GyroKomp_Int < 0) GyroKomp_Int = GyroKomp_Int + 360;
 
GyroKomp_Int = (GyroKomp_Int%360) * GYROKOMP_INC_GRAD_DEFAULT; // An Magnetkompasswert annaehern
ANALOG_ON; // ADC einschalten
}
}
Kompass_Neuer_Wert = 0;
}
 
// Salvo End *************************
 
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Kompass
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
766,8 → 819,10
DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);
DebugOut.Analog[7] = GasMischanteil;
DebugOut.Analog[8] = KompassValue;
DebugOut.Analog[9] = GyroKomp_Int;
DebugOut.Analog[10] = GyroKomp_Int2;
DebugOut.Analog[9] = GyroKomp_Int/GYROKOMP_INC_GRAD_DEFAULT;
DebugOut.Analog[10] = GyroKomp_Int2/GYROKOMP_INC_GRAD_DEFAULT;
DebugOut.Analog[11] = GyroKomp_Inc_Grad;
DebugOut.Analog[12] = GyroKomp_Value;
 
// DebugOut.Analog[9] = SollHoehe;
// DebugOut.Analog[10] = Mess_Integral_Gier / 128;
/branches/salvo_gierkompass/fc.h
13,6 → 13,10
#define ACC_Z_NEUTRAL 745 // ADC Wandler Wert in Neutrallage (1g)
 
#define ACC_WAAGRECHT_LIMIT 100 // Nick und Roll kleiner als dieser Wert gelten als kriterium fuer waagrechte Lage
// Salvo End
//Salvo 2.9.2007 Ersatzkompass: Gyroincrements/Grad als Defaultwert *****
// Laut Datenblatt sind die Werte ueber Zeit und Temperatur sehr stabil.
#define GYROKOMP_INC_GRAD_DEFAULT 1250 // Gyroincrements/Grad als Defaultwert
 
// Salvo End
 
35,6 → 39,9
extern volatile float NeutralAccZ;
//Salvo 2.9.2007 Ersatzkompass
extern volatile long GyroKomp_Int,GyroKomp_Int2;
extern volatile int GyroKomp_Inc_Grad;
extern volatile int GyroKomp_Value; // Der ermittelte Kompasswert aus Gyro und Magnetkompass
 
// Salvo End
 
void MotorRegler(void);
/branches/salvo_gierkompass/makefile
4,7 → 4,7
F_CPU = 20000000
#-------------------------------------------------------------------
HAUPT_VERSION = 0
NEBEN_VERSION = 04
NEBEN_VERSION = 05
VERSION_KOMPATIBEL = 4 # PC-Kompatibilität
#-------------------------------------------------------------------
 
/branches/salvo_gierkompass/timer0.c
6,7 → 6,10
volatile unsigned int cntKompass = 0;
volatile unsigned int beeptime = 0;
int ServoValue = 0;
 
//Salvo 8.9.2007
volatile unsigned int Kompass_Neuer_Wert= 0;
volatile unsigned int Kompass_Value_Old = 0;
// Salvo End
enum {
STOP = 0,
CK = 1,
42,7 → 45,7
else
PORTD &= ~(1<<2);
 
if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
// if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
{
if(PINC & 0x10)
{
53,6 → 56,7
if((cntKompass) && (cntKompass < 4000))
{
// Salvo Kompassoffset 30.8.2007 ***********
Kompass_Value_Old = KompassValue;
KompassValue = cntKompass -KOMPASS_OFFSET;
 
if (KompassValue < 0)
68,7 → 72,8
// if(cntKompass < 10) cntKompass = 10;
// KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L;
KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
cntKompass = 0;
Kompass_Neuer_Wert = 1;
cntKompass = 0;
}
}
}
/branches/salvo_gierkompass/timer0.h
16,3 → 16,8
extern volatile unsigned int beeptime;
extern volatile unsigned int cntKompass;
extern int ServoValue;
 
//Salvo 8.9.2007
extern volatile unsigned int Kompass_Neuer_Wert;
extern volatile unsigned int Kompass_Value_Old;
// Salvo End