This page was copied to the official place on ardupilot website The new location may be more up to date and you should likely link to it instead of this page:
http://plane.ardupilot.com/wiki/flaperons-on-plane
Elevons, Ruddervators and flaperons with Ardupilot/APM::Plane
Note that this page is current as of August 2015 and tested with APM::Plane 3.3, although what I'm describing should be relevant to older versions too.
Ardupilot/APM::Plane takes your RC input and either passes it through, or uses it as input for automatic modules like FBWA or CRUISE (and in some cases will mix the RC input with the generated output, like allowing you to add aileron control to the aileron control computed by let's say RTL).
The part where things get complicated is:
Elevons (flying wings have only 2 controls used as elevator and ailerons)
Ruddervators (V-Tail) where rudder and elevator are mixed into a V-Tail surfaces. This is used by planes like the X-UAV Talon
Flaperons is simply allowing your 2 ailerons (using one channel each) to be used as flaps and ailerons
Elevon and ruddervators are well documented. Even if you care about flaperons, you should look at this page since it explains the basics of mixed modes, and they are relevant to flaperons too: http://plane.ardupilot.com/wiki/arduplane-setup/first-time-apm-setup/reversing-servos-and-setting-normalelevon-mode/
The first concern on a pixhawk is that using any of those mixed modes requires decoupling the control surfaces from direct passthrough control coming from the RC Controller. Passthrough is a mode where if the pixhawk has a bad failure, it's able to connect RC1-8 directly to the relevant output channels without doing anything with them.
Obviously, if your control surfaces are mixed by the pixhawk, passthrough will not work anymore. While this kind of bothred me, I've been told that pixhawk failures are so rare that I should just forget that passthrough even exists, and not worry aobut losing it (besides quadcopters never had passthrough support anyway).
For flaperons, in the past, I naively connected my first aileron to channel 1, and my 2nd aileron to channel 5, setting RC5_FUNCTION to 18. This looks like it works, as in Ardupilot can control both ailerons in auto mode while it will passthrough channel 5 in manual mode and allow my controller to generate flaps down by controlling both ailerons.
This of course, did not allow Ardupilot to control ailerons itself in auto modes, but I didn't care.
But, I soon found out that if I had flaps down with my controller and then switched to auto mode, ardupilot would receive an aileron command on channel 1 and assume that I'm trying to mix in a turn into RTL or FBWA. APM::Plane could support this properly, but does not. You can follow this issue for details: https://github.com/diydrones/ardupilot/issues/2186
Given this, the only way to get proper flaperon support is to use the support in ardupilot is to give aileron control to Ardupilot (i.e. no passthrough anymore). There is only incomplete documentation on it, hence this post. See:
http://plane.ardupilot.com/wiki/arduplane-parameters/#flaperon_output_arduplaneflaperon_output
http://plane.ardupilot.com/wiki/arduplane-parameters/#servo_out_function_rc5_function (24 and 25)
http://plane.ardupilot.com/wiki/arduplane-setup/first-time-apm-setup/automatic-flaps
How to get flaperons to work
So here's what you need to know:
do not do any more aileron mixing on your TX, only send aileron input on channel 1
channel 1 is unfortunately lost, as in you can't connect an aileron to it (this is because RCx_FUNCTION does not work for channels 1-4). This is arguably a shortcoming of ardupilot because it is able to use a channel for input and output like we will do for channel 5 below.
you then need to put your ailerons on 2 other channels. Unfortunately, again, they must be on channels 1-8, even if it would be convenient to put them on RC13 and RC14 so has not to burn channels used by your transmitter. Turns out that as discussed on https://github.com/diydrones/ardupilot/issues/2523 , your ailerons still work in passthrough mode when the pixhawk is crashed or rebooting, but this only works if they are on channels 1-8, so in the end you probably wouldn't want to put them on channels 13 and 14 where passthrough would not work. Given that, you put your ailerons on channels 5 and 6 and set RC5_FUNCTION to 24 and RC6_FUNCTION to 25 (which one is which doesn't matter).
now, you need to add a channel on your transmitter to say how much flaps you want in manual mode. The good news is that you can re-use RC5 for this (i.e. it'll be used to sample flap input and totally separately used to generate aileron output). You don't have to do this (you can send flap input on channel 9 for instance) but reusing channel 5 saves you an RC channel since you're unable to move your ailerons on output channels higher than 8.
Ok, from there it gets more tricky. If you are unlucky, sending flaps input may cause your flaps to go up and act as spoilers, which is not what you want. To be clear with direct aileron control from your TX, you can have your flaperons go up or down (flaps or spoilers) but once you go through Ardupilot, they will only work as flaps. It's not ideal but likely good enough for most.
So, here's what you need to do next:
Setup your transmitter to send flaps on channel 5 (either a switch or a rotary button)
Set FLAP_IN_CHANNEL to 5
Set FLAPERON_OUTPUT to 4
Switch to FBWA or CRUISE, tilt your plane and make sure the ailerons move in the right direction (flap goes down on the wing that you tilt down). If they don't, try setting FLAPERON_OUTPUT to 1
Once this works, try your flaps switch and make sure flaps go down and not up. If they go the wrong way, change RC1_REV from 1 to -1 (or the other way around) and change FLAPERON_OUTPUT too. Make sure FBWA still moves the ailerons in the right direction, and now your flaps should go down.
Only then, try the ailerons on your TX. If they go the wrong way, reverse channel 1 on the TX without touching RC1_REV (if you put your stick left, the left aileron should go up)
Tuning
Go to failsafe setup in apmplanner/mission planner, and make sure the max/min values match RC5_MIN/MAX (or adjust them) so that your flaps move all the way (RC1_TRIM should also be set to 1500)
Set FLAP_SLEWRATE to 100 to allow moving flaps from 0 to 100% in one second (or lower this to make your flaps move more slowly)
Play with FLAP_x_PERCNT|SPEED as desired for auto modes, see http://plane.ardupilot.com/wiki/arduplane-setup/first-time-apm-setup/automatic-flaps/ (ignore the comment saying "parameter for the channel function for the channel you are using for flaps to a value of 3". This is not true anymore, FLAP_IN_CHANNEL does this).
Also have a look at TKOFF_FLAP_PCNT and LAND_FLAP_PERCNT if they are relevant to you.
When you are flying in manual mode, it can be helpful to setup an elevator down mix on your TX when you set flaps (i.e. the more flaps you send, the more elevator down you should send to correct pitch up from flaps). I recommend you set up the mix value on a rotary switch so that you can control the elevator down correction during a test flight (if you set too much elevator down as a fixed value in your mix, you'll be stuck not being able to use flaps for landing if you put too much elevator down). Note that using a Frsky Taranis makes such complex mixes much easier (or possible) compared to some other more basic controllers.
Crow flaps
See http://plane.ardupilot.com/wiki/fixed-wing-faq/#how_would_i_setup_crow_flaps gives some hints.
If you need crow flaps (which means your ailerons must go up, not down), you can use these instructions and reverse RC1_REV so that when you send flaps input, ailerons go up instead of down (while the real flaps go down). Then you should be able to set your flaps channels as flap or flap_auto (see http://plane.ardupilot.com/wiki/flight-features/channel-output-functions/#flap_auto ).
Note that this is not as versatile as direct RC control where you could use your flaps surfaces 2nd ailerons for tight turns in thermals, but only if a switch if flicked, as with this setup you can only have both flaps go down at the same time your flaperon-ailerons go up as spoilers, and only ailerons can be used for turning.
This is likely good enough for most people though.
Notes
Manual flaps input is mixed into auto modes. That means if you're landing in manual mode with flaps set to full on your TX, and you flip the mode to RTL or some other mode to abort the landing and go back to an auto mode, flaps will stay full. You need to retract them on your TX.
RCx_MIN and RCx_MAX for flaperon output channels limit deflection of flaperons and you can use the TRIM value to move the neutral position in case you want more down travel than up travel.
RC1_TRIM acts as normal aileron trim, RC1_MIN and RC1_MAX should match the TX setting
If you share RC5 for flap input from TX and aileron output, you must ensure that your TX MIN and MAX for that channel match what you set for RC5_MIN and RC5_MAX if you changed the aileron travel.
Don't go fly yet. Go back to square 1 and make really sure that FBWA/CRUISE moves the ailerons in the right direction and that ailerons also go in the right direction in manual mode.
Now, go flying and enjoy!
Associated bugs with background:
https://github.com/diydrones/ardupilot/issues/760
https://github.com/diydrones/ardupilot/issues/2186
https://github.com/diydrones/ardupilot/issues/2524
My X-UAV Talon with pixhawk I setup flaperons on
|