Sunday, July 21, 2013

Configuring deviationTx on a Devo 10 for Phoenix

Goal

There are actually two different ways to configure an rc aircraft controller for use with a simulator. If you're fine-tuning maneuvers, or learning the advanced maneuvers, then you want the simulation to be as close to the craft you fly as possible. To get there, you tweak the sim to make the model act more like yours. You also use your controller configured the way you normally configure it to fly the aircraft. This is great for advanced flyers, and most - if not all - of the guides on the net have you do things this way.
However, if you're practicing basic skills - flying in different orientations, for instance - and want to experiment with different kinds of aircraft, there is an alternative approach. Since the simulator isn't an aircraft, but a computer, it can do a lot more for you than just pretend to be an aircraft - it can take over some of the functionality of the controller. For instance, it can provide helicopter pitch curves for inverted flight, which most helicopters can't do. They won't be exact, but they'll be good enough for practicing flying inverted while you learn the orientation. And it frees up a channel between the sim and the controller for other things. This is the way the manuals I've seen have you do things. Which may well explain why there is so much confusion about such things.
This isn't so much a guide on setting up a controller for use with a sim, but a demonstration of the capabilities of open source controller software. It takes the latter approach because that lets you get more functionality out of the sim/controller system. If you're looking for instructions on making your sim/controller combination as much like your aircraft as possible - this isn't for you. You're probably well beyond this in any case, so thank you for taking the time to read my blog.
If, on the other hand, you're still working on those basic skills, and interested in trying out various different aircraft without having to re-arrange your controller every time - this is for you. I'll show you how to set up deviationTx on the Devo 10 so you can fly a heli inverted with the same configuration you use for fine control of flaps on an aircraft, while still having the ability to raise the gear and control the engine angle on tilt-rotor craft.

What you're going to find here

The deviationTx software makes the models available as a USB file system, each model being in a file formatted like a DOS .ini file. That means it has sections that each line takes the form variable=value, with sections for different things marked by lines with the section name enclosed in square brackets. I'm going to show you the relevant sections, then describe what they mean. The section names will be in blue, and the subsections - if any - in green.
Finally, I'll tell you where you can download a copy of my model file, so you can just use it directly if you're using deviationTx software.

Getting started - radio and simple channels

Radio config

For completeness sake - as in you'll need this if you're trying to copy the config without using my .ini file - the radio setup looks like this:

name=Phoenix
mixermode=Advanced
[radio]
protocol=PPM
num_channels=8
That is, the name for this model is Phoenix (yes, I'm using the Phoenix flight sim), I'm using the Advanced mixer mode, with the PPM protocol with eight channels. If you haven't aren't familiar with open source controller software, the existence of a protocol setting might surprise you. The software implements multiple protocols in the same controller, sometimes with the same transmitter.

The Simple channels

There are three simple channels - literally. They use the simple mixer type in deviationTx. The first is for AUX4, one of the extra input knobs. You won't find a simpler mixer in a deviationTx config:

[channel7]
template=simple
[mixer]
src=AUX4
dest=Ch7
This doesn't specify a curve type, so it's 1-1. No scaling, no offset, so those default to 100 and 0. I.e. - it copies the input AUX4 direct to the output Ch7.
It does have one twist. In the trims section, I've set up the trim switches in the upper left - near that knob - to tweak it's output:

[trim5]
src=AUX4
pos=TRIM_L-
neg=TRIM_L+
Two of the switches near that knob are nearly as simple:

[channel5]
template=simple
[mixer]
src=GEAR1
dest=Ch5
curvetype=min/max

[channel6]
template=simple
[mixer]
src=ELE DR1
dest=Ch6
curvetype=min/max
These add the curevetype of min/max, meaning they go from -100 to 100 as they turn on, giving a good sharp edge should you have an edge-triggered control. The two are identical except for the channel number, src and dest (all italicized).

Elevator, Aileron and Rudder

These are all set the same, and are the a bit more complicated. The model file entry for them looks like this:

[channel1]
template=expo_dr
[mixer]
src=ELE
dest=Ch1
curvetype=expo
points=35,35
[mixer]
src=ELE
dest=Ch1
switch=FMODE0
scalar=70
The bits in italic are what vary between the three channels - the channel number, source and output channel.
To translate, this is the settings for channel1. I'm going to use an expo_dr template - meaning three mixers, the last two controlled by switches. I only use two mixes, the reason to be revealed later. The first mixer uses a curve from the ELE stick to Ch1 with an expo of 35 on both sides of 0. The second mixer just copies the ELE stick setting to Ch1 with a 70% rate (the scalar value). Obviously, these should be adjusted to taste, I use them on my real helis because they give the same feel near center, but the low rate mode keeps me from getting into trouble with a new craft. The switch setting in the second mixer (aka low rate) controls when it is used. If the FMODE switch is in position 0 this mixer is used, otherwise the first one is.

Pitch (or is it flaps?)

Now we're going to see the first bit of the magic this software can do. Channel 8 has a complex template, meaning an arbitrary number of mixers, each which has the full mixer facilities available:

[channel8]
template=complex
[mixer]
src=AUX5
dest=Ch8
switch=MIX0
scalar=-100
curvetype=fixed
[mixer]
src=AUX5
dest=Ch8
switch=MIX1
[mixer]
src=AUX5
dest=Ch8
switch=MIX2
curvetype=fixed
[mixer]
src=Virt3
dest=Ch8
switch=AIL DR0
usetrim=0
These all have a switch setting which controls how each mixer is used. The last one whose switch is on will be the mixer that actually gets used. The first three:

[mixer]
src=AUX5
dest=Ch8
switch=MIX0
scalar=-100
curvetype=fixed
[mixer]
src=AUX5
dest=Ch8
switch=MIX1
[mixer]
src=AUX5
dest=Ch8
switch=MIX2
curvetype=fixed
are selected by the MIX switch as it moves through it's three positions. The middle one is a straight copy of the other knob - AUX5 - to Ch8. The ones above and below this one have a fixed curvetype, meaning they always output their values when selected. The first one has a scaler of -100, so that's the value it outputs. The last one doesn't have a scaler, so it outputs the default of 100.
This one mixer also has a trim set up in the trim config:

[trim6]
src=AUX5
pos=TRIM_R-
neg=TRIM_R+
These three mixers let you toggle the output to Ch8 from -100, through the knob setting, to 100. I use it for flaps when flying airplanes.
Finally, the last mixer in that template is:

[mixer]
src=Virt3
dest=Ch8
switch=AIL DR0
usetrim=0
This is a straight copy of Virt3 to Ch8 when the AIL DR0 switch is on. Since this is the last mixer, it will always have priority if enabled, meaning that the AIL DR switch switches between the previous behavior (when down) and Virt3 - whatever that is - when up.
So what is Virt3? A virtual channel. It's not output to anything by itself, but can be used in other mixers, as it is here. It looks like:

[virtchan3]
template=complex
[mixer]
src=THR
dest=Virt3
scalar=55
offset=45
usetrim=0
[mixer]
src=THR
dest=Virt3
switch=FMODE2
usetrim=0
A channel whose template is complex, but with only two mixes. The second one is a straight copy of the THR to Virt3 when FMODE2 is on. The first one is a tweaked copy, scaled back to a factor of 55 and having 45 added to it, meaning it runs from -10 to 100. This could be pair of collective pitch curves, one for idle-up mode, and one for inverted flight. Given that the latter is on FMODE2, and I use FMODE0 for a low rate mode, that would be logical.
I could have used two virtual channels here, one for the MIX settings, and virtchan3, and switched between them in the channel8 template. That would have been a bit cleaner, but this model - putting one virtual channel in the real channel, then a switch to turn the other one on - works equally well with one less virtual channel.

Throttle

At this point, I've only got one channel left - the throttle. We are about to go through the looking glass.

[channel3]
safetysw=Virt2
safetyval=-100
template=expo_dr
[mixer]
src=THR
dest=Ch3
[mixer]
src=THR
dest=Ch3
switch=FMODE2
curvetype=fixed
[mixer]
src=THR
dest=Ch3
switch=AIL DR1
channel3 uses another expo_dr template, though it doesn't actually use an expo. Or dual rates, for that matter, though it has DR switch. The first and third mixers are direct copies from THR to Ch3, with the last one being enabled by AIL DR1. The middle one is enabled by FMODE2, and sets the throttle output to the default value of 100, or full on.
So, if FMODE2 is on, giving us the full range pitch curve on channel 8, I get a throttle fixed at full on, which is what I want (well, close to it) for 3d flight. If you prefer a V-curve here, you can either use a 3 point curve, or a scaled and offset absolute value curve to get it.
However, if AIL DR1 is on, you don't get the fixed throttle - you get normal behavior. If you recall, Channel 8 is set up to only use the pitch curve virtual channel if AIL DR0 is on. So AIL DR will switch between CP heli mode (up) and airplane or 4 channel 'copter mode (down).
The real magic is in the setup for channel3, though. It has a safetysw of Virt2, using a virtual channel as a switch. When that switch is on, the value output to channel3 will be -100, creating a throttle hold.
So lets look at that virtual channel. Well, channels:

[virtchan1]
template=complex
[mixer]
src=THR
dest=Virt1
scalar=-50
offset=-49
usetrim=0
[mixer]
src=!FMODE2
dest=Virt1
switch=AIL DR0
usetrim=0
muxtype=min
curvetype=min/max
I start with virtchan1. This translates the combination of THR, FMODE2 and AIL DR0 into an on/off value. It uses a complex template.
The first mixer uses the throttle stick - still THR - as input. It maps the value directly to the output, with a scaler of -50 - meaning it will slope down from left to right. Further, we subtract 49 from it before outputting it, so the value goes from 1 (when the throttle is at the bottom of it's travel) to -49. This will cause the Virt1 switch to be on when the throttle is all the way down, and off otherwise.
But we're not done yet! The second mixer is controlled by the AIL DR switch, being used if it is up. The input is !FMODE2, so it will be -100 if the FMODE switch is in position 2, and 100 otherwise. The curvetype is min/max, because I like those for switches. The result of all this is that this mixer is only on if the controller is either in airplane mode (AIL_DR0 is off) or in heli mode and FMODE is not inverted (2).
This mixer also has the first (and only) appearance of the muxtype value. It is min, meaning that the value from this mixer - if it is enabled - will be the minimum of the value from the last enabled mixer and it's value. All the other mixers use the default muxtype of replace, meaning their value is used if they are enabled, replacing the previous value.
Because of this, virtchan2 will be on if both the first mixer is on - meaning the throttle stick is full off - and the second one is on. In other words, virtchan2 is on if and only if the controller is set so that the propellers aren't getting power.
The second virtual channel is even more complex:

[virtchan2]
template=complex
[mixer]
src=Virt2
dest=Virt2
usetrim=0
curvetype=min/max
[mixer]
src=AIL
dest=Virt2
switch=Virt1
scalar=-100
usetrim=0
curvetype=fixed
[mixer]
src=AIL
dest=Virt2
switch=RUD DR1
usetrim=0
curvetype=fixed
Another complex template. The first mixer copies Virt2 to itself. The curve is min/max, meaning we force the channel to 100% or -100%. That's not really necessary, but we want this channel to be clearly on or off. The source is also Virt2, meaning the default behavior is to continue outputting the old value.
The second mixer is another fixed curve, with a value of -100. It is controlled by the Virt1 switch - which means that it's going to be on only if we're not going to spin the props. If it goes on, Virt2 will go off.
The third and final mixer is controlled by the RUD DR1 switch, or rudder dual rate when it's spelled out. If that switch is on, we get fixed output default value of 100. So when we switch the rudder dual rate switch down, Virt2 will go on.
Ok, let's put this all together to see it in action. During normal flying, rudder dual rate is off, flight mode is either 0 or 1, and the throttle output tracks the stick. Virt2 is also off. I throw the rudder dual rate switch, the third mixer for Virt2 goes on, so the safetysw entry for the throttle sets the output to -100. If I turn off the rudder dual rate, the first mixer will keep Virt2 off! I.e. - the throttle output will stay at -100. It will stay that way until Virt1 goes on - meaning things are set so the props won't spin.
I was introduced to this for just the throttle stick as a sticky throttle hold. The first time I tried it with a CP heli, I managed to turn throttle hold off in an inverted flight mode. Fortunately, I was using a sim, so no damage was done, but I quickly fixed it. I call this a safe throttle hold. When using it, your good habits of making sure the throttle is down and you're not in an inverted flight mode will still work - but should you accidental skip a step, it will help you avoid a nasty accident.

A little lagniape

You can also control the display with this software. I have it set this way:

[gui-qvga]
trim=6
barsize=half
box1=Ch1
box2=Ch2
box3=Ch3
box4=Ch4
box5=Ch5
box6=Ch6
box7=Ch7
box8=Ch8
bar1=Ch1
bar2=Ch2
bar3=Ch3
bar4=Ch4
toggle1=FMODE
tglico1=5,6,19
toggle2=Virt2
tglico2=0,13,19
toggle3=AIL DR
tglico3=0,3,0
toggle4=GEAR
tglico4=0,23,0
This displays the values of all 6 trims as bars, and provides the value of all 8 output channels as numeric output. It provides four toggles, from left to right underneath the model name. toggle1 shows the flight mode, switching to white-on-black when in FMODE2. toggle2 turns on a throttle hold icon when Virt2 is on. toggle3 turns on an A-down icon when in airplane mode. toggle4 turns on a G-down icon when you put the gear down.

Summary

This setup allows me to use one model on my Devo 10 to fly both CP helicopters and everything else. With 30 models, I could certainly spare more than one, but that could be problematical as Phoenix doesn't deal well with multiple transmitters.

Review

Let's go over the controls we have.
The elevator, aileron and rudder sticks are sent to channels 1, 2 and 4 respectively. They all have a low rate mode enabled by FMODE being 0.
The GEAR and ELE DR switches are sent to channels 5 and 6, respectively. GEAR being on brings up a G-down icon on the display. The AUX4 knob goes to channel 7, with trim adjustment.
The AIL DR switch switches between CP heli and other modes. When it's on, channel 8 is a mix of the MIX switch and AUX5 and trims, the throttle stick goes to channel 4, and an A-down icon shows on the display. When AIL DR is off you are in CP mode, and channel 8 is pitch, controlled by the throttle. In CP mode, when FMODE is 2 the throttle is full on and you have the full range of pitch available, so you can fly inverted. Otherwise CP mode has the throttle stick with full range and pitch limited to the top 60% of the range. FMODE also has an icon on the display.
Finally, RUD DR functions a safe throttle hold, that re-enables the throttle only when it shouldn't spin the props, adjusted depending on the setting of AIL DR. Whenever the throttle is held, there's a TH icon on the display.

Download

You can download this model.ini file from the deviationTx forums.

Conclusion

While setting up a sim this way is useful, it really doesn't help you become a better flier. What it does do is provide an example of how flexible this firmware really is - and those features come in useful as your aircraft gets more complex. If there is a controller using proprietary firmware that can duplicate this functionality, I'd be interested in hearing about it. Maybe a pointer to the manual?

Postscript

This setup was done with version 3.0.0 of the deviationTx firmware. The next release will have more functionality, adding the ability to use trim switches (which can include the UP/DN/EXT/R/L/ENT buttons) as momentary switches, toggles, and paired switches. I'll probably use some of those on the current switched channels. It also drastically improves the control of the display. Watch this space if you're interested in how that plays out.