1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Configurable saturation limit for Airmode

This commit is contained in:
borisbstyle 2016-02-07 23:29:00 +01:00
parent 8b85c57723
commit 9b826f4373
4 changed files with 9 additions and 8 deletions

View file

@ -332,7 +332,7 @@ void resetRcControlsConfig(rcControlsConfig_t *rcControlsConfig) {
void resetMixerConfig(mixerConfig_t *mixerConfig) { void resetMixerConfig(mixerConfig_t *mixerConfig) {
mixerConfig->yaw_motor_direction = 1; mixerConfig->yaw_motor_direction = 1;
mixerConfig->agressive_airmode = 0; mixerConfig->airmode_saturation_limit = 50;
mixerConfig->yaw_jump_prevention_limit = 200; mixerConfig->yaw_jump_prevention_limit = 200;
#ifdef USE_SERVOS #ifdef USE_SERVOS
mixerConfig->tri_unarmed_servo = 1; mixerConfig->tri_unarmed_servo = 1;

View file

@ -19,6 +19,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h>
#include "platform.h" #include "platform.h"
#include "debug.h" #include "debug.h"
@ -814,12 +815,12 @@ void mixTable(void)
if (rollPitchYawMixRange > throttleRange) { if (rollPitchYawMixRange > throttleRange) {
motorLimitReached = true; motorLimitReached = true;
float mixReduction = (float) throttleRange / rollPitchYawMixRange;
for (i = 0; i < motorCount; i++) { for (i = 0; i < motorCount; i++) {
rollPitchYawMix[i] = (rollPitchYawMix[i] * throttleRange) / rollPitchYawMixRange; rollPitchYawMix[i] = lrintf((float) rollPitchYawMix[i] * mixReduction);
// Get the max correction from center when agressivity enabled. (Some setups don't like this option)
if (mixerConfig->agressive_airmode) throttleMin = throttleMax = throttleMin + (throttleRange / 2);
} }
// Get the maximum correction by setting offset to center. Only active below 50% of saturation levels to reduce spazzing out in crashes
if (mixReduction > (mixerConfig->airmode_saturation_limit / 100.0f)) throttleMin = throttleMax = throttleMin + (throttleRange / 2);
} else { } else {
motorLimitReached = false; motorLimitReached = false;
throttleMin = throttleMin + (rollPitchYawMixRange / 2); throttleMin = throttleMin + (rollPitchYawMixRange / 2);

View file

@ -71,7 +71,7 @@ typedef struct mixer_s {
typedef struct mixerConfig_s { typedef struct mixerConfig_s {
int8_t yaw_motor_direction; int8_t yaw_motor_direction;
uint8_t agressive_airmode; uint8_t airmode_saturation_limit; // Percentage in airmode where the mixer stops trying to get maximum possible correction
uint16_t yaw_jump_prevention_limit; // make limit configurable (original fixed value was 100) uint16_t yaw_jump_prevention_limit; // make limit configurable (original fixed value was 100)
#ifdef USE_SERVOS #ifdef USE_SERVOS
uint8_t tri_unarmed_servo; // send tail servo correction pulses even when unarmed uint8_t tri_unarmed_servo; // send tail servo correction pulses even when unarmed

View file

@ -623,7 +623,7 @@ const clivalue_t valueTable[] = {
{ "yaw_control_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.yaw_control_direction, .config.minmax = { -1, 1 } }, { "yaw_control_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.yaw_control_direction, .config.minmax = { -1, 1 } },
{ "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_motor_direction, .config.minmax = { -1, 1 } }, { "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_motor_direction, .config.minmax = { -1, 1 } },
{ "agressive_airmode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.agressive_airmode, .config.lookup = { TABLE_OFF_ON } }, { "airmode_saturation_limit", VAR_UINT8 | MASTER_VALUE, &masterConfig.mixerConfig.airmode_saturation_limit, .config.minmax = { 0, 100 } },
{ "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_jump_prevention_limit, .config.minmax = { YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH } }, { "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_jump_prevention_limit, .config.minmax = { YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH } },
#ifdef USE_SERVOS #ifdef USE_SERVOS
{ "tri_unarmed_servo", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.tri_unarmed_servo, .config.lookup = { TABLE_OFF_ON } }, { "tri_unarmed_servo", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.tri_unarmed_servo, .config.lookup = { TABLE_OFF_ON } },