Sunday, June 23, 2013

OpenTX: Setting A Six-Position Switch

Here's the tl;dr:

CH05
   +100%3POS Curve(Curve 1) 
 * +100%AIL

Curve 1:  (type: 3 points) 81 48 15


And the longer explanation.  We want to mix two switches (3 position and 2 position) so that they map smoothly over the range of one transmitter channel.  This will allow us to use a combination of the two switches to control something the the Ardupilot Mega flight modes.  We'll use the 3 position switch and the Aileron D/R switch in this example.

There's a lot of slop, but we basically want to get the approximate midway values here.


-100%      -67%      -34%       0%       32%       65%      100%
  |         |         |         |         |         |         |
  |  -84%   |   -51%  |   -18%  |   15%   |   48%   |   81%   |
  |         |         |         |         |         |         |
  |    1    |    2    |    3    |    4    |    5    |    6    |


We start by mapping the 3 position switch.  By specifying just the switch, we get the values (-100, 0, 100)  in positions 0, 1, and 2.  That's not quite what we want; we want the values (15, 48, 81) so that it corresponds to positions 4, 5, 6 in the diagram above.

We can do that using a Curve.  We'll use curve 1. First we set the curve type to "3 points".  Fill in the point values to 81, 48, and 15 as shown.




Then set the first part of the mix to 3POS, Curve 1 as shown.  Note that multiplex is ADD.  As you toggle the switch among the three positions, the mix will follow the curve and fill in 15%, 48%, and 81%.

So, that takes care of three of your positions (4,5,6).

To get the other three positions easily, we'll cheat a little bit.  We can do this because we don't need to hit the midpoints exactly -- we just need to hit somewhere in the range.




Now, we're going to cheat a little to get the other positions.  We can do this because we don't need to hit the midpoint of each position exactly... we just need to be between the high and low points of each range.

So, we look at the low three values, and note that they are close to being the negatives of the top three values (-84 : -81, -51 : 48, -18 : 15).

So, we add the the channel mix the AIL switch.  This will give us -100 and 100 for when the switch is on or off (or vice versa).  So, we set Multiplex to MULTIPLY, and that gives us a handy way to multiply by 1 (keeping the positions we already have) or -1 (giving us the approximate positions we want for 1,2,3).

Here's the Companion 9x simulation.  You can see that as we toggle the buttons, channel 5 outputs the desired values for all the positions.


1 comment:

  1. Thank you, I been searching for this to program my 9xr with opentx firmware for apm 2.5

    ReplyDelete