Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1677 → Rev 1678

/beta/Code Redesign killagreg/capacity.c
69,6 → 69,7
Capacity.ActualCurrent = 0;
Capacity.UsedCapacity = 0;
Capacity.ActualPower = 0;
Capacity.MinOfMaxPWM = 0;
update_timer = SetDelay(CAPACITY_UPDATE_INTERVAL);
}
 
80,7 → 81,7
static uint16_t SubCounter = 0;
static uint16_t CurrentOffset = 0;
static uint32_t SumCurrentOffset = 0;
uint8_t i, NumOfMotors;
uint8_t i, NumOfMotors, MinOfMaxPWM;
 
if(CheckDelay(update_timer))
{
90,6 → 91,7
Current = 0;
SetSum = 0;
NumOfMotors = 0;
MinOfMaxPWM = 255;
for(i = 0; i < MAX_MOTORS; i++)
{
if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
97,8 → 99,10
NumOfMotors++;
Current += (int16_t)(Motor[i].Current);
SetSum += (int16_t)(Motor[i].SetPoint);
if(Motor[i].MaxPWM < MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM;
}
}
Capacity.MinOfMaxPWM = MinOfMaxPWM;
 
if(SetSum == 0) // if all setpoints are 0
{ // determine offsets of motor currents
/beta/Code Redesign killagreg/capacity.h
8,6 → 8,7
uint16_t ActualCurrent; // in 0.1A Steps
uint16_t UsedCapacity; // in mAh
uint16_t ActualPower; // in 0.1W Steps
uint8_t MinOfMaxPWM; // smallest value of all MaxPWM values
} __attribute__((packed)) Capacity_t;
 
extern Capacity_t Capacity;
/beta/Code Redesign killagreg/eeprom.c
127,7 → 127,7
ParamSet.Revision = EEPARAM_REVISION;
if(BoardRelease >= 20)
{
ParamSet.GyroD = 5;
ParamSet.GyroD = 10;
ParamSet.DriftComp = 0;
ParamSet.GyroAccFactor = 27;
ParamSet.AngleTurnOverNick = 78;
234,7 → 234,7
ParamSet.Revision = EEPARAM_REVISION;
if(BoardRelease >= 20)
{
ParamSet.GyroD = 5;
ParamSet.GyroD = 10;
ParamSet.DriftComp = 0;
ParamSet.GyroAccFactor = 27;
ParamSet.AngleTurnOverNick = 78;
341,7 → 341,7
ParamSet.Revision = EEPARAM_REVISION;
if(BoardRelease >= 20)
{
ParamSet.GyroD = 5;
ParamSet.GyroD = 10;
ParamSet.DriftComp = 0;
ParamSet.GyroAccFactor = 27; // Value : 1-64
ParamSet.AngleTurnOverNick = 78;
/beta/Code Redesign killagreg/fc.c
139,7 → 139,7
uint8_t GyroPFactor, GyroIFactor; // the PD factors for the attitude control
uint8_t GyroYawPFactor, GyroYawIFactor; // the PD factors for the yae control
 
int16_t Ki = (10300/2) / 33;
int16_t Ki = 10300 / 33;
 
#define Poti1 Poti[0]
#define Poti2 Poti[1]
646,7 → 646,7
CHK_POTI(FCParam.AxisCouplingYawCorrection,ParamSet.AxisCouplingYawCorrection);
CHK_POTI(FCParam.DynamicStability,ParamSet.DynamicStability);
CHK_POTI(FCParam.ExternalControl,ParamSet.ExternalControl);
Ki = (10300/2) / ( FCParam.IFactor + 1 );
Ki = 10300 / ( FCParam.IFactor + 1 );
 
CHK_POTI(tmp,ParamSet.OrientationModeControl);
if(tmp > 50 && NCDataOkay > 200) CareFree = 1;
989,7 → 989,7
stick_roll = (stick_roll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.StickP) / 4;
stick_roll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.StickD;
 
if(CareFree) // according to start reference
if(CareFree) // according to motor start reference
{
int16_t nick, roll;
//angle = ((540 + ControlHeading * 2 - (YawGyroHeading / GYRO_DEG_FACTOR)) % 360) - 180;
998,8 → 998,9
//sin_h = c_sin_8192(angle)/256; // -32 ... 32
//cos_h = c_cos_8192(angle)/256; // -32 ... 32
// rotate sticks virtually to global reference
StickNick = ((NCRotate_C * nick) + (NCRotate_C * roll))/(32 / 4);
StickRoll = ((NCRotate_C * roll) - (NCRotate_C * nick))/(32 / 4);
StickNick = ((NCRotate_C * nick) + (NCRotate_S * roll))/(32 / 4);
StickRoll = ((NCRotate_C * roll) - (NCRotate_S * nick))/(32 / 4);
 
}
else // body frame (according to ParamSet.OrientationModeControl * 15 in deg)
{
1858,12 → 1859,14
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// all BL-Ctrl connected?
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(MissingMotor)
if(MissingMotor || Capacity.MinOfMaxPWM != 255)
{
// if we are in the lift off condition
if( (ModelIsFlying > 1) && (ModelIsFlying < 50) && (GasMixFraction > 0) )
ModelIsFlying = 1; // keep within lift off condition
GasMixFraction = ParamSet.GasMin * STICK_GAIN; // reduce gas to min to avoid lift of
{
ModelIsFlying = 1; // keep within lift off condition
GasMixFraction = (ParamSet.GasMin + 10) * STICK_GAIN; // reduce gas to min to avoid lift of
}
}
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1909,7 → 1912,7
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Limiter
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tmp_int1 = (int32_t)((int32_t)FCParam.DynamicStability * (int32_t)(GasMixFraction + abs(YawMixFraction) / 2)) / (64/2);
tmp_int1 = (int32_t)((int32_t)FCParam.DynamicStability * (int32_t)(GasMixFraction + abs(YawMixFraction) / 2)) / 64;
LIMIT_MIN_MAX(NickMixFraction, -tmp_int1, tmp_int1);
LIMIT_MIN_MAX(RollMixFraction, -tmp_int1, tmp_int1);
 
1921,8 → 1924,8
int16_t tmp;
if(Mixer.Motor[i][MIX_GAS] > 0) // if gas then mixer
{
if(Mixer.Motor[i][MIX_GAS] == 64) tmp = GasMixFraction * 2;
else tmp = ((int32_t)GasMixFraction * Mixer.Motor[i][MIX_GAS] ) / 32L;
if(Mixer.Motor[i][MIX_GAS] == 64) tmp = GasMixFraction;
else tmp = ((int32_t)GasMixFraction * Mixer.Motor[i][MIX_GAS] ) / 64L;
 
if(Mixer.Motor[i][MIX_NICK] == 64) tmp += NickMixFraction;
else if (Mixer.Motor[i][MIX_NICK] == -64) tmp -= NickMixFraction;
1932,19 → 1935,17
else if(Mixer.Motor[i][MIX_ROLL] == -64) tmp -= RollMixFraction;
else tmp += ((int32_t)RollMixFraction * Mixer.Motor[i][MIX_ROLL]) / 64L;
 
if(Mixer.Motor[i][MIX_YAW] == 64) tmp += 2 * YawMixFraction;
else if(Mixer.Motor[i][MIX_YAW] == -64)tmp -= 2 * YawMixFraction;
else tmp += ((int32_t)YawMixFraction * Mixer.Motor[i][MIX_YAW] ) / 32L;
if(Mixer.Motor[i][MIX_YAW] == 64) tmp += YawMixFraction;
else if(Mixer.Motor[i][MIX_YAW] == -64)tmp -= YawMixFraction;
else tmp += ((int32_t)YawMixFraction * Mixer.Motor[i][MIX_YAW] ) / 64L;
 
/*
// Smoothing
if(tmp > MotorValue[i]) tmp = (MotorValue[i] + tmp) / 2;
else tmp = 2 * tmp - MotorValue[i];
*/
 
LIMIT_MIN_MAX(tmp, 8 * ParamSet.GasMin, 8 * ParamSet.GasMax);
Motor[i].SetPoint = tmp / 8;
Motor[i].SetPointLowerBits = tmp % 8; // remaining bits
LIMIT_MIN_MAX(tmp, 4 * ParamSet.GasMin, 4 * ParamSet.GasMax);
Motor[i].SetPoint = tmp / 4;
Motor[i].SetPointLowerBits = (tmp % 4)<<1; // remaining bits (3 bits total)
MotorValue[i] = tmp;
 
}
/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/makefile
6,7 → 6,7
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 79
VERSION_PATCH = 3
VERSION_PATCH = 5
 
VERSION_SERIAL_MAJOR = 11 # Serial Protocol Major Version
VERSION_SERIAL_MINOR = 0 # Serial Protocol Minor Version
/beta/Code Redesign killagreg/menu.c
257,7 → 257,7
break;
 
case 16:// new BL infos
LCD_printfxy(0,0,"BL Temperature" );
LCD_printfxy(0,0,"BL Temperature", Capacity.MinOfMaxPWM);
for(i = 0; i < 3; i++)
{
j=i<<2;
/beta/Code Redesign killagreg/twimaster.c
267,7 → 267,7
else // old BL version
{
pBuff = (uint8_t*)&(Motor[motor_read].Current);
if(BLFlags & BLFLAG_READ_VERSION) BuffLen = 2; // Current & MaxPwm
if((BLFlags & BLFLAG_READ_VERSION) || (motor_read == motor_read_temperature)) BuffLen = 2; // Current & MaxPwm
else BuffLen = 1; // read Current only
}
if(BuffLen == 1)
425,7 → 425,8
uint8_t i;
 
if((FCFlags & FCFLAG_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if((motor == 0) || (motor > MAX_MOTORS)) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
if(motor > MAX_MOTORS) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
if(motor == 0) return (BLCONFIG_ERR_READ_NOT_POSSIBLE); // motor read any
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!
 
/beta/Code Redesign killagreg/twimaster.h
86,12 → 86,13
void I2C_Reset(void); // Reset I2C
 
 
#define BLCONFIG_SUCCESS 0
#define BLCONFIG_ERR_MOTOR_RUNNING 1
#define BLCONFIG_ERR_MOTOR_NOT_EXIST 2
#define BLCONFIG_ERR_HW_NOT_COMPATIBLE 3
#define BLCONFIG_ERR_SW_NOT_COMPATIBLE 4
#define BLCONFIG_ERR_CHECKSUM 5
#define BLCONFIG_SUCCESS 0
#define BLCONFIG_ERR_MOTOR_RUNNING 1
#define BLCONFIG_ERR_MOTOR_NOT_EXIST 2
#define BLCONFIG_ERR_HW_NOT_COMPATIBLE 3
#define BLCONFIG_ERR_SW_NOT_COMPATIBLE 4
#define BLCONFIG_ERR_CHECKSUM 5
#define BLCONFIG_ERR_READ_NOT_POSSIBLE 6
 
uint8_t I2C_WriteBLConfig(uint8_t motor);
uint8_t I2C_ReadBLConfig(uint8_t motor);
/beta/Code Redesign killagreg/uart0.c
608,11 → 608,10
Debug("Reading BL %d", pRxData[0]);
// try to read BL configuration
tempchar2 = I2C_ReadBLConfig(pRxData[0]);
if(tempchar2 == BLCONFIG_SUCCESS)
{
while(!txd_complete); // wait for previous frame to be sent
SendOutData('U', FC_ADDRESS, 2, pRxData[0], 1, &BLConfig, sizeof(BLConfig_t));
}
if(tempchar2 == BLCONFIG_SUCCESS) tempchar1 = 1;
else tempchar1 = 0;
while(!txd_complete); // wait for previous frame to be sent
SendOutData('U', FC_ADDRESS, 4, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), &pRxData[0], 1, &BLConfig, sizeof(BLConfig_t));
break;
 
case 'w': // write BL parameter
/beta/Code Redesign killagreg/version.txt
395,12 → 395,19
 
0.79d H. Buss 31.5.2010
- Freie Belegung der "Vorne"-Richtung
0.79e H.Buss 05.6.2010
- MotorSmooth auf UserParameter5
 
0.79f H.Buss 07.5.2010
- Bug im Lageregler -> zurück auf 10Bit Auflösung
 
 
Anpassungen bzgl. V0.78f
G.Stobrawa 23.3.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