On-board Elevon/V-tail mixer
Posted: 05 Mar 2022, 17:45
Normally you wouldn't need such a thing because you can do the mixing on the transmitter.
A friend who I've been teaching to fly has a receiver with a built-in autopilot system that does auto-level, return to home, and such: it came in a foamy carbon cub, and it worked great in that. But after he crashed the cub, he's built it into a flying wing and for that we need elevon mix. We don't think the autopilot system can do elevon (or at least we don't know how to enable it, if it can) so we need an on-board mixer. I thought I had a commercial one somewhere, but I've not been able to find it, so this morning I programmed an Arduino to do the job.
My mixer is better than the commercial ones because it has four outputs that servos can be plugged into. If you call the two input channels A and B, then it provides A+B, A-B, -A+B and -A-B outputs. So there's no need to reverse any servo outputs (we're not sure if the autopilot system can do that) You just plug each of the servos into one of the four possible positions, and then swap them around until both controls operate correctly for both input functions.
I built the prototype using a DiyMore PRO-MINI Expand, but any AtMega328 16MHz Arduino would work: Nano, Uno, Pro-Mini, etc.
The code uses pins 2 and 3 for the two input channels. These are the pins that have hardware interrupts available, so they give the most accurate position sensing with the least possible jitter into the Arduino. Some receivers output the servo pulses in sequence, and some start two or more of the pulses to different channels at the same time; by using interrupt routines to measure the widths of the pulses, the code works equally well with either type.
Then the four outputs, A+B, A-B, -A+B, and -A-B, are put out on pins 4, 5, 6, and 7. It uses Timer1 in interrupt mode to control the pulse widths. If you edit the code, you could any pins for those, but it made a neater set-up on the DiyMore board to use six consecutive pins.
I've attached the code ("sketch"), which doesn't rely on any libraries. I can make a circuit diagram and a YouTube video of it working if anyone's interested.
A friend who I've been teaching to fly has a receiver with a built-in autopilot system that does auto-level, return to home, and such: it came in a foamy carbon cub, and it worked great in that. But after he crashed the cub, he's built it into a flying wing and for that we need elevon mix. We don't think the autopilot system can do elevon (or at least we don't know how to enable it, if it can) so we need an on-board mixer. I thought I had a commercial one somewhere, but I've not been able to find it, so this morning I programmed an Arduino to do the job.
My mixer is better than the commercial ones because it has four outputs that servos can be plugged into. If you call the two input channels A and B, then it provides A+B, A-B, -A+B and -A-B outputs. So there's no need to reverse any servo outputs (we're not sure if the autopilot system can do that) You just plug each of the servos into one of the four possible positions, and then swap them around until both controls operate correctly for both input functions.
I built the prototype using a DiyMore PRO-MINI Expand, but any AtMega328 16MHz Arduino would work: Nano, Uno, Pro-Mini, etc.
The code uses pins 2 and 3 for the two input channels. These are the pins that have hardware interrupts available, so they give the most accurate position sensing with the least possible jitter into the Arduino. Some receivers output the servo pulses in sequence, and some start two or more of the pulses to different channels at the same time; by using interrupt routines to measure the widths of the pulses, the code works equally well with either type.
Then the four outputs, A+B, A-B, -A+B, and -A-B, are put out on pins 4, 5, 6, and 7. It uses Timer1 in interrupt mode to control the pulse widths. If you edit the code, you could any pins for those, but it made a neater set-up on the DiyMore board to use six consecutive pins.
I've attached the code ("sketch"), which doesn't rely on any libraries. I can make a circuit diagram and a YouTube video of it working if anyone's interested.