1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

corrected gyro scale factor for MPU3000/6000

fixed fy90q battery adc (which didn't actually exist)
spektrum channel order is configurable by 'map' command (maybe).

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@147 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop 2012-04-09 15:01:51 +00:00
parent d9920756d9
commit 4087cc0ca7
7 changed files with 4415 additions and 3943 deletions

View file

@ -827,10 +827,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>12</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>49</TopLine>
<CurrentLine>17</CurrentLine> <CurrentLine>62</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\main.c</PathWithFileName> <PathWithFileName>.\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath> <FilenameWithoutPath>main.c</FilenameWithoutPath>

View file

@ -1787,7 +1787,7 @@
</ArmAdsMisc> </ArmAdsMisc>
<Cads> <Cads>
<interw>1</interw> <interw>1</interw>
<Optim>4</Optim> <Optim>1</Optim>
<oTime>0</oTime> <oTime>0</oTime>
<SplitLS>0</SplitLS> <SplitLS>0</SplitLS>
<OneElfS>0</OneElfS> <OneElfS>0</OneElfS>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
#include "board.h" #include "board.h"
#define ADC_CHANNELS 10 #define ADC_CHANNELS 9
volatile uint16_t adcData[ADC_CHANNELS] = { 0, }; volatile uint16_t adcData[ADC_CHANNELS] = { 0, };
extern uint16_t acc_1G; extern uint16_t acc_1G;
@ -82,8 +82,6 @@ void adcInit(void)
ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 8, ADC_SampleTime_28Cycles5); // POT_AIL ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 8, ADC_SampleTime_28Cycles5); // POT_AIL
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 9, ADC_SampleTime_28Cycles5); // POT_RUD ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 9, ADC_SampleTime_28Cycles5); // POT_RUD
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 10, ADC_SampleTime_28Cycles5); // Power Monitor??
ADC_DMACmd(ADC1, ENABLE); ADC_DMACmd(ADC1, ENABLE);
ADC_Cmd(ADC1, ENABLE); ADC_Cmd(ADC1, ENABLE);
@ -97,6 +95,9 @@ void adcInit(void)
static void adcAccRead(int16_t *accelData) static void adcAccRead(int16_t *accelData)
{ {
// ADXL335
// 300mV/g
// Vcc 3.0V
accelData[0] = adcData[3]; accelData[0] = adcData[3];
accelData[1] = adcData[4]; accelData[1] = adcData[4];
accelData[2] = adcData[5]; accelData[2] = adcData[5];
@ -109,6 +110,17 @@ static void adcAccAlign(int16_t *accelData)
static void adcGyroRead(int16_t *gyroData) static void adcGyroRead(int16_t *gyroData)
{ {
// Vcc: 3.0V
// Pitch/Roll: LPR550AL, 2000dps mode.
// 0.5mV/dps
// Zero-rate: 1.23V
// Yaw: LPY550AL, 2000dps mode.
// 0.5mV/dps
// Zero-rate: 1.23V
// Need to match with: 14.375lsb per dps
// 12-bit ADC
gyroData[0] = adcData[0] * 2; gyroData[0] = adcData[0] * 2;
gyroData[1] = adcData[1] * 2; gyroData[1] = adcData[1] * 2;
gyroData[2] = adcData[2] * 2; gyroData[2] = adcData[2] * 2;
@ -126,5 +138,5 @@ static void adcDummyInit(void)
uint16_t adcGetBattery(void) uint16_t adcGetBattery(void)
{ {
return adcData[9]; return 0;
} }

View file

@ -129,7 +129,10 @@ void computeIMU(void)
#define INV_GYR_CMPF_FACTOR (1.0f / (GYR_CMPF_FACTOR + 1.0f)) #define INV_GYR_CMPF_FACTOR (1.0f / (GYR_CMPF_FACTOR + 1.0f))
#define INV_GYR_CMPFM_FACTOR (1.0f / (GYR_CMPFM_FACTOR + 1.0f)) #define INV_GYR_CMPFM_FACTOR (1.0f / (GYR_CMPFM_FACTOR + 1.0f))
#define GYRO_SCALE ((2380 * M_PI)/((32767.0f / 4.0f ) * 180.0f * 1000000.0f)) //should be 2279.44 but 2380 gives better result
#define GYRO_SCALE ((1998 * M_PI)/((32767.0f / 4.0f ) * 180.0f * 1000000.0f)) // 32767 / 16.4lsb/dps for MPU3000
// #define GYRO_SCALE ((2380 * M_PI)/((32767.0f / 4.0f ) * 180.0f * 1000000.0f)) //should be 2279.44 but 2380 gives better result (ITG-3200)
// +-2000/sec deg scale // +-2000/sec deg scale
//#define GYRO_SCALE ((200.0f * PI)/((32768.0f / 5.0f / 4.0f ) * 180.0f * 1000000.0f) * 1.5f) //#define GYRO_SCALE ((200.0f * PI)/((32768.0f / 5.0f / 4.0f ) * 180.0f * 1000000.0f) * 1.5f)
// +- 200/sec deg scale // +- 200/sec deg scale

View file

@ -60,7 +60,7 @@ bool spektrumFrameComplete(void)
return rcFrameComplete; return rcFrameComplete;
} }
static const uint8_t spekRcChannelMap[SPEK_MAX_CHANNEL] = {1, 2, 3, 0, 4, 5, 6}; // static const uint8_t spekRcChannelMap[SPEK_MAX_CHANNEL] = {1, 2, 3, 0, 4, 5, 6};
uint16_t spektrumReadRawRC(uint8_t chan) uint16_t spektrumReadRawRC(uint8_t chan)
{ {
@ -78,12 +78,12 @@ uint16_t spektrumReadRawRC(uint8_t chan)
} }
if (chan >= SPEK_MAX_CHANNEL || !spekDataIncoming) { if (chan >= SPEK_MAX_CHANNEL || !spekDataIncoming) {
data = 1500; data = cfg.midrc;
} else { } else {
if (cfg.spektrum_hires) if (cfg.spektrum_hires)
data = 988 + (spekChannelData[spekRcChannelMap[chan]] >> 1); // 2048 mode data = 988 + (spekChannelData[cfg.rcmap[chan]] >> 1); // 2048 mode
else else
data = 988 + spekChannelData[spekRcChannelMap[chan]]; // 1024 mode data = 988 + spekChannelData[cfg.rcmap[chan]]; // 1024 mode
} }
return data; return data;