Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mixer throttle calculation #7463

Merged
merged 1 commit into from Jan 26, 2019

Conversation

Projects
None yet
2 participants
@etracer65
Copy link
Member

commented Jan 25, 2019

The calculation used to transform the rcCommand[THROTTLE] value to a throttle value used in the mixer was incorrectly applying the min_check range a second time. This leads to the mixer throttle value scaling incorrectly and adds an additional deadzone at the low range that basically doubles the min_check range. The rcCommand[THROTTLE] value is already reduced by min_check and then scaled to 1000 - 2000. So the mixer doesn't need to reapply min_check.

During analysis and subsequent fix testing, added the following debugging (not included in PR):

        DEBUG_SET(DEBUG_MIXER_THROTTLE, 0, rcData[THROTTLE]);
        DEBUG_SET(DEBUG_MIXER_THROTTLE, 1, rcCommand[THROTTLE]);
        throttle = rcCommand[THROTTLE] - rxConfig()->mincheck + throttleAngleCorrection;
        DEBUG_SET(DEBUG_MIXER_THROTTLE, 2, throttle);
        currentThrottleInputRange = rcCommandThrottleRange;
        motorRangeMin = motorOutputLow;
        motorRangeMax = motorOutputHigh;
        motorOutputMin = motorOutputLow;
        motorOutputRange = motorOutputHigh - motorOutputLow;
        motorOutputMixSign = 1;
    }

    throttle = constrainf(throttle / currentThrottleInputRange, 0.0f, 1.0f);
    DEBUG_SET(DEBUG_MIXER_THROTTLE, 3, throttle * 100);

The debugging is:

debug[0] == raw rcData[THROTTLE]
debug[1] == rcCommand[THROTTLE]
debug[2] == the initial throttle calc where min_check is subtracted
debug[3] == the final float mixer throttle scaled from 0.0 - 1.0

Here's the results before the fix (min_check setting is default 1050):

incorrect_mixer_throttle

Note the red section showing the throttle value going negative because we're subtracting min_check (1050) from the rcCommand values starting at 1000. After the scaling to a float (again with the wrong range), the value is constrained to the range 0.0 - 1.0. This prevents the negative throttle, but the net effect is additional deadzone as indicated by the blue section.

Next is the same logging after the fix:

fixed_mixer_throttle

Note that the mixer throttle values become non-zero as soon as the raw rcData values reach 1050 (min_check). No additional deadzone and the throttle values are calculated correctly.

Fix mixer throttle calculation
The calculation used to transform the rcCommand[THROTTLE] value to a throttle value used in the mixer was incorrectly applying the `min_check` range a second time. This leads to the mixer throttle value scaling incorrectly and adds an additional deadzone at the low range that basically doubles the `min_check` range.

@etracer65 etracer65 added this to the 3.5.6 milestone Jan 25, 2019

@etracer65

This comment has been minimized.

Copy link
Member Author

commented Jan 25, 2019

One change that people may notice with this is the reduced (but now correct) throttle deadzone. Previously the effective deadzone was about twice what it should have been. People who are used to running really small min_check values may have to adjust. I did a LOS test flight and I noticed the quicker throttle response.

@etracer65

This comment has been minimized.

Copy link
Member Author

commented Jan 26, 2019

So here's how the throttle used by the mixer is corrected with this fix. Old is red, fixed is blue. You can clearly see the extra deadzone and the affect it has. As a result the previous throttle resolution was reduced and the throttle curve steeper. Simulation was run with default min_check or 1050.

mixer throttle graph

@mikeller mikeller merged commit 06f8960 into betaflight:master Jan 26, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details

@mikeller mikeller modified the milestones: 3.5.6, 4.0 Jan 26, 2019

@mikeller

This comment has been minimized.

Copy link
Member

commented Jan 26, 2019

Changed Milestone to 4.0 as this will require a configuration change for some pilots (or all pilots, if they want the throttle behaviour to stay the same).

@etracer65 etracer65 deleted the etracer65:mixer_throttle_fix branch Feb 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.