Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1284 → Rev 1285

/beta/Code Redesign killagreg/fc.c
1523,10 → 1523,11
 
int16_t CosNick, CosRoll;
int16_t HCGas, HeightDeviation;
static int16_t HeightTrimming = 0; // rate for change of height setpoint
static uint8_t HCActive = 0;
static int16_t FilterHCGas = 0;
static int16_t HooverGas = 400, HooverGasMin = 0, HooverGasMax = 1023;
static uint32_t HooverGasFilter = 400L * HOOVER_GAS_AVERAGE;
static uint32_t HooverGasFilter = 0;
static uint8_t delay = 100;
 
// get the current hooverpoint
1591,12 → 1592,11
// the setpoint will be fine adjusted with the gas stick position
if(HCActive && !(MKFlags & MKFLAG_EMERGENCY_LANDING))
{
static int16_t HeightTrimming = 0;
#define HEIGHT_TRIM_UP 0x01
#define HEIGHT_TRIM_DOWN 0x02
static uint8_t HeightTrimmingFlag = 0x00;
 
#define HEIGHT_CONTROL_STICKTHRESHOLD 15 * STICK_GAIN
#define HEIGHT_CONTROL_STICKTHRESHOLD 10 * STICK_GAIN
 
if(MKFlags & MKFLAG_FLY) // trim setpoint only when flying
{ // gas stick is above hoover point
1620,13 → 1620,15
HeightTrimmingFlag |= HEIGHT_TRIM_DOWN;
HeightTrimming -= abs(GasMixFraction - (HooverGas - HEIGHT_CONTROL_STICKTHRESHOLD))/STICK_GAIN;
}
else
else // Gas Stinck in Hoover Range
{
if(HeightTrimmingFlag & (HEIGHT_TRIM_UP|HEIGHT_TRIM_DOWN))
{
HeightTrimmingFlag &= ~(HEIGHT_TRIM_UP|HEIGHT_TRIM_DOWN);
HeightTrimming = 0;
SetPointHeight = ReadingHeight; // update setpointto current heigth
SetPointHeight = ReadingHeight; // update setpoint to current height
BeepModulation = 0x0100;
BeepTime = 500; // indicate hoover range entrance
}
}
// Trim height set point
1649,7 → 1651,7
if((ReadingHeight > SetPointHeight) && HCActive && !(MKFlags & MKFLAG_EMERGENCY_LANDING))
{
HCGas = GasMixFraction; // take current stick gas as neutral point for the height control
 
HeightTrimming = 0;
#endif // from this point the Heigth Control Algorithm is identical for both versions
 
 
1672,7 → 1674,7
HCGas -= tmp_int;
 
// limit deviation from hoover point within the target region
if(abs(HeightDeviation) < 200 && (HooverGas > 0)) // deviation is less than 2 meter
if( (!HeightTrimming) && (HooverGas > 0)) // height setpoint is not changed and hoover gas not zero
{
 
LIMIT_MIN_MAX(HCGas, HooverGasMin, HooverGasMax); // limit gas around the hoover point
/beta/Code Redesign killagreg/makefile
20,7 → 20,7
#EXT = MK3MAG
 
# Use one of the height control algorithms (no selection uses Holgers original)
#HC = HC_HOOVER_GAS
HC = HC_HOOVER_GAS
 
# Use optional one the RCs if EXT = NAVICTRL has been used
RC = DSL
/beta/Code Redesign killagreg/uart0.c
657,7 → 657,7
SendOutData('V', FC_ADDRESS, 1, (uint8_t *) &UART_VersionInfo, sizeof(UART_VersionInfo));
Request_VerInfo = FALSE;
}
if(Request_Display && txd_complete)
else if(Request_Display && txd_complete)
{
LCD_PrintMenu();
SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), &DisplayBuff[DisplayLine * 20], 20);
665,13 → 665,13
if(DisplayLine >= 4) DisplayLine = 0;
Request_Display = FALSE;
}
if(Request_Display1 && txd_complete)
else if(Request_Display1 && txd_complete)
{
LCD_PrintMenu();
SendOutData('L', FC_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff));
Request_Display1 = FALSE;
}
if(Request_DebugLabel != 0xFF) // Texte für die Analogdaten
else if(Request_DebugLabel != 0xFF) // Texte für die Analogdaten
{
uint8_t label[16]; // local sram buffer
memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer
678,18 → 678,18
SendOutData('A', FC_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16);
Request_DebugLabel = 0xFF;
}
if(ConfirmFrame && txd_complete) // Datensatz ohne CRC bestätigen
else if(ConfirmFrame && txd_complete) // Datensatz ohne CRC bestätigen
{
SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame));
ConfirmFrame = 0;
}
if( ((DebugData_Interval && CheckDelay(DebugData_Timer)) || Request_DebugData) && txd_complete)
else if( (((DebugData_Interval > 0) && CheckDelay(DebugData_Timer)) || Request_DebugData) && txd_complete)
{
SendOutData('D', FC_ADDRESS, 1,(uint8_t *) &DebugOut, sizeof(DebugOut));
DebugData_Timer = SetDelay(DebugData_Interval);
Request_DebugData = FALSE;
}
if( ((Data3D_Interval && CheckDelay(Data3D_Timer)) || Request_Data3D) && txd_complete)
else if( (((Data3D_Interval > 0) && CheckDelay(Data3D_Timer)) || Request_Data3D) && txd_complete)
{
SendOutData('C', FC_ADDRESS, 1,(uint8_t *) &Data3D, sizeof(Data3D));
Data3D.AngleNick = (int16_t)((10 * IntegralGyroNick) / GYRO_DEG_FACTOR); // convert to multiple of 0.1°
698,7 → 698,7
Data3D_Timer = SetDelay(Data3D_Interval);
Request_Data3D = FALSE;
}
if(Request_ExternalControl && txd_complete)
else if(Request_ExternalControl && txd_complete)
{
SendOutData('G', FC_ADDRESS, 1,(uint8_t *) &ExternControl, sizeof(ExternControl));
Request_ExternalControl = FALSE;
705,7 → 705,7
}
 
#ifdef USE_MK3MAG
if((CheckDelay(Compass_Timer)) && txd_complete)
else if((CheckDelay(Compass_Timer)) && txd_complete)
{
ToMk3Mag.Attitude[0] = (int16_t)((10 * IntegralGyroNick) / GYRO_DEG_FACTOR); // approx. 0.1 deg
ToMk3Mag.Attitude[1] = (int16_t)((10 * IntegralGyroRoll) / GYRO_DEG_FACTOR); // approx. 0.1 deg
719,12 → 719,12
}
#endif
 
if(Request_MotorTest && txd_complete)
else if(Request_MotorTest && txd_complete)
{
SendOutData('T', FC_ADDRESS, 0);
Request_MotorTest = FALSE;
}
if(Request_PPMChannels && txd_complete)
else if(Request_PPMChannels && txd_complete)
{
SendOutData('P', FC_ADDRESS, 1, (uint8_t *)&PPM_in, sizeof(PPM_in));
Request_PPMChannels = FALSE;