Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 706 → Rev 707

/branches/V0.68d Code Redesign killagreg/eeprom.c
31,7 → 31,7
{
ParamSet.ChannelAssignment[CH_PITCH] = 1;
ParamSet.ChannelAssignment[CH_ROLL] = 2;
ParamSet.ChannelAssignment[CH_GAS] = 3;
ParamSet.ChannelAssignment[CH_THRUST] = 3;
ParamSet.ChannelAssignment[CH_YAW] = 4;
ParamSet.ChannelAssignment[CH_POTI1] = 5;
ParamSet.ChannelAssignment[CH_POTI2] = 6;
38,7 → 38,7
ParamSet.ChannelAssignment[CH_POTI3] = 7;
ParamSet.ChannelAssignment[CH_POTI4] = 8;
ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE;//CFG_HEIGHT_CONTROL | /*CFG_HEIGHT_SWITCH |*/ CFG_COMPASS_ACTIVE | CFG_COMPASS_FIX;//0x01;
ParamSet.Hight_MinGas = 30;
ParamSet.Hight_MinThrust = 30;
ParamSet.MaxHight = 251; // Wert : 0-250 251 -> Poti1
ParamSet.Hight_P = 10; // Wert : 0-32
ParamSet.AirPressure_D = 30; // Wert : 0-250
47,15 → 47,15
ParamSet.Stick_P = 4; //2 // Wert : 1-6
ParamSet.Stick_D = 8; //8 // Wert : 0-64
ParamSet.Yaw_P = 12; // Wert : 1-20
ParamSet.Gas_Min = 15; // Wert : 0-32
ParamSet.Gas_Max = 250; // Wert : 33-250
ParamSet.Trust_Min = 15; // Wert : 0-32
ParamSet.Trust_Max = 250; // Wert : 33-250
ParamSet.GyroAccFaktor = 30; // Wert : 1-64
ParamSet.CompassYawEffect = 128; // Wert : 0-250
ParamSet.Gyro_P = 80; // Wert : 0-250
ParamSet.Gyro_I = 150; // Wert : 0-250
ParamSet.LowVoltageWarning = 94; // Wert : 0-250
ParamSet.EmergencyGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyGasDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyGas geschaltet wird, wg. Rx-Problemen
ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyThrustDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen
ParamSet.UfoArrangement = 0; // X oder + Formation
ParamSet.I_Factor = 32;
ParamSet.UserParam1 = 32 * 4; //zur freien Verwendung
72,7 → 72,7
ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchRefresh = 5;
ParamSet.LoopGasLimit = 50;
ParamSet.LoopThrustLimit = 50;
ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag
ParamSet.LoopHysteresis = 50;
ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
94,7 → 94,7
{
ParamSet.ChannelAssignment[CH_PITCH] = 1;
ParamSet.ChannelAssignment[CH_ROLL] = 2;
ParamSet.ChannelAssignment[CH_GAS] = 3;
ParamSet.ChannelAssignment[CH_THRUST] = 3;
ParamSet.ChannelAssignment[CH_YAW] = 4;
ParamSet.ChannelAssignment[CH_POTI1] = 5;
ParamSet.ChannelAssignment[CH_POTI2] = 6;
101,7 → 101,7
ParamSet.ChannelAssignment[CH_POTI3] = 7;
ParamSet.ChannelAssignment[CH_POTI4] = 8;
ParamSet.GlobalConfig = CFG_AXIS_COUPLING_ACTIVE;//CFG_HEIGHT_CONTROL | /*CFG_HEIGHT_SWITCH |*/ CFG_COMPASS_ACTIVE;//0x01;
ParamSet.Hight_MinGas = 30;
ParamSet.Hight_MinThrust = 30;
ParamSet.MaxHight = 251; // Wert : 0-250 251 -> Poti1
ParamSet.Hight_P = 10; // Wert : 0-32
ParamSet.AirPressure_D = 30; // Wert : 0-250
110,15 → 110,15
ParamSet.Stick_P = 3; //2 // Wert : 1-6
ParamSet.Stick_D = 4; //8 // Wert : 0-64
ParamSet.Yaw_P = 6; // Wert : 1-20
ParamSet.Gas_Min = 15; // Wert : 0-32
ParamSet.Gas_Max = 250; // Wert : 33-250
ParamSet.Trust_Min = 15; // Wert : 0-32
ParamSet.Trust_Max = 250; // Wert : 33-250
ParamSet.GyroAccFaktor = 30; // Wert : 1-64
ParamSet.CompassYawEffect = 128; // Wert : 0-250
ParamSet.Gyro_P = 80; // Wert : 0-250
ParamSet.Gyro_I = 120; // Wert : 0-250
ParamSet.LowVoltageWarning = 94; // Wert : 0-250
ParamSet.EmergencyGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyGasDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyGas geschaltet wird, wg. Rx-Problemen
ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyThrustDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen
ParamSet.UfoArrangement = 0; // X oder + Formation
ParamSet.I_Factor = 32;
ParamSet.UserParam1 = 20 * 4; // zur freien Verwendung
135,7 → 135,7
ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchRefresh = 5;
ParamSet.LoopGasLimit = 50;
ParamSet.LoopThrustLimit = 50;
ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag
ParamSet.LoopHysteresis = 50;
ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts
157,7 → 157,7
{
ParamSet.ChannelAssignment[CH_PITCH] = 1;
ParamSet.ChannelAssignment[CH_ROLL] = 2;
ParamSet.ChannelAssignment[CH_GAS] = 3;
ParamSet.ChannelAssignment[CH_THRUST] = 3;
ParamSet.ChannelAssignment[CH_YAW] = 4;
ParamSet.ChannelAssignment[CH_POTI1] = 5;
ParamSet.ChannelAssignment[CH_POTI2] = 6;
164,7 → 164,7
ParamSet.ChannelAssignment[CH_POTI3] = 7;
ParamSet.ChannelAssignment[CH_POTI4] = 8;
ParamSet.GlobalConfig = CFG_ROTARY_RATE_LIMITER | CFG_AXIS_COUPLING_ACTIVE;///*CFG_HEIGHT_SWITCH |*/ CFG_COMPASS_ACTIVE;//0x01;
ParamSet.Hight_MinGas = 30;
ParamSet.Hight_MinThrust = 30;
ParamSet.MaxHight = 251; // Wert : 0-250 251 -> Poti1
ParamSet.Hight_P = 10; // Wert : 0-32
ParamSet.AirPressure_D = 30; // Wert : 0-250
173,15 → 173,15
ParamSet.Stick_P = 2; //2 // Wert : 1-6
ParamSet.Stick_D = 4; //8 // Wert : 0-64
ParamSet.Yaw_P = 6; // Wert : 1-20
ParamSet.Gas_Min = 15; // Wert : 0-32
ParamSet.Gas_Max = 250; // Wert : 33-250
ParamSet.Trust_Min = 15; // Wert : 0-32
ParamSet.Trust_Max = 250; // Wert : 33-250
ParamSet.GyroAccFaktor = 30; // Wert : 1-64
ParamSet.CompassYawEffect = 128; // Wert : 0-250
ParamSet.Gyro_P = 100; // Wert : 0-250
ParamSet.Gyro_I = 140; // Wert : 0-250
ParamSet.LowVoltageWarning = 94; // Wert : 0-250
ParamSet.EmergencyGas = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyGasDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyGas geschaltet wird, wg. Rx-Problemen
ParamSet.EmergencyThrust = 35; // Wert : 0-250 // Gaswert bei Empangsverlust
ParamSet.EmergencyThrustDuration = 20; // Wert : 0-250 // Zeit bis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen
ParamSet.UfoArrangement = 0; // X oder + Formation
ParamSet.I_Factor = 16;
ParamSet.UserParam1 = 20 * 4; // zur freien Verwendung
198,7 → 198,7
ParamSet.ServoPitchMin = 50; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchMax = 150; // Wert : 0-250 // Anschlag
ParamSet.ServoPitchRefresh = 5;
ParamSet.LoopGasLimit = 50;
ParamSet.LoopThrustLimit = 50;
ParamSet.LoopThreshold = 90; // Wert: 0-250 Schwelle für Stickausschlag
ParamSet.LoopHysteresis = 50;
ParamSet.LoopConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts
/branches/V0.68d Code Redesign killagreg/eeprom.h
39,13 → 39,13
 
// defines for lookup mk_param_struct.ChannelAssignment
#define CH_PITCH 0
#define CH_ROLL 1
#define CH_GAS 2
#define CH_YAW 3
#define CH_POTI1 4
#define CH_POTI2 5
#define CH_POTI3 6
#define CH_POTI4 7
#define CH_ROLL 1
#define CH_THRUST 2
#define CH_YAW 3
#define CH_POTI1 4
#define CH_POTI2 5
#define CH_POTI3 6
#define CH_POTI4 7
 
#define EEPARAM_VERSION 69 // is count up, if EE_Paramater stucture has changed (compatibility)
 
54,7 → 54,7
{
uint8_t ChannelAssignment[8]; // see upper defines for details
uint8_t GlobalConfig; // see upper defines for bitcoding
uint8_t Hight_MinGas; // Wert : 0-100
uint8_t Hight_MinThrust; // Wert : 0-100
uint8_t AirPressure_D; // Wert : 0-250
uint8_t MaxHight; // Wert : 0-32
uint8_t Hight_P; // Wert : 0-32
63,15 → 63,15
uint8_t Stick_P; // Wert : 1-6
uint8_t Stick_D; // Wert : 0-64
uint8_t Yaw_P; // Wert : 1-20
uint8_t Gas_Min; // Wert : 0-32
uint8_t Gas_Max; // Wert : 33-250
uint8_t Trust_Min; // Wert : 0-32
uint8_t Trust_Max; // Wert : 33-250
uint8_t GyroAccFaktor; // Wert : 1-64
uint8_t CompassYawEffect; // Wert : 0-32
uint8_t Gyro_P; // Wert : 10-250
uint8_t Gyro_I; // Wert : 0-250
uint8_t LowVoltageWarning; // Wert : 0-250
uint8_t EmergencyGas; // Wert : 0-250 //Gaswert bei Empängsverlust
uint8_t EmergencyGasDuration; // Wert : 0-250 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen
uint8_t EmergencyThrust; // Wert : 0-250 //Gaswert bei Empängsverlust
uint8_t EmergencyThrustDuration; // Wert : 0-250 // Zeitbis auf EmergencyThrust geschaltet wird, wg. Rx-Problemen
uint8_t UfoArrangement; // X oder + Formation
uint8_t I_Factor; // Wert : 0-250
uint8_t UserParam1; // Wert : 0-250
83,7 → 83,7
uint8_t ServoPitchMin; // Wert : 0-250 // Anschlag
uint8_t ServoPitchMax; // Wert : 0-250 // Anschlag
uint8_t ServoPitchRefresh; //
uint8_t LoopGasLimit; // Wert: 0-250 max. Gas während Looping
uint8_t LoopThrustLimit; // Wert: 0-250 max. Gas während Looping
uint8_t LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag
uint8_t LoopHysteresis; // Wert: 0-250 Hysterese für Stickausschlag
uint8_t Yaw_PosFeedback; // Wert: 0-250 Faktor, mit dem Yaw die Achsen Roll und Pitch koppelt (PitchRollMitkopplung)
/branches/V0.68d Code Redesign killagreg/fc.c
115,7 → 115,7
volatile uint8_t Motor_Front, Motor_Rear, Motor_Right, Motor_Left;
 
// stick values derived by rc channels readings
int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickGas = 0;
int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickThrust = 0;
// stick values derived by uart inputs
int16_t ExternStickPitch = 0, ExternStickRoll = 0, ExternStickYaw = 0, ExternHightValue = -20;
 
417,7 → 417,7
CHK_POTI(FCParam.UserParam7,ParamSet.UserParam7,0,255);
CHK_POTI(FCParam.UserParam8,ParamSet.UserParam8,0,255);
CHK_POTI(FCParam.ServoPitchControl,ParamSet.ServoPitchControl,0,255);
CHK_POTI(FCParam.LoopGasLimit,ParamSet.LoopGasLimit,0,255);
CHK_POTI(FCParam.LoopThrustLimit,ParamSet.LoopThrustLimit,0,255);
CHK_POTI(FCParam.Yaw_PosFeedback,ParamSet.Yaw_PosFeedback,0,255);
CHK_POTI(FCParam.Yaw_NegFeedback,ParamSet.Yaw_NegFeedback,0,255);
CHK_POTI(FCParam.DynamicStability,ParamSet.DynamicStability,0,255);
432,7 → 432,7
void MotorRegler(void)
{
int16_t MotorValue, pd_ergebnis, h, tmp_int;
int16_t YawMixingFraction, GasMixingFraction;
int16_t YawMixingFraction, ThrustMixingFraction;
static int32_t SumPitch = 0, SumRoll = 0;
static int32_t SetPointYaw = 0, tmp_long, tmp_long2;
static int32_t IntegralErrorPitch = 0;
451,10 → 451,10
 
GRN_ON;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// determine GAS value
// determine thrust value
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GasMixingFraction = StickGas;
if(GasMixingFraction < 0) GasMixingFraction = 0;
ThrustMixingFraction = StickThrust;
if(ThrustMixingFraction < 0) ThrustMixingFraction = 0;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// RC-signal is bad
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
482,7 → 482,7
ROT_ON; // set red led
if(Modell_Is_Flying > 2000) // wahrscheinlich in der Luft --> langsam absenken
{
GasMixingFraction = ParamSet.EmergencyGas; // set emergency gas
ThrustMixingFraction = ParamSet.EmergencyThrust; // set emergency thrust
EmergencyLanding = 1; // enable emergency landing
// set neutral rc inputs
PPM_diff[ParamSet.ChannelAssignment[CH_PITCH]] = 0;
501,12 → 501,12
{
EmergencyLanding = 0; // switch off emergency landing if RC-signal is okay
// reset emergency timer
RcLostTimer = ParamSet.EmergencyGasDuration * 50;
if(GasMixingFraction > 40)
RcLostTimer = ParamSet.EmergencyThrustDuration * 50;
if(ThrustMixingFraction > 40)
{
if(Modell_Is_Flying < 0xFFFF) Modell_Is_Flying++;
}
if((Modell_Is_Flying < 200) || (GasMixingFraction < 40))
if((Modell_Is_Flying < 200) || (ThrustMixingFraction < 40))
{
SumPitch = 0;
SumRoll = 0;
514,7 → 514,7
Reading_IntegralYaw2 = 0;
}
// if motors are off and the thrust stick is in the upper position
if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && MotorsOn == 0)
if((PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] > 80) && MotorsOn == 0)
{
// and if the yaw stick is in the leftmost position
if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 75)
581,7 → 581,7
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// thrust stick is down
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(PPM_in[ParamSet.ChannelAssignment[CH_GAS]] < -85)
if(PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] < -85)
{
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// and yaw stick is rightmost --> start motors
635,9 → 635,9
StickRoll = (StickRoll * 3 + PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_P) / 4;
StickRoll += PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] * ParamSet.Stick_D;
 
// direct mapping of yaw and gas
// direct mapping of yaw and thrust
StickYaw = -PPM_in[ParamSet.ChannelAssignment[CH_YAW]];
StickGas = PPM_in[ParamSet.ChannelAssignment[CH_GAS]] + 120;// shift to positive numbers
StickThrust = PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] + 120;// shift to positive numbers
 
// update max stick positions for pitch and roll
if(abs(PPM_in[ParamSet.ChannelAssignment[CH_PITCH]]) > MaxStickPitch)
686,7 → 686,7
StickRoll += (int16_t) ExternControl.Roll * (int16_t) ParamSet.Stick_P;
StickYaw += ExternControl.Yaw;
ExternHightValue = (int16_t) ExternControl.Hight * (int16_t)ParamSet.Hight_Gain;
if(ExternControl.Gas < StickGas) StickGas = ExternControl.Gas;
if(ExternControl.Thrust < StickThrust) StickThrust = ExternControl.Thrust;
}
// disable I part of gyro control feedback
if(ParamSet.GlobalConfig & CFG_HEADING_HOLD) Gyro_I_Factor = 0;
733,19 → 733,19
 
if(Looping_Left || Looping_Right) Looping_Roll = 1; else Looping_Roll = 0;
if(Looping_Top || Looping_Down) {Looping_Pitch = 1; Looping_Roll = 0; Looping_Left = 0; Looping_Right = 0;} else Looping_Pitch = 0;
} // End of new RC values
} // End of new RC-Values or Emergency Landing
 
 
if(Looping_Roll) BeepTime = 100;
if(Looping_Roll || Looping_Pitch)
{
if(GasMixingFraction > ParamSet.LoopGasLimit) GasMixingFraction = ParamSet.LoopGasLimit;
if(ThrustMixingFraction > ParamSet.LoopThrustLimit) ThrustMixingFraction = ParamSet.LoopThrustLimit;
}
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// in case of emergency landing
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
// set all inputs to save values
if(EmergencyLanding)
{
StickYaw = 0;
804,11 → 804,11
tmp_long2 /= 3;
}
 
#define AUSGLEICH 32
if(tmp_long > AUSGLEICH) tmp_long = AUSGLEICH;
if(tmp_long < -AUSGLEICH) tmp_long =-AUSGLEICH;
if(tmp_long2 > AUSGLEICH) tmp_long2 = AUSGLEICH;
if(tmp_long2 <-AUSGLEICH) tmp_long2 =-AUSGLEICH;
#define BALANCE 32
if(tmp_long > BALANCE) tmp_long = BALANCE;
if(tmp_long < -BALANCE) tmp_long =-BALANCE;
if(tmp_long2 > BALANCE) tmp_long2 = BALANCE;
if(tmp_long2 <-BALANCE) tmp_long2 =-BALANCE;
 
Reading_IntegralPitch -= tmp_long;
Reading_IntegralRoll -= tmp_long2;
1051,7 → 1051,7
// DebugOut.Analog[10] = FCParam.Gyro_I;
// DebugOut.Analog[10] = ParamSet.Gyro_I;
// DebugOut.Analog[9] = CompassOffCourse;
// DebugOut.Analog[10] = GasMixingFraction;
// DebugOut.Analog[10] = ThrustMixingFraction;
// DebugOut.Analog[3] = HightD * 32;
// DebugOut.Analog[4] = hoehenregler;
}
1110,7 → 1110,7
h = ReadingHight;
if((h > SetPointHight) && HightControlActive) // zu hoch --> drosseln
{ h = ((h - SetPointHight) * (int) FCParam.Hight_P) / 16; // Differenz bestimmen --> P-Anteil
h = GasMixingFraction - h; // vom Gas abziehen
h = ThrustMixingFraction - h; // vom Gas abziehen
h -= (HightD * FCParam.AirPressure_D)/8; // D-Anteil
tmp_int = ((Reading_Integral_Top / 512) * (signed long) FCParam.Hight_ACC_Effect) / 32;
if(tmp_int > 50) tmp_int = 50;
1117,20 → 1117,20
else if(tmp_int < -50) tmp_int = -50;
h -= tmp_int;
hoehenregler = (hoehenregler*15 + h) / 16;
if(hoehenregler < ParamSet.Hight_MinGas) // nicht unter MIN
if(hoehenregler < ParamSet.Hight_MinThrust) // nicht unter MIN
{
if(GasMixingFraction >= ParamSet.Hight_MinGas) hoehenregler = ParamSet.Hight_MinGas;
if(GasMixingFraction < ParamSet.Hight_MinGas) hoehenregler = GasMixingFraction;
if(ThrustMixingFraction >= ParamSet.Hight_MinThrust) hoehenregler = ParamSet.Hight_MinThrust;
if(ThrustMixingFraction < ParamSet.Hight_MinThrust) hoehenregler = ThrustMixingFraction;
}
if(hoehenregler > GasMixingFraction) hoehenregler = GasMixingFraction; // nicht mehr als Gas
GasMixingFraction = hoehenregler;
if(hoehenregler > ThrustMixingFraction) hoehenregler = ThrustMixingFraction; // nicht mehr als Gas
ThrustMixingFraction = hoehenregler;
}
}
if(GasMixingFraction > ParamSet.Gas_Max - 20) GasMixingFraction = ParamSet.Gas_Max - 20;
if(ThrustMixingFraction > ParamSet.Trust_Max - 20) ThrustMixingFraction = ParamSet.Trust_Max - 20;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Mischer und PI-Regler
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DebugOut.Analog[7] = GasMixingFraction;
DebugOut.Analog[7] = ThrustMixingFraction;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Gier-Anteil
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1138,12 → 1138,12
YawMixingFraction = ReadingYaw - SetPointYaw; // Regler für Gier
// YawMixingFraction = 0;
 
if(YawMixingFraction > (GasMixingFraction / 2)) YawMixingFraction = GasMixingFraction / 2;
if(YawMixingFraction < -(GasMixingFraction / 2)) YawMixingFraction = -(GasMixingFraction / 2);
if(YawMixingFraction > ((ParamSet.Gas_Max - GasMixingFraction))) YawMixingFraction = ((ParamSet.Gas_Max - GasMixingFraction));
if(YawMixingFraction < -((ParamSet.Gas_Max - GasMixingFraction))) YawMixingFraction = -((ParamSet.Gas_Max - GasMixingFraction));
if(YawMixingFraction > (ThrustMixingFraction / 2)) YawMixingFraction = ThrustMixingFraction / 2;
if(YawMixingFraction < -(ThrustMixingFraction / 2)) YawMixingFraction = -(ThrustMixingFraction / 2);
if(YawMixingFraction > ((ParamSet.Trust_Max - ThrustMixingFraction))) YawMixingFraction = ((ParamSet.Trust_Max - ThrustMixingFraction));
if(YawMixingFraction < -((ParamSet.Trust_Max - ThrustMixingFraction))) YawMixingFraction = -((ParamSet.Trust_Max - ThrustMixingFraction));
 
if(GasMixingFraction < 20) YawMixingFraction = 0;
if(ThrustMixingFraction < 20) YawMixingFraction = 0;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Pitch-Achse
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1154,20 → 1154,20
if(SumPitch < -16000) SumPitch = -16000;
pd_ergebnis = DiffPitch + Ki * SumPitch; // PI-Regler für Pitch
// Motor Vorn
tmp_int = (long)((long)FCParam.DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
tmp_int = (long)((long)FCParam.DynamicStability * (long)(ThrustMixingFraction + abs(YawMixingFraction)/2)) / 64;
if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
 
MotorValue = GasMixingFraction + pd_ergebnis + YawMixingFraction; // Mischer
MotorValue = ThrustMixingFraction + pd_ergebnis + YawMixingFraction; // Mischer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Gas_Max) MotorValue = ParamSet.Gas_Max;
if (MotorValue < ParamSet.Gas_Min) MotorValue = ParamSet.Gas_Min;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Front = MotorValue;
// Motor Heck
MotorValue = GasMixingFraction - pd_ergebnis + YawMixingFraction;
MotorValue = ThrustMixingFraction - pd_ergebnis + YawMixingFraction;
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Gas_Max) MotorValue = ParamSet.Gas_Max;
if (MotorValue < ParamSet.Gas_Min) MotorValue = ParamSet.Gas_Min;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Rear = MotorValue;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Roll-Achse
1178,23 → 1178,23
if(SumRoll > 16000) SumRoll = 16000;
if(SumRoll < -16000) SumRoll = -16000;
pd_ergebnis = DiffRoll + Ki * SumRoll; // PI-Regler für Roll
tmp_int = (long)((long)FCParam.DynamicStability * (long)(GasMixingFraction + abs(YawMixingFraction)/2)) / 64;
tmp_int = (long)((long)FCParam.DynamicStability * (long)(ThrustMixingFraction + abs(YawMixingFraction)/2)) / 64;
if(pd_ergebnis > tmp_int) pd_ergebnis = tmp_int;
if(pd_ergebnis < -tmp_int) pd_ergebnis = -tmp_int;
// Motor Links
MotorValue = GasMixingFraction + pd_ergebnis - YawMixingFraction;
MotorValue = ThrustMixingFraction + pd_ergebnis - YawMixingFraction;
#define GRENZE Poti1
 
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Gas_Max) MotorValue = ParamSet.Gas_Max;
if (MotorValue < ParamSet.Gas_Min) MotorValue = ParamSet.Gas_Min;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Left = MotorValue;
// Motor Rechts
MotorValue = GasMixingFraction - pd_ergebnis - YawMixingFraction;
MotorValue = ThrustMixingFraction - pd_ergebnis - YawMixingFraction;
 
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Gas_Max) MotorValue = ParamSet.Gas_Max;
if (MotorValue < ParamSet.Gas_Min) MotorValue = ParamSet.Gas_Min;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Right = MotorValue;
// +++++++++++++++++++++++++++++++++++++++++++++++
}
/branches/V0.68d Code Redesign killagreg/fc.h
25,7 → 25,7
uint8_t UserParam7;
uint8_t UserParam8;
uint8_t ServoPitchControl;
uint8_t LoopGasLimit;
uint8_t LoopThrustLimit;
uint8_t Yaw_PosFeedback;
uint8_t Yaw_NegFeedback;
uint8_t DynamicStability;
/branches/V0.68d Code Redesign killagreg/main.c
109,7 → 109,7
 
BeepTime = 2000;
 
PPM_in[CH_GAS] = 0;
PPM_in[CH_THRUST] = 0;
StickYaw = 0;
StickRoll = 0;
StickPitch = 0;
150,7 → 150,7
while(!CheckDelay(timer));
 
//Compass calibration?
if(PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 100 && PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 100)
if(PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] > 100 && PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 100)
{
printf("\n\rCalibrating Compass");
MM3_calibrate();
/branches/V0.68d Code Redesign killagreg/menu.c
117,7 → 117,7
break;
case 4:// Remote Control Mapping Menu Item
LCD_printfxy(0,0,"Pi:%4i Ro:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_PITCH]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]);
LCD_printfxy(0,1,"Gs:%4i Ya:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_GAS]],PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
LCD_printfxy(0,1,"Gs:%4i Ya:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_THRUST]],PPM_in[ParamSet.ChannelAssignment[CH_YAW]]);
LCD_printfxy(0,2,"P1:%4i P2:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]],PPM_in[ParamSet.ChannelAssignment[CH_POTI2]]);
LCD_printfxy(0,3,"P3:%4i P4:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]],PPM_in[ParamSet.ChannelAssignment[CH_POTI4]]);
break;
167,7 → 167,7
case 11://Extern Control
LCD_printfxy(0,0,"ExternControl " );
LCD_printfxy(0,1,"Pi:%4i Ro:%4i ",ExternControl.Pitch, ExternControl.Roll);
LCD_printfxy(0,2,"Gs:%4i Ya:%4i ",ExternControl.Gas, ExternControl.Yaw);
LCD_printfxy(0,2,"Gs:%4i Ya:%4i ",ExternControl.Thrust, ExternControl.Yaw);
LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Hight, ExternControl.Config);
break;
case 12:// MM3 Kompass
/branches/V0.68d Code Redesign killagreg/mm3.c
236,8 → 236,8
timer = SetDelay(10);
while(!CheckDelay(timer));
 
// If Gas is less than 100, stop calibration with a delay of 0.5 seconds
if (PPM_in[ParamSet.ChannelAssignment[CH_GAS]] < 100) measurement--;
// If thrust is less than 100, stop calibration with a delay of 0.5 seconds
if (PPM_in[ParamSet.ChannelAssignment[CH_THRUST]] < 100) measurement--;
}
 
// Rage of all axis
/branches/V0.68d Code Redesign killagreg/uart.c
53,7 → 53,7
"GyroYaw ",
"ReadingHight ", //5
"AccZ ",
"Gas ",
"Thrust ",
"CompassHeading ",
"Voltage ",
"Receiver Level ", //10
/branches/V0.68d Code Redesign killagreg/uart.h
55,7 → 55,7
int8_t Pitch;
int8_t Roll;
int8_t Yaw;
uint8_t Gas;
uint8_t Thrust;
int8_t Hight;
uint8_t free;
uint8_t Frame;