make the accZ lpf used for althold configurable

set the variable accz_lpf_cutoff to the desired cutoff frequency
this can help to make althold smoother on copters with lots of
vibrations

Conflicts:

	src/cli.c
	src/config.c
	src/imu.c
	src/mw.h
This commit is contained in:
luggi 2014-06-03 16:32:18 +02:00 committed by Dominic Clifton
parent c53268b7be
commit 1bf806f54c
5 changed files with 13 additions and 5 deletions

View File

@ -85,7 +85,7 @@ static uint32_t flashWriteAddress = (0x08000000 + (uint32_t)((FLASH_PAGE_SIZE *
master_t masterConfig; // master config struct with data independent from profiles
profile_t currentProfile; // profile config struct
static const uint8_t EEPROM_CONF_VERSION = 73;
static const uint8_t EEPROM_CONF_VERSION = 74;
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
{
@ -305,6 +305,7 @@ static void resetConf(void)
currentProfile.mag_declination = 0;
currentProfile.acc_lpf_factor = 4;
currentProfile.accz_lpf_cutoff = 5.0f;
currentProfile.accDeadband.xy = 40;
currentProfile.accDeadband.z = 40;
@ -425,6 +426,7 @@ void activateConfig(void)
configureImu(&imuRuntimeConfig, &currentProfile.pidProfile, &currentProfile.barometerConfig, &currentProfile.accDeadband);
calculateThrottleAngleScale(currentProfile.throttle_correction_angle);
calculateAccZLowPassFilterRCTimeConstant(currentProfile.accz_lpf_cutoff);
#ifdef BARO
useBarometerConfig(&currentProfile.barometerConfig);

View File

@ -34,6 +34,7 @@ typedef struct profile_s {
// sensor-related stuff
uint8_t acc_lpf_factor; // Set the Low Pass Filter factor for ACC. Increasing this value would reduce ACC noise (visible in GUI), but would increase ACC lag time. Zero = no filter
float accz_lpf_cutoff; // cutoff frequency for the low pass filter used on the acc z-axis for althold in Hz
accDeadband_t accDeadband;
barometerConfig_t barometerConfig;
@ -46,7 +47,7 @@ typedef struct profile_s {
// Radio/ESC-related configuration
uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero.
uint8_t yaw_deadband; // introduce a deadband around the stick center for yaw axis. Must be greater than zero.
uint8_t alt_hold_deadband; // defines the neutral zone of throttle stick during altitude hold, default setting is +/-40
uint8_t alt_hold_deadband; // defines the neutral zone of throttle stick during altitude hold, default setting is +/-40
uint8_t alt_hold_fast_change; // when disabled, turn off the althold when throttle stick is out of deadband defined with alt_hold_deadband; when enabled, altitude changes slowly proportional to stick movement
uint16_t throttle_correction_angle; // the angle when the throttle correction is maximal. in 0.1 degres, ex 225 = 22.5 ,30.0, 450 = 45.0 deg

View File

@ -61,6 +61,7 @@ int32_t errorAltitudeI = 0;
int32_t vario = 0; // variometer in cm/s
float throttleAngleScale;
float fc_acc;
int32_t BaroPID = 0;
@ -103,6 +104,11 @@ void calculateThrottleAngleScale(uint16_t throttle_correction_angle)
throttleAngleScale = (1800.0f / M_PI) * (900.0f / throttle_correction_angle);
}
void calculateAccZLowPassFilterRCTimeConstant(float accz_lpf_cutoff)
{
fc_acc = 0.5f / (M_PI * accz_lpf_cutoff); // calculate RC time constant used in the accZ lpf
}
void computeIMU(rollAndPitchTrims_t *accelerometerTrims, uint8_t mixerConfiguration)
{
static int16_t gyroYawSmooth = 0;
@ -207,9 +213,6 @@ int32_t applyDeadband(int32_t value, int32_t deadband)
return value;
}
#define F_CUT_ACCZ 10.0f // 10Hz should still be fast enough
static const float fc_acc = 0.5f / (M_PI * F_CUT_ACCZ);
// rotate acc into Earth frame and calculate acceleration in it
void acc_calc(uint32_t deltaT)
{

View File

@ -35,3 +35,4 @@ void calculateEstimatedAltitude(uint32_t currentTime);
void computeIMU(rollAndPitchTrims_t *accelerometerTrims, uint8_t mixerConfiguration);
void calculateThrottleAngleScale(uint16_t throttle_correction_angle);
int16_t calculateThrottleAngleCorrection(uint8_t throttle_correction_value);
void calculateAccZLowPassFilterRCTimeConstant(float accz_lpf_cutoff);

View File

@ -296,6 +296,7 @@ const clivalue_t valueTable[] = {
{ "acc_lpf_factor", VAR_UINT8, &currentProfile.acc_lpf_factor, 0, 250 },
{ "accxy_deadband", VAR_UINT8, &currentProfile.accDeadband.xy, 0, 100 },
{ "accz_deadband", VAR_UINT8, &currentProfile.accDeadband.z, 0, 100 },
{ "accz_lpf_cutoff", VAR_FLOAT, &currentProfile.accz_lpf_cutoff, 1, 20 },
{ "acc_unarmedcal", VAR_UINT8, &currentProfile.acc_unarmedcal, 0, 1 },
{ "acc_trim_pitch", VAR_INT16, &currentProfile.accelerometerTrims.values.pitch, -300, 300 },
{ "acc_trim_roll", VAR_INT16, &currentProfile.accelerometerTrims.values.roll, -300, 300 },