Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2091 → Rev 976

/branches/V0.70d HexaLotte/Hex-Files/Flight-Ctrl_MEGA644_HEXA_V0_70d.hex
File deleted
/branches/V0.70d HexaLotte/fc.c
89,11 → 89,7
float IntegralFaktor;
volatile int DiffNick,DiffRoll;
int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0;
#ifdef HEXAKOPTER
volatile unsigned char Motor_VorneLinks,Motor_VorneRechts,Motor_HintenLinks,Motor_HintenRechts,Motor_Rechts,Motor_Links, Count;
#else
volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
#endif
volatile unsigned char SenderOkay = 0;
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
char MotorenEin = 0;
231,7 → 227,7
MesswertNick = (signed int) AdWertNick - AdNeutralNick;
 
//DebugOut.Analog[26] = MesswertNick;
//DebugOut.Analog[28] = MesswertRoll;
DebugOut.Analog[28] = MesswertRoll;
 
// Beschleunigungssensor ++++++++++++++++++++++++++++++++++++++++++++++++
Mittelwert_AccNick = ((long)Mittelwert_AccNick * 1 + ((ACC_AMPLIFY * (long)AdWertAccNick))) / 2L;
380,18 → 376,6
{
if(!MotorenEin)
{
#ifdef HEXAKOPTER
Motor_HintenLinks = 0;
Motor_HintenRechts = 0;
Motor_VorneLinks = 0;
Motor_VorneRechts = 0;
Motor_Rechts = 0;
Motor_Links = 0;
if(MotorTest[0]) Motor_VorneLinks = Motor_VorneRechts = MotorTest[0];
if(MotorTest[1]) Motor_HintenLinks = Motor_HintenRechts = MotorTest[1];
if(MotorTest[2]) Motor_Links = MotorTest[2];
if(MotorTest[3]) Motor_Rechts = MotorTest[3];
#else
Motor_Hinten = 0;
Motor_Vorne = 0;
Motor_Rechts = 0;
400,23 → 384,14
if(MotorTest[1]) Motor_Hinten = MotorTest[1];
if(MotorTest[2]) Motor_Links = MotorTest[2];
if(MotorTest[3]) Motor_Rechts = MotorTest[3];
#endif
MikroKopterFlags &= ~(FLAG_MOTOR_RUN | FLAG_FLY);
} else MikroKopterFlags |= FLAG_MOTOR_RUN;
 
#ifdef HEXAKOPTER
DebugOut.Analog[10] = Motor_VorneLinks;
DebugOut.Analog[11] = Motor_VorneRechts;
DebugOut.Analog[12] = Motor_HintenLinks;
DebugOut.Analog[13] = Motor_HintenRechts;
DebugOut.Analog[14] = Motor_Links;
DebugOut.Analog[15] = Motor_Rechts;
#else
DebugOut.Analog[12] = Motor_Vorne;
DebugOut.Analog[13] = Motor_Hinten;
DebugOut.Analog[14] = Motor_Links;
DebugOut.Analog[15] = Motor_Rechts;
#endif
 
//Start I2C Interrupt Mode
twi_state = 0;
motor = 0;
479,7 → 454,6
{
int motorwert,pd_ergebnis,h,tmp_int;
int GierMischanteil,GasMischanteil;
int NickMischanteil, RollMischanteil;
static long SummeNick=0,SummeRoll=0;
static long sollGier = 0,tmp_long,tmp_long2;
static long IntegralFehlerNick = 0;
1112,9 → 1086,8
DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);
DebugOut.Analog[8] = KompassValue;
DebugOut.Analog[9] = UBat;
DebugOut.Analog[28] = ErsatzKompass / GIER_GRAD_FAKTOR;
DebugOut.Analog[29] = SenderOkay;
DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
DebugOut.Analog[10] = SenderOkay;
//DebugOut.Analog[16] = Mittelwert_AccHoch;
// DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
// DebugOut.Analog[18] = (int)FromNaviCtrl_Value.OsdBar;
1258,13 → 1231,24
if(SummeNick > (STICK_GAIN * 16000L)) SummeNick = (STICK_GAIN * 16000L);
if(SummeNick < -(16000L * STICK_GAIN)) SummeNick = -(16000L * STICK_GAIN);
pd_ergebnis = DiffNick + Ki * SummeNick; // PI-Regler für Nick
 
// Motor Vorn
tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
 
NickMischanteil = (pd_ergebnis*4) / 7;
 
motorwert = GasMischanteil + pd_ergebnis + GierMischanteil; // Mischer
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Vorne = motorwert;
// Motor Heck
motorwert = GasMischanteil - pd_ergebnis + GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Hinten = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Roll-Achse
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1276,87 → 1260,21
pd_ergebnis = DiffRoll + Ki * SummeRoll; // PI-Regler für Roll
tmp_int = (long)((long)Parameter_DynamicStability * (long)(GasMischanteil + abs(GierMischanteil)/2)) / 64;
if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
 
RollMischanteil = pd_ergebnis/3;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Mischer für die Motorenanteile
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
#ifdef HEXAKOPTER
// Motor Vorn Links
motorwert = GasMischanteil + NickMischanteil + RollMischanteil/2 - GierMischanteil; // Mischer
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_VorneLinks = motorwert;
// Motor Vorn Rechts
motorwert = GasMischanteil + NickMischanteil - RollMischanteil/2 + GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_VorneRechts = motorwert;
// Motor Hinten Links
motorwert = GasMischanteil - NickMischanteil + RollMischanteil/2 - GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_HintenLinks = motorwert;
// Motor HintenRechts
motorwert = GasMischanteil - NickMischanteil - RollMischanteil/2 + GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_HintenRechts = motorwert;
// Motor Rechts
motorwert = GasMischanteil - RollMischanteil - GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Rechts = motorwert;
if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
// Motor Links
motorwert = GasMischanteil + RollMischanteil + GierMischanteil;
motorwert = GasMischanteil + pd_ergebnis - GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Links = motorwert;
#else
// Motor Vorn
motorwert = GasMischanteil + NickMischanteil + GierMischanteil; // Mischer
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Vorne = motorwert;
// Motor Heck
motorwert = GasMischanteil - NickMischanteil + GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Hinten = motorwert;
// Motor Links
motorwert = GasMischanteil + RollMischanteil - GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Links = motorwert;
// Motor Rechts
motorwert = GasMischanteil - RollMischanteil - GierMischanteil;
motorwert = GasMischanteil - pd_ergebnis - GierMischanteil;
motorwert /= STICK_GAIN;
if ((motorwert < 0)) motorwert = 0;
else if(motorwert > MAX_GAS) motorwert = MAX_GAS;
if (motorwert < MIN_GAS) motorwert = MIN_GAS;
Motor_Rechts = motorwert;
#endif
Motor_Rechts = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++
}
 
/branches/V0.70d HexaLotte/fc.h
54,11 → 54,7
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
extern volatile int DiffNick,DiffRoll;
extern int Poti1, Poti2, Poti3, Poti4;
#ifdef HEXAKOPTER
extern volatile unsigned char Motor_VorneLinks,Motor_VorneRechts,Motor_HintenLinks,Motor_HintenRechts,Motor_Rechts,Motor_Links, Count;
#else
extern volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
#endif
extern volatile unsigned char SenderOkay;
extern int StickNick,StickRoll,StickGier;
extern char MotorenEin;
/branches/V0.70d HexaLotte/main.h
49,13 → 49,6
#define CFG_LOOP_LINKS 0x04
#define CFG_LOOP_RECHTS 0x08
 
#ifdef HEXAKOPTER
#define MOTOR_COUNT 6
#else
#define MOTOR_COUNT 4
#endif
 
 
//#define SYSCLK
//extern unsigned long SYSCLK;
extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll;
/branches/V0.70d HexaLotte/makefile
9,16 → 9,11
 
VERSION_KOMPATIBEL = 8 # PC-Kompatibilität
#-------------------------------------------------------------------
#
#-------------------------------------------------------------------
# comment out for Quadro, uncomment for Hexakopter
HEXAKOPTER = _HEXA
#-------------------------------------------------------------------
 
ifeq ($(MCU), atmega32)
# FUSE_SETTINGS= -u -U lfuse:w:0xff:m -U hfuse:w:0xcf:m
 
HEX_NAME = MEGA32$(HEXAKOPTER)
HEX_NAME = MEGA32
endif
 
ifeq ($(MCU), atmega644)
25,12 → 20,12
FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
#FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
# -u bei neuen Controllern wieder einspielen
HEX_NAME = MEGA644$(HEXAKOPTER)
HEX_NAME = MEGA644
endif
 
ifeq ($(MCU), atmega644p)
FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
HEX_NAME = MEGA644$(HEXAKOPTER)
HEX_NAME = MEGA644
endif
 
 
134,9 → 129,6
 
CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION) -DVERSION_KOMPATIBEL=$(VERSION_KOMPATIBEL) -DVERSION_INDEX=$(VERSION_INDEX)
 
ifeq ($(HEXAKOPTER), _HEXA)
CFLAGS += -DHEXAKOPTER
endif
 
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
/branches/V0.70d HexaLotte/twimaster.c
6,7 → 6,7
volatile unsigned char twi_state = 0;
unsigned char motor = 0;
unsigned char motorread = 0;
unsigned char motor_rx[MOTOR_COUNT*2];
unsigned char motor_rx[8];
 
//############################################################################
//Initzialisieren der I2C (TWI) Schnittstelle
76,32 → 76,9
i2c_write_byte(0x52+(motor*2));
break;
case 1:
#ifdef HEXAKOPTER
switch(motor++)
{
case 0:
i2c_write_byte(Motor_VorneLinks);
break;
case 1:
i2c_write_byte(Motor_HintenRechts);
break;
case 2:
i2c_write_byte(Motor_VorneRechts);
break;
case 3:
i2c_write_byte(Motor_HintenLinks);
break;
case 4:
i2c_write_byte(Motor_Rechts);
break;
case 5:
i2c_write_byte(Motor_Links);
break;
}
#else
switch(motor++)
{
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
114,11 → 91,10
i2c_write_byte(Motor_Links);
break;
}
#endif
break;
case 2:
i2c_stop();
if (motor<MOTOR_COUNT) twi_state = 0;
if (motor<4) twi_state = 0;
else motor = 0;
i2c_start();
break;
128,18 → 104,46
i2c_write_byte(0x53+(motorread*2));
break;
case 4:
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);
switch(motorread)
{
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
i2c_write_byte(Motor_Hinten);
break;
case 2:
i2c_write_byte(Motor_Rechts);
break;
case 3:
i2c_write_byte(Motor_Links);
break;
}
break;
case 5: //1 Byte vom Motor lesen
motor_rx[motorread] = TWDR;
 
case 6:
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
switch(motorread)
{
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
i2c_write_byte(Motor_Hinten);
break;
case 2:
i2c_write_byte(Motor_Rechts);
break;
case 3:
i2c_write_byte(Motor_Links);
break;
}
break;
case 7: //2 Byte vom Motor lesen
motor_rx[motorread+MOTOR_COUNT] = TWDR;
motor_rx[motorread+4] = TWDR;
motorread++;
if (motorread>=MOTOR_COUNT) motorread=0;
if (motorread>3) motorread=0;
i2c_stop();
I2CTimeout = 10;
twi_state = 0;
/branches/V0.70d HexaLotte/twimaster.h
21,7 → 21,7
extern volatile unsigned char twi_state;
extern unsigned char motor;
extern unsigned char motorread;
extern unsigned char motor_rx[2*MOTOR_COUNT];
extern unsigned char motor_rx[8];
 
void i2c_reset(void);
extern void i2c_init (void); // I2C initialisieren
/branches/V0.70d HexaLotte/uart.c
47,22 → 47,13
"Gas ",
"KompassValue ",
"Spannung ",
#ifdef HEXAKOPTER
"Motor VL ", //10
"Motor VR ",
"Motor HL ",
"Motor HR ",
"Motor Links ",
"Motor Rechts ", //15
#else
" ", //10
"Empfang ", //10
"Ersatzkompass ",
"Motor_Vorne ",
"Motor_Hinten ",
"Motor_Links ",
"Motor_Rechts ", //15
" ",
"Motor Vorne ",
"Motor Hinten ",
"Motor Links ",
"Motor Rechts ", //15
#endif
" ",
"Distance ",
"OsdBar ",
"MK3Mag CalState ",
74,8 → 65,8
" ", //25
" ",
" ",
"Ersatzkompass ",
"Empfang ",
" ",
" ",
"GPS_Nick ", //30
"GPS_Roll "
};