Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1518 → Rev 1519

/beta/Code Redesign killagreg/fc.c
174,6 → 174,33
 
 
/************************************************************************/
/* Update Debug Outputs */
/************************************************************************/
void UpdateDebugValues(void)
{
DebugOut.Analog[0] = (10 * IntegralGyroNick) / GYRO_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[1] = (10 * IntegralGyroRoll) / GYRO_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[2] = (10 * AccNick) / ACC_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[3] = (10 * AccRoll) / ACC_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[4] = GyroYaw;
DebugOut.Analog[5] = ReadingHeight/5;
DebugOut.Analog[6] = AdValueAccTop;//(ReadingIntegralTop / 512);//AdValueAccZ;
DebugOut.Analog[8] = CompassHeading;
DebugOut.Analog[9] = UBat;
DebugOut.Analog[10] = RC_Quality;
DebugOut.Analog[11] = YawGyroHeading / GYRO_DEG_FACTOR;
DebugOut.Analog[18] = ReadingVario;
DebugOut.Analog[19] = CompassCalState;
DebugOut.Analog[20] = ServoNickValue;
DebugOut.Analog[22] = Capacity.ActualCurrent;
DebugOut.Analog[23] = Capacity.UsedCapacity;
DebugOut.Analog[29] = NCSerialDataOkay;
DebugOut.Analog[30] = GPSStickNick;
DebugOut.Analog[31] = GPSStickRoll;
}
 
 
/************************************************************************/
/* Filter for motor value smoothing */
/************************************************************************/
int16_t MotorSmoothing(int16_t newvalue, int16_t oldvalue)
663,7 → 690,6
static int32_t CorrectionNick, CorrectionRoll;
static uint16_t RcLostTimer;
static uint8_t delay_neutral = 0, delay_startmotors = 0, delay_stopmotors = 0;
static int8_t TimerDebugOut = 0;
static uint16_t UpdateCompassCourse = 0;
// high resolution motor values for smoothing of PID motor outputs
static int16_t MotorValue[MAX_MOTORS];
1397,33 → 1423,6
}
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DebugOutputs
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(!TimerDebugOut--)
{
TimerDebugOut = 24; // update debug outputs every 25*2ms = 50 ms (20Hz)
DebugOut.Analog[0] = (10 * IntegralGyroNick) / GYRO_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[1] = (10 * IntegralGyroRoll) / GYRO_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[2] = (10 * AccNick) / ACC_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[3] = (10 * AccRoll) / ACC_DEG_FACTOR; // in 0.1 deg
DebugOut.Analog[4] = GyroYaw;
DebugOut.Analog[5] = ReadingHeight/5;
DebugOut.Analog[6] = AdValueAccTop;//(ReadingIntegralTop / 512);//AdValueAccZ;
DebugOut.Analog[8] = CompassHeading;
DebugOut.Analog[9] = UBat;
DebugOut.Analog[10] = RC_Quality;
DebugOut.Analog[11] = YawGyroHeading / GYRO_DEG_FACTOR;
DebugOut.Analog[18] = ReadingVario;
DebugOut.Analog[19] = CompassCalState;
DebugOut.Analog[20] = ServoNickValue;
DebugOut.Analog[22] = Capacity.ActualCurrent;
DebugOut.Analog[23] = Capacity.UsedCapacity;
DebugOut.Analog[29] = NCSerialDataOkay;
DebugOut.Analog[30] = GPSStickNick;
DebugOut.Analog[31] = GPSStickRoll;
}
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// calculate control feedback from angle (gyro integral) and agular velocity (gyro signal)
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
/beta/Code Redesign killagreg/fc.h
119,8 → 119,8
void SendMotorData(void);
void SetNeutral(uint8_t AccAdjustment);
void Beep(uint8_t numbeeps, uint16_t duration);
void UpdateDebugValues(void);
 
 
extern uint8_t Poti[];
 
// current stick values
/beta/Code Redesign killagreg/libfc.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/main.c
353,6 → 353,7
{
static uint8_t counter_second = 0;
static uint16_t counter_minute = 0;
static uint8_t counter_debug = 0;
 
timer += 20; // every 20 ms
if(PcAccess) PcAccess--;
417,6 → 418,13
SetParamWord(PID_FLIGHT_MINUTES, FlightMinutes);
timer = SetDelay(20); // in case "timer += 20;" will not work
}
 
 
if((++counter_debug > 2) && (!UpdateMotor)) // 60 ms
{
counter_debug = 0;
UpdateDebugValues();
}
}// EOF CheckDelay(timer)
 
LED_Update();
/beta/Code Redesign killagreg/timer0.c
144,7 → 144,7
/*****************************************************/
ISR(TIMER0_OVF_vect) // 9.765 kHz
{
static uint8_t cnt_1ms = 1,cnt = 0;
static uint8_t cnt = 0;
uint8_t Beeper_On = 0;
 
#ifdef USE_NAVICTRL
156,15 → 156,17
if(!cnt--) // every 10th run (9.765kHz/10 = 976Hz)
{
cnt = 9;
cnt_1ms++;
cnt_1ms %= 2;
if(!cnt_1ms) UpdateMotor = 1; // every 2nd run (976Hz/2 = 488 Hz)
 
CountMilliseconds++; // increment millisecond counter
if(CountMilliseconds & 0x0001)
{
UpdateMotor = 1; // every 2nd run (976Hz/2 = 488 Hz)
}
}
 
 
// beeper on if duration is not over
if(BeepTime)
if(BeepTime) // resolution of 1 ms second is enought
{
BeepTime--; // decrement BeepTime
if(BeepTime & BeepModulation) Beeper_On = 1;