Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1503 → Rev 1504

/branches/V0.76g_WKN-hef/fc.c
166,9 → 166,39
int MotorSmoothing(int neu, int alt)
{
int motor;
if(neu > alt) motor = (1*(int)alt + neu) / 2;
else motor = neu - (alt - neu)*1;
//if(Poti2 < 20) return(neu);
if(neu > alt)
{
motor = (1*(int)alt + neu) / 2;
}
else
{
// Arthur P: the original code allowed the motor value to drop to 0 or negative values
// straight off, i.e. could amplify an intended decrease excessively while upregulation
// is dampened. The modification would still allow immediate drop below intended value
// but would dampen this. This would still allow for airbraking of the prop to have effect
// but it might lead to less sudden excessive drops in rpm with only gradual recovery.
// 090807 Arthur P: Due to problems with uart.c which still refers to user parameter 1 and 2 and
// possible timing issues with the shutter interval load, removed the shutter interval functions
// and switched to use of userparam6 for the motor smoothing.
// 091114 Inserted modification into 0.76g source code.
 
if(Parameter_UserParam6 < 1)
{ // Original function
motor = neu - (alt - neu)*1;
}
else
{
if(Parameter_UserParam6 == 1) // If userpara1 = 1 then 150% down on the first step followed by upsmoothing.
{
motor = neu - (1*(alt - neu)/2);
}
else // If userpara5 > 1 then allow >= 50% of the intended step down to rapidly reach the intended value.
{
motor = neu + ((alt - neu)/Parameter_UserParam6);
}
}
}
 
return(motor);
}
 
/branches/V0.76g_WKN-hef/menu.c
45,7 → 45,8
{
case 0:
LCD_printfxy(0,0,"+ MikroKopter +");
LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH +'a');
// 091114 Modified the next line by adding -Arthur P after the verion text.
LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c-Arthur P",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH +'a');
LCD_printfxy(0,2,"Setting:%d %s",GetActiveParamSetNumber(),Mixer.Name);
if(I2CTimeout < 6) LCD_printfxy(0,3,"I2C ERROR!!!")
else
/branches/V0.76g_WKN-hef/timer0.c
13,7 → 13,15
volatile int16_t ServoNickValue = 0;
volatile int16_t ServoRollValue = 0;
 
// Arthur P: Added two variables for control of the shutter servo cycle.
// 091114 Inserted same changes into v.0.76g code.
// 091114 Inactivated the following two lines as the shutter interval funtion is not
// used at the moment.
// volatile static unsigned int CameraShutterCycleCounter = 0;
// volatile static unsigned int CameraShutterCycle = 0;
 
 
 
enum {
STOP = 0,
CK = 1,
28,66 → 36,90
 
SIGNAL (SIG_OVERFLOW0) // 9,7kHz
{
static unsigned char cnt_1ms = 1,cnt = 0;
static unsigned char cnt_1ms = 1,cnt = 0;
unsigned char pieper_ein = 0;
if(SendSPI) SendSPI--;
if(SpektrumTimer) SpektrumTimer--;
if(SendSPI) SendSPI--;
if(SpektrumTimer) SpektrumTimer--;
 
if(!cnt--)
if(!cnt--)
{
cnt = 9;
cnt_1ms++;
cnt_1ms %= 2;
if(!cnt_1ms) UpdateMotor = 1;
CountMilliseconds++;
cnt = 9;
cnt_1ms++;
cnt_1ms %= 2;
if(!cnt_1ms) UpdateMotor = 1;
CountMilliseconds++;
}
 
if(beeptime >= 1)
{
beeptime--;
if(beeptime >= 1)
{
beeptime--;
if(beeptime & BeepMuster)
{
pieper_ein = 1;
}
else pieper_ein = 0;
{
pieper_ein = 1;
}
else
{
pieper_ein = 0;
BeepMuster = 0xffff;
}
else
{
pieper_ein = 0;
}
}
else
{
pieper_ein = 0;
BeepMuster = 0xffff;
}
 
if(pieper_ein)
{
if(PlatinenVersion == 10) PORTD |= (1<<2); // Speaker an PORTD.2
else PORTC |= (1<<7); // Speaker an PORTC.7
if(pieper_ein)
{
if(PlatinenVersion == 10)
{
PORTD |= (1<<2); // Speaker an PORTD.2
}
else
{
if(PlatinenVersion == 10) PORTD &= ~(1<<2);
else PORTC &= ~(1<<7);
else
{
PORTC |= (1<<7); // Speaker an PORTC.7
}
 
if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
{
if(PINC & 0x10)
{
cntKompass++;
}
else
{
if((cntKompass) && (cntKompass < 362))
}
else
{
cntKompass += cntKompass / 41;
if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0;
if(PlatinenVersion == 10)
{
PORTD &= ~(1<<2);
}
else
{
PORTC &= ~(1<<7);
}
}
// if(cntKompass < 10) cntKompass =r 10;
// KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L;
KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
cntKompass = 0;
}
}
 
if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
{
if(PINC & 0x10)
{
cntKompass++;
}
else
{
if((cntKompass) && (cntKompass < 362))
{
cntKompass += cntKompass / 41;
if(cntKompass > 10)
{
KompassValue = cntKompass - 10;
}
else
{
KompassValue = 0;
}
}
 
// if(cntKompass < 10) cntKompass =r 10;
// KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L;
KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
cntKompass = 0;
}
}
 
}
 
 
216,7 → 248,18
static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon
static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon
 
// replace below line with if(PlatinenVersion < 20) to revert to original (WKN-change)
// Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only
// called once. This retains all code changes in timer0.c. If parameter 6 > 0 then the user
// has set a value for the cycle. CameraShuytterCycle == 5x Para6 to get approx 0.1sec increments.
// 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops.
// CameraShutterCycle = 5 * Parameter_UserParam6;
// CameraShutterCycle = Parameter_UserParam6;
 
// Arthur P: Modified the code to scheck the value of parameter 8. If 128 or higher then a HEF4017 is
// expected and will be used. Else J7 and J9 are seen as separate normal outputs.
// if((PlatinenVersion < 20)
// 091114. Inserted same changes into v.0.76g code.
if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 ))
{
//---------------------------
315,7 → 358,7
RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position
ServoNickValue /= MULTIPLYER;
break;
case 2: // Roll Compensation Servo
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)
340,11 → 383,27
ServoRollValue /= MULTIPLYER;
//DebugOut.Analog[20] = ServoRollValue;
break;
case 3: // Arthur P: Shutter Servo including interval control over parameter 5 and 6.
// 091114 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts.
if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32)
{
// Set servo to null position, turning camera off.
RemainingPulse = MINSERVOPULSE;
}
else
{
RemainingPulse = MINSERVOPULSE + SERVORANGE/2;
}
break;
 
default: // other servo channels
RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs
break;
// 090807 Arthur P: Removed the output of the remaining channels as this just eats time and probably
// does not have much of a function. Better to add specific outputs as needed.
// default: // other servo channels
// RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs
// break;
}
 
// range servo pulse width
if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit
else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit