Move elevon servos to the output rail on the NANOWII in FLYING_WING mode #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Premise
I ordered Hobby King's NanoWii board since it comes with a 6-axis sensor in a nice 3 cm x 3 cm form factor, which means it fits quite small models.
I am primarily looking at fixed-wing applications at the moment. With that premise, NanoWii's config.h provides two modes that sound somewhat relevant; AIRPLANE and FLYING_WING.
Problem: figuring out how to use elevon mixing
The Wiki page on Multicopter Types is the closest thing to a end-user manual I found that mentions these airframe types, but it doesn't really explain how to use them, so I started experimenting a bit, trial-and-error style:
I briefly tried out AIRPLANE mode, which seemed to work as expected. I hooked up a few servos to the output rail and they responded to my transmitter (4-channel setup) in a consistent, usable manner in passthrough mode. The particular airframe I intend to set up with the NanoWii first however, is a flying wing, which means I need MultiWii to provide elevon mixing, which seems to be exactly what the FLYING_WING mode does. When hooking up the servos the same way I got no reaction from the servos... The indicators in MultiWiiConf.app showed that MultiWii responded to sensor input as desired. What I didn't know was where MultiWii expected me to hook up the servos...
...until some hours later when I found this diagram:
What is the motivation for using A0 and A1 as elevons? Does that make sense on some specific hardware that is common or happens to be used by some particular developer? Or is flying wing mode an experimental thing that nobody cares about? The elevons are mapped to A0 and A1 via more generic-sounding SERVO* constants though... It seems to me that something called "servo n" would be preferable to map to an output that provides power and ground pins if at all possible, regardless of use-case.
Is this something that the person adding support for a specific board is supposed to consider re-mapping on a board by board basis (and per airframe type in case you run out of friendly pins - for example nanowii + hexacopter)? Or is this something MultiWii leaves to the end-user to figure out with the help of a soldering iron? Mapping A0 and A1 (and hence possibly servo 1 and 2 although I haven't verified that in the code) to servo-unfriendly pins seems to be done on other boards too.
Suggested solution
If I would solder directly to the board (and I probably will take that approach later when I deal with a smaller model) and having found that diagram, this isn't really an issue, since the A0 and A1 are broken out on the HK NanoWii board.
By default however, it would be nice (i.e. more user-friendly and more intuitive) to have the elevon signals on the board's output rail which provides power and ground pins for the servos.
The attached branch provides a way to accomplish that on the board I'm using. It re-maps servo 1 and 2 to pins on the output rail that appear not to do anything useful in FLYING_WING configuration. Written for and tested a couple of hours the air with the "release-2.1" tag. Rebased on top of and tested briefly on the ground with the commit that the SVN repo claims corresponds to the 2.2 release (no corresponding tag in the git repo currently).
A few caveats:
Commit message
At least on Felix Nessen's NanoWii and Hobby King's NanoWii - both of which
suggest that board definition NANOWII should be used - Arduino pins 10 and 5
map to the second and third channels on the output rail that provides power
and ground pins next to each signal pin.
FLYING_WING mode uses SERVO_1 and SERVO_2 as elevons, which by default
are mapped to Arduino pins A0 and A1, which are accessible on these boards,
but lack the convenient power and ground pins. This commit re-maps the pins
for SERVO_1 and SERVO_2 (and SERVO_5 and SERVO_7) to the mentioned pins
on the output rail in this situation.
This change is probably only beneficial to you if you use one of the
mentioned boards AND want to fly in elevon mode AND you choose to use
pin headers and standard servo connectors instead of soldering
directly to the board.
AIRPLANE mode seems to map aileron, elevator and rudder to the second,
third and fourth channels (Arduino pins 10, 5, and 6) on the output rail
as desired, regardless of this change.
The throttle channel seems to map to the first channel on the output
rail in both AIRPLANE mode and FLYING_WING mode.
http://flyduino.net/documents/NanoWii_manual.pdf
http://www.hobbyking.com/hobbyking/store/__22322__MultiWii_NanoWii_ATmega32U4_Micro_Flight_Controller_USB_GYRO_ACC.html
http://multiwii.googlecode.com/svn/trunk/Doc/Diagrams/7%20Connection%20diagram%20flying%20wing.png