Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1683 → Rev 1684

/beta/Code Redesign killagreg/fc.c
56,6 → 56,8
#include <stdlib.h>
#include <avr/io.h>
 
//#define SWITCH_LEARNS_CAREFREE
 
#include "main.h"
#include "eeprom.h"
#include "timer0.h"
195,7 → 197,7
DebugOut.Analog[20] = ServoNickValue;
DebugOut.Analog[22] = Capacity.ActualCurrent;
DebugOut.Analog[23] = Capacity.UsedCapacity;
DebugOut.Analog[29] = NCSerialDataOkay;
DebugOut.Analog[29] = Capacity.MinOfMaxPWM;
DebugOut.Analog[30] = GPSStickNick;
DebugOut.Analog[31] = GPSStickRoll;
}
649,7 → 651,13
Ki = 10300 / ( FCParam.IFactor + 1 );
 
CHK_POTI(tmp,ParamSet.OrientationModeControl);
if(tmp > 50 && NCDataOkay > 200) CareFree = 1;
if(tmp > 50 && NCDataOkay > 200)
{
#ifdef SWITCH_LEARNS_CAREFREE
if(!CareFree) ControlHeading = (((int16_t) ParamSet.OrientationAngle * 15 + CompassHeading) % 360) / 2;
#endif
CareFree = 1;
}
else CareFree = 0;
 
if(CareFree) {if(FCParam.AxisCoupling1 < 210) FCParam.AxisCoupling1 += 30;}
749,11 → 757,11
IPartNick = 0;
IPartRoll = 0;
StickYaw = 0;
ReadingIntegralGyroYaw = 0;
SetPointYaw = 0;
if(ModelIsFlying == 250)
{
UpdateCompassCourse = 1;
ReadingIntegralGyroYaw = 0;
SetPointYaw = 0;
}
}
else FCFlags |= FCFLAG_FLY; // set fly flag
1891,6 → 1899,7
tmp_int1 = ParamSet.GasMax * STICK_GAIN;
LIMIT_MIN_MAX(YawMixFraction, -(tmp_int1 - GasMixFraction), (tmp_int1 - GasMixFraction));
 
#define ATTENUATE_PD 2
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Nick-Axis
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1898,6 → 1907,9
if(GyroIFactor) IPartNick += PPartNick - StickNick; // I-part for attitude control
else IPartNick += DiffNick; // I-part for head holding
LIMIT_MIN_MAX(IPartNick, -(STICK_GAIN * 16000L), (STICK_GAIN * 16000L));
if(FCParam.UserParam5 > 50)
NickMixFraction = DiffNick/ATTENUATE_PD + (IPartNick / Ki); // PID-controller for nick
else
NickMixFraction = DiffNick + (IPartNick / Ki); // PID-controller for nick
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1907,6 → 1919,9
if(GyroIFactor) IPartRoll += PPartRoll - StickRoll; // I-part for attitude control
else IPartRoll += DiffRoll; // I-part for head holding
LIMIT_MIN_MAX(IPartRoll, -(STICK_GAIN * 16000L), (STICK_GAIN * 16000L));
if(FCParam.UserParam5 > 50)
RollMixFraction = DiffRoll/ATTENUATE_PD + (IPartRoll / Ki); // PID-controller for roll
else
RollMixFraction = DiffRoll + (IPartRoll / Ki); // PID-controller for roll
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/beta/Code Redesign killagreg/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/libfc644.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/main.c
207,7 → 207,8
BLFlags |= BLFLAG_READ_VERSION;
motor_read = 0; // read the first I2C-Data
SendMotorData();
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
timer = SetDelay(500); // set timeout to 0.5 seconds
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
 
printf("\n\rFound BL-Ctrl: ");
timer = SetDelay(4000); // set timeout to 4 seconds
214,13 → 215,13
for(i = 0; i < MAX_MOTORS; i++)
{
SendMotorData();
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
if(Mixer.Motor[i][MIX_GAS] > 0) // ignore BLs that not are not used in the mixer table
{ // wait max 4 sec for the BL-Ctrls to wake up
while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) // while not timeout and motor is not present
{
SendMotorData();
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
}
}
if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
369,13 → 370,19
}
}
#ifdef USE_NAVICTRL
if(NCDataOkay)
if(NCDataOkay > 200)
{
NCDataOkay--;
if(!BeepTime) FCFlags &= ~FCFLAG_SPI_RX_ERR;
}
else // no data from NC
{ // set gps control sticks neutral
{
if(NC_Version.Compatible && BeepModulation == 0xFFFF)
{
BeepTime = 15000;
BeepModulation = 0xA000;
}
// set gps control sticks neutral
GPSStickNick = 0;
GPSStickNick = 0;
FCFlags |= FCFLAG_SPI_RX_ERR;
/beta/Code Redesign killagreg/makefile
6,7 → 6,7
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 79
VERSION_PATCH = 9
VERSION_PATCH = 10
 
VERSION_SERIAL_MAJOR = 11 # Serial Protocol Major Version
VERSION_SERIAL_MINOR = 0 # Serial Protocol Minor Version
/beta/Code Redesign killagreg/twimaster.c
58,6 → 58,7
#include "fc.h"
#include "analog.h"
#include "uart0.h"
#include "timer0.h"
 
volatile uint8_t twi_state = TWI_STATE_MOTOR_TX;
volatile uint8_t dac_channel = 0;
377,6 → 378,7
uint8_t I2C_WriteBLConfig(uint8_t motor)
{
uint8_t i;
static uint16_t timer;
 
if((FCFlags & FCFLAG_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if(motor > MAX_MOTORS) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
390,7 → 392,8
i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1);
if(i != BLConfig.crc) return(BLCONFIG_ERR_CHECKSUM); // bad checksum
 
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
timer = SetDelay(2000);
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
 
// prepare the bitmask
if(!motor) // 0 means all
415,8 → 418,9
do
{
I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
}while(BLConfig_WriteMask); // repeat until the BL config has been sent
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
}while(BLConfig_WriteMask && !CheckDelay(timer)); // repeat until the BL config has been sent
if(BLConfig_WriteMask) return(BLCONFIG_ERR_MOTOR_NOT_EXIST);
return(BLCONFIG_SUCCESS);
}
 
423,6 → 427,7
uint8_t I2C_ReadBLConfig(uint8_t motor)
{
uint8_t i;
uint16_t timer;
 
if((FCFlags & FCFLAG_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if(motor > MAX_MOTORS) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
430,7 → 435,8
if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
if(!(Motor[motor-1].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)) return(BLCONFIG_ERR_HW_NOT_COMPATIBLE); // not a new BL!
 
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
timer = SetDelay(2000);
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
 
// prepare the bitmask
BLConfig_ReadMask = 0x0001<<(motor-1);
451,8 → 457,8
do
{
I2C_Start(TWI_STATE_MOTOR_TX); // start an i2c transmission
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
}while(BLConfig_ReadMask); // repeat until the BL config has been received from all motors
while(!(BLFlags & BLFLAG_TX_COMPLETE) && !CheckDelay(timer)); //wait for complete transfer
}while(BLConfig_ReadMask && !CheckDelay(timer)); // repeat until the BL config has been received from all motors
// validate result
if(BLConfig.Revision != BLCONFIG_REVISION) return (BLCONFIG_ERR_SW_NOT_COMPATIBLE); // bad revison
i = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1);
/beta/Code Redesign killagreg/uart0.c
165,7 → 165,7
" ",
" ",
"I2C-Error ",
" ",
"BL Limit ",
"GPS Nick ", //30
"GPS Roll "
};
/beta/Code Redesign killagreg/version.txt
402,12 → 402,19
0.79f H.Buss 07.5.2010
- Bug im Lageregler -> zurück auf 10Bit Auflösung
 
0.79j S.Pendsa & H.Buss 22.06.2010
- RECEIVER_SPEKTRUM_EXP
0.79k H.Buss
- #define SWITCH_LEARNS_CAREFREE eingeführt
- Piepen, wenn NC-Kommunikation wegfällt
- Da kann man mit UserParameter5 wieder das Verhalten der 0.79b herstellen
 
 
Anpassungen bzgl. V0.79j
G.Stobrawa 24.6.2010
 
Anpassungen bzgl. V0.79f
G.Stobrawa 8.6.2010
 
- Code stärker modularisiert und restrukturiert
- viele Kommentare zur Erklärug eingefügt
- konsequent englische Variablennamen