Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 478 → Rev 479

/branches/v0.60_MicroMag3_Nick666/v0.66c/analog.c
80,12 → 80,12
kanal = 6;
break;
case 4:
Aktuell_ay = NeutralAccY - ADC;
Aktuell_ay = acc_neutral.Y - ADC;
AdWertAccRoll = Aktuell_ay;
kanal = 7;
break;
case 5:
Aktuell_ax = ADC - NeutralAccX;
Aktuell_ax = ADC - acc_neutral.X;
AdWertAccNick = Aktuell_ax;
kanal = 0;
break;
105,15 → 105,15
kanal = 5;
break;
case 9:
AdWertAccHoch = (signed int) ADC - NeutralAccZ;
AdWertAccHoch = (signed int) ADC - acc_neutral.Z;
AdWertAccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4;
if(AdWertAccHoch > 1)
{
if(NeutralAccZ < 800) NeutralAccZ+= 0.02;
if(acc_neutral.Z < 800) acc_neutral.Z+= 0.02;
}
else if(AdWertAccHoch < -1)
{
if(NeutralAccZ > 600) NeutralAccZ-= 0.02;
if(acc_neutral.Z > 600) acc_neutral.Z-= 0.02;
}
messanzahl_AccHoch = 1;
Aktuell_az = ADC;
/branches/v0.60_MicroMag3_Nick666/v0.66c/compass.c
176,7 → 176,8
{
float sin_nick, cos_nick, sin_roll, cos_roll;
float x_corr, y_corr;
signed int x_axis,y_axis,z_axis, heading, nicktilt, rolltilt;
signed int x_axis,y_axis,z_axis,heading;
signed int nicktilt,rolltilt;
unsigned int div_faktor;
div_faktor = (uint16_t)EE_Parameter.UserParam1 * 8;
/branches/v0.60_MicroMag3_Nick666/v0.66c/compass.h
5,9 → 5,9
uint8_t STATE;
unsigned int DRDY;
uint8_t AXIS;
signed int x_axis;
signed int y_axis;
signed int z_axis;
volatile signed int x_axis;
volatile signed int y_axis;
volatile signed int z_axis;
};
 
 
/branches/v0.60_MicroMag3_Nick666/v0.66c/fc.c
58,23 → 58,22
 
unsigned char h,m,s;
volatile unsigned int I2CTimeout = 100;
volatile int MesswertNick,MesswertRoll,MesswertGier;
volatile int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
volatile int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
volatile float NeutralAccZ = 0;
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
volatile long IntegralNick = 0,IntegralNick2 = 0;
volatile long IntegralRoll = 0,IntegralRoll2 = 0;
volatile long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
volatile long Integral_Gier = 0;
int MesswertNick,MesswertRoll,MesswertGier;
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0, StartNeutralRoll = 0, StartNeutralNick = 0;
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch;
 
long IntegralNick = 0,IntegralNick2 = 0;
long IntegralRoll = 0,IntegralRoll2 = 0;
long IntegralAccNick = 0,IntegralAccRoll = 0,IntegralAccZ = 0;
long Integral_Gier = 0;
volatile long Mess_IntegralNick = 0,Mess_IntegralNick2 = 0;
volatile long Mess_IntegralRoll = 0,Mess_IntegralRoll2 = 0;
volatile long Mess_Integral_Gier = 0,Mess_Integral_Gier2 = 0;
volatile long MittelIntegralNick,MittelIntegralRoll,MittelIntegralNick2,MittelIntegralRoll2;
volatile long Mess_Integral_Hoch = 0;
int KompassValue = 0;
int KompassStartwert = 0;
int KompassRichtung = 0;
int KompassValue = 0;
int KompassStartwert = 0;
int KompassRichtung = 0;
uint8_t updKompass = 0;
unsigned char MAX_GAS,MIN_GAS;
unsigned char Notlandung = 0;
84,7 → 83,7
float GyroFaktor;
float IntegralFaktor;
 
volatile int DiffNick,DiffRoll;
int DiffNick,DiffRoll;
int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
unsigned char MotorWert[5];
116,8 → 115,13
unsigned char Parameter_LoopGasLimit = 70;
unsigned char Parameter_AchsKopplung1 = 0;
unsigned char Parameter_AchsGegenKopplung1 = 0;
 
struct mk_param_struct EE_Parameter;
struct acc_neutral_struct ee_acc_neutral EEMEM; // Reservierung im EEPROM
struct acc_neutral_struct acc_neutral;
 
 
 
void Piep(unsigned char Anzahl)
{
while(Anzahl--)
129,13 → 133,32
}
 
//############################################################################
// Neutrallage kalibrieren und fest im EEPROM abspeichern
void calib_acc(void)
//############################################################################
{
acc_neutral.X = 0;
acc_neutral.Y = 0;
acc_neutral.Z = 0;
CalibrierMittelwert();
Delay_ms_Mess(100);
CalibrierMittelwert();
acc_neutral.X = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
acc_neutral.Y = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
acc_neutral.Z = Aktuell_az;
eeprom_write_block(&acc_neutral,&ee_acc_neutral,sizeof(struct acc_neutral_struct));
}
 
//############################################################################
// Nullwerte ermitteln
void SetNeutral(void)
//############################################################################
{
NeutralAccX = 0;
NeutralAccY = 0;
NeutralAccZ = 0;
acc_neutral.X = 0;
acc_neutral.Y = 0;
acc_neutral.Z = 0;
AdNeutralNick = 0;
AdNeutralRoll = 0;
AdNeutralGier = 0;
154,9 → 177,8
AdNeutralGier= AdWertGier;
StartNeutralRoll = AdNeutralRoll;
StartNeutralNick = AdNeutralNick;
NeutralAccY = abs(Mittelwert_AccRoll) / ACC_AMPLIFY;
NeutralAccX = abs(Mittelwert_AccNick) / ACC_AMPLIFY;
NeutralAccZ = Aktuell_az;
eeprom_read_block(&acc_neutral,&ee_acc_neutral,sizeof(struct acc_neutral_struct));
Mess_IntegralNick = 0;
Mess_IntegralNick2 = 0;
192,7 → 214,7
Mittelwert_AccHoch = ((long)Mittelwert_AccHoch * 1 + ((long)AdWertAccHoch)) / 2L;
IntegralAccNick += ACC_AMPLIFY * AdWertAccNick;
IntegralAccRoll += ACC_AMPLIFY * AdWertAccRoll;
IntegralAccZ += Aktuell_az - 704;//NeutralAccZ;
IntegralAccZ += Aktuell_az - 704;//acc_neutral.Z;
// Gier ++++++++++++++++++++++++++++++++++++++++++++++++
Mess_Integral_Gier += MesswertGier;
Mess_Integral_Gier2 += MesswertGier;
/branches/v0.60_MicroMag3_Nick666/v0.66c/fc.h
7,22 → 7,22
 
extern volatile unsigned int I2CTimeout;
extern unsigned char Sekunde,Minute;
extern volatile long IntegralNick,IntegralNick2;
extern volatile long IntegralRoll,IntegralRoll2;
extern long IntegralNick,IntegralNick2;
extern long IntegralRoll,IntegralRoll2;
extern long Integral_Gier;
extern volatile long Mess_IntegralNick,Mess_IntegralNick2;
extern volatile long Mess_IntegralRoll,Mess_IntegralRoll2;
extern volatile long IntegralAccNick,IntegralAccRoll;
extern volatile long Mess_Integral_Hoch;
extern volatile long Integral_Gier,Mess_Integral_Gier,Mess_Integral_Gier2;
extern int KompassValue;
extern int KompassStartwert;
extern int KompassRichtung;
extern long IntegralAccNick,IntegralAccRoll;
volatile long Mess_Integral_Hoch;
extern volatile long Mess_Integral_Gier,Mess_Integral_Gier2;
extern int KompassValue;
extern int KompassStartwert;
extern int KompassRichtung;
extern int HoehenWert;
extern int SollHoehe;
extern volatile int MesswertNick,MesswertRoll,MesswertGier;
extern volatile int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll;
extern volatile int NeutralAccX, NeutralAccY,Mittelwert_AccHoch;
extern volatile float NeutralAccZ;
extern int MesswertNick,MesswertRoll,MesswertGier;
int AdNeutralNick,AdNeutralRoll,AdNeutralGier;
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch;
extern long Umschlag180Nick, Umschlag180Roll;
 
void MotorRegler(void);
36,23 → 36,14
void DefaultKonstanten2(void);
 
extern unsigned char h,m,s;
extern volatile unsigned char Timeout ;
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
extern volatile long IntegralNick,IntegralNick2;
extern volatile long IntegralRoll,IntegralRoll2;
extern volatile long Integral_Gier;
extern volatile long Mess_IntegralNick,Mess_IntegralNick2;
extern volatile long Mess_IntegralRoll,Mess_IntegralRoll2;
extern volatile long Mess_Integral_Gier;
extern volatile int DiffNick,DiffRoll;
extern int Poti1, Poti2, Poti3, Poti4;
extern volatile unsigned char Timeout;
extern int DiffNick,DiffRoll;
extern int Poti1, Poti2, Poti3, Poti4;
extern volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
extern unsigned char MotorWert[5];
extern volatile unsigned char SenderOkay;
extern int StickNick,StickRoll,StickGier;
extern char MotorenEin;
extern void DefaultKonstanten1(void);
extern void DefaultKonstanten2(void);
 
#define STRUCT_PARAM_LAENGE 65
struct mk_param_struct
106,6 → 97,16
};
 
 
struct acc_neutral_struct
{
volatile int X;
volatile int Y;
volatile float Z;
};
 
extern struct acc_neutral_struct acc_neutral;
extern void calib_acc(void);
 
/*
unsigned char ServoNickMax; // Wert : 0-250
unsigned char ServoNickRefresh; //
/branches/v0.60_MicroMag3_Nick666/v0.66c/main.c
52,7 → 52,7
#include "main.h"
 
// Reservierung im EEPROM
unsigned char EEPromArray[10] EEMEM;
unsigned char EEPromArray[5] EEMEM;
struct mk_param_struct EEParameterArray[5] EEMEM;
 
unsigned char PlatinenVersion = 10;
153,6 → 153,8
}
eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], 3); // default-Setting
eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION);
calib_acc();
}
ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
168,7 → 170,7
printf("\n\rKalibriere Kompass");
calib_MM3();
}
/*
//Neutrallage kalibrieren?
if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 100 && PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -100)
{
175,7 → 177,8
printf("\n\rKalibriere Neutrallage");
calib_acc();
}
*/
if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
{
printf("\n\rAbgleich Luftdrucksensor..");
/branches/v0.60_MicroMag3_Nick666/v0.66c/main.h
43,11 → 43,6
#define CFG_LOOP_LINKS 0x04
#define CFG_LOOP_RECHTS 0x08
 
//#define SYSCLK
//extern unsigned long SYSCLK;
extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll;
extern volatile unsigned char SenderOkay;
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
extern unsigned char PlatinenVersion;
 
void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length);
/branches/v0.60_MicroMag3_Nick666/v0.66c/menu.c
94,9 → 94,9
break;
case 6:
LCD_printfxy(0,0,"ACC - Sensor");
LCD_printfxy(0,1,"Nick %4i (%3i)",AdWertAccNick,NeutralAccX);
LCD_printfxy(0,2,"Roll %4i (%3i)",AdWertAccRoll,NeutralAccY);
LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ);
LCD_printfxy(0,1,"Nick %4i (%3i)",AdWertAccNick,acc_neutral.X);
LCD_printfxy(0,2,"Roll %4i (%3i)",AdWertAccRoll,acc_neutral.Y);
LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)acc_neutral.Z);
break;
case 7:
LCD_printfxy(0,1,"Spannung: %5i",UBat);
/branches/v0.60_MicroMag3_Nick666/v0.66c/rc.c
18,7 → 18,7
//############################################################################
//zum decodieren des PPM-Signals wird Timer1 mit seiner Input
//Capture Funktion benutzt:
void rc_sum_init (void)
void rc_sum_init(void)
//############################################################################
{
TCCR1B=(1<<CS11)|(1<<CS10)|(1<<ICES1)|(1<<ICNC1);//|(1 << WGM12); //timer1 prescale 64
/branches/v0.60_MicroMag3_Nick666/v0.66c/timer0.c
1,7 → 1,6
#include "main.h"
 
volatile unsigned int CountMilliseconds = 0;
volatile static unsigned int tim_main;
volatile unsigned char UpdateMotor = 0;
volatile unsigned int beeptime = 0;
unsigned int BeepMuster = 0xffff;
67,7 → 66,6
 
void Timer_Init(void)
{
tim_main = SetDelay(10);
TCCR0B = CK8;
TCCR0A = (1<<COM0A1)|(1<<COM0B1)|3;//fast PWM
OCR0A = 0;