Friday, 8 September 2017

Optimising snapflap using a Lua script (F3F)

Warning: if you're someone who winces at the merest mention of Lua, then please look away now!! On the other hand, if you fly F3F or F3B, and like to push the boundaries a bit, then read on...

How to succeed in F3F

There's an old F3F adage that competitions are won and lost in the turns. A good pilot will anticipate the turn bases consistently - a skill which requires a lot of practice. However another important factor is the snapflap mix - in particular how well the travel and curve are optimised.

A decent radio will provide dynamic control over the snapflap travel and also allow you to specify a curve. However most systems will not allow you to alter the curve whilst flying the model. This means landing the model to make the necessary changes in the menu, during which time the conditions may have changed.

Snapping your flap with Lua 

In this post I'll describe a Lua-based snapflap mix that I've been using for a couple of years in my Taranis X9D transmitter running OpenTx. The script allows flexible adjustment of the snapflap curve whilst flying the model.

The script is of proven reliability, however it's only recently (since my Needle 115) that I've really started to explore its capabilities.

Where it's won - or lost


Overview

The script works in concert with standard OpenTx mixes. Together they allow the following snapflap parameters to be adjusted:
  • Deadband - stick deflection at which snapflap starts. 
  • Saturation limit - elevator stick deflection at which max snapflap is reached. 
  • Expo - how aggressively the snapflap is applied. 
  • Volume - maximum snapflap deflection.
These four parameters completely define the shape of a snapflap curve. It is possible in theory to adjust all four parameters using any free transmitter controls. In practice, the availability of controls is a limiting factor and depending on your transmitter, it may be necessary to relegate one or two to a menu. For my Needle, I adjust expo, volume and saturation limit via transmittter controls, while deadband is set in a menu.

Processing overview

Processing is split between a Lua script, and the standard OpenTx mixing. The pipeline from elevator stick to snapflap is as follows:

Script operation

The Lua script takes two input parameters, deadband and saturation limit. These are used to construct a virtual 4-point curve describing an S shape as follows:



The script applies the S-curve to the elevator value and returns the result. 

Intregation into existing setups

Integration is straightforward. Any existing snapflap mixer is modified to use the script as source, instead of elevator. Here's an example, with CH17 performing the snapflap mix calculation:

CH17 outputs snapflap value. '1Snap' is Lua script. 
The 'Snap' line should have Expo set to a GVAR, with the latter bound to a suitable control (I use the right hand lever RS).

The following line ('SnapVol') implements the Volume adjustment with throttle trim as source. The operator is 'Multiply', so the output of CH17 is the product of the 'Snap' and 'SnapVol' lines. The output represents the final snapflap deflection. It will typically be used as the source of a flap mix.

Response curves

Here are some actual examples of snapflap curves which can be generated by the system (the data points were recorded using a second script):

Fig 1: Effect of snapflap expo

Fig 2: Effect of saturation limit (stick deflection at which maximum snapflap is achieved).

Fig 3: Effect of volume

In the field

I've done some flight testing recently with my Needle 115 at Ivinghoe Beacon. The focus of the tests was to optimise the expo setting.

Author's Needle 115 with Taranis X9D

My Taranis X9D is set up so that volumesaturation limit and expo are adjustable via transmitter controls, while deadband is adjustable in a menu. Before the session, I set the parameters as follows:
  • volume - max snapflap travel as recommended by the manufacturer.
  • deadband - just enough to prevent unwanted snapflap movement around neutral
  • saturation limit - matches max stick deflection in the turns. This adjustment will vary with conditions, fast conditions means more pull on the elevator stick.  Some guestimation required here.
During the flight tests, I adjusted expo dynamically using the slider RS. Back for aggressive, forward for soft, centre for linear.

So what about the results? In fast air it was evident that the Needle doesn't like positive snapflap expo - the model tends to shimmy as it enters the turn, scrubbing off speed. With negative expo turn entry is more progressive and the model is able 'ping' out of the turn. I need to do some more testing to find the optimum between zero and max negative expo.

I haven't done any conclusive testing in slow conditions. As I tend to pull less elevator in slow conditions, I will reduce the saturation limit to match. With my latest script, this can be adjusted directly using a knob.

Future enhancements: haptic feedback

One enhancement would be to generate some haptic feedback when max snapflap is reached. This is best done in the Lua script. More investigation required.

Conclusion

The ability to make adjustments using transmitter controls is proving very useful when trimming the model. It also makes it easy to alter the curve according to the conditions.

When trimming, the key is to focus on those adjustments which make an obvious difference like volume and expo. However, just finding that certain adjustments make no discernable difference is also useful information.

Download

The original Lua script (for OpenTx) is available on my web site.

No comments: