Advanced programming using GVARs

Mike Shellim
Last updated 21 May 2017

GVARs are one of the most powerful - and misunderstood - features of OpenTx. They are useful in two contexts: first, where you need to specify the same value in more than one place. And secondly, they provide a user-friendly front end for adjusting mixer weights etc.

Used sensibly, GVARs can greatly simplify the design and adjustability of your model! In this article, I'll describe how to use them effectively.

1. Introduction

GVAR stands for 'global variable'. A GVAR represents a number, and you can use GVARs in many places where you would normally use a number, e.g.

GVARs share a useful property with digital trims - they retain their values even after you switch off the transmitter. (In fact the the similarity between GVARs and digital trims run deeper, as we'll see.)

2. Setting and referencing GVARs

In this section we'll examine how to

2.1. Setting a GVAR

OpenTx provides nine GVARS, named 'GV1', 'GV2'... 'GV9. They are managed in the GLOBAL VARS menu, where you can view and alter their values.

"GVARS menu"

GVARs menu (first 7 shown)

Each GVAR has nine columns labeled FM0, FM1, ... FM8, representing the nine flight modes.

You can enter a different number for each flight mode. When a GVAR is referenced, OpenTx retrieves the value for the active flight mode. For example, if FM1 is active, then GV1 will return '20'. If FM2 was active, GV1 would return '40'. And so on.

If you don't use flight modes explicitly, then FM0 is always active (the default flight mode), in which case you only need specify values in the FM0 column.

2.3. Referencing a GVAR

In this section we'll see how to use a previously assigned GVAR. As an example we'll reference a GVAR in the weight field in a mixer.

  1. In the mixer list, highlight a mix line
  2. Open the mixer editor
  3. Highlight the weight field
  4. Press [ENTER long]
  5. The display changes from a number to 'GV1'. You can choose another GVAR using the +/- keys. You can also select the negated value by selecting the corresponding '-' entry.

    Long press to display GVAR

4. Creating a test setup

OK, so that's the theory... let's see how GVARs are used in practice. As an example, create a simple glider setup, with channels 5 and 6 assigned to ailerons:

CH5 (left ail)



CH6 (right ail)


4.1 Adding differential

Now add some differential for each aileron servo. We'll do this first by specifying the value directly.

Note: we are assuming that the model behaves perfectly symmetrically. You can achieve this, regardless of mechanical differences, by calibrating your servos

CH5 (left ail)

Src=Ail Diff = 30


CH6 (right ail)

Src=Ail Diff = -30

There's one problem with this: In order to alter diff, we would have to make two identical data entry operations, which is both tiresome and error prone. Let's see how to improve it!

4.2 Storing Diff in a GVAR

Instead of specifying the value of diff directly, let's store the diff value in a GVAR.

  1. Go to the GVARs menu
  2. In the 'GV1' line, go to the FM0 column, and enter '30'.
  3. Finally, in the Mixers menu, set diff GV1 and -GV1 for the two aileron channels.


GV1=30 -- stores diff value


CH1 (left ail)

Src=Ail, diff = GV1


CH2 (right ail)

Src=Ail, diff = -GV1

To change diff in both mixes, only one adjustment is required, to GV1.

4.3 Making diff flight mode specific

So far we've only used the default flight mode (FM0). Suppose our setup uses several flight modes.

We saw earlier that a single GVAR can provide different values for different flight modes - so we simply assign the required diff values to the appropriate flight modes in the GVAR menu.


GV1=30 (FM0), 45 (FM1) -- stores diff value for FM0 and FM1


CH1 (left ail)

Src=Ail, diff = GV1


CH2 (right ail)

Src=Ail, diff = -GV1

Compare this with the solution without using GVAR's:

CH5 (left ail)

Src=Ail Diff = 30 Flightmode = FM0

Src=Ail Diff = 45 Flightmode = FM1


CH6 (right ail)

Src=Ail Diff = -30 Flightmode = FM0

Src=Ail Diff = -45 Flightmode = FM1

The benefits of GVARs should be clear!

5. [advanced] Setting GVARs using a Special Function

So far we've set our GVARs by typing in the value directly in the GVARs menu. However, OpenTx provides an alternative and very powerful mechanism for setting GVARs, using the 'Adjust GVAR' action. This opens up exciting possibilities for varying expo, diff etc. dynamically.

5.1 'Adjust GVAR' action

To use the Adjust GVAR action,

  1. Create a Special Function
  2. Select 'Adjust GVAR' from the list of actions
  3. Choose the action:
    VALUE: Set GVAR to a number
    SRC: Set GVAR to the value of a channel, switch or input
    GVAR: Set GVAR to value of another GVAR (copy GVAR)
    INC: Add or subtract 1 from GVAR
  4. Finally, specify a switch to trigger the action

The action is executed when the switch (step 4) becomes True. The switch may be any physical or logical switch.

You can also specify a special 'ON' switch, which triggers whenever the source value changes. We'll see why this is useful in the next section.

5.3 Binding a GVAR to its source

Sometimes it's useful for a GVAR to always match the value of the source, in other words to be 'bound' to the source. For example, you may wish to a GVAR to track the value of a channel output.

To implement binding,

  1. Create a special function
  2. Choose the "Adjust GVAR" action
  3. Choose the SRC option, and set the source to the channel you want the GVAR to bind to
  4. In the switch field, select "ON"

In the screenshot below, GV1 is bound to CH8. GV1 will be updated with the value of CH8.

Special funcs menu

Binding GV1 to CH8 using ON switch

We'll see why this is useful in the next section.

5.4 Implementing variable Diff or Expo using binding

Say we want to vary aileron differential in flight, depending on the position of the rudder trim (TrmR). We can do this by binding GV1 to the rudder trim, then setting Diff = GV1.

The code is in three parts:

CH8 -- outputs between 20 and 60 depending on rudder trim

Src=TrmR wt=20 offset=40


SF1 -- Special Function which binds GV1 to CH8

switch="ON" Action="Adjust GV1" Parameters="Src=CH8"


CH1 -- aileron servo channel, with variable diff from GV1

Src=Ail, Diff=GV1

6. Summary: benefits and drawbacks of GVARs

The benefits of GVARs are as follows

The drawbacks

7. Using GVARs with cascading mixers

GVARs can be used in conjunction with cascading mixers to create powerful and elegant solutions.