Friday, 8 September 2017

Advanced snapflap mixing with OpenTx and Lua

In this post, I'll describe a snapflap mix with the emphasis on 'trimmability'. It offers full control over the snapflap curve, with all adjustments via dedicated controls. The mix is in use in both my Needle 115 and Stribog setups, so is well tested.

F3F turn: Phil Taylor's T-Master rounds base A. Shot at ~6fps.

Enhanced functions

'Snapflap' is of course just a fancy term for an elevator-to-flap mix. The purpose is to minimise drag during the apex of the turn, when the wing is generating maximum lift.

Any decent R/C system should allow the pilot to adjust snapflap volume in flight. However other adjustments like expo and deadband will typically require reprogramming, which makes it impossible to compare settings in real time.

With OpenTx we can do better! My goal was to be able to adjust the following parameters dynamically, and independently, whilst flying the model:
  • Volume - max snapflap deflection
  • Deadband - elevator stick deflection at which snapflap starts.
  • Saturation limit - elevator stick deflection at which max snapflap is reached. 
  • Expo - snapflap exponential
These four parameters may be represented as follows:

So how do we make these parameters adjustable in flight?

Volume and expo may be implemented using stock OpenTx features. However deadband and saturation limit present a problem: these correspond to intermediate points on a curve, and like other systems OpenTx doesn't allow these to be altered dynamically. However, unlike most other systems, OpenTx can call on a helping hand, in the form of an integrated Lua interpreter. This allows us to create and apply a curve on the fly.

Lua pre-processor and mixing

The first stage of the pipeline is the Lua script. This performs the function of a regular elevator to flap mix, except it takes two parameters deadband and saturation limit whose values are derived from transmitter controls and can therefore be varied in flight.

The script reads the elevator value and applies a 4-point straight-line virtual curve ("virtual" because it's constructed internally, independently of OpenTx curves). The output of the script represents a raw snapflap command in the range -100 to +100.

Next, expo and volume are applied using standard OpenTx features (no Lua involved). Their values also supplied via transmitter controls. (Note: expo works best inputs in the range -100 to +100, so must be applied to the Lua output, before volume is applied. Fortunately this corresponds to OpenTx's mixer processing sequence.)

Snapflap mix operation

User interface

With four parameters to adjust, careful consideration must be given to the user interface. I've found the following works well on my Taranis X9D:
  • Volume - adjusted via the throttle trim. 
  • Saturation limit - adjusted via a rotary knob.
  • Expo - adjusted via the right slider.
  • Deadband - supplied as a MAX-based preset value (but it could equally be assigned to a spare control). 

Audio alerts

On my setups, I've configured audio alerts when the snapflap reaches 5% and 95% of the maximum. The audio is helpful for tuning deadband and saturation limit. The alerts are implemented using 2 logical switches and 2 special functions. A master switch is used to enable/disable the alerts (I disable them during a competition).

Sample snapflap curves

Below are sample curves which can be generated by the system (the data was recorded using a second script). These are by way of demonstration only.

In the field

This is the method I use for trimming snapflap:
  1. Volume - start with snapflap travel as recommended by the manufacturer, and adjust later. 
  2. Saturation limit - adjust to match elevator deflection at apex of turn. Use audio alert.
  3. Deadband - set deadband to suppress snapflap during minor pitch corrections. Ues audio alert. 
  4. Expo - set this to linear (zero) for first flights and tune.

Author's Needle 115 with Taranis X9D


The enhanced snapflap system was easy to incorporate in my existing setups and has proved particularly useful for trimming out snapflap in my Needle 115. Not only has it speeded up the whole process, it has also provided a deeper insight into the adjustments.


No comments: