Subversion Repositories FlightCtrl

Rev

Rev 1701 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1701 Rev 1702
Line 21... Line 21...
21
unsigned char DruckOffsetSetting;
21
unsigned char DruckOffsetSetting;
22
signed char ExpandBaro = 0;
22
signed char ExpandBaro = 0;
23
volatile int VarioMeter = 0;
23
volatile int VarioMeter = 0;
24
volatile unsigned int ZaehlMessungen = 0;
24
volatile unsigned int ZaehlMessungen = 0;
25
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115;
25
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115;
26
unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0;
-
 
27
volatile unsigned char AdReady = 1;
26
volatile unsigned char AdReady = 1;
28
float NeutralAccZ_float;
27
float NeutralAccZ_float;
29
//#######################################################################################
28
//#######################################################################################
30
//
29
//
31
void ADC_Init(void)
30
void ADC_Init(void)
Line 53... Line 52...
53
  printf(".");
52
  printf(".");
54
  if(MessLuftdruck < DESIRED_H_ADC) break;
53
  if(MessLuftdruck < DESIRED_H_ADC) break;
55
  }
54
  }
56
 SetParamByte(PID_PRESSURE_OFFSET, off);
55
 SetParamByte(PID_PRESSURE_OFFSET, off);
57
 DruckOffsetSetting = off;
56
 DruckOffsetSetting = off;
-
 
57
 if((EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) && (DruckOffsetSetting < 10 || DruckOffsetSetting >= 245)) VersionInfo.HardwareError[0] |= DEFEKT_PRESSURE;
58
 OCR0A = off;
58
 OCR0A = off;
59
 Delay_ms_Mess(300);
59
 Delay_ms_Mess(300);
60
 
-
 
61
}
60
}
Line 62... Line 61...
62
 
61
 
63
void SucheGyroOffset(void)
62
void SucheGyroOffset(void)
64
{
63
{
65
 unsigned char i, ready = 0;
64
 unsigned char i, ready = 0;
66
 int timeout;
-
 
67
 GyroDefektN = 0; GyroDefektR = 0; GyroDefektG = 0;
65
 int timeout;
68
 timeout = SetDelay(2000);
66
 timeout = SetDelay(2000);
69
 for(i=140; i != 0; i--)
67
 for(i=140; i != 0; i--)
70
  {
68
  {
71
   if(ready == 3 && i > 10) i = 9;
69
   if(ready == 3 && i > 10) i = 9;
72
   ready = 0;
70
   ready = 0;
73
   if(AdWertNick < 1020) AnalogOffsetNick--; else if(AdWertNick > 1030) AnalogOffsetNick++; else ready++;
71
   if(AdWertNick < 1020) AnalogOffsetNick--; else if(AdWertNick > 1030) AnalogOffsetNick++; else ready++;
74
   if(AdWertRoll < 1020) AnalogOffsetRoll--; else if(AdWertRoll > 1030) AnalogOffsetRoll++; else ready++;
72
   if(AdWertRoll < 1020) AnalogOffsetRoll--; else if(AdWertRoll > 1030) AnalogOffsetRoll++; else ready++;
75
   if(AdWertGier < 1020) AnalogOffsetGier--; else if(AdWertGier > 1030) AnalogOffsetGier++; else ready++;
73
   if(AdWertGier < 1020) AnalogOffsetGier--; else if(AdWertGier > 1030) AnalogOffsetGier++; else ready++;
76
   I2C_Start(TWI_STATE_GYRO_OFFSET_TX);
74
   I2C_Start(TWI_STATE_GYRO_OFFSET_TX);
77
   if(AnalogOffsetNick < 10)  { GyroDefektN = 1; AnalogOffsetNick = 10;}; if(AnalogOffsetNick > 245) { GyroDefektN = 1; AnalogOffsetNick = 245;};
75
   if(AnalogOffsetNick < 10)  { VersionInfo.HardwareError[0] |= DEFEKT_G_NICK; AnalogOffsetNick = 10;}; if(AnalogOffsetNick > 245) { VersionInfo.HardwareError[0] |= DEFEKT_G_NICK; AnalogOffsetNick = 245;};
78
   if(AnalogOffsetRoll < 10)  { GyroDefektR = 1; AnalogOffsetRoll = 10;}; if(AnalogOffsetRoll > 245) { GyroDefektR = 1; AnalogOffsetRoll = 245;};
76
   if(AnalogOffsetRoll < 10)  { VersionInfo.HardwareError[0] |= DEFEKT_G_ROLL; AnalogOffsetRoll = 10;}; if(AnalogOffsetRoll > 245) { VersionInfo.HardwareError[0] |= DEFEKT_G_ROLL; AnalogOffsetRoll = 245;};
79
   if(AnalogOffsetGier < 10)  { GyroDefektG = 1; AnalogOffsetGier = 10;}; if(AnalogOffsetGier > 245) { GyroDefektG = 1; AnalogOffsetGier = 245;};
77
   if(AnalogOffsetGier < 10)  { VersionInfo.HardwareError[0] |= DEFEKT_G_GIER; AnalogOffsetGier = 10;}; if(AnalogOffsetGier > 245) { VersionInfo.HardwareError[0] |= DEFEKT_G_GIER; AnalogOffsetGier = 245;};
80
   while(twi_state) if(CheckDelay(timeout)) {printf("\n\r DAC or I2C ERROR! Check I2C, 3Vref, DAC and BL-Ctrl"); break;}
78
   while(twi_state) if(CheckDelay(timeout)) {printf("\n\r DAC or I2C ERROR! Check I2C, 3Vref, DAC and BL-Ctrl"); break;}
81
   AdReady = 0;
79
   AdReady = 0;
82
   ANALOG_ON;
80
   ANALOG_ON;
83
   while(!AdReady);
81
   while(!AdReady);