Skip to content

Commit

Permalink
Merge pull request #38 from Bengt-M/angles
Browse files Browse the repository at this point in the history
tailServoMaxAngle
  • Loading branch information
lkaino committed May 30, 2016
2 parents f1f93d2 + 8612472 commit e50e801
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/main/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static uint32_t activeFeaturesLatch = 0;
static uint8_t currentControlRateProfileIndex = 0;
controlRateConfig_t *currentControlRateProfile;

static const uint8_t EEPROM_CONF_VERSION = 113;
static const uint8_t EEPROM_CONF_VERSION = 114;

void resetPidProfile(pidProfile_t *pidProfile)
{
Expand Down Expand Up @@ -325,7 +325,6 @@ static void resetMixerConfig(mixerConfig_t *mixerConfig) {
#ifdef USE_SERVOS
mixerConfig->tri_unarmed_servo = 1;
mixerConfig->servo_lowpass_freq = 400.0f;
mixerConfig->tri_servo_angle_at_max = 400;
mixerConfig->tri_tail_motor_thrustfactor = 138;
mixerConfig->tri_tail_servo_speed = 300; // Default for BMS-210DMH at 5V
mixerConfig->tri_servo_min_adc = 0;
Expand Down Expand Up @@ -514,6 +513,10 @@ STATIC_UNIT_TESTED void resetConf(void)
currentProfile->servoConf[i].angleAtMax = DEFAULT_SERVO_MAX_ANGLE;
currentProfile->servoConf[i].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
}
if (masterConfig.mixerMode == MIXER_TRI) {
currentProfile->servoConf[5].angleAtMin = 40;
currentProfile->servoConf[5].angleAtMax = 40;
}

// gimbal
currentProfile->gimbalConfig.mode = GIMBAL_MODE_NORMAL;
Expand Down
1 change: 0 additions & 1 deletion src/main/flight/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ typedef struct mixerConfig_s {
uint8_t tri_unarmed_servo; // send tail servo correction pulses even when unarmed
float servo_lowpass_freq; // lowpass servo filter frequency selection; 1/1000ths of loop freq
int8_t servo_lowpass_enable; // enable/disable lowpass filter
int16_t tri_servo_angle_at_max;
int16_t tri_tail_motor_thrustfactor;
int16_t tri_tail_servo_speed;
uint8_t tri_servo_feedback;
Expand Down
4 changes: 2 additions & 2 deletions src/main/flight/mixer_tricopter.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void triInitMixer(servoParam_t *pTailServoConfig,
gpTailServoConf = pTailServoConfig;
gpTailServo = pTailServo;
tailServoThrustFactor = pMixerConfig->tri_tail_motor_thrustfactor / 10.0f;
tailServoMaxAngle = pMixerConfig->tri_servo_angle_at_max;
tailServoMaxAngle = gpTailServoConf->angleAtMax *10;
tailServoSpeed = pMixerConfig->tri_tail_servo_speed;
gpMixerConfig = pMixerConfig;

Expand Down Expand Up @@ -409,7 +409,7 @@ static uint16_t feedbackServoStep(mixerConfig_t *mixerConf, uint16_t tailServoAD
const int32_t ADCFeedback = tailServoADC;
const int16_t midValue = mixerConf->tri_servo_mid_adc;
const int16_t endValue = ADCFeedback < midValue ? mixerConf->tri_servo_min_adc : mixerConf->tri_servo_max_adc;
const int16_t tailServoMaxAngle = mixerConf->tri_servo_angle_at_max;
const int16_t tailServoMaxAngle = gpTailServoConf->angleAtMax *10;
const int16_t endAngle = ADCFeedback < midValue ? TRI_TAIL_SERVO_ANGLE_MID - tailServoMaxAngle : TRI_TAIL_SERVO_ANGLE_MID + tailServoMaxAngle;
return ((endAngle - TRI_TAIL_SERVO_ANGLE_MID) * (ADCFeedback - midValue) / (endValue - midValue) + TRI_TAIL_SERVO_ANGLE_MID);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ const clivalue_t valueTable[] = {
{ "tri_unarmed_servo", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.tri_unarmed_servo, .config.lookup = { TABLE_OFF_ON } },
{ "servo_lowpass_freq", VAR_FLOAT | MASTER_VALUE, &masterConfig.mixerConfig.servo_lowpass_freq, .config.minmax = { 10, 400} },
{ "servo_lowpass_enable", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.servo_lowpass_enable, .config.lookup = { TABLE_OFF_ON } },
{ "tri_servo_angle_at_max", VAR_INT16 | MASTER_VALUE, &masterConfig.mixerConfig.tri_servo_angle_at_max, .config.minmax = { 0, 500 } },
{ "tri_tail_motor_thrustfactor",VAR_INT16 | MASTER_VALUE, &masterConfig.mixerConfig.tri_tail_motor_thrustfactor, .config.minmax = { TAIL_THRUST_FACTOR_MIN, TAIL_THRUST_FACTOR_MAX } },
{ "tri_tail_servo_speed", VAR_INT16 | MASTER_VALUE, &masterConfig.mixerConfig.tri_tail_servo_speed, .config.minmax = { 0, 1000 } },
{ "tri_servo_feedback", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.tri_servo_feedback, .config.lookup = { TABLE_SERVO_FEEDBACK } },
Expand Down

0 comments on commit e50e801

Please sign in to comment.