Arduino-based mode switch

FILE0080.jpg?width=750First, I used combinations of switches to select the mode of my APM. But IMHO, there is hardly anything more counter-intuitive and if things hit the fan, you can be sure to switch to the wrong mode out of pure hectic.

Next, I replaced a pot of my transmitter with a 6-position switch and variable resistors. That is already better, but to get to one mode, you likely have to switch through other modes. Also, without any markings, again, not very intuitive and it's impossible to see at one glance which mode you are in.

Finally, I hacked together a small board with 6 pushbuttons, 6 LEDs and an Arduino Pro Mini. The Arduino creates an 8-channel PPM stream of which channel 1 contains the data for the mode. The whole thing connects to the trainer port of my 9x. Additionally, I steal 5V from the display output of my FrSky module but theoretically, the Arduino could also be powered by the 3S transmitter LiPo. The program is pretty easy. Check the buttons and set the respective PPM value. The LEDs are not set by the buttons but by the actual value of PPM1 - just to be safe, in case e.g. the Arduino resets or something.

Here's the schematic:

APM_mode_switch_schem.png?width=750I'll attach design files for the PCB and the source code in the comments then.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • PWM converts to analog with simple r/c circuit (resistor and capacitor).

    Values need to be balanced according to PWM update frequency.

    Additional resistor and capacitor with reference voltage input can permit output voltage greater than max PWM voltage.

    An Op amp in line can drive higher load.

    If resolution required is low as above 6 position switch, should be fairly easy to get 6 position switch to work.

    Interesting might be to hack into open source transmitters firmware (FRSky and Turnigy) and use trainer port to control variety of things.

  • I tried to download the Mode switch for APM - Gerber files, but I got this error message:

    Error while downloading file File not found on server.

  • Well, the board is CC-BY-SA and the Software GPL... I have no problems if anybody wants to make a bunch of those.

    Besides, I was thinking of having a small batch of the PCBs made if nobody else makes them and there's interest. Just the naked PCBs - for people who know how to solder :).

  • Maybe your design will be copied and sold on Hobby King :)

  • About as well as all other switch solutions but still better than switch-combinations :). All a matter of training.

    But - I anyways fly with a screen, not with goggles. I need to be aware of my surrounding. You know, we have bears and stuff here in Finland :D.

  • How well does this work when your doing FPV and your fingers need to find the right button by themselves without sight ?

  • My code outputs a full 8 channel PPM stream. In the code you can also change into which channel the mode value goes. At least most TXs should allow you to choose, which channel should be overridden by the trainer port.

    You can with an R/C-stage convert a PWM signal to analog but you still have to figure out, which voltage exactly to send to achieve which signal from the TX. That's not so trivial, I think, and requires some subsequent code hacking.

  • But can all Tx take a single channel input on the trainer port?  I don't know.

    Can't you convert the PWM output to true analog with a simple Cap?

  • Robert, you'd need to put an electronic potentiometer in between. The Arduino cannot output true analog voltages - only PWM. As most transmitters are computerized and expect a true analog voltage coming from a pot (wired as voltage divider), they might get confused by a PWM signal at the input. Therefrom comes another problem then - you need to know, what voltage exactly to feed into the pot port. Some TXs run on 5V, some on 3.3V, some use voltage divider circuits for the pots, some don't. Pretty many variables to account for.

    But talking about simplifying... Isn't it simpler to just plug a cable into the trainer port instead of starting to mess in the guts of your transmitter? :) Especially, the trainer port solution is reversible without problems :).

  • Yes Robert, this should be totally doable. Just use a pwm output and the proper RC constant. I will work on that and include it in my upcoming blog post.

This reply was deleted.