Saturday, July 19, 2014

200 QX Dialable Stagility Mode

The 200 QX

If you aren't familiar with the 200 QX, you might want to read my review of it.
The critical thing is that it, like other recent Blade quads, has both a stable mode and an agile mode. The stable mode (or modes) has a limited flight envelope, and will automatically return to level flight when there is no cyclic input. The agile mode has no limits on the flight envelope, but won't return to level.
This is a really nifty idea, as it lets the quad have a personality suitable for beginners, flying very much like a coax, as well as one suitable for advanced pilots, allowing acrobatics of various kinds, but requiring some skill to do. It's much better than the solution found on toys of having a flip button.

Stagility mode

The one downside of this is that - well, as you transition from one to the other, you'd really like to have the ability to do some acrobatics in stable mode, or have a open flight envelope that levels itself.
Some bright person figured they could get that if they could get the quad to switch from stable mode to agile mode automatically when it's given cyclic input. This is relatively straightforward - just mix the cyclic input into the channel that controls the mode appropriately.

The bad

While that approach works, there are two downsides to this:
  1. The behavior is fixed. There are a number of behaviors that might be desirable, and changing between them is generally not supported.
  2. There have been reports that the quad becomes unstable doing things this way.
While I set out to deal with #1, my solution means that, instead of getting odd values from a mix on the mode control channel, the quad only gets values it expects on that channel. I believe this should solve the stability issues, but a discussion with Horizon Hobby about it just resulted in "We still don't recommend that."

An automatic switch

If your transmitter runs deviationTx or similar, then you have the ability to use a virtual channel as a switch. If the value output on the channel is greater than 0, then the switch is on. Otherwise, it's off.
So, the first step is to get the deflection on the aileron channel. That's not hard. The mixer looks like so:
[mixer]
src=AIL
dest=Virt4
usetrim=0
curvetype=absval
points=0
That is, the source is the aileron input, and we want use a curvetype of absval to get its absolute value. Since it goes from -100 to 100, being 0 when centered, this gets us the deflection on the stick.
Second, we want the same for the elevator, which looks surprisingly similar:
[mixer]
src=ELE
dest=Virt4
usetrim=0
muxtype=max
curvetype=absval
points=0
The only difference is that the muxtype is max which means the output will be the larger of the output from the aileron mixer and this one. So we now have the larger of the two cyclic deflections.
Last step - let's compare this to some other value, so that it's only positive if the deflection is larger than that value. Instead of hard coding the value into the mixer, we can use the knob next to the flight mode switch, which is AUX5:
[mixer]
src=AUX5
dest=Virt4
scalar=50
offset=-55
usetrim=0
muxtype=add
This mixer uses the scaler setting to make the value go from -50 to 50 instead of -100 to 100, and then the offset setting to move it to -105 to -5. And the muxtype is add, so this will be added to the larger of the cyclic deflections.
So we now have a switch that goes on with cyclic input, and we can adjust how much input it takes to turn it on with the AUX5 knob.

Controlling the mode

The mode is a bit more complicated than before, or the above. The standard behavior uses two switches and three mixers, like so:
[channel5]
reverse=1
max=100
min=-100
template=complex
[mixer]
src=AIL
dest=Ch5
scalar=0
curvetype=fixed
[mixer]
src=AIL
dest=Ch5
switch=FMODE0
scalar=-100
usetrim=0
curvetype=fixed
[mixer]
src=AIL
dest=Ch5
switch=FMODE2
curvetype=fixed
The channel is reversed, because that's how the manual said to do it, though it's not really required when using devaitionTx. The first mixer sets the output to 0, which is the high-angle stability, or blue mode. The second mixer - enabled by the flight mode switch being in the 0 position - sets the channel to -100, the value for the low angle stability or green mode. The last mixer - enabled by the flight mode switch being in the 2 positition - sets the channel to the default value of 100, the value for the agility or red mode.
We now add a mixer:
[mixer]
src=AIL
dest=Ch5
switch=Virt4
curvetype=fixed
This one is enabled by the virtual switch we set up previously, and sets the output to the default value of 100, effectively switching to agility mode when it goes on.
I added this mixer after the first mixer, so that only the blue mode gets the stagility behavior. If it were added after the second mixer, both stability modes would actually be stagility modes. Added after the last one, and agility mode would also automatically switch to agility mode, for whatever that's worth.

Video proof of working

Here's a video showing off the four different behaviors I use. There are probably more:

The four behaviors are:
  1. stagility dialed all the way down, and it's just stock high angle stability mode.
  2. stagility dialed all the way up, and it's an auto-leveling agility mode.
  3. stagility is tuned by pushing the aileron all the way out, then turn up stagility until it switches to agility mode. This causes it to switch to agility mode when the sticks are at full throw, which usually results in an immediate flip. This is a behavior seen on some of the RTF "toy" quadcopters.
  4. stagility set somewhere in the middle of the range, and it behaves like the versions that mix the cyclic controls into the mode control channel.

My DeviationTx model

Warning

There are reports that using stagility mode can cause your quad to become unstable in flight. According to the support peopel at Horizon Hobby, this can be permanent, requiring reflashing the quad firmware to fix. While I believe that this variant doesn't have that problem, nobody knows for sure, so understand you are USING THIS AT YOUR OWN RISK.
That said, if you use deviationTx you can download my model for the Devo 10 here.