Just watched another great video on Joshua Bardwell YouTube Channel put it all on the page below so I don’t loose it.

 

Cleanflight has the ability to use switches to do in-flight tuning. One aux channel controls the parameter that you’re modifying (e.g. yaw rate, pitch/roll P gain, etc…). A second aux channel is used to increase or decrease the parameter, via a three-position switch. I’m going to show you a way to really get the most out of this function.

A typical setup might be that you use a three-position switch to choose between modifying pitch/roll P, I, or D gain. When the switch is up, you’re modifying P; when it’s middle, you’re modifying I; when it’s down, you’re modifying D. That’s all well and good, but what if you want to modify more than three parameters at a time? One way to do it is to use another aux channel to choose that parameter, and another aux channel to modify that parameter. Example:

Aux 1 – Choose between pitch/roll P, I, or D
Aux 2 – Increase/Decrease Aux 1
Aux 3 – Choose between yaw P, I, or D
Aux 4 – Increase/Decrease Aux 2

Well, there’s an obvious problem here: you’ve used up your aux channels! What if you want to use an aux channel for a gimbal, or for arming/disarming your copter? What if you just want to be more efficient? The answer is to multiplex more than one switch onto a single aux channel.

What’s that mean?

01

The table above shows that, for two three-position switches, there are 3^2 = 9 possible combinations. In order to represent all of these combinations on a single Aux channel, all we have to do is make the Aux channel take on nine different values, depending on which combination of switch positions is active.

Since we need nine different values, the first thing to do is figure out how big each subdivision of the channel is going to be. The Taranis represents channels internally as going from -100 to +100, for a total range of 200 units. 200 / 9 = 22 units per subdivision.

Let’s take those 22 units and allocate them to the switch positions in our table.

02

What I’ve done is start at -100 and add 22 for each cell, going from left to right and top to bottom, standard reading order. So now we can say that if both switches were in the middle position, we would want the channel to be at -12. If both switches were up, we would want the channel to be at 76. By the way, the reason we only went from -100 to +76 is that 200 / 9 is actually 22.2, and those 0.2 remainders that we ignored added up. So technically, you could fit a tenth item into this category, except that ten isn’t a power of three, so there’s no combination of three-position switches that would give us ten items. Anyway, moving on…

Now that we know how we want to map the switch positions to the channels, the only thing that remains is to create a mapping that accomplishes this. And it’s dead simple once you know how:

03

What do these mixes actually accomplish? The first one, for switch SE, gives a weight of 22 and an offset of -78. This causes that switch to give the channel values of -100 (up), -78 (middle), and -56 (down). The second mix, for switch SA, gives a weight of 66 and an offset of 66. This causes that switch to give the channel values of 0 (up), 66 (middle), and 132 (down). For the numerically minded, what we’ve done is create a base-three counting system, where one switch is the ones digit and the other switch is the tens digit. Then we’ve multiplied everything by 22, our sub-division size. If you work through some examples, you’ll see that the aux channel takes on the values described in the table, depending on the position of the two switches. Voila!

Finally, you go into Cleanflight’s Adjustments tab, and do something like this:

04

Unfortunately, it won’t all fit one one of my laptop’s screens, but you get the idea. So in my example above, Aux 4 channel (ch. 8) selects which one of the nine parameters you want to modify, and Aux 3 channel (ch. 7) adjusts the parameter up and down.

To make things simpler copy the PID adjustment setup below, paste the following text into your CLI, hit Enter, then type “save” and hit Enter. You may need to tweak the exact end-points of the adjustment ranges depending on your channel calibration.

adjrange 0 0 1 950 1000 15 3
adjrange 1 0 1 1075 1125 16 3
adjrange 2 0 1 1175 1225 17 3
adjrange 3 0 1 1300 1350 18 3
adjrange 4 0 1 1400 1450 19 3
adjrange 5 0 1 1525 1575 20 3
adjrange 6 0 1 1625 1675 9 3
adjrange 7 0 1 1750 1800 10 3
adjrange 8 0 1 1850 1900 11 3