Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2016 → Rev 2017

/branches/dongfang_FC_rewrite/analog.c
4,7 → 4,7
// + www.MikroKopter.com
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
// + dass eine Nutzung (auch auszugsweise) nur f�r den privaten und nicht-kommerziellen Gebrauch zulässig ist.
// + dass eine Nutzung (auch auszugsweise) nur für den privaten und nicht-kommerziellen Gebrauch zulässig ist.
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
// + bzgl. der Nutzungsbedingungen aufzunehmen.
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
134,6 → 134,9
* 7: pp=-1,pr=1, rp=1, rr=1 // +315 degrees with pitch reversed
*/
 
void rotate(int16_t* result, uint8_t quadrant, uint8_t reverse) {}
 
/*
void rotate(int16_t* result, uint8_t quadrant, uint8_t reverse) {
static const int8_t rotationTab[] = {1,1,0,-1,-1,-1,0,1};
// Pitch to Pitch part
158,7 → 161,7
result[1] = (result[1]*11) >> 4;
}
}
 
*/
/*
* Air pressure
*/
301,6 → 304,7
 
void startAnalogConversionCycle(void) {
analogDataReady = 0;
 
// Stop the sampling. Cycle is over.
for (uint8_t i = 0; i < 8; i++) {
sensorInputs[i] = 0;
340,7 → 344,6
debugOut.digital[0] &= ~DEBUG_SENSORLIMIT;
for (uint8_t axis=0; axis<2; axis++) {
tempGyro = rawGyroValue(axis);
 
/*
* Process the gyro data for the PID controller.
*/
386,6 → 389,15
*/
rotate(tempOffsetGyro, staticParams.gyroQuadrant, staticParams.imuReversedFlags & 1);
 
gyro_ATT[PITCH] = tempOffsetGyro[PITCH];
gyro_ATT[ROLL] = tempOffsetGyro[ROLL];
 
debugOut.analog[22 + 0] = gyro_PID[0];
debugOut.analog[22 + 1] = gyro_PID[1];
 
debugOut.analog[24 + 0] = gyro_ATT[0];
debugOut.analog[24 + 1] = gyro_ATT[1];
 
// 2) Filter. This should really be quite unnecessary. The integration should gobble up any noise anyway and the values are not used for anything else.
// gyro_ATT[PITCH] = (gyro_ATT[PITCH] * (staticParams.attitudeGyroFilter - 1) + tempOffsetGyro[PITCH]) / staticParams.attitudeGyroFilter;
// gyro_ATT[ROLL] = (gyro_ATT[ROLL] * (staticParams.attitudeGyroFilter - 1) + tempOffsetGyro[ROLL]) / staticParams.attitudeGyroFilter;
/branches/dongfang_FC_rewrite/attitude.c
303,7 → 303,7
}
 
if (accVector <= dynamicParams.maxAccVector) {
debugOut.digital[0] |= DEBUG_ACC0THORDER;
debugOut.digital[0] &= ~ DEBUG_ACC0THORDER;
uint8_t permilleAcc = staticParams.zerothOrderCorrection;
int32_t accDerived;
344,7 → 344,7
debugOut.analog[10] = 0;
// experiment: Kill drift compensation updates when not flying smooth.
// correctionSum[PITCH] = correctionSum[ROLL] = 0;
debugOut.digital[0] &= ~DEBUG_ACC0THORDER;
debugOut.digital[0] |= DEBUG_ACC0THORDER;
}
}
 
/branches/dongfang_FC_rewrite/configuration.c
163,7 → 163,7
 
uint8_t getCPUType(void) { // works only after reset or power on when the registers have default values
uint8_t CPUType = ATMEGA644;
//if((UCSR1A == 0x20) && (UCSR1C == 0x06)) CPUType = ATMEGA644P; // initial Values for 644P after reset
if((UCSR1A == 0x20) && (UCSR1C == 0x06)) CPUType = ATMEGA644P; // initial Values for 644P after reset
return CPUType;
}
 
/branches/dongfang_FC_rewrite/configuration.h
61,7 → 61,7
extern channelMap_t channelMap;
 
typedef struct {
int8_t name[12];
char name[12];
int8_t motor[MAX_MOTORS][4];
}__attribute__((packed)) mixerMatrix_t;
extern mixerMatrix_t mixerMatrix;
113,7 → 113,6
uint8_t motorSmoothing;
// IMU
// IMU stuff
uint8_t gyroQuadrant;
uint8_t accQuadrant;
uint8_t imuReversedFlags;
160,7 → 159,7
uint8_t userParams[8]; // Value : 0-250
 
// Name
uint8_t name[12];
char name[12];
} paramset_t;
extern paramset_t staticParams;
 
/branches/dongfang_FC_rewrite/controlMixer.c
142,6 → 142,7
void updateControlAndMeasureControlActivity(uint8_t index, int16_t newValue) {
int16_t tmp = controls[index];
controls[index] = newValue;
tmp -= newValue;
tmp /= 2;
tmp = tmp * tmp;
/branches/dongfang_FC_rewrite/flight.c
437,7 → 437,7
CHECK_MIN_MAX(tmp, 1, 255);
throttle = tmp;
 
if (i < 4) debugOut.analog[22 + i] = throttle;
// if (i < 4) debugOut.analog[22 + i] = throttle;
 
if ((MKFlags & MKFLAG_MOTOR_RUN) && mixerMatrix.motor[i][MIX_THROTTLE] > 0) {
motor[i].SetPoint = throttle;
/branches/dongfang_FC_rewrite/invenSense.c
16,8 → 16,7
 
void gyro_calibrate(void) {
// If port not already set to output and high, do it.
if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
<< AUTOZERO_BIT))) {
if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1 << AUTOZERO_BIT))) {
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
delay_ms(100);
28,7 → 27,7
delay_ms(1);
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
// Delay_ms(10);
delay_ms_with_adc_measurement(100);
delay_ms_with_adc_measurement(100, 0);
}
 
void gyro_loadAmplifierOffsets(uint8_t overwriteWithDefaults) {
38,6 → 37,7
void gyro_setDefaultParameters(void) {
staticParams.gyroD = 3;
staticParams.driftCompDivider = 2;
staticParams.driftCompLimit = 3;
staticParams.zerothOrderCorrection = 2;
staticParams.driftCompLimit = 5;
staticParams.zerothOrderCorrection = 1;
staticParams.imuReversedFlags = 8;
}
/branches/dongfang_FC_rewrite/makefile
23,11 → 23,11
#RC = DSL
#RC = SPECTRUM
 
GYRO=ENC-03_FC1.3
GYRO_HW_NAME=ENC
GYRO_HW_FACTOR=1.304f
GYRO_PITCHROLL_CORRECTION=1.0f
GYRO_YAW_CORRECTION=1.0f
#GYRO=ENC-03_FC1.3
#GYRO_HW_NAME=ENC
#GYRO_HW_FACTOR=1.304f
#GYRO_PITCHROLL_CORRECTION=1.0f
#GYRO_YAW_CORRECTION=1.0f
 
#GYRO=ADXRS610_FC2.0
#GYRO_HW_NAME=ADXR
35,11 → 35,11
#GYRO_PITCHROLL_CORRECTION=1.0f
#GYRO_YAW_CORRECTION=1.0f
 
#GYRO=invenSense
#GYRO_HW_NAME=Isense
#GYRO_HW_FACTOR=0.6827f
#GYRO_PITCHROLL_CORRECTION=1.0f
#GYRO_YAW_CORRECTION=1.0f
GYRO=invenSense
GYRO_HW_NAME=Isense
GYRO_HW_FACTOR=0.6827f
GYRO_PITCHROLL_CORRECTION=1.0f
GYRO_YAW_CORRECTION=1.0f
 
#-------------------------------------------------------------------
# get SVN revision
/branches/dongfang_FC_rewrite/rc.c
170,7 → 170,7
// signal range is from 1.0ms/3.2us = 312 to 2.0ms/3.2us = 625
if ((signal > 250) && (signal < 687)) {
// shift signal to zero symmetric range -154 to 159
signal -= 470; // offset of 1.4912 ms ??? (469 * 3.2�s = 1.5008 ms)
signal -= 470; // offset of 1.4912 ms ??? (469 * 3.2us = 1.5008 ms)
// check for stable signal
if (abs(signal - PPM_in[index]) < 6) {
if (RC_Quality < 200)