Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 850 → Rev 898

/branches/V0.68d CRK HexaLotte/GPS.c
134,8 → 134,8
GPSPosDev_East *= cos_target_latitude;
GPSPosDev_East /= 8192;
 
DebugOut.Analog[12] = GPSPosDev_North;
DebugOut.Analog[13] = GPSPosDev_East;
//DebugOut.Analog[12] = GPSPosDev_North;
//DebugOut.Analog[13] = GPSPosDev_East;
//DebugOut.Analog[12] = GPSInfo.velnorth;
//DebugOut.Analog[13] = GPSInfo.veleast;
}
375,7 → 375,7
GPSInfo.status = PROCESSED;
break;
} // eof GPSInfo.status
DebugOut.Analog[14] = GPS_Pitch;
DebugOut.Analog[15] = GPS_Roll;
//DebugOut.Analog[14] = GPS_Pitch;
//DebugOut.Analog[15] = GPS_Roll;
}
 
/branches/V0.68d CRK HexaLotte/fc.c
118,7 → 118,7
int16_t Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0, Poti5 = 0, Poti6 = 0, Poti7 = 0, Poti8 = 0;
 
// setpoints for motors
volatile uint8_t Motor_Front, Motor_Rear, Motor_Right, Motor_Left;
volatile uint8_t Motor_FrontLeft, Motor_FrontRight, Motor_RearLeft, Motor_RearRight, Motor_Right, Motor_Left;
 
// stick values derived by rc channels readings
int16_t StickPitch = 0, StickRoll = 0, StickYaw = 0, StickThrust = 0;
359,21 → 359,25
{
if(MOTOR_OFF || !MotorsOn)
{
Motor_Rear = 0;
Motor_Front = 0;
Motor_RearLeft = 0;
Motor_RearRight = 0;
Motor_FrontLeft = 0;
Motor_FrontRight = 0;
Motor_Right = 0;
Motor_Left = 0;
if(MotorTest[0]) Motor_Front = MotorTest[0];
if(MotorTest[1]) Motor_Rear = MotorTest[1];
if(MotorTest[0]) Motor_FrontLeft = Motor_FrontRight = MotorTest[0];
if(MotorTest[1]) Motor_RearLeft = Motor_RearRight = MotorTest[1];
if(MotorTest[2]) Motor_Left = MotorTest[2];
if(MotorTest[3]) Motor_Right = MotorTest[3];
}
 
//DebugOut.Analog[12] = Motor_Front;
//DebugOut.Analog[13] = Motor_Rear;
//DebugOut.Analog[14] = Motor_Left;
//DebugOut.Analog[15] = Motor_Right;
 
DebugOut.Analog[12] = Motor_FrontLeft;
DebugOut.Analog[13] = Motor_RearRight;
DebugOut.Analog[14] = Motor_FrontRight;
DebugOut.Analog[15] = Motor_RearLeft;
DebugOut.Analog[16] = Motor_Left;
DebugOut.Analog[17] = Motor_Right;
//Start I2C Interrupt Mode
twi_state = 0;
motor = 0;
424,7 → 428,7
void MotorControl(void)
{
int16_t MotorValue, pd_result, h, tmp_int;
int16_t YawMixFraction, ThrustMixFraction;
int16_t YawMixFraction, ThrustMixFraction, PitchMixFraction, RollMixFraction;
static int32_t SumPitch = 0, SumRoll = 0;
static int32_t SetPointYaw = 0;
static int32_t IntegralErrorPitch = 0;
887,7 → 891,7
Reading_IntegralGyroRoll2 -= IntegralErrorRoll;
 
 
DebugOut.Analog[17] = IntegralAccPitch / 26;
// DebugOut.Analog[17] = IntegralAccPitch / 26;
DebugOut.Analog[18] = IntegralAccRoll / 26;
DebugOut.Analog[19] = IntegralErrorPitch;// / 26;
DebugOut.Analog[20] = IntegralErrorRoll;// / 26;
1091,7 → 1095,7
DebugOut.Analog[9] = UBat;
DebugOut.Analog[10] = RC_Quality;
//DebugOut.Analog[11] = RC_Quality;
DebugOut.Analog[16] = Mean_AccTop;
//DebugOut.Analog[16] = Mean_AccTop;
 
/* DebugOut.Analog[16] = motor_rx[0];
DebugOut.Analog[17] = motor_rx[1];
1199,6 → 1203,7
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Mixer and PI-Controller
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
DebugOut.Analog[7] = ThrustMixFraction;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Yaw-Fraction
1211,6 → 1216,7
if(YawMixFraction > ((ParamSet.Trust_Max - ThrustMixFraction))) YawMixFraction = ((ParamSet.Trust_Max - ThrustMixFraction));
if(YawMixFraction < -((ParamSet.Trust_Max - ThrustMixFraction))) YawMixFraction = -((ParamSet.Trust_Max - ThrustMixFraction));
if(ThrustMixFraction < 20) YawMixFraction = 0;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Pitch-Axis
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1224,20 → 1230,9
tmp_int = (int32_t)((int32_t)FCParam.DynamicStability * (int32_t)(ThrustMixFraction + abs(YawMixFraction)/2)) / 64;
if(pd_result > tmp_int) pd_result = tmp_int;
if(pd_result < -tmp_int) pd_result = -tmp_int;
 
// Motor Front
MotorValue = ThrustMixFraction + pd_result + YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Front = MotorValue;
 
// Motor Rear
MotorValue = ThrustMixFraction - pd_result + YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Rear = MotorValue;
PitchMixFraction = pd_result;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Roll-Axis
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1251,15 → 1246,62
if(pd_result > tmp_int) pd_result = tmp_int;
if(pd_result < -tmp_int) pd_result = -tmp_int;
 
RollMixFraction = pd_result;
 
// Calculate Motor Mixes
// Motor FrontLeft
MotorValue = ThrustMixFraction
+ PitchMixFraction
+ RollMixFraction/2
- YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_FrontLeft = MotorValue;
 
// Motor FrontRight
MotorValue = ThrustMixFraction
+ PitchMixFraction
- RollMixFraction/2
+ YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_FrontRight = MotorValue;
 
// Motor RearLeft
MotorValue = ThrustMixFraction
- PitchMixFraction
+ RollMixFraction/2
- YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_RearLeft = MotorValue;
// Motor RearRight
MotorValue = ThrustMixFraction
- PitchMixFraction
- RollMixFraction/2
+ YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_RearRight= MotorValue;
// Motor Left
MotorValue = ThrustMixFraction + pd_result - YawMixFraction; // Mixer
MotorValue = ThrustMixFraction
+ RollMixFraction
+ YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
Motor_Left = MotorValue;
 
// Motor Right
MotorValue = ThrustMixFraction - pd_result - YawMixFraction; // Mixer
// Motor Right
MotorValue = ThrustMixFraction
- RollMixFraction
- YawMixFraction; // Mixer
if ((MotorValue < 0)) MotorValue = 0;
else if(MotorValue > ParamSet.Trust_Max) MotorValue = ParamSet.Trust_Max;
if (MotorValue < ParamSet.Trust_Min) MotorValue = ParamSet.Trust_Min;
/branches/V0.68d CRK HexaLotte/fc.h
77,7 → 77,7
extern int16_t Poti1, Poti2, Poti3, Poti4, Poti5, Poti6, Poti7, Poti8;
 
// setpoints for motors
extern volatile uint8_t Motor_Front, Motor_Rear, Motor_Right, Motor_Left; //used by twimaster isr
extern volatile uint8_t Motor_FrontLeft, Motor_FrontRight, Motor_RearLeft, Motor_RearRight, Motor_Right, Motor_Left; //used by twimaster isr
 
// current stick values
extern int16_t StickPitch, StickRoll, StickYaw;
/branches/V0.68d CRK HexaLotte/makefile
11,8 → 11,8
VERSION_COMPATIBLE = 7 # PC-Kompatibilität
#-------------------------------------------------------------------
#OPTIONS
COMPASS = MM3
#COMPASS = CMPS03
#COMPASS = _MM3
#COMPASS = _CMPS03
#EXT = WALTER
#-------------------------------------------------------------------
 
20,12 → 20,12
FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
#FUSE_SETTINGS = -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
# -u bei neuen Controllern wieder einspielen
HEX_NAME = MEGA644_$(COMPASS)
HEX_NAME = MEGA644$(COMPASS)
endif
 
ifeq ($(MCU), atmega644p)
FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
HEX_NAME = MEGA644p_$(COMPASS)
HEX_NAME = MEGA644p$(COMPASS)
endif
 
 
/branches/V0.68d CRK HexaLotte/spi.c
44,7 → 44,7
SPITransferCompleted = 0;
UpdateSPI_Buffer(); // update buffer
SPI_BufferIndex = 1;
DebugOut.Analog[16]++;
// DebugOut.Analog[16]++;
// -- Debug-Output ---
/* DebugOut.Analog[20] = FromNaviCtrl.Comp;
DebugOut.Analog[21] = FromNaviCtrl.GPS_Pitch;
/branches/V0.68d CRK HexaLotte/twimaster.c
10,7 → 10,7
 
volatile uint8_t twi_state = 0;
volatile uint8_t motor = 0;
volatile uint8_t motor_rx[8];
volatile uint8_t motor_rx[12];
 
/**************************************************/
/* Initialize I2C (TWI) */
139,21 → 139,27
switch(motor++)
{
case 0:
I2C_WriteByte(Motor_Front);
I2C_WriteByte(Motor_FrontLeft);
break;
case 1:
I2C_WriteByte(Motor_Rear);
I2C_WriteByte(Motor_RearRight);
break;
case 2:
I2C_WriteByte(Motor_FrontRight);
break;
case 3:
I2C_WriteByte(Motor_RearLeft);
break;
case 4:
I2C_WriteByte(Motor_Right);
break;
case 3:
case 5:
I2C_WriteByte(Motor_Left);
break;
}
break;
case 2: // repeat case 0+1 for all Slaves
if (motor<4) twi_state = 0;
if (motor<6) twi_state = 0;
I2C_Start(); // Repeated start -> switch salve or switch Master Transmit -> Master Receive
break;
 
171,9 → 177,9
break;
case 6:
//Read 2nd byte
motor_rx[motorread+4] = TWDR;
motor_rx[motorread+6] = TWDR;
motorread++;
if (motorread > 3) motorread=0;
if (motorread > 5) motorread=0;
 
default:
I2C_Stop();
/branches/V0.68d CRK HexaLotte/twimaster.h
22,7 → 22,7
extern volatile uint8_t twi_state;
extern volatile uint8_t motor;
extern volatile uint8_t motorread;
extern volatile uint8_t motor_rx[8];
extern volatile uint8_t motor_rx[12];
 
extern void I2C_Init (void); // Initialize I2C
extern void I2C_Start (void); // Start I2C
/branches/V0.68d CRK HexaLotte/uart.c
63,12 → 63,12
"Voltage ",
"Receiver Level ", //10
"AnalogOut11 ",
"GPSDevNorth ",
"GPSDevEast ",
"GPS_Pitch ",
"GPS_Roll ", //15
"Acc_Z ",
"MeanAccPitch ",
"Motor VL ",
"Motor RR ",
"Motor VR ",
"Motor RL ", //15
"Motor Left ",
"Motor Right ",
"MeanAccRoll ",
"IntegralErrPitch",
"IntegralErrRoll ", //20