Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1759 → Rev 1760

/trunk/eeprom.c
122,7 → 122,7
/***************************************************/
/* Default Values for parameter set 1 */
/***************************************************/
void ParamSet_DefaultSet1(void) // sport
void CommonDefaults(void)
{
EE_Parameter.Revision = EEPARAM_REVISION;
 
142,32 → 142,7
EE_Parameter.WinkelUmschlagNick = 85;
EE_Parameter.WinkelUmschlagRoll = 85;
}
EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER;
EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC
EE_Parameter.Hoehe_MinGas = 30;
EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1
EE_Parameter.Hoehe_P = 15; // Wert : 0-32
EE_Parameter.Luftdruck_D = 30; // Wert : 0-247
EE_Parameter.Hoehe_ACC_Wirkung = 00; // Wert : 0-247
EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247
EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247
EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation)
EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50
EE_Parameter.Stick_P = 14; // Wert : 1-20
EE_Parameter.Stick_D = 16; // Wert : 0-20
EE_Parameter.Gier_P = 12; // Wert : 1-20
EE_Parameter.Gas_Min = 8; // Wert : 0-32
EE_Parameter.Gas_Max = 230; // Wert : 33-247
EE_Parameter.KompassWirkung = 128; // Wert : 0-247
EE_Parameter.Gyro_P = 80; // Wert : 0-247
EE_Parameter.Gyro_I = 150; // Wert : 0-247
EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247
EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247
EE_Parameter.Gyro_Stability = 6; // Wert : 1-8
EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50)
EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust
EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
EE_Parameter.I_Faktor = 32;
 
EE_Parameter.UserParam1 = 0; // zur freien Verwendung
EE_Parameter.UserParam2 = 0; // zur freien Verwendung
EE_Parameter.UserParam3 = 0; // zur freien Verwendung
189,21 → 164,12
EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo
EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag
EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag
EE_Parameter.LoopGasLimit = 50;
EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag
EE_Parameter.LoopHysterese = 50;
EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
EE_Parameter.AchsKopplung1 = 90;
EE_Parameter.AchsKopplung2 = 80;
EE_Parameter.CouplingYawCorrection = 1;
EE_Parameter.GyroAccAbgleich = 16; // 1/k;
EE_Parameter.DynamicStability = 100;
EE_Parameter.J16Bitmask = 95;
EE_Parameter.J17Bitmask = 243;
EE_Parameter.WARN_J16_Bitmask = 0xAA;
EE_Parameter.WARN_J17_Bitmask = 0xAA;
EE_Parameter.J16Timing = 15;
EE_Parameter.J17Timing = 15;
EE_Parameter.J16Timing = 20;
EE_Parameter.J17Timing = 20;
EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2
EE_Parameter.NaviGpsGain = 100;
EE_Parameter.NaviGpsP = 90;
223,6 → 189,49
EE_Parameter.Receiver = RECEIVER_SPEKTRUM;
EE_Parameter.OrientationAngle = 0;
EE_Parameter.OrientationModeControl = 0;
EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50)
EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust
EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
EE_Parameter.MotorSafetySwitch = 0;
EE_Parameter.ServoManualControlSpeed = 20;
EE_Parameter.CamOrientation = 0;
}
 
void ParamSet_DefaultSet1(void) // sport
{
CommonDefaults();
EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER;
EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC
EE_Parameter.Hoehe_MinGas = 30;
EE_Parameter.MaxHoehe = 255; // Wert : 0-247 255 -> Poti1
EE_Parameter.Hoehe_P = 15; // Wert : 0-32
EE_Parameter.Luftdruck_D = 30; // Wert : 0-247
EE_Parameter.Hoehe_ACC_Wirkung = 00; // Wert : 0-247
EE_Parameter.Hoehe_HoverBand = 8; // Wert : 0-247
EE_Parameter.Hoehe_GPS_Z = 64; // Wert : 0-247
EE_Parameter.Hoehe_StickNeutralPoint = 0; // Wert : 0-247 (0 = Hover-Estimation)
EE_Parameter.Hoehe_Verstaerkung = 20; // Wert : 0-50
EE_Parameter.Stick_P = 14; // Wert : 1-20
EE_Parameter.Stick_D = 16; // Wert : 0-20
EE_Parameter.Gier_P = 12; // Wert : 1-20
EE_Parameter.Gas_Min = 8; // Wert : 0-32
EE_Parameter.Gas_Max = 230; // Wert : 33-247
EE_Parameter.KompassWirkung = 128; // Wert : 0-247
EE_Parameter.Gyro_P = 80; // Wert : 0-247
EE_Parameter.Gyro_I = 150; // Wert : 0-247
EE_Parameter.Gyro_Gier_P = 80; // Wert : 0-247
EE_Parameter.Gyro_Gier_I = 150; // Wert : 0-247
EE_Parameter.Gyro_Stability = 6; // Wert : 1-8
EE_Parameter.I_Faktor = 32;
EE_Parameter.LoopGasLimit = 50;
EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag
EE_Parameter.LoopHysterese = 50;
EE_Parameter.BitConfig = 0; // Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
EE_Parameter.AchsKopplung1 = 90;
EE_Parameter.AchsKopplung2 = 80;
EE_Parameter.CouplingYawCorrection = 1;
EE_Parameter.GyroAccAbgleich = 16; // 1/k;
EE_Parameter.DynamicStability = 100;
memcpy(EE_Parameter.Name, "Sport\0", 12);
EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1);
}
233,24 → 242,7
/***************************************************/
void ParamSet_DefaultSet2(void) // normal
{
EE_Parameter.Revision = EEPARAM_REVISION;
 
if(PlatinenVersion >= 20)
{
EE_Parameter.Gyro_D = 10;
EE_Parameter.Driftkomp = 0;
EE_Parameter.GyroAccFaktor = 27;
EE_Parameter.WinkelUmschlagNick = 78;
EE_Parameter.WinkelUmschlagRoll = 78;
}
else
{
EE_Parameter.Gyro_D = 3;
EE_Parameter.Driftkomp = 32;
EE_Parameter.GyroAccFaktor = 30;
EE_Parameter.WinkelUmschlagNick = 85;
EE_Parameter.WinkelUmschlagRoll = 85;
}
CommonDefaults();
EE_Parameter.GlobalConfig = CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER;
EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// CFG_SENSITIVE_RC
EE_Parameter.Hoehe_MinGas = 30;
273,31 → 265,7
EE_Parameter.Gyro_Gier_P = 90; // Wert : 0-247
EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247
EE_Parameter.Gyro_Stability = 6; // Wert : 1-8
EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50)
EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust
EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
EE_Parameter.I_Faktor = 32;
EE_Parameter.UserParam1 = 0; // zur freien Verwendung
EE_Parameter.UserParam2 = 0; // zur freien Verwendung
EE_Parameter.UserParam3 = 0; // zur freien Verwendung
EE_Parameter.UserParam4 = 0; // zur freien Verwendung
EE_Parameter.UserParam5 = 0; // zur freien Verwendung
EE_Parameter.UserParam6 = 0; // zur freien Verwendung
EE_Parameter.UserParam7 = 0; // zur freien Verwendung
EE_Parameter.UserParam8 = 0; // zur freien Verwendung
EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos
EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo
EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo
EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag
EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag
EE_Parameter.ServoNickRefresh = 6;
EE_Parameter.Servo3 = 125;
EE_Parameter.Servo4 = 125;
EE_Parameter.Servo5 = 125;
EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos
EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo
EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag
EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag
EE_Parameter.LoopGasLimit = 50;
EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag
EE_Parameter.LoopHysterese = 50;
307,31 → 275,6
EE_Parameter.CouplingYawCorrection = 60;
EE_Parameter.GyroAccAbgleich = 32; // 1/k
EE_Parameter.DynamicStability = 75;
EE_Parameter.J16Bitmask = 95;
EE_Parameter.J17Bitmask = 243;
EE_Parameter.WARN_J16_Bitmask = 0xAA;
EE_Parameter.WARN_J17_Bitmask = 0xAA;
EE_Parameter.J16Timing = 20;
EE_Parameter.J17Timing = 20;
EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2
EE_Parameter.NaviGpsGain = 100;
EE_Parameter.NaviGpsP = 90;
EE_Parameter.NaviGpsI = 90;
EE_Parameter.NaviGpsD = 90;
EE_Parameter.NaviGpsPLimit = 75;
EE_Parameter.NaviGpsILimit = 75;
EE_Parameter.NaviGpsDLimit = 75;
EE_Parameter.NaviGpsACC = 0;
EE_Parameter.NaviGpsMinSat = 6;
EE_Parameter.NaviStickThreshold = 8;
EE_Parameter.NaviWindCorrection = 90;
EE_Parameter.NaviSpeedCompensation = 30;
EE_Parameter.NaviOperatingRadius = 100;
EE_Parameter.NaviAngleLimitation = 100;
EE_Parameter.NaviPH_LoginTime = 2;
EE_Parameter.Receiver = RECEIVER_SPEKTRUM;
EE_Parameter.OrientationAngle = 0;
EE_Parameter.OrientationModeControl = 0;
memcpy(EE_Parameter.Name, "Normal\0", 12);
EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1);
}
342,23 → 285,6
/***************************************************/
void ParamSet_DefaultSet3(void) // beginner
{
EE_Parameter.Revision = EEPARAM_REVISION;
if(PlatinenVersion >= 20)
{
EE_Parameter.Gyro_D = 10;
EE_Parameter.Driftkomp = 0;
EE_Parameter.GyroAccFaktor = 27;
EE_Parameter.WinkelUmschlagNick = 78;
EE_Parameter.WinkelUmschlagRoll = 78;
}
else
{
EE_Parameter.Gyro_D = 3;
EE_Parameter.Driftkomp = 32;
EE_Parameter.GyroAccFaktor = 30;
EE_Parameter.WinkelUmschlagNick = 85;
EE_Parameter.WinkelUmschlagRoll = 85;
}
EE_Parameter.GlobalConfig = /*CFG_DREHRATEN_BEGRENZER |*/ CFG_ACHSENKOPPLUNG_AKTIV | CFG_KOMPASS_AKTIV | CFG_GPS_AKTIV | CFG_HOEHEN_SCHALTER;
EE_Parameter.ExtraConfig = CFG2_HEIGHT_LIMIT | CFG2_VARIO_BEEP;// | CFG_SENSITIVE_RC
EE_Parameter.Hoehe_MinGas = 30;
381,31 → 307,7
EE_Parameter.Gyro_Gier_P = 100; // Wert : 0-247
EE_Parameter.Gyro_Gier_I = 120; // Wert : 0-247
EE_Parameter.Gyro_Stability = 6; // Wert : 1-8
EE_Parameter.UnterspannungsWarnung = 33; // Wert : 0-247 ( Automatische Zellenerkennung bei < 50)
EE_Parameter.NotGas = 45; // Wert : 0-247 // Gaswert bei Empangsverlust
EE_Parameter.NotGasZeit = 90; // Wert : 0-247 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen
EE_Parameter.I_Faktor = 16;
EE_Parameter.UserParam1 = 0; // zur freien Verwendung
EE_Parameter.UserParam2 = 0; // zur freien Verwendung
EE_Parameter.UserParam3 = 0; // zur freien Verwendung
EE_Parameter.UserParam4 = 0; // zur freien Verwendung
EE_Parameter.UserParam5 = 0; // zur freien Verwendung
EE_Parameter.UserParam6 = 0; // zur freien Verwendung
EE_Parameter.UserParam7 = 0; // zur freien Verwendung
EE_Parameter.UserParam8 = 0; // zur freien Verwendung
EE_Parameter.ServoNickControl = 100; // Wert : 0-247 // Stellung des Servos
EE_Parameter.ServoNickComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo
EE_Parameter.ServoCompInvert = 1; // Wert : 0-247 // Richtung Einfluss Gyro/Servo
EE_Parameter.ServoNickMin = 0; // Wert : 0-247 // Anschlag
EE_Parameter.ServoNickMax = 247; // Wert : 0-247 // Anschlag
EE_Parameter.ServoNickRefresh = 6;
EE_Parameter.Servo3 = 125;
EE_Parameter.Servo4 = 125;
EE_Parameter.Servo5 = 125;
EE_Parameter.ServoRollControl = 100; // Wert : 0-247 // Stellung des Servos
EE_Parameter.ServoRollComp = 40; // Wert : 0-247 // Einfluss Gyro/Servo
EE_Parameter.ServoRollMin = 0; // Wert : 0-247 // Anschlag
EE_Parameter.ServoRollMax = 247; // Wert : 0-247 // Anschlag
EE_Parameter.LoopGasLimit = 50;
EE_Parameter.LoopThreshold = 90; // Wert: 0-247 Schwelle für Stickausschlag
EE_Parameter.LoopHysterese = 50;
415,31 → 317,6
EE_Parameter.CouplingYawCorrection = 70;
EE_Parameter.GyroAccAbgleich = 32; // 1/k
EE_Parameter.DynamicStability = 70;
EE_Parameter.J16Bitmask = 95;
EE_Parameter.J17Bitmask = 243;
EE_Parameter.WARN_J16_Bitmask = 0xAA;
EE_Parameter.WARN_J17_Bitmask = 0xAA;
EE_Parameter.J16Timing = 30;
EE_Parameter.J17Timing = 30;
EE_Parameter.NaviGpsModeControl = 254; // 254 -> Poti 2
EE_Parameter.NaviGpsGain = 100;
EE_Parameter.NaviGpsP = 90;
EE_Parameter.NaviGpsI = 90;
EE_Parameter.NaviGpsD = 90;
EE_Parameter.NaviGpsPLimit = 75;
EE_Parameter.NaviGpsILimit = 75;
EE_Parameter.NaviGpsDLimit = 75;
EE_Parameter.NaviGpsACC = 0;
EE_Parameter.NaviGpsMinSat = 6;
EE_Parameter.NaviStickThreshold = 8;
EE_Parameter.NaviWindCorrection = 90;
EE_Parameter.NaviSpeedCompensation = 30;
EE_Parameter.NaviOperatingRadius = 100;
EE_Parameter.NaviAngleLimitation = 100;
EE_Parameter.NaviPH_LoginTime = 2;
EE_Parameter.Receiver = RECEIVER_SPEKTRUM;
EE_Parameter.OrientationAngle = 0;
EE_Parameter.OrientationModeControl = 0;
memcpy(EE_Parameter.Name, "Beginner\0", 12);
EE_Parameter.crc = RAM_Checksum((uint8_t*)(&EE_Parameter), sizeof(EE_Parameter)-1);
}
/trunk/eeprom.h
4,7 → 4,7
#include <inttypes.h>
#include "twimaster.h"
 
#define EEPARAM_REVISION 84 // is count up, if paramater stucture has changed (compatibility)
#define EEPARAM_REVISION 85 // is count up, if paramater stucture has changed (compatibility)
#define EEMIXER_REVISION 1 // is count up, if mixer stucture has changed (compatibility)
 
 
20,7 → 20,6
#define PID_FLIGHT_MINUTES_TOTAL 10 // word
#define PID_FLIGHT_MINUTES 14 // word
 
 
#define EEPROM_ADR_CHANNELS 80 // 80 - 93, 12 bytes + 1 byte crc
#define EEPROM_ADR_PARAMSET 100 // 100 - 650, 5 * 110 bytes
#define EEPROM_ADR_MIXERTABLE 1000 // 1000 - 1078, 78 bytes
156,6 → 155,8
unsigned char ServoRollMax; // Wert : 0-250
//---
unsigned char ServoNickRefresh; // Speed of the Servo
unsigned char ServoManualControlSpeed;//
unsigned char CamOrientation; //
unsigned char Servo3; // Value or mapping of the Servo Output
unsigned char Servo4; // Value or mapping of the Servo Output
unsigned char Servo5; // Value or mapping of the Servo Output
204,6 → 205,7
//---CareFree---------------------------------------------
unsigned char OrientationAngle; // Where is the front-direction?
unsigned char OrientationModeControl; // switch for CareFree
unsigned char MotorSafetySwitch;
//------------------------------------------------
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen
/trunk/fc.c
149,6 → 149,7
unsigned char Parameter_ExternalControl;
unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5;
unsigned char CareFree = 0;
const signed char sintab[31] = { 0, 2, 4, 6, 7, 8, 8, 8, 7, 6, 4, 2, 0, -2, -4, -6, -7, -8, -8, -8, -7, -6, -4, -2, 0, 2, 4, 6, 7, 8, 8};
 
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
int MaxStickNick = 0,MaxStickRoll = 0;
193,8 → 194,13
DebugOut.Analog[30] = GPS_Nick;
DebugOut.Analog[31] = GPS_Roll;
if(VersionInfo.HardwareError[0] || VersionInfo.HardwareError[1]) DebugOut.Status[1] |= 1; else DebugOut.Status[1] &= 0xfe;
 
if(Capacity.MinOfMaxPWM < 250/* && modell_fliegt > 500*/) { beeptime = 1000; DebugOut.Analog[25]++; }
 
}
 
 
 
void Piep(unsigned char Anzahl, unsigned int dauer)
{
if(MotorenEin) return; //auf keinen Fall im Flug!
529,8 → 535,8
Motor[i].SetPoint = MotorTest[i];
Motor[i].SetPointLowerBits = 0;
/*
Motor[i].SetPoint = MotorTest[i] / 4; // testing the high resolution
Motor[i].SetPointLowerBits = MotorTest[i] % 4;
Motor[i].SetPoint = MotorTest[i] / 4; // testing the high resolution
Motor[i].SetPointLowerBits = MotorTest[i] % 4;
*/
}
if(PC_MotortestActive) PC_MotortestActive--;
539,14 → 545,12
 
if(I2C_TransferActive)
{
DebugOut.Analog[16]++; // transmission was not finished yet
// I2C_TransferActive = 0; // enable for the next time
I2C_TransferActive = 0; // enable for the next time
}
//else
else
{
motor_write = 0;
//Start I2C Interrupt Mode
I2C_Start(TWI_STATE_MOTOR_TX);
I2C_Start(TWI_STATE_MOTOR_TX); //Start I2C Interrupt Mode
}
}
 
761,12 → 765,14
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Gas ist unten
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DebugOut.Analog[16] = EE_Parameter.MotorSafetySwitch;
 
if(PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] < 35-120)
{
// Motoren Starten
if(!MotorenEin)
{
if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75)
if((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] < -75) && (PPM_in[EE_Parameter.MotorSafetySwitch] < -75 || EE_Parameter.MotorSafetySwitch == 0))
{
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Einschalten
803,7 → 809,7
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
else // only if motors are running
{
if(PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75)
if((PPM_in[EE_Parameter.Kanalbelegung[K_GIER]] > 75) && (PPM_in[EE_Parameter.MotorSafetySwitch] < -75 || EE_Parameter.MotorSafetySwitch == 0))
{
if(++delay_ausschalten > 200) // nicht sofort
{
832,8 → 838,6
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CareFree und freie Wahl der vorderen Richtung
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
signed char sintab[31] = { 0, 2, 4, 6, 7, 8, 8, 8, 7, 6, 4, 2, 0, -2, -4, -6, -7, -8, -8, -8, -7, -6, -4, -2, 0, 2, 4, 6, 7, 8, 8};
 
if(CareFree)
{
signed int nick, roll;
850,7 → 854,6
StickRoll = ((FromNC_Rotate_C * stick_roll) - (FromNC_Rotate_S * stick_nick)) / 8;
}
 
 
StickGier = -PPM_in[EE_Parameter.Kanalbelegung[K_GIER]];
if(StickGier > 2) StickGier -= 2; else
if(StickGier < -2) StickGier += 2; else StickGier = 0;
1703,7 → 1706,7
if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing
else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // MotorSmoothing
 
LIMIT_MIN_MAX(tmp_int,MIN_GAS * 4,MAX_GAS * 4);
LIMIT_MIN_MAX(tmp_int,(int) MIN_GAS * 4,(int) MAX_GAS * 4);
Motor[i].SetPoint = tmp_int / 4;
Motor[i].SetPointLowerBits = (tmp_int % 4)<<1; // (3 bits total)
tmp_motorwert[i] = tmp_int;
1714,5 → 1717,4
Motor[i].SetPointLowerBits = 0;
}
}
//if(!(CountMilliseconds % 999)) Motor[3].SetPoint = 0;
}
/trunk/fc.h
116,5 → 116,6
extern unsigned char Parameter_J17Bitmask; // for the J17 Output
extern unsigned char Parameter_J17Timing; // for the J17 Output
extern signed char MixerTable[MAX_MOTORS][4];
extern const signed char sintab[31];
#endif //_FC_H
 
/trunk/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libfc644.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/main.c
302,8 → 302,9
}
if(!UpdateMotor)
{
DatenUebertragung();
BearbeiteRxDaten();
if(CalculateServoSignals) CalculateServo();
DatenUebertragung();
BearbeiteRxDaten();
if(CheckDelay(timer))
{
static unsigned char second;
/trunk/makefile
5,8 → 5,8
F_CPU = 20000000
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 80
VERSION_PATCH = 7
VERSION_MINOR = 81
VERSION_PATCH = 0
VERSION_SERIAL_MAJOR = 11 # Serial Protocol
VERSION_SERIAL_MINOR = 0 # Serial Protocol
NC_SPI_COMPATIBLE = 14 # Navi-Kompatibilität
/trunk/timer0.c
1,12 → 1,15
#include "main.h"
#define MULTIPLYER 4
 
 
volatile unsigned int CountMilliseconds = 0;
volatile static unsigned int tim_main;
volatile unsigned char UpdateMotor = 0;
volatile unsigned int cntKompass = 0;
volatile unsigned int beeptime = 0;
volatile unsigned char SendSPI = 0, ServoActive = 0;
volatile unsigned char SendSPI = 0, ServoActive = 0, CalculateServoSignals = 1;
uint16_t RemainingPulse = 0;
volatile int16_t ServoNickOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon
volatile int16_t ServoRollOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon
 
unsigned int BeepMuster = 0xffff;
 
185,6 → 188,70
/* Control Servo Position */
/*****************************************************/
 
 
void CalculateServo(void)
{
long cosinus, sinus;
long nick, roll;
 
cosinus = sintab[EE_Parameter.CamOrientation + 6];
sinus = sintab[EE_Parameter.CamOrientation];
 
if(CalculateServoSignals == 1)
{
nick = ((cosinus * (IntegralNick / (8 * 128L))) - (sinus * (IntegralRoll / (8 * 128L))));
//nick = (IntegralNick / 128L);
 
ServoNickOffset += ((int16_t)Parameter_ServoNickControl * (MULTIPLYER*16) - ServoNickOffset) / EE_Parameter.ServoManualControlSpeed;
ServoNickValue = ServoNickOffset / 16; // offset (Range from 0 to 255 * 3 = 765)
if(EE_Parameter.ServoCompInvert & 0x01)
{ // inverting movement of servo
ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * nick) / (256L) );
}
else
{ // non inverting movement of servo
ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * nick) / (256L) );
}
// limit servo value to its parameter range definition
if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER;
}
else
if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER;
}
if(PlatinenVersion < 20) CalculateServoSignals = 0; else CalculateServoSignals++;
}
else
{
roll = ((cosinus * (IntegralRoll / (8 * 128L))) + (sinus * (IntegralNick / (8 * 128L))));
 
ServoRollOffset += ((int16_t)Parameter_ServoRollControl * (MULTIPLYER*16) - ServoRollOffset) / EE_Parameter.ServoManualControlSpeed;
ServoRollValue = ServoRollOffset/16; // offset (Range from 0 to 255 * 3 = 765)
if(EE_Parameter.ServoCompInvert & 0x02)
{ // inverting movement of servo
ServoRollValue += (int16_t)( ( (int32_t) EE_Parameter.ServoRollComp * MULTIPLYER * roll ) / (256L) );
}
else
{ // non inverting movement of servo
ServoRollValue -= (int16_t)( ( (int32_t) EE_Parameter.ServoRollComp * MULTIPLYER * roll ) / (256L) );
}
// limit servo value to its parameter range definition
if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER) )
{
ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER;
}
else
if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER) )
{
ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER;
}
CalculateServoSignals = 0;
}
}
 
ISR(TIMER2_COMPA_vect)
{
// frame len 22.5 ms = 14063 * 1.6 us
195,7 → 262,6
 
#define IRS_RUNTIME 127
#define PPM_STOPPULSE 188
// #define PPM_FRAMELEN (14063
#define PPM_FRAMELEN (1757 * EE_Parameter.ServoNickRefresh)
#define MINSERVOPULSE 375
#define MAXSERVOPULSE 1500
202,13 → 268,9
#define SERVORANGE (MAXSERVOPULSE - MINSERVOPULSE)
 
static uint8_t PulseOutput = 0;
static uint16_t RemainingPulse = 0;
static uint16_t ServoFrameTime = 0;
static uint8_t ServoIndex = 0;
 
#define MULTIPLYER 4
static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon
static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon
 
if(PlatinenVersion < 20)
{
221,32 → 283,7
{
TCCR2A &= ~(1<<COM2A0);// make a high pulse
RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms
 
ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset
ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765)
if(EE_Parameter.ServoCompInvert & 0x01)
{ // inverting movement of servo
ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) );
}
else
{ // non inverting movement of servo
ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) );
}
// limit servo value to its parameter range definition
if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER;
}
else
if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER;
}
 
RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position
 
ServoNickValue /= MULTIPLYER;
 
// range servo pulse width
if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit
else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit
285,53 → 322,10
switch(ServoIndex) // map servo channels
{
case 1: // Nick Compensation Servo
ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset
ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765)
if(EE_Parameter.ServoCompInvert & 0x01)
{ // inverting movement of servo
ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) );
}
else
{ // non inverting movement of servo
ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) );
}
// limit servo value to its parameter range definition
if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER;
}
else
if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) )
{
ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER;
}
RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position
ServoNickValue /= MULTIPLYER;
break;
case 2: // Roll Compensation Servo
ServoRollOffset = (ServoRollOffset * 3 + (int16_t) Parameter_ServoRollControl * MULTIPLYER) / 4; // lowpass offset
ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765)
if(EE_Parameter.ServoCompInvert & 0x02)
{ // inverting movement of servo
ServoRollValue += (int16_t)( ( (int32_t) EE_Parameter.ServoRollComp * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) );
}
else
{ // non inverting movement of servo
ServoRollValue -= (int16_t)( ( (int32_t) EE_Parameter.ServoRollComp * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) );
}
// limit servo value to its parameter range definition
if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER) )
{
ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER;
}
else
if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER) )
{
ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER;
}
RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position
ServoRollValue /= MULTIPLYER;
//DebugOut.Analog[20] = ServoRollValue;
break;
case 3:
RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER;
365,7 → 359,11
if((ServoActive && SenderOkay > 180) || ServoActive == 2) HEF4017R_OFF; // disable HEF4017 reset
else HEF4017R_ON;
ServoIndex++; // change to next servo channel
if(ServoIndex > EE_Parameter.ServoNickRefresh) ServoIndex = 0; // reset to the sync gap
if(ServoIndex > EE_Parameter.ServoNickRefresh)
{
CalculateServoSignals = 1;
ServoIndex = 0; // reset to the sync gap
}
}
// set pulse output active
PulseOutput = 1;
/trunk/timer0.h
10,6 → 10,7
void Delay_ms_Mess(unsigned int);
unsigned int SetDelay (unsigned int t);
char CheckDelay (unsigned int t);
void CalculateServo(void);
 
extern volatile unsigned int CountMilliseconds;
extern volatile unsigned char UpdateMotor;
16,6 → 17,6
extern volatile unsigned int beeptime;
extern volatile unsigned int cntKompass;
extern unsigned int BeepMuster;
extern volatile unsigned char SendSPI, ServoActive;
extern volatile unsigned char SendSPI, ServoActive, CalculateServoSignals;
extern volatile int16_t ServoNickValue;
extern volatile int16_t ServoRollValue;
/trunk/twimaster.c
175,7 → 175,6
break;
case 1: // Send Data to Slave
I2C_WriteByte(Motor[motor_write].SetPoint); // transmit setpoint
if(Motor[motor_write].SetPoint == 0) if(MotorenEin) DebugOut.Analog[17]++;
// if old version has been detected
if(!(Motor[motor_write].Version & MOTOR_STATE_NEW_PROTOCOL_MASK))
{
/trunk/uart.c
12,8 → 12,6
#include "libfc.h"
#include "eeprom.h"
 
 
 
#define FC_ADDRESS 1
#define NC_ADDRESS 2
#define MK3MAG_ADDRESS 3
20,10 → 18,9
#define BL_CTRL_ADDRESS 5
 
#define ABO_TIMEOUT 4000 // disable abo after 4 seconds
#define MAX_SENDE_BUFF 160
#define MAX_EMPFANGS_BUFF 160
#define MAX_SENDE_BUFF 170
#define MAX_EMPFANGS_BUFF 170
 
 
#define BLPARAM_REVISION 1
#define MASK_SET_PWM_SCALING 0x01
#define MASK_SET_CURRENT_LIMIT 0x02
/trunk/version.txt
428,4 → 428,8
- bei I2C-Fehlern wurden die Counter zurück gesetzt und für einige ms die Interrupts angehalten - das ist jetzt behoben
- Nur I2C-Daten senden, wenn das alte Paket komplett raus ist
 
 
0.81a
- MotorSafetySwitch
- ServoManualControlSpeed
- CamOrientation