Constrain invalid values by using rx_min_usec and rc_max_usec. Provide

sensible/fix min/max settings for those settings.

This fixes erratic flight behaviour before failsafe kicks in on SBus
receivers.

An X8R SBus RX in failsafe mode outputs 880 on all channels.

See #918 and #919
This commit is contained in:
Dominic Clifton 2015-05-20 00:28:52 +01:00
parent 22bf890cf0
commit 7a01bab50f
3 changed files with 6 additions and 6 deletions

View File

@ -417,8 +417,8 @@ const clivalue_t valueTable[] = {
{ "failsafe_off_delay", VAR_UINT8 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_off_delay, 0, 200 },
{ "failsafe_throttle", VAR_UINT16 | MASTER_VALUE, &masterConfig.failsafeConfig.failsafe_throttle, PWM_RANGE_MIN, PWM_RANGE_MAX },
{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_min_usec, 100, PWM_RANGE_MAX },
{ "rx_max_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_max_usec, 100, PWM_RANGE_MAX + (PWM_RANGE_MAX - PWM_RANGE_MIN) },
{ "rx_min_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_min_usec, PWM_PULSE_MIN, PWM_PULSE_MAX },
{ "rx_max_usec", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.rx_max_usec, PWM_PULSE_MIN, PWM_PULSE_MAX },
#ifdef USE_SERVOS
{ "gimbal_flags", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].gimbalConfig.gimbal_flags, 0, 255},

View File

@ -75,9 +75,6 @@ int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
#define PPM_AND_PWM_SAMPLE_COUNT 4
#define PULSE_MIN 750 // minimum PWM pulse width which is considered valid
#define PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
#define DELAY_50_HZ (1000000 / 50)
#define DELAY_10_HZ (1000000 / 10)
@ -336,7 +333,7 @@ static void processRxChannels(void)
}
// validate the range
if (sample < PULSE_MIN || sample > PULSE_MAX)
if (sample < rxConfig->rx_min_usec || sample > rxConfig->rx_max_usec)
sample = rxConfig->midrc;
if (isRxDataDriven()) {

View File

@ -24,6 +24,9 @@
#define PWM_RANGE_MAX 2000
#define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + ((PWM_RANGE_MAX - PWM_RANGE_MIN) / 2))
#define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid
#define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
#define DEFAULT_SERVO_MIN 1020
#define DEFAULT_SERVO_MIDDLE 1500
#define DEFAULT_SERVO_MAX 2000