/trunk/analog.c |
---|
108,14 → 108,22 |
break; |
case 9: |
AdWertAccHoch = (signed int) ADC - NeutralAccZ; |
AdWertAccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4; |
// AdWertAccHoch += abs(Aktuell_ay) / 4 + abs(Aktuell_ax) / 4; |
if(AdWertAccHoch > 1) |
{ |
if(NeutralAccZ < 800) NeutralAccZ+= 0.02; |
if(NeutralAccZ < 750) |
{ |
NeutralAccZ += 0.02; |
if(modell_fliegt < 500) NeutralAccZ += 0.1; |
} |
} |
else if(AdWertAccHoch < -1) |
{ |
if(NeutralAccZ > 600) NeutralAccZ-= 0.02; |
if(NeutralAccZ > 550) |
{ |
NeutralAccZ-= 0.02; |
if(modell_fliegt < 500) NeutralAccZ -= 0.1; |
} |
} |
messanzahl_AccHoch = 1; |
Aktuell_az = ADC; |
129,7 → 137,7 |
{ |
MessLuftdruck = ADC; |
messanzahl_Druck = 0; |
HoeheD = (int)(StartLuftdruck - tmpLuftdruck - HoehenWert); // D-Anteil = neuerWert - AlterWert |
HoeheD = (7 * HoeheD + (int) Parameter_Luftdruck_D * (int)(StartLuftdruck - tmpLuftdruck - HoehenWert))/8; // D-Anteil = neuerWert - AlterWert |
Luftdruck = (tmpLuftdruck + 3 * Luftdruck) / 4; |
HoehenWert = StartLuftdruck - Luftdruck; |
tmpLuftdruck = 0; |
/trunk/fc.c |
---|
123,6 → 123,7 |
struct mk_param_struct EE_Parameter; |
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20; |
int MaxStickNick = 0,MaxStickRoll = 0; |
unsigned int modell_fliegt = 0; |
void Piep(unsigned char Anzahl) |
{ |
428,7 → 429,6 |
static unsigned int RcLostTimer; |
static unsigned char delay_neutral = 0; |
static unsigned char delay_einschalten = 0,delay_ausschalten = 0; |
static unsigned int modell_fliegt = 0; |
static int hoehenregler = 0; |
static char TimerWerteausgabe = 0; |
static char NeueKompassRichtungMerken = 0; |
486,13 → 486,11 |
{ |
if(modell_fliegt < 0xffff) modell_fliegt++; |
} |
if((modell_fliegt < 200)) |
if((modell_fliegt < 256)) |
{ |
SummeNick = 0; |
SummeRoll = 0; |
// StickGier = 0; |
// Mess_Integral_Gier = 0; |
// Mess_Integral_Gier2 = 0; |
if(modell_fliegt == 260) NeueKompassRichtungMerken = 1; |
} |
if((PPM_in[EE_Parameter.Kanalbelegung[K_GAS]] > 80) && MotorenEin == 0) |
{ |
635,7 → 633,7 |
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
//+ Digitale Steuerung per DubWise |
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#define KEY_VALUE (Parameter_UserParam1 * 4) //(Poti3 * 8) |
#define KEY_VALUE (Parameter_UserParam8 * 4) //(Poti3 * 8) |
if(DubWiseKeys[1]) beeptime = 10; |
if(DubWiseKeys[1] & DUB_KEY_UP) tmp_int = KEY_VALUE; else |
if(DubWiseKeys[1] & DUB_KEY_DOWN) tmp_int = -KEY_VALUE; else tmp_int = 0; |
655,7 → 653,7 |
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
//+ Analoge Steuerung per Seriell |
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if(ExternControl.Config & 0x01 && Parameter_UserParam1 > 128) |
if(ExternControl.Config & 0x01 && Parameter_UserParam8 > 128) |
{ |
StickNick += (int) ExternControl.Nick * (int) EE_Parameter.Stick_P; |
StickRoll += (int) ExternControl.Roll * (int) EE_Parameter.Stick_P; |
1135,10 → 1133,11 |
{ |
h = ((h - SollHoehe) * (int) Parameter_Hoehe_P) / (16 / STICK_GAIN); // Differenz bestimmen --> P-Anteil |
h = GasMischanteil - h; // vom Gas abziehen |
h -= (HoeheD * Parameter_Luftdruck_D)/(8/STICK_GAIN); // D-Anteil |
tmp_int = ((Mess_Integral_Hoch / 512) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (32 / STICK_GAIN); |
if(tmp_int > 50*STICK_GAIN) tmp_int = 50*STICK_GAIN; |
else if(tmp_int < -(50*STICK_GAIN)) tmp_int = -(50*STICK_GAIN); |
// h -= (HoeheD * Parameter_Luftdruck_D)/(8/STICK_GAIN); // D-Anteil |
h -= (HoeheD)/(8/STICK_GAIN); // D-Anteil |
tmp_int = ((Mess_Integral_Hoch / 128) * (signed long) Parameter_Hoehe_ACC_Wirkung) / (128 / STICK_GAIN); |
if(tmp_int > 70*STICK_GAIN) tmp_int = 70*STICK_GAIN; |
else if(tmp_int < -(70*STICK_GAIN)) tmp_int = -(70*STICK_GAIN); |
h -= tmp_int; |
hoehenregler = (hoehenregler*15 + h) / 16; |
if(hoehenregler < EE_Parameter.Hoehe_MinGas * STICK_GAIN) // nicht unter MIN |
/trunk/fc.h |
---|
31,6 → 31,7 |
extern signed int ExternStickNick,ExternStickRoll,ExternStickGier; |
extern unsigned char Parameter_UserParam1,Parameter_UserParam2,Parameter_UserParam3,Parameter_UserParam4,Parameter_UserParam5,Parameter_UserParam6,Parameter_UserParam7,Parameter_UserParam8; |
extern int NaviAccNick,NaviAccRoll,NaviCntAcc; |
extern unsigned int modell_fliegt; |
void MotorRegler(void); |
void SendMotorData(void); |
void CalibrierMittelwert(void); |
/trunk/makefile |
---|
5,7 → 5,7 |
#------------------------------------------------------------------- |
HAUPT_VERSION = 0 |
NEBEN_VERSION = 69 |
VERSION_INDEX = 8 |
VERSION_INDEX = 9 |
VERSION_KOMPATIBEL = 7 # PC-Kompatibilität |
#------------------------------------------------------------------- |
/trunk/spi.c |
---|
176,13 → 176,13 |
break; |
case SPI_CMD_STICK: |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; if(tmp > 128) tmp = 128; else if(tmp < -127) tmp = -127; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
ToNaviCtrl.Param.Byte[0] = (char) tmp; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; if(tmp > 128) tmp = 128; else if(tmp < -127) tmp = -127; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
ToNaviCtrl.Param.Byte[1] = (char) tmp; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; if(tmp > 128) tmp = 128; else if(tmp < -127) tmp = -127; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
ToNaviCtrl.Param.Byte[2] = (char) tmp; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; if(tmp > 128) tmp = 128; else if(tmp < -127) tmp = -127; |
tmp = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
ToNaviCtrl.Param.Byte[3] = (char) tmp; |
ToNaviCtrl.Param.Byte[4] = (unsigned char) Poti1; |
ToNaviCtrl.Param.Byte[5] = (unsigned char) Poti2; |
/trunk/timer0.c |
---|
85,7 → 85,7 |
} |
} |
//---------------------------- |
void Timer_Init(void) |
{ |
tim_main = SetDelay(10); |
97,10 → 97,11 |
//OCR1 = 0x00; |
TCCR2A=(1<<COM2A1)|(1<<COM2A0)|3; |
TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22); |
// TCCR2B=(0<<CS20)|(1<<CS21)|(1<<CS22); // clk/256 |
TCCR2B=(0<<CS20)|(0<<CS21)|(1<<CS22); // clk/64 |
// TIMSK2 |= _BV(TOIE2); |
TIMSK2 |= _BV(OCIE2A); |
TIMSK2 |= _BV(OCIE2A); |
TIMSK0 |= _BV(TOIE0); |
OCR2A = 10; |
143,10 → 144,60 |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// Servo ansteuern |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
SIGNAL(SIG_OVERFLOW2) |
{ |
PORTD |= 0x80; |
TCCR2A =3; |
TIMSK2 &= ~_BV(TOIE2); |
} |
SIGNAL(SIG_OUTPUT_COMPARE2A) |
{ |
static unsigned char timer = 10; |
#define MULTIPLIER 4 |
#define PPM_OFFSET 256 // 820us |
static unsigned int timer = 10 * MULTIPLIER; |
if(timer == 3) |
{ |
ServoValue = PPM_OFFSET; |
ServoValue += (int) Parameter_ServoNickControl * 2; |
if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128 )/ (512/MULTIPLIER); |
else ServoValue -= ((long) (EE_Parameter.ServoNickComp * IntegralNick) / 128) / (512/MULTIPLIER); |
if((ServoValue) < ((int)EE_Parameter.ServoNickMin*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMin*MULTIPLIER; |
else if((ServoValue) > ((int)EE_Parameter.ServoNickMax*MULTIPLIER)) ServoValue = (int)EE_Parameter.ServoNickMax*MULTIPLIER; |
ServoValue = 500; |
DebugOut.Analog[23] = ServoValue; |
TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3; |
OCR2A = ServoValue % 256; |
TIMSK2 |= _BV(TOIE2); |
} |
else if (timer < 3) |
{ |
if (ServoValue > 255) |
{ PORTD |= 0x80; |
TCCR2A =3; |
ServoValue -= 255; |
} |
else |
{ |
TCCR2A =3; |
PORTD&=~0x80; |
OCR2A = 0xff; |
} |
if (timer == 0) timer = (int) EE_Parameter.ServoNickRefresh * MULTIPLIER; |
} |
timer--; |
/* static unsigned char timer = 10; |
if(!timer--) |
{ |
TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3; |
164,5 → 215,6 |
{ |
TCCR2A =3; |
PORTD&=~0x80; |
} |
} */ |
} |