Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 903 → Rev 916

/branches/V0.69k CRK HexaLotte/analog.c
17,8 → 17,8
 
volatile int16_t Current_AccZ = 0;
volatile int16_t UBat = 100;
volatile int16_t AdValueGyrPitch = 0, AdValueGyrRoll = 0, AdValueGyrYaw = 0;
volatile int16_t AdValueAccRoll = 0, AdValueAccPitch = 0, AdValueAccTop = 0;
volatile int16_t AdValueGyrNick = 0, AdValueGyrRoll = 0, AdValueGyrYaw = 0;
volatile int16_t AdValueAccRoll = 0, AdValueAccNick = 0, AdValueAccTop = 0;
volatile int32_t AirPressure = 32000;
volatile int16_t StartAirPressure;
volatile uint16_t ReadingAirPressure = 1023;
87,13 → 87,13
// thru the state machine by the following order.
// state 0: ch0 (yaw gyro)
// state 1: ch1 (roll gyro)
// state 2: ch2 (pitch gyro)
// state 2: ch2 (nick gyro)
// state 3: ch4 (battery voltage -> UBat)
// state 4: ch6 (acc y -> Current_AccY)
// state 5: ch7 (acc x -> Current_AccX)
// state 6: ch0 (yaw gyro average with first reading -> AdValueGyrYaw)
// state 7: ch1 (roll gyro average with first reading -> AdValueGyrRoll)
// state 8: ch2 (pitch gyro average with first reading -> AdValueGyrPitch)
// state 8: ch2 (nick gyro average with first reading -> AdValueGyrNick)
// state 9: ch5 (acc z add also 4th part of acc x and acc y to reading)
// state10: ch3 (air pressure averaging over 5 single readings -> tmpAirPressure)
 
100,7 → 100,7
ISR(ADC_vect)
{
static uint8_t adc_channel = 0, state = 0;
static uint16_t yaw1, roll1, pitch1;
static uint16_t yaw1, roll1, nick1;
static uint8_t average_pressure = 0;
static int16_t tmpAirPressure = 0;
// disable further AD conversion
115,10 → 115,10
break;
case 1:
roll1 = ADC; // get Gyro Roll Voltage 1st sample
adc_channel = 2; // set next channel to ADC2 = PITCH GYRO
adc_channel = 2; // set next channel to ADC2 = NICK GYRO
break;
case 2:
pitch1 = ADC; // get Gyro Pitch Voltage 1st sample
nick1 = ADC; // get Gyro Nick Voltage 1st sample
adc_channel = 4; // set next channel to ADC4 = UBAT
break;
case 3:
131,7 → 131,7
adc_channel = 7; // set next channel to ADC7 = ACC_X
break;
case 5:
AdValueAccPitch = ADC - NeutralAccX; // get acceleration in X direction
AdValueAccNick = ADC - NeutralAccX; // get acceleration in X direction
adc_channel = 0; // set next channel to ADC7 = YAW GYRO
break;
case 6:
144,18 → 144,18
// average over two samples to create current ADValueGyrRoll
if(BoardRelease == 10) AdValueGyrRoll = (ADC + roll1) / 2;
else AdValueGyrRoll = ADC + roll1; // gain is 2 times lower on FC 1.1
adc_channel = 2; // set next channel to ADC2 = PITCH GYRO
adc_channel = 2; // set next channel to ADC2 = NICK GYRO
break;
case 8:
// average over two samples to create current ADValuePitch
if(BoardRelease == 10) AdValueGyrPitch = (ADC + pitch1) / 2;
else AdValueGyrPitch = ADC + pitch1; // gain is 2 times lower on FC 1.1
// average over two samples to create current ADValueNick
if(BoardRelease == 10) AdValueGyrNick = (ADC + nick1) / 2;
else AdValueGyrNick = ADC + nick1; // gain is 2 times lower on FC 1.1
adc_channel = 5; // set next channel to ADC5 = ACC_Z
break;
case 9:
// get z acceleration
AdValueAccTop = (int16_t) ADC - NeutralAccZ; // get plain acceleration in Z direction
AdValueAccTop += abs(AdValueAccPitch) / 4 + abs(AdValueAccRoll) / 4;
AdValueAccTop += abs(AdValueAccNick) / 4 + abs(AdValueAccRoll) / 4;
if(AdValueAccTop > 1)
{
if(NeutralAccZ < 750)