/branches/thjac/V1_11/altcon.c |
---|
35,7 → 35,7 |
* Speichert die aktuelle Höhe als Sollhöhe |
*/ |
void altcon_lock( void ) { |
pressureOffset = airPressure; |
pressureOffset = analog_airPressure(); |
} |
78,7 → 78,7 |
if( enabled && !Notlandung ) { |
// Fehlerwert für Regler ermitteln |
error = airPressure - pressureOffset; |
error = analog_airPressure() - pressureOffset; |
// Proportionalanteil |
n = ( PARAM_ALT_P * error ) / 4; // dividiert durch ( 16 / STICK_GAIN ) = 16 / 4 = 4 |
94,8 → 94,9 |
n += altIntegral / 4000; |
*/ |
// Differenzialanteil |
n += ( PARAM_ALT_D * ( error - lastError ) ) / 2; |
// Differenzialanteil wird in analog.c berechnet |
n += analog_airPressureDiff() / 2; |
// n += ( PARAM_ALT_D * ( error - lastError ) ) / 2; |
// ACC-Z-Integral zur Dämpfung einbeziehen |
temp = ( ( ( Mess_Integral_Hoch / 128 ) - accZOffset ) * (signed long) PARAM_ALT_ACC ) / 32; |
/branches/thjac/V1_11/analog.c |
---|
6,6 → 6,7 |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#include "main.h" |
#include "parameter.h" |
volatile int Aktuell_Nick,Aktuell_Roll,Aktuell_Gier,Aktuell_ax, Aktuell_ay,Aktuell_az, UBat = 100; |
volatile int AdWertNick = 0, AdWertRoll = 0, AdWertGier = 0; |
16,7 → 17,6 |
volatile int StartLuftdruck; |
volatile unsigned int MessLuftdruck = 1023; |
unsigned char DruckOffsetSetting; |
signed char ExpandBaro = 0; |
volatile int HoeheD = 0; |
volatile char messanzahl_Druck; |
volatile int tmpLuftdruck; |
23,10 → 23,6 |
volatile unsigned int ZaehlMessungen = 0; |
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115; |
unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0; |
int airPressure = 0; |
//####################################################################################### |
// |
void ADC_Init(void) |
43,7 → 39,6 |
off = eeprom_read_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET]); |
if(off > 20) off -= 10; |
OCR0A = off; |
ExpandBaro = 0; |
Delay_ms_Mess(100); |
if(MessLuftdruck < 850) off = 0; |
for(; off < 250;off++) |
51,7 → 46,7 |
OCR0A = off; |
Delay_ms_Mess(50); |
printf("."); |
if(MessLuftdruck < 850) break; |
if(MessLuftdruck < 900) break; |
} |
eeprom_write_byte(&EEPromArray[EEPROM_ADR_LAST_OFFSET], off); |
DruckOffsetSetting = off; |
123,8 → 118,6 |
break; |
case 6: |
if(PlatinenVersion == 10) AdWertGier = (ADC + gier1) / 2; |
else |
if(PlatinenVersion == 20) AdWertGier = 1023 - (ADC + gier1); |
else AdWertGier = ADC + gier1; |
kanal = 1; |
break; |
167,17 → 160,15 |
break; |
case 10: |
tmpLuftdruck += ADC; |
if(++messanzahl_Druck >= 5) { |
if(++messanzahl_Druck >= 5) |
{ |
MessLuftdruck = ADC; |
messanzahl_Druck = 0; |
HoeheD = (7 * HoeheD + (int) PARAM_ALT_D * (int)(StartLuftdruck - tmpLuftdruck - HoehenWert))/8; // D-Anteil = neuerWert - AlterWert |
Luftdruck = (tmpLuftdruck + 3 * Luftdruck) / 4; |
airPressure = StartLuftdruck - Luftdruck; |
HoehenWert = StartLuftdruck - Luftdruck; |
tmpLuftdruck = 0; |
DebugOut.Analog[5] = airPressure; |
} |
} |
kanal = 0; |
state = 0; |
break; |
/branches/thjac/V1_11/analog.h |
---|
17,13 → 17,13 |
extern volatile char MessanzahlNick; |
extern unsigned char AnalogOffsetNick,AnalogOffsetRoll,AnalogOffsetGier; |
extern int airPressure; |
unsigned int ReadADC(unsigned char adc_input); |
void ADC_Init(void); |
void SucheLuftruckOffset(void); |
void SucheGyroOffset(void); |
#define analog_airPressure() HoehenWert |
#define analog_airPressureDiff() HoeheD |
#define ANALOG_OFF ADCSRA=0 |
#define ANALOG_ON ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADATE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)|(1<<ADIE) |
/branches/thjac/V1_11/fc.c |
---|
170,7 → 170,6 |
AdNeutralGierBias = 0; |
Parameter_AchsKopplung1 = 0; |
Parameter_AchsGegenKopplung1 = 0; |
ExpandBaro = 0; |
CalibrierMittelwert(); |
Delay_ms_Mess(100); |
CalibrierMittelwert(); |
/branches/thjac/V1_11/menu.c |
---|
10,6 → 10,7 |
#include "pitch_neutral.h" |
#include "pitch_md.h" |
#include "parameter.h" |
#include "fc.h" |
unsigned int TestInt = 0; |
#define ARRAYGROESSE 10 |
60,7 → 61,7 |
if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
{ |
LCD_printfxy(0,0,"RegOffset: %5i", pressureOffset ); |
LCD_printfxy(0,1,"Luftdruck: %5i", airPressure ); |
LCD_printfxy(0,1,"Luftdruck: %5i", analog_airPressure() ); |
LCD_printfxy(0,2,"Off : %5i",DruckOffsetSetting); |
} |
else |