Skip to content

Channel limits, generic mixer and channel remapper #2869

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

awigen
Copy link
Contributor

@awigen awigen commented Jul 30, 2024

RFC - Adding a generic mixer

This PR adds prerequisites for receiver gyro support, primarily to be used for stabilization of airplanes and cars.

Having a generic receiver mixer is however very useful in many cases.

The gyro devlopment happens here: https://github.com/awigen/ExpressLRS

Full resolution failsafe

Full resolution channels can go from 885us to 2135us and the current failsafe configuration storage isn't large enough to hold it.

The current failsafe configuration is stored in the EEPROM as a 10-bit value and a magic constant of 988us is used to convert it to the appropriate units.

To allow a failsafe to any valid channel range, this PR converts the failsafe configuration to an 11-bit value and removes the magic constant.

Channel limits

When controlling servo outputs it's important to limit the range of motion of the servo to avoid binding and possible damage. When gyro support is added it is no longer possible to limit the servo range solely from the transmitter as the gyro will add to the channel commanded position.

This PR adds a channel limits to channels.

TODO: Change the way the limits are applied so that we map the input range 0-100% to the new limited output range. This would mean the servo limit only needs to be set once on the receiver, the transmitter should just use default 100% limits.

The downside to this approach is that the limits can not be adjusted on the transmitter without using forward programming with lua.

Generic mixer

To support gyro functionality, a mixer is needed to add the gyro output to the channel output. A generic mixer is also useful for other scenarios, some examples are:

  • Sbus channel ordering. By mixing input CRSF channels to different output channels, the order of the SBUS channels can be changed.
  • Rudder -> Nose wheel mixing. Logical conditions for a mixer rule can be used to set the mix active only when the landing gear is down.
  • V-tail mixing and other tail configurations
  • Reducing the number of TX channels. One TX aileron channel, one TX flapp channel while controlling multiple servos with individual limits. This can open up different ELRS modes to be used by not transmitting redundant/extrapolatable data.

TODO: Add logical conditions to the mixer.

Receiver gyro support

With the addition of the prerequisites, gyro support can be added to the receiver. See my https://github.com/awigen/ExpressLRS/tree/gyro-with-mixer branch for the current state of this work.

image

@pacaj2am
Copy link

if gyros should be mixed like this, shouldn't one have possibility to use one of the channels as weight as well?

@awigen
Copy link
Contributor Author

awigen commented Aug 1, 2024

if gyros should be mixed like this, shouldn't one have possibility to use one of the channels as weight as well?

That's exactly right, there are two mix output destinations to control gyro mode and gyro gain.

In the gyro branch it looks like this at the moment:
image

I will be adding a wizard to help people setup their basic mixes.

Full resoulution channels can go from 885us to 2135us and the current
failsafe configuration storage isn't large enough to hold it.

By using a larger field for failsafe we no-longer need to use a 988
constant sprinkled through the codebase.
@functionpointer
Copy link

Seems similar to #2671

@pfeerick
Copy link
Contributor

pfeerick commented Aug 3, 2024

Except that was extending the hardware page, not the model page, which is where it actually belongs. This would not only enable the gyro branch to progress further, but also cater for the "one model" crowd somewhat, as more of the model differences can be handed on the RX side.

One think to keep in mind is there is also some interest being able to support a wider output range than 885us to 2135us, specifically 500us to 2500us in #2773, to allow continuous rotation and wider movement servos to be used without additional hardware.

@awigen
Copy link
Contributor Author

awigen commented Aug 3, 2024

@pfeerick said

One think to keep in mind is there is also some interest being able to support a wider output range than 885us to 2135us, specifically 500us to 2500us in #2773, to allow continuous rotation and wider movement servos to be used without additional hardware.

Perhaps this could be handled by increasing a mixer weight to over 100%, so 150% to reach what ever PWM timing required?

@awigen awigen force-pushed the generic-mixer branch 4 times, most recently from 95cc5b9 to 689a6e7 Compare August 3, 2024 07:42
@adras
Copy link

adras commented Aug 3, 2024

@pfeerick said

One think to keep in mind is there is also some interest being able to support a wider output range than 885us to 2135us, specifically 500us to 2500us in #2773, to allow continuous rotation and wider movement servos to be used without additional hardware.

Perhaps this could be handled by increasing a mixer weight to over 100%, so 150% to reach what ever PWM timing required?

I think this would also be suitable for me. I'm also looking for a range of 500-2500 us. Wouldn't it make sense to have two columns for MAX min and MAX max values? So that the input value first gets transformed by weight and then cutoff to the MAX and MIN values. This would basically allow the user to create any output PWM that's supported by the hardware. Well, I could also enforce these limits by exactly calculating my weight. Same could be done for a gyro though, once you know it's max and min values, together with the other max and min input, you could calculate the weight that's within the valid range.

These signals also seem difficult to debug. Can I somehow see the input and output of the RX? I don't know if it's a common use-case. But let's say I have a normal servo, however physically it can turn 180°, that makes the 500-2500 range. Now I believe the best way to kill a servo is to give it a position that's out of bounds and some proper current. So I would like to configure my range to be 600-2400. I know these numbers, I could just enter them in the online thing. For the weights, I just increase them step by step.

Now if I can only configure weights, I need to check my TX for it's min and max values, put them into a calculator to figure out the weight to have it in a 600-2400 range. That's a formula I always forget. Do I really need to know it, when I just want to drive/fly something?

@bd4
Copy link

bd4 commented Aug 4, 2024

I have been testing the gyro branch and plan on using it extensively, so this gets a +1 from me. I do have some old models that use the Radiolink Byme-A gyro, which has flight mode configured via channels 5 and 7 and it cannot be changed. So this mixer allows me to output channel 6 from the TX to channel 5, and use channel 5 on tx for arm so I can use dynamic power and have it work correctly. The mixer is overkill for this, but it's still a welcome addition. So far I bench tested it and seems to be working great, will fly it tomorrow.

I can also imagine setting up a model for a friend or as a club trainer where simple TX setup would be desirable.

@bd4
Copy link

bd4 commented Aug 19, 2024

Swapped my model with the Byme-A over to an RP3-H so I could use the PWM receiver on a different model, and I am not seeing channel mixer coming up on the Model in webui, or the output mapping in the lua. Am I dowing something wrong or is mixer only enabled for PWM rx currently?

@bd4
Copy link

bd4 commented Aug 19, 2024

Swapped my model with the Byme-A over to an RP3-H so I could use the PWM receiver on a different model, and I am not seeing channel mixer coming up on the Model in webui, or the output mapping in the lua. Am I dowing something wrong or is mixer only enabled for PWM rx currently?

Answered my own question by looking at the diffs. MIXER is only defined for ESP32 platform. Can this be enabled for ESP8285 as well?

@stanislavdavid
Copy link
Contributor

This PR solves this issue: #2584

Co-authored-by: Bryce Allen <bryce@bda.space>
@Sea-Kerman
Copy link

I too desire the ability to output 500-2500us

@derFrickler
Copy link
Contributor

@awigen Hi There, i just flashed your generic-mixer branch to a BetaFPV PPM receiver.
I can see the mixer settings on the webpage, but can you gibe a hint/example on how to mix roll and nick for a Wing or a V-Tail? That would be great.

Thanks a lot for your work.

@Tiefflieger68
Copy link

Tiefflieger68 commented Nov 3, 2024

i did some tests and it works great.
Imho there should be a checkbox to activate or hide (reset to default if hidden) the mixer menue. Otherwise this may confuse some users, cause this specific feature may not be used from that much users.

One strange thing: I did all my tests with an RM ER5C-i. The settings of the RX is coming up after flashing (flashing by ExpressLRS Configurator via WiFi) with the "pull request" firmware (3.5.1 was installed before) are compleatly stupid and always different (did several swaps between regular and pull request firmware).
After reset to default by Web UI everything seems fine. Flashing by UART and check "Erase befor flash" works as well.

@Tiefflieger68
Copy link

@derFrickler
Copy link
Contributor

@derFrickler very easy thing.

Yes, you are right, works flawless, problem was that that my servo limits were totally messed up due to the settings were from another firmware. Thanks a lot!

@Tiefflieger68
Copy link

Tiefflieger68 commented Nov 4, 2024

one more bug:
if set weight (no matter if positive or negative) up to 127 everything is fine.
Set to 128, enter safe and refresh browser the weight is "0". The Servo didn't do what expected. There should be no Servo movement at a weight of "0". But it moves in one direction. Not so if entered "0" manually.
Entering Values over 128 cause a negative value after refreshing the browser

@hyp0dermik-code
Copy link

No personal experience, but have helped a user set it up. Overall the mixer seems very well structured and behaves similar to implementations like EdgeTX.

Perhaps a note or a tooltip could be added specifying the ranges(and that negative weights invert?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.