/trunk/eeprom.c |
---|
148,8 → 148,9 |
EE_Parameter.Gas_Max = 230; // Wert : 33-247 |
EE_Parameter.KompassWirkung = 64; // Wert : 0-247 |
EE_Parameter.HoeheChannel = 5; // Wert : 0-32 |
EE_Parameter.Hoehe_MinGas = 30; |
EE_Parameter.HoeheChannel = 5; // Wert : 0-32 |
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
if(ACC_AltitudeControl) |
{ |
242,6 → 243,8 |
EE_Parameter.FailsafeChannel = 0; |
EE_Parameter.ServoFilterNick = 0; |
EE_Parameter.ServoFilterRoll = 0; |
EE_Parameter.CompassOffset = 0; |
EE_Parameter.AutoLandingVoltage = 32; |
} |
/* |
void ParamSet_DefaultSet1(void) // sport |
/trunk/eeprom.h |
---|
4,7 → 4,7 |
#include <inttypes.h> |
#include "twimaster.h" |
#define EEPARAM_REVISION 96 // is count up, if paramater stucture has changed (compatibility) |
#define EEPARAM_REVISION 97 // is count up, if paramater stucture has changed (compatibility) |
#define EEMIXER_REVISION 1 // is count up, if mixer stucture has changed (compatibility) |
#define EEPROM_ADR_PARAM_BEGIN 0 |
246,6 → 246,8 |
unsigned char ServoFilterRoll; |
unsigned char StartLandChannel; |
unsigned char LandingSpeed; |
unsigned char CompassOffset; |
unsigned char AutoLandingVoltage; // in 0,1V 0 -> disabled |
//------------------------------------------------ |
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, 0x04 = relative moving // WICHTIG!!! am Ende lassen |
/trunk/fc.c |
---|
95,7 → 95,7 |
char GyroFaktor,GyroFaktorGier; |
char IntegralFaktor,IntegralFaktorGier; |
int DiffNick,DiffRoll; |
int StickGasHover = 120, HoverGasMin = 0, HoverGasMax = 1023; |
int StickGasHover = 127, HoverGasMin = 0, HoverGasMax = 1023; |
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0; |
//int Poti1 = 0, Poti2 = 0, Poti3 = 0, Poti4 = 0, Poti5 = 0, Poti6 = 0, Poti7 = 0, Poti8 = 0; |
unsigned char Poti[9] = {0,0,0,0,0,0,0,0}; |
182,6 → 182,7 |
signed int Variance = 0; |
signed int CosAttitude; // for projection of hoover gas |
unsigned char ACC_AltitudeControl = 0; |
unsigned char LowVoltageLandingActive = 0; |
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
#define OPA_OFFSET_STEP 5 |
1588,10 → 1589,38 |
if(MesswertGier < -MAX_SENSOR) MesswertGier = -MAX_SENSOR; |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// Undervoltage |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if(!(FC_StatusFlags & FC_STATUS_LOWBAT)) |
{ |
GasMischanteil = ((unsigned int)GasMischanteil * BattLowVoltageWarning) / UBat; // Gas auf das aktuelle Spannungvieveau beziehen |
} |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// Auto-Landing |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
static unsigned char slower; |
if(!slower--) |
{ |
slower = 50; // 10Hz |
if(UBat < EE_Parameter.AutoLandingVoltage) |
{ |
LowVoltageLandingActive = 20; // 2 sek |
} |
else if(UBat > EE_Parameter.AutoLandingVoltage + 2 && LowVoltageLandingActive) LowVoltageLandingActive--; |
} |
if(LowVoltageLandingActive && FromNC_AltitudeSetpoint >= 0) |
{ |
FromNC_AltitudeSpeed = EE_Parameter.LandingSpeed; |
FromNC_AltitudeSetpoint = -20000; |
} |
//DebugOut.Analog[16] = StickGasMiddle; |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// Höhenregelung |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if(UBat > BattLowVoltageWarning) GasMischanteil = ((unsigned int)GasMischanteil * BattLowVoltageWarning) / UBat; // Gas auf das aktuelle Spannungvieveau beziehen |
GasMischanteil *= STICK_GAIN; |
// if height control is activated |
if((Parameter_GlobalConfig & CFG_HOEHENREGELUNG) && !(Looping_Roll || Looping_Nick) && !(VersionInfo.HardwareError[0] & 0x7F)) // Höhenregelung |
{ |
1699,7 → 1728,6 |
AltitudeSetpointTrimming = 0; |
if(HoehenReglerAktiv && !(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING)) |
{ |
#define HEIGHT_CONTROL_STICKTHRESHOLD 15 |
// Holger original version |
// start of height control algorithm |
// the height control is only an attenuation of the actual gas stick. |
1720,7 → 1748,7 |
// PD-Control with respect to hoover point |
// the thrust loss out of horizontal attitude is compensated |
// the setpoint will be fine adjusted with the gas stick position |
if(FC_StatusFlags & FC_STATUS_FLY) // trim setpoint only when flying |
if(/*1 || */FC_StatusFlags & FC_STATUS_FLY) // trim setpoint only when flying |
{ // gas stick is above hoover point |
if(StickGas > (StickGasHover + HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtUpperLimit) |
{ |
1740,16 → 1768,15 |
} |
else |
{ |
// SollHoehe = (long) Parameter_MaximumAltitude * 100L; |
// HeightTrimming += abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
if(HeightDeviation > 20) SollHoehe = HoehenWertF; // update setpoint to current heigth |
FC_StatusFlags |= FC_STATUS_VARIO_TRIM_UP; |
AltitudeSetpointTrimming = abs(StickGas - (StickGasHover + HEIGHT_CONTROL_STICKTHRESHOLD)); |
if(LowVoltageLandingActive) AltitudeSetpointTrimming /= 3; // only 33% rising |
VarioCharacter = '+'; |
} |
WaypointTrimming = 0; |
} // gas stick is below hoover point |
else if(StickGas < (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtLowerLimit ) |
else if(StickGas < (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD) && !BaroAtLowerLimit ) // Minus |
{ |
if(FC_StatusFlags & FC_STATUS_VARIO_TRIM_UP) |
{ |
1758,7 → 1785,6 |
} |
FC_StatusFlags |= FC_STATUS_VARIO_TRIM_DOWN; |
AltitudeSetpointTrimming = -abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
// HeightTrimming -= abs(StickGas - (StickGasHover - HEIGHT_CONTROL_STICKTHRESHOLD)); |
VarioCharacter = '-'; |
WaypointTrimming = 0; |
} |
/trunk/fc.h |
---|
9,6 → 9,7 |
extern long GIER_GRAD_FAKTOR; // Abhängigkeit zwischen GyroIntegral und Winkel |
#define STICK_GAIN 4 |
#define ACC_AMPLIFY 6 |
#define HEIGHT_CONTROL_STICKTHRESHOLD 15 |
// FC_StatusFlags |
#define FC_STATUS_MOTOR_RUN 0x01 |
146,6 → 147,7 |
extern unsigned char Parameter_ExtraConfig; |
extern signed char MixerTable[MAX_MOTORS][4]; |
extern const signed char sintab[31]; |
extern unsigned char LowVoltageLandingActive; |
#endif //_FC_H |
/trunk/hottmenu.c |
---|
97,6 → 97,7 |
int HoTTVarioMeter = 0; |
const char PROGMEM MIKROKOPTER[] = {" MikroKopter "}; |
const char PROGMEM UNDERVOLTAGE[] = {" !! LiPo voltage !! "}; |
const char PROGMEM LANDING[] = {" !! LANDING !! "}; |
const char PROGMEM SETTING[] = {"Set :"}; |
const char PROGMEM NC_ERROR_TEXT[MAX_ERR_NUMBER][17] = |
{ |
209,7 → 210,11 |
static int repeat; |
//if(Parameter_UserParam1) return(Parameter_UserParam1); |
ToNC_SpeakHoTT = SpeakHoTT; |
if(FC_StatusFlags & FC_STATUS_LOWBAT) status = VOICE_MINIMALE_EINGANSSPANNUNG; |
if(FC_StatusFlags & FC_STATUS_LOWBAT) |
{ |
if(LowVoltageLandingActive && (EE_Parameter.Receiver == RECEIVER_HOTT)) status = SPEAK_LANDING; |
else status = VOICE_MINIMALE_EINGANSSPANNUNG; // Jeti hat kein wort: "LANDEN" |
} |
else |
if(NC_ErrorCode && NC_ErrorCode+1 < MAX_ERR_NUMBER) // Fehlercodes |
{ |
223,10 → 228,10 |
} |
else ToNC_SpeakHoTT = status; |
if(old_status == status) // Gleichen Fehler nur alle 5 sek bringen |
if(old_status == status) // Gleichen Fehler nur alle 4 sek bringen |
{ |
if(!CheckDelay(repeat)) return(0); |
repeat = SetDelay(5000); |
repeat = SetDelay(4000); |
} |
else repeat = SetDelay(2000); |
347,6 → 352,8 |
VarioPacket.Text[20] = ' '; |
} |
else |
if(LowVoltageLandingActive) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&LANDING[i]); // no Error |
else |
if(FC_StatusFlags & FC_STATUS_LOWBAT) for(i=0; i<21;i++) VarioPacket.Text[i] = pgm_read_byte(&UNDERVOLTAGE[i]); // no Error |
else |
if(ShowSettingNameTime) // no Error |
/trunk/libfc1284.a |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/main.c |
---|
88,18 → 88,15 |
void LipoDetection(unsigned char print) |
{ |
#define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
unsigned int timer, cells; |
unsigned char cells; |
if(print) printf("\n\rBatt:"); |
if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
// timer = SetDelay(100); |
// if(print) while (!CheckDelay(timer)); |
// up to 6s LiPo, less than 2s is technical impossible |
// for(cells = 2; cells < 7; cells++) if(UBat < cells * MAX_CELL_VOLTAGE) break; |
cells = 1 + UBat / MAX_CELL_VOLTAGE; |
if(EE_Parameter.UnterspannungsWarnung < 50) |
{ |
timer = SetDelay(500); |
if(print) while (!CheckDelay(timer)); |
// up to 6s LiPo, less than 2s is technical impossible |
for(cells = 2; cells < 7; cells++) |
{ |
if(UBat < cells * MAX_CELL_VOLTAGE) break; |
} |
BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
if(print) |
{ |
108,7 → 105,17 |
} |
} |
else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
if(print) printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
// automatische Zellenerkennung |
if(EE_Parameter.AutoLandingVoltage < 50) EE_Parameter.AutoLandingVoltage = cells * EE_Parameter.AutoLandingVoltage; |
if(EE_Parameter.AutoLandingVoltage > BattLowVoltageWarning) EE_Parameter.AutoLandingVoltage = BattLowVoltageWarning - 1; |
if(print) |
{ |
printf(" Low warning: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
if(EE_Parameter.AutoLandingVoltage) printf(" Autolanding: %d.%d",EE_Parameter.AutoLandingVoltage/10,EE_Parameter.AutoLandingVoltage%10); |
} |
} |
//############################################################################ |
350,9 → 357,9 |
else AccZ_ErrorCnt = 0; |
// ++++++++++++++++++++++++++++ |
#endif |
if(MissingMotor) |
if(MissingMotor || Capacity.MinOfMaxPWM < 30) |
{ |
VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
if(MissingMotor) VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING; |
DebugOut.Status[1] |= 0x02; // BL-Error-Status |
} |
else |
411,7 → 418,7 |
VersionInfo.Flags &= ~FC_VERSION_FLAG_NC_PRESENT; |
NaviDataOkay = 0; |
} |
if(UBat < BattLowVoltageWarning) |
if(UBat <= BattLowVoltageWarning) |
{ |
FC_StatusFlags |= FC_STATUS_LOWBAT; |
if(BeepMuster == 0xffff && UBat > 10) // Do not beep, if the voltage reading is below 1V (Supplied via MKUSB) |
420,7 → 427,6 |
BeepMuster = 0x0300; |
} |
} |
else if(!beeptime) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
// SendSPI = SPI_BYTEGAP; |
EEAR = EE_DUMMY; // Set the EEPROM Address pointer to an unused space |
// +++++++++++++++++++++++++++++++++ |
439,6 → 445,7 |
else |
if(StartLuftdruck > Luftdruck) StartLuftdruck -= 5; |
} |
if(UBat > BattLowVoltageWarning + 1) FC_StatusFlags &= ~FC_STATUS_LOWBAT; |
} |
// +++++++++++++++++++++++++++++++++ |
if(++timer2 == 2930) // eine Minute |
/trunk/makefile |
---|
6,7 → 6,7 |
#------------------------------------------------------------------- |
VERSION_MAJOR = 2 |
VERSION_MINOR = 01 |
VERSION_PATCH = 4 |
VERSION_PATCH = 5 |
VERSION_SERIAL_MAJOR = 11 # Serial Protocol |
VERSION_SERIAL_MINOR = 0 # Serial Protocol |
NC_SPI_COMPATIBLE = 57 # Navi-Kompatibilität |
/trunk/spi.c |
---|
269,7 → 269,7 |
ToNaviCtrl.Param.Byte[6] = VersionInfo.HardwareError[1]; |
VersionInfo.HardwareError[0] &= ~FC_ERROR0_CAREFREE; // VersionInfo.HardwareError[0] = 0; |
VersionInfo.HardwareError[1] &= FC_ERROR1_MIXER; |
ToNaviCtrl.Param.Byte[7] = 0; |
ToNaviCtrl.Param.Byte[7] = EE_Parameter.CompassOffset; |
ToNaviCtrl.Param.Byte[8] = Parameter_GlobalConfig; |
ToNaviCtrl.Param.Byte[9] = Parameter_ExtraConfig; |
ToNaviCtrl.Param.Byte[10] = EE_Parameter.OrientationAngle; |
/trunk/uart.c |
---|
457,8 → 457,11 |
} |
while(!UebertragungAbgeschlossen); |
SendOutData('S', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
if(!MotorenEin) Piep(tempchar1,110); |
LipoDetection(0); |
if(!MotorenEin) |
{ |
Piep(tempchar1,110); |
LipoDetection(0); |
} |
LIBFC_ReceiverInit(EE_Parameter.Receiver); |
break; |
case 'f': // auf anderen Parametersatz umschalten |
467,8 → 470,11 |
tempchar1 = GetActiveParamSet(); |
while(!UebertragungAbgeschlossen); |
SendOutData('F', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
Piep(tempchar1,110); |
LipoDetection(0); |
if(!MotorenEin) |
{ |
Piep(tempchar1,110); |
LipoDetection(0); |
} |
LIBFC_ReceiverInit(EE_Parameter.Receiver); |
break; |
case 'y':// serial Potis |
/trunk/version.txt |
---|
653,8 → 653,12 |
- prepared for current measurements up to 75A per ESC |
- reduced speed of capacity-calculation() from 10ms to 50ms - that should be fast enough |
- Timing correction for NC-Data (41Hz) |
2.01f |
- Autolanding if undervoltage |
- Compass offset angle |
- 0.2V hysteresis in undervoltage warning |