Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1642 → Rev 1643

/trunk/analog.c
25,6 → 25,7
unsigned char AnalogOffsetNick = 115,AnalogOffsetRoll = 115,AnalogOffsetGier = 115;
unsigned char GyroDefektN = 0,GyroDefektR = 0,GyroDefektG = 0;
volatile unsigned char AdReady = 1;
float NeutralAccZ_float;
//#######################################################################################
//
void ADC_Init(void)
155,6 → 156,7
kanal = AD_ACC_Z;
break;
case 8:
 
AdWertAccHoch = (signed int) ADC - NeutralAccZ;
if(AdWertAccHoch > 1)
{
174,34 → 176,29
if(subcount < -1000) { NeutralAccZ--; subcount += 1000;}
}
}
messanzahl_AccHoch = 1;
Aktuell_az = ADC;
Mess_Integral_Hoch += AdWertAccHoch; // Integrieren
Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen
 
/*
AdWertAccHoch = (signed int) ADC - NeutralAccZ;
AdWertAccHoch = (signed int) ADC - NeutralAccZ_float;
if(AdWertAccHoch > 1)
{
if(NeutralAccZ < 750)
if(NeutralAccZ_float < 750)
{
NeutralAccZ += 0.02;
if(modell_fliegt < 500) NeutralAccZ += 0.1;
NeutralAccZ_float += 0.02;
if(modell_fliegt < 500) NeutralAccZ_float += 0.1;
}
}
else if(AdWertAccHoch < -1)
{
if(NeutralAccZ > 550)
if(NeutralAccZ_float > 550)
{
NeutralAccZ-= 0.02;
if(modell_fliegt < 500) NeutralAccZ -= 0.1;
NeutralAccZ_float-= 0.02;
if(modell_fliegt < 500) NeutralAccZ_float -= 0.1;
}
}
*/
messanzahl_AccHoch = 1;
Aktuell_az = ADC;
Mess_Integral_Hoch += AdWertAccHoch; // Integrieren
Mess_Integral_Hoch -= Mess_Integral_Hoch / 1024; // dämfen
*/
kanal = AD_DRUCK;
break;
// "case 8:" fehlt hier absichtlich
/trunk/fc.c
63,7 → 63,8
int MesswertNick,MesswertRoll,MesswertGier,MesswertGierBias, RohMesswertNick,RohMesswertRoll;
int TrimNick, TrimRoll;
int AdNeutralNick = 0,AdNeutralRoll = 0,AdNeutralGier = 0,StartNeutralRoll = 0,StartNeutralNick = 0;
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch, NeutralAccX=0, NeutralAccY=0;
int Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch;
unsigned int NeutralAccX=0, NeutralAccY=0;
int NaviAccNick, NaviAccRoll,NaviCntAcc = 0;
int NeutralAccZ = 0;
unsigned char CosinusNickWinkel = 0, CosinusRollWinkel = 0;
184,13 → 185,12
DebugOut.Analog[3] = Mittelwert_AccRoll / 4;
DebugOut.Analog[4] = MesswertGier;
DebugOut.Analog[5] = HoehenWert/5;
DebugOut.Analog[6] = AdWertAccHoch;// Aktuell_az;//(Mess_Integral_Hoch / 512);//Aktuell_az;
DebugOut.Analog[6] = (Mess_Integral_Hoch / 512);//AdWertAccHoch;// Aktuell_az;//(Mess_Integral_Hoch / 512);//Aktuell_az;
DebugOut.Analog[8] = KompassValue;
DebugOut.Analog[9] = UBat;
DebugOut.Analog[10] = SenderOkay;
DebugOut.Analog[11] = ErsatzKompass / GIER_GRAD_FAKTOR;
DebugOut.Analog[16] = NeutralAccZ;
DebugOut.Analog[18] = TransmitBlConfig;
//DebugOut.Analog[16] = Motor[0].Temperature;
//DebugOut.Analog[17] = FromNaviCtrl_Value.Distance;
// DebugOut.Analog[18] = VarioMeter;
/trunk/fc.h
52,8 → 52,8
extern long HoehenWert;
extern long SollHoehe;
extern int MesswertNick,MesswertRoll,MesswertGier;
extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll;
extern int NeutralAccX, NeutralAccY,Mittelwert_AccHoch;
extern int AdNeutralNick,AdNeutralRoll,AdNeutralGier, Mittelwert_AccNick, Mittelwert_AccRoll,Mittelwert_AccHoch;
extern unsigned int NeutralAccX, NeutralAccY;
extern unsigned char HoehenReglerAktiv;
extern int NeutralAccZ;
extern long Umschlag180Nick, Umschlag180Roll;
/trunk/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/main.c
254,13 → 254,13
}
if(UpdateMotor && AdReady) // ReglerIntervall
{
J3High;
UpdateMotor=0;
J4High;
if(WinkelOut.CalcState) CalMk3Mag();
else MotorRegler();
SendMotorData();
J3Low;
if(UpdateMotor) DebugOut.Analog[17]++;
J4Low;
ROT_OFF;
if(SenderOkay) SenderOkay--;
else
/trunk/timer0.c
28,21 → 28,23
 
ISR(TIMER0_OVF_vect) // 9,7kHz
{
static unsigned char cnt_1ms = 1,cnt = 0;
unsigned char pieper_ein = 0;
static unsigned char cnt_1ms = 1,cnt = 0, compass_active = 0;
unsigned char pieper_ein = 0;
if(SendSPI) SendSPI--;
if(SpektrumTimer) SpektrumTimer--;
if(!cnt--)
{
cnt = 9;
CountMilliseconds++;
cnt_1ms++;
cnt_1ms %= 2;
 
if(!cnt_1ms) UpdateMotor = 1;
CountMilliseconds++;
}
if(beeptime >= 1)
if(!PINC & 0x10) compass_active = 1;
 
if(beeptime >= 10)
{
beeptime--;
beeptime -= 10;
if(beeptime & BeepMuster)
{
pieper_ein = 1;
64,12 → 66,12
if(PlatinenVersion == 10) PORTD &= ~(1<<2);
else PORTC &= ~(1<<7);
}
 
if(!NaviDataOkay && EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
}
if(compass_active && !NaviDataOkay && EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV)
{
if(PINC & 0x10)
{
cntKompass++;
if(++cntKompass > 1000) compass_active = 0;
}
else
{
/trunk/twimaster.c
4,8 → 4,9
#include "main.h"
 
volatile unsigned char twi_state = 0;
unsigned char motor = 0,TransmitBlConfig = 0;
unsigned char motor = 0,TransmitBlConfig = 1;
unsigned char motorread = 0,MissingMotor = 0;
unsigned char ReadTemperature = 0;
 
MotorData_t Motor[MAX_MOTORS];
 
37,30 → 38,8
I2C_Start();
i2c_write_byte(0);
}
/*
//############################################################################
void i2c_write_byte(char byte)
//############################################################################
{
TWSR = 0x00;
TWDR = byte;
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
}
*/
 
/*
void I2C_WriteByte(int8_t byte)
{
// move byte to send into TWI Data Register
TWDR = byte;
// clear interrupt flag (TWINT = 1)
// enable i2c bus (TWEN = 1)
// enable interrupt (TWIE = 1)
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
}
*/
 
/*
//############################################################################
SIGNAL (TWI_vect)
//############################################################################
202,8 → 181,8
SIGNAL (TWI_vect)
//############################################################################
{ // 2 3 4 5 6 7 8 9
unsigned char test[] = {0,0,'#',0x1F,255,30,100,64,0x00,7,8,9,10};
static unsigned char missing_motor,send = 0,crc = 0;
unsigned char test[] = {0,0,'#',0x1F,255,30,99,49,0x00,7,8,9,10};
static unsigned char missing_motor,send = 0,crc = 0,read_more = 0;
 
switch(twi_state++)
{
223,13 → 202,14
break;
case 1:
i2c_write_byte(Motor[motor].SetPoint);
if(!(Motor[motor].Version & MOTOR_STATE_NEW_PROTOCOL_MASK)/* || !Motor[motor].SetPointLowerBits*/)
twi_state++;
// if(!(Motor[motor].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) /*|| !Motor[motor].SetPointLowerBits*/)
if(!(Motor[motor].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) || !Motor[motor].SetPointLowerBits && !TransmitBlConfig)
twi_state++; // skip
break;
case 2:
if(!send++)
{
i2c_write_byte((Motor[motor].SetPointLowerBits << 1));// + (7 << 0));
i2c_write_byte((Motor[motor].SetPointLowerBits << 1) & 0x07);
crc = 0xAA;
}
else
266,7 → 246,7
{
Motor[motorread].State &= ~MOTOR_STATE_PRESENT_MASK; // clear present bit
motorread++;
if(motorread >= MAX_MOTORS) { TransmitBlConfig = 0; motorread = 0; }
if(motorread >= MAX_MOTORS) { TransmitBlConfig = 0; motorread = 0; ReadTemperature = ++ReadTemperature & 0x0f;}
I2C_Stop();
twi_state = 0;
}
273,7 → 253,16
else
{
Motor[motorread].State |= MOTOR_STATE_PRESENT_MASK; // set present bit
I2C_ReceiveByte();
if(motorread == ReadTemperature || TransmitBlConfig)
{
read_more = 1;
I2C_ReceiveByte();
}
else
{
I2C_ReceiveLastByte();
read_more = 0;
}
}
MissingMotor = missing_motor;
missing_motor = 0;
280,7 → 269,14
break;
case 5: //Read 1st byte and transmit 2nd Byte
Motor[motorread].Current = TWDR;
I2C_ReceiveByte(); //nack
if(read_more) I2C_ReceiveByte() //nack
else
{
motorread++; // next motor
if(motorread >= MAX_MOTORS) { TransmitBlConfig = 0; motorread = 0; ReadTemperature = ++ReadTemperature & 0x0f;}
I2C_Stop();
twi_state = 0;
}
break;
case 6:
//Read 2nd byte and transmit 3rd Byte
287,7 → 283,7
Motor[motorread].MaxPWM = TWDR;
if(TWDR == 250)
{
Motor[motorread].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK;
if(!MotorenEin) Motor[motorread].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK;
}
else if(TransmitBlConfig) Motor[motorread].Version = 0;
I2C_ReceiveLastByte(); //nack
298,7 → 294,7
if(motorread >= MAX_MOTORS) { TransmitBlConfig = 0; motorread = 0; }
I2C_Stop();
twi_state = 0;
break;
break;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// writing Gyro-Offset
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++