Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1208 → Rev 1209

/trunk/fc.c
146,10 → 146,43
signed int ExternStickNick = 0,ExternStickRoll = 0,ExternStickGier = 0, ExternHoehenValue = -20;
int MaxStickNick = 0,MaxStickRoll = 0;
unsigned int modell_fliegt = 0;
unsigned char MikroKopterFlags = 0;
volatile unsigned char MikroKopterFlags = 0;
long GIER_GRAD_FAKTOR = 1291;
signed int KopplungsteilNickRoll,KopplungsteilRollNick;
unsigned char RequiredMotors = 4;
 
/*
signed char Mixer.Motor[MAX_MOTORS][4] = {
{64, +64, 0, +64},//1
{64, +64, -64, -64},//2
{64, 0, -64, +64},//3
{64, -64, -64, -64},//4
{64, -64, 0, +64},//5
{64, -64, +64, -64},//6
{64, 0, +64, +64},//7
{64, +64, +64, -64},//8
{ 0, 0, 0, 0},//9
{ 0, 0, 0, 0},//10
{ 0, 0, 0, 0},//11
{ 0, 0, 0, 0}};//12
*/
/*
signed char Mixer.Motor[MAX_MOTORS][4] = {
{ 64, +64, 0, +64},//1
{ 64, -64, 0, +64},//2
{ 64, 0, -64, -64},//3
{ 64, 0, +64, -64},//4
{ 0, 0, 0, 0},//5
{ 0, 0, 0, 0},//6
{ 0, 0, 0, 0},//7
{ 0, 0, 0, 0},//8
{ 0, 0, 0, 0},//9
{ 0, 0, 0, 0},//10
{ 0, 0, 0, 0},//11
{ 0, 0, 0, 0}};//12
*/
unsigned char Motor[MAX_MOTORS];
signed int tmp_motorwert[MAX_MOTORS];
 
int MotorSmoothing(int neu, int alt)
{
458,8 → 491,10
void SendMotorData(void)
//############################################################################
{
unsigned char i;
if(!MotorenEin)
{
for(i=0;i<MAX_MOTORS;i++) Motor[i] = 0;
#ifndef QUADRO
Motor1 = 0;Motor2 = 0;Motor3 = 0;Motor4 = 0;Motor5 = 0;Motor6 = 0;Motor7 = 0;Motor8 = 0;
if(MotorTest[0]) {Motor1 = MotorTest[0]; Motor2 = MotorTest[0];}
473,6 → 508,10
if(MotorTest[2]) Motor_Links = MotorTest[2];
if(MotorTest[3]) Motor_Rechts = MotorTest[3];
#endif
if(MotorTest[0]) Motor[0] = MotorTest[0];
if(MotorTest[1]) Motor[1] = MotorTest[1];
if(MotorTest[2]) Motor[2] = MotorTest[2];
if(MotorTest[3]) Motor[3] = MotorTest[3];
 
MikroKopterFlags &= ~(FLAG_MOTOR_RUN | FLAG_FLY);
} else MikroKopterFlags |= FLAG_MOTOR_RUN;
536,7 → 575,7
void MotorRegler(void)
//############################################################################
{
int motorwert,pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
int pd_ergebnis_nick,pd_ergebnis_roll,h,tmp_int;
int GierMischanteil,GasMischanteil;
static long SummeNick=0,SummeRoll=0;
static long sollGier = 0,tmp_long,tmp_long2;
546,11 → 585,12
static unsigned char delay_neutral = 0;
static unsigned char delay_einschalten = 0,delay_ausschalten = 0;
static int hoehenregler = 0;
static int motorwert1,motorwert2,motorwert3,motorwert4,motorwert5,motorwert6,motorwert7,motorwert8;
// static int motorwert1,motorwert2,motorwert3,motorwert4,motorwert5,motorwert6,motorwert7,motorwert8;
static char TimerWerteausgabe = 0;
static char NeueKompassRichtungMerken = 0;
static long ausgleichNick, ausgleichRoll;
int IntegralNickMalFaktor,IntegralRollMalFaktor;
unsigned char i;
Mittelwert();
 
GRN_ON;
1398,143 → 1438,25
if(pd_ergebnis_roll > tmp_int) pd_ergebnis_roll = tmp_int;
if(pd_ergebnis_roll < -tmp_int) pd_ergebnis_roll = -tmp_int;
 
#ifdef QUADRO
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Quadro-Mischer
// Universal Mixer
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil; // Mischer
motorwert1 = MotorSmoothing(motorwert,motorwert1);
motorwert = motorwert1 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor_Vorne = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick + GierMischanteil;
motorwert2 = MotorSmoothing(motorwert,motorwert2);
motorwert = motorwert2 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor_Hinten = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_roll - GierMischanteil;
motorwert3 = MotorSmoothing(motorwert,motorwert3);
motorwert = motorwert3 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor_Links = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_roll - GierMischanteil;
motorwert4 = MotorSmoothing(motorwert,motorwert4);
motorwert = motorwert4 / STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor_Rechts = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++
#endif
#ifdef OCTO
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Octo-Mischer
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor1 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor2 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor3 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor4 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor5 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor6 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor7 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor8 = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++
#endif
#ifdef OCTO2
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Octo-Mischer
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor1 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor2 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor3 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick - pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor4 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor5 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor6 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor7 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick + pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor8 = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++
#endif
#ifdef OCTO3
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Octo-Mischer
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
motorwert = GasMischanteil + pd_ergebnis_nick + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor1 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_nick - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor2 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor3 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor4 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor5 = motorwert;
 
motorwert = GasMischanteil - pd_ergebnis_nick - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor6 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_roll + GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor7 = motorwert;
 
motorwert = GasMischanteil + pd_ergebnis_roll - GierMischanteil;
motorwert /= STICK_GAIN; CHECK_MIN_MAX(motorwert,MIN_GAS,MAX_GAS);
Motor8 = motorwert;
// +++++++++++++++++++++++++++++++++++++++++++++++
#endif
 
for(i=0; i<MAX_MOTORS; i++)
{
signed int tmp_int;
if(Mixer.Motor[i][0] > 0)
{
tmp_int = ((long)GasMischanteil * Mixer.Motor[i][0]) / 64L;
tmp_int += ((long)pd_ergebnis_nick * Mixer.Motor[i][1]) / 64L;
tmp_int += ((long)pd_ergebnis_roll * Mixer.Motor[i][2]) / 64L;
tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L;
tmp_motorwert[i] = MotorSmoothing(tmp_int,tmp_motorwert[i]); // Filter
tmp_int = tmp_motorwert[i] / STICK_GAIN;
CHECK_MIN_MAX(tmp_int,MIN_GAS,MAX_GAS);
Motor[i] = tmp_int;
}
else Motor[i] = 0;
}
/*
if(Poti1 > 20) Motor1 = 0;
if(Poti1 > 90) Motor6 = 0;
/trunk/fc.h
13,10 → 13,11
#define FLAG_FLY 2
#define FLAG_CALIBRATE 4
#define FLAG_START 8
#define MAX_MOTORS 12
 
#define CHECK_MIN_MAX(wert,min,max) {if(wert < min) wert = min; else if(wert > max) wert = max;}
 
extern unsigned char MikroKopterFlags;
extern volatile unsigned char MikroKopterFlags;
extern volatile unsigned int I2CTimeout;
extern unsigned char Sekunde,Minute;
 
65,13 → 66,13
extern volatile unsigned char Motor_Vorne,Motor_Hinten,Motor_Rechts,Motor_Links, Count;
extern volatile unsigned char Motor1, Motor2,Motor3,Motor4,Motor5,Motor6,Motor7,Motor8;
extern volatile unsigned char SenderOkay;
extern unsigned char RequiredMotors;
extern int StickNick,StickRoll,StickGier;
extern char MotorenEin;
extern void DefaultKonstanten1(void);
extern void DefaultKonstanten2(void);
 
 
#define STRUCT_PARAM_LAENGE 92
#define STRUCT_PARAM_LAENGE sizeof(EE_Parameter)
struct mk_param_struct
{
unsigned char Kanalbelegung[8]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3
152,9 → 153,14
char Name[12];
};
 
 
struct
{
char Name[12];
signed char Motor[16][4];
} Mixer;
extern struct mk_param_struct EE_Parameter;
 
extern unsigned char Parameter_Luftdruck_D;
extern unsigned char Parameter_MaxHoehe;
extern unsigned char Parameter_Hoehe_P;
171,16 → 177,7
extern unsigned char Parameter_J16Timing; // for the J16 Output
extern unsigned char Parameter_J17Bitmask; // for the J17 Output
extern unsigned char Parameter_J17Timing; // for the J17 Output
/*
extern unsigned char Parameter_NaviGpsModeControl; // Parameters for the Naviboard
extern unsigned char Parameter_NaviGpsGain;
extern unsigned char Parameter_NaviGpsP;
extern unsigned char Parameter_NaviGpsI;
extern unsigned char Parameter_NaviGpsD;
extern unsigned char Parameter_NaviGpsACC;
extern unsigned char Parameter_NaviOperatingRadius;
extern unsigned char Parameter_NaviWindCorrection;
extern unsigned char Parameter_NaviSpeedCompensation;
*/
extern signed char MixerTable[MAX_MOTORS][4];
extern unsigned char Motor[MAX_MOTORS];
#endif //_FC_H
 
/trunk/main.c
170,10 → 170,31
{
Uart1Init();
}
printf("\n\r==============================");
GRN_ON;
ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 9); // read only the first bytes
 
if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_REVISION]) == EE_MIXER_REVISION)
{
unsigned char i;
RequiredMotors = 0;
eeprom_read_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer));
for(i=0; i<16;i++) { if(Mixer.Motor[i][0] > 0) RequiredMotors++;}
}
else // default
{
unsigned char i;
for(i=0; i<16;i++) { Mixer.Motor[i][0] = 0;Mixer.Motor[i][1] = 0;Mixer.Motor[i][2] = 0;Mixer.Motor[i][3] = 0;};
// default = Quadro
Mixer.Motor[0][0] = 64; Mixer.Motor[0][1] = +64; Mixer.Motor[0][2] = 0; Mixer.Motor[0][3] = +64;
Mixer.Motor[1][0] = 64; Mixer.Motor[1][1] = -64; Mixer.Motor[1][2] = 0; Mixer.Motor[1][3] = +64;
Mixer.Motor[2][0] = 64; Mixer.Motor[2][1] = 0; Mixer.Motor[2][2] = -64; Mixer.Motor[2][3] = -64;
Mixer.Motor[3][0] = 64; Mixer.Motor[3][1] = 0; Mixer.Motor[3][2] = +64; Mixer.Motor[3][3] = -64;
memcpy(Mixer.Name, "Quadro\0", 11);
eeprom_write_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer));
eeprom_write_byte(&EEPromArray[EEPROM_ADR_MIXER_REVISION],EE_MIXER_REVISION); // Länge der Datensätze merken
}
printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name,RequiredMotors);
printf("\n\r==============================");
if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION)
{
DefaultKonstanten1();
250,10 → 271,8
if(UpdateMotor && AdReady) // ReglerIntervall
{
UpdateMotor=0;
//J3High;
if(WinkelOut.CalcState) CalMk3Mag();
else MotorRegler();
//J3Low;
SendMotorData();
ROT_OFF;
if(PcZugriff) PcZugriff--;
/trunk/main.h
68,7 → 68,8
//#error ################## F_CPU nicht definiert oder ungültig #############
//#endif
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define EE_DATENREVISION 74 // wird angepasst, wenn sich die EEPROM-Daten geändert haben
#define EE_DATENREVISION 75 // wird angepasst, wenn sich die EEPROM-Daten geändert haben
#define EE_MIXER_REVISION 10 // wird angepasst, wenn sich die Mixer-Daten geändert haben
 
#define EEPROM_ADR_VALID 1
#define EEPROM_ADR_ACTIVE_SET 2
83,6 → 84,9
#define EEPROM_ADR_PARAM_LENGTH 98
#define EEPROM_ADR_PARAM_BEGIN 100
 
#define EEPROM_ADR_MIXER_REVISION 1000
#define EEPROM_ADR_MIXER_TABLE 1001 // 1001 - 1100
 
#define CFG_HOEHENREGELUNG 0x01
#define CFG_HOEHEN_SCHALTER 0x02
#define CFG_HEADING_HOLD 0x04
/trunk/makefile
4,8 → 4,8
F_CPU = 20000000
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 72
VERSION_PATCH = 15
VERSION_MINOR = 73
VERSION_PATCH = 0
 
VERSION_SERIAL_MAJOR = 10 # Serial Protocol
VERSION_SERIAL_MINOR = 0 # Serial Protocol
/trunk/rc.c
65,9 → 65,9
PPM_in[index] = tmp;
}
index++;
if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen
if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen
if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen
// if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen
// if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen
// if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen
}
}
}
/trunk/spi.c
157,7 → 157,6
//------------------------------------------------------
void UpdateSPI_Buffer(void)
{
static unsigned char i =0;
signed int tmp;
cli();
 
/trunk/twimaster.c
6,7 → 6,7
volatile unsigned char twi_state = 0;
unsigned char motor = 0;
unsigned char motorread = 0;
unsigned char motor_rx[16];
unsigned char motor_rx[16],motor_rx2[16];
 
//############################################################################
//Initzialisieren der I2C (TWI) Schnittstelle
19,11 → 19,10
 
//############################################################################
//Start I2C
char i2c_start(void)
void i2c_start(void)
//############################################################################
{
TWCR = (1<<TWSTA) | (1<<TWEN) | (1<<TWINT) | (1<<TWIE);
return(0);
}
 
//############################################################################
52,18 → 51,45
}
 
//############################################################################
char i2c_write_byte(char byte)
void i2c_write_byte(char byte)
//############################################################################
{
TWSR = 0x00;
TWDR = byte;
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
return(0);
}
 
#ifndef QUADRO
/****************************************/
/* Write to I2C */
/****************************************/
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);
}
 
/****************************************/
/* Receive byte and send ACK */
/****************************************/
void I2C_ReceiveByte(void)
{
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA);
}
 
/****************************************/
/* I2C receive last byte and send no ACK*/
/****************************************/
void I2C_ReceiveLastByte(void)
{
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
}
 
 
 
//############################################################################
SIGNAL (TWI_vect)
//############################################################################
71,116 → 97,40
switch (twi_state++)
{
case 0:
i2c_write_byte(0x52+(motor*2));
J3High;
while(Mixer.Motor[motor][0] <= 0 && motor < MAX_MOTORS-1) motor++; // skip if not used
if(motor == MAX_MOTORS) { motor = 0; twi_state = 3; i2c_start(); } // writing finished -> now read
else i2c_write_byte(0x52+(motor*2));
break;
case 1:
switch(motor++)
{
case 0:
i2c_write_byte(Motor1);
break;
case 1:
i2c_write_byte(Motor2);
break;
case 2:
i2c_write_byte(Motor3);
break;
case 3:
i2c_write_byte(Motor4);
break;
case 4:
i2c_write_byte(Motor5);
break;
case 5:
i2c_write_byte(Motor6);
break;
case 6:
i2c_write_byte(Motor7);
break;
case 7:
i2c_write_byte(Motor8);
break;
}
i2c_write_byte(Motor[motor++]);
break;
case 2:
i2c_stop();
if (motor<8) twi_state = 0;
else motor = 0;
twi_state = 0;
i2c_start();
break;
//Liest Daten von Motor
case 3:
i2c_write_byte(0x53+(motorread*2));
J5High;
while(Mixer.Motor[motorread][0] <= 0 && MAX_MOTORS-1) motorread++;
if(motorread >= MAX_MOTORS) {motorread = 0;J4High;}
else i2c_write_byte(0x53+(motorread*2));
break;
case 4:
switch(motorread)
{
case 0:
i2c_write_byte(Motor1);
break;
case 1:
i2c_write_byte(Motor2);
break;
case 2:
i2c_write_byte(Motor3);
break;
case 3:
i2c_write_byte(Motor4);
break;
case 4:
i2c_write_byte(Motor5);
break;
case 5:
i2c_write_byte(Motor6);
break;
case 6:
i2c_write_byte(Motor7);
break;
case 7:
i2c_write_byte(Motor8);
break;
}
//Transmit 1st byte for reading
I2C_ReceiveByte();
break;
case 5: //1 Byte vom Motor lesen
case 5: //Read 1st byte and transmit 2nd Byte
motor_rx[motorread] = TWDR;
 
I2C_ReceiveLastByte(); //nack
break;
case 6:
switch(motorread)
{
case 0:
i2c_write_byte(Motor1);
break;
case 1:
i2c_write_byte(Motor2);
break;
case 2:
i2c_write_byte(Motor3);
break;
case 3:
i2c_write_byte(Motor4);
break;
case 4:
i2c_write_byte(Motor5);
break;
case 5:
i2c_write_byte(Motor6);
break;
case 6:
i2c_write_byte(Motor7);
break;
case 7:
i2c_write_byte(Motor8);
break;
}
break;
case 7: //2 Byte vom Motor lesen
motor_rx[motorread+8] = TWDR;
motorread++;
if (motorread>7) motorread=0;
//Read 2nd byte
motor_rx2[motorread++] = TWDR;
i2c_stop();
twi_state = 0;
I2CTimeout = 10;
twi_state = 0;
break;
case 8: // Gyro-Offset
i2c_write_byte(0x98); // Address of the DAC
233,10 → 183,15
I2CTimeout = 10;
twi_state = 0;
break;
}
default: twi_state = 0;
break;
}
TWCR |= 0x80;
J3Low;
J4Low;
J5Low;
}
#else
/*
//############################################################################
SIGNAL (TWI_vect)
//############################################################################
373,4 → 328,4
}
TWCR |= 0x80;
}
#endif
*/
/trunk/twimaster.h
25,9 → 25,9
 
void i2c_reset(void);
extern void i2c_init (void); // I2C initialisieren
extern char i2c_start (void); // Start I2C
extern void i2c_start (void); // Start I2C
extern void i2c_stop (void); // Stop I2C
extern char i2c_write_byte (char byte); // 1 Byte schreiben
extern void i2c_write_byte (char byte); // 1 Byte schreiben
extern void i2c_reset(void);
 
#endif
/trunk/uart.c
306,6 → 306,19
PcZugriff = 255;
break;
 
case 'n':// "Get Mixer
while(!UebertragungAbgeschlossen);
SendOutData('N', FC_ADDRESS, 1, (unsigned char *) &Mixer,sizeof(Mixer));
break;
 
case 'm':// "Write Mixer
memcpy(&Mixer, (unsigned char *)pRxData, sizeof(Mixer));
eeprom_write_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer));
eeprom_write_byte(&EEPromArray[EEPROM_ADR_MIXER_REVISION],EE_MIXER_REVISION); // Länge der Datensätze merken
while(!UebertragungAbgeschlossen);
SendOutData('M', FC_ADDRESS, 1, 1, 1);
break;
 
case 'p': // get PPM Channels
GetPPMChannelAnforderung = 1;
break;
/trunk/version.txt
237,3 → 237,8
0.72p: H.Buss 01.03.2009
- Octo3 erstellt
- Analogwerte umbenannt
 
0.73a: H.Buss 12.03.2009
- MixerTabelle implementiert