Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 379 → Rev 380

/trunk/analog.c
8,8 → 8,8
#include "main.h"
 
volatile int Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100;
volatile int AccumulateNick = 0, AccumulateRoll = 0, AccumulateGier = 0;
volatile int accumulate_AccRoll = 0,accumulate_AccNick = 0,accumulate_AccHoch = 0;
volatile int AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0;
volatile int AdWertAccRoll = 0,AdWertAccNick = 0,AdWertAccHoch = 0;
volatile char MessanzahlNick = 0, MessanzahlRoll = 0, MessanzahlGier = 0;
volatile char messanzahl_AccNick = 0, messanzahl_AccRoll = 0, messanzahl_AccHoch = 0;
volatile long Luftdruck = 32000;
37,18 → 37,18
off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]);
if(off > 20) off -= 10;
OCR0A = off;
Delay_ms(100);
Delay_ms_Mess(100);
if(MessLuftdruck < 850) off = 0;
for(; off < 250;off++)
{
OCR0A = off;
Delay_ms(50);
Delay_ms_Mess(50);
printf(".");
if(MessLuftdruck < 900) break;
}
eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off);
DruckOffsetSetting = off;
Delay_ms(300);
Delay_ms_Mess(300);
}
 
 
58,48 → 58,20
//#######################################################################################
{
static unsigned char kanal=0,state = 0;
signed int wert;
ANALOG_OFF;
switch(state++)
{
case 0:
wert = (signed int) AdNeutralGier - ADC;
if(PlatinenVersion != 10) wert *= 2;
AccumulateGier += wert; //
MessanzahlGier++;
Mess_Integral_Gier += wert;// / 16;
Mess_Integral_Gier2 += wert;
AdWertGier = ADC;
kanal = 1;
ZaehlMessungen++;
break;
case 1:
wert = (signed int) ADC - AdNeutralRoll;
if(PlatinenVersion != 10) wert *= 2;
Mess_IntegralRoll += wert;
Mess_IntegralRoll2 += wert;
if(Mess_IntegralRoll > 310000L) Mess_IntegralRoll = -290000L;
if(Mess_IntegralRoll <-310000L) Mess_IntegralRoll = 290000L;
if(ADC < 15) wert = -1000;
if(ADC < 7) wert = -2000;
if(ADC > 1010) wert = +1000;
if(ADC > 1017) wert = +2000;
AccumulateRoll += wert;
MessanzahlRoll++;
AdWertRoll = ADC;
kanal = 2;
break;
case 2:
wert = (signed int) ADC - AdNeutralNick;
if(PlatinenVersion != 10) wert *= 2;
Mess_IntegralNick += wert;
Mess_IntegralNick2 += wert;
if(Mess_IntegralNick > 310000L) Mess_IntegralNick = -290000L;
if(Mess_IntegralNick <-310000L) Mess_IntegralNick = 290000L;
if(ADC < 15) wert = -1000;
if(ADC < 7) wert = -2000;
if(ADC > 1010) wert = +1000;
if(ADC > 1017) wert = +2000;
AccumulateNick += wert;
MessanzahlNick++;
AdWertNick = ADC;
kanal = 4;
break;
case 3:
108,45 → 80,30
break;
case 4:
Aktuell_ay = NeutralAccY - ADC;
accumulate_AccRoll += Aktuell_ay;
messanzahl_AccRoll++;
AdWertAccRoll = Aktuell_ay;
kanal = 7;
break;
case 5:
Aktuell_ax = ADC - NeutralAccX;
accumulate_AccNick += Aktuell_ax;
messanzahl_AccNick++;
AdWertAccNick = Aktuell_ax;
kanal = 5;
state = 6;
break;
case 6:
accumulate_AccHoch = (signed int) ADC - NeutralAccZ;
accumulate_AccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4;
if(accumulate_AccHoch > 1)
AdWertAccHoch = (signed int) ADC - NeutralAccZ;
AdWertAccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4;
if(AdWertAccHoch > 1)
{
if(NeutralAccZ < 800) NeutralAccZ+= 0.02;
}
else if(accumulate_AccHoch < -1)
else if(AdWertAccHoch < -1)
{
if(NeutralAccZ > 600) NeutralAccZ-= 0.02;
}
messanzahl_AccHoch = 1;
Aktuell_az = ADC;
Mess_Integral_Hoch += accumulate_AccHoch; // Integrieren
Mess_Integral_Hoch += AdWertAccHoch; // Integrieren
Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen
// Mess_Integral_Hoch -= Mess_Integral_Hoch / 512; // dämfen
/* if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
{
kanal = 3;
state = 7;
}
else
{
kanal = 0;
state = 0;
}*/
kanal = 3;
state = 7;
kanal = 3;
break;
case 7:
tmpLuftdruck += ADC;
168,5 → 125,5
break;
}
ADMUX = kanal;
ANALOG_ON;
if(state != 0) ANALOG_ON;
}