Arduino-based mode-switch for APM

Electronic projects that are either related to the firmwares for the 9x, or simply great for radio control applications.
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Arduino-based mode-switch for APM

Post by sgofferj »

Image

First, 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:
Image

Design files and code attached.
Attachments
APM_mode_switch.ino.zip
Source code
(1.78 KiB) Downloaded 966 times
APM_mode_switch_gerber.zip
Layouts as Gerber
(204.64 KiB) Downloaded 751 times
APM_mode_switch_etch_pdf.zip
Layouts as PDF
(783 KiB) Downloaded 984 times

User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

book marked. This is one thing to have when flying APM. just plug in trainer port. Another project on the to do list. ;)
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

There was some good resonance on DIYD. I might have a bunch of PCBs made if I find a fab which does small numbers with reasonable prices.
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by rperkins »

Very cool.
1SQ
Posts: 37
Joined: Sat May 11, 2013 9:07 am
Country: -

Re: Arduino-based mode-switch for APM

Post by 1SQ »

any more news on this diy pcb?

sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

What kind of news are you looking for? I was otherwise engaged and one of my dogs died, so I wasn't really looking for a fab. There's a chance that 3DR or jDrones pick up the concept and make a product but I haven't heard more of that yet.
If you want it now, the easiest would be to do what I did - use an Arduino pro mini and a prototype circuit board.
User avatar
cre8tiveleo
Posts: 1434
Joined: Tue Dec 27, 2011 6:13 pm
Country: -
Location: Ontario,(GTA North)
Contact:

Re: Arduino-based mode-switch for APM

Post by cre8tiveleo »

Hmmm... Nano should work too? I've tonnes of those, no Pro mini's.
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

Sure. I used the Pro Mini because it's smaller and I have a whole basket full.
RJM
Posts: 23
Joined: Fri Aug 17, 2012 10:27 pm
Country: -
Location: Burlington, Ontario

Re: Arduino-based mode-switch for APM

Post by RJM »

Do you have a link to a connector I could use for the trainer port?

Great idea!
not2fast
Posts: 21
Joined: Fri Dec 21, 2012 4:22 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by not2fast »

I've used the 6 positions switch too and it' works ok but this goes to a whole new level. I have put one together using a Nano and the code worked perfectly. I have not connected it to the radio yet but the light sequence worked without playing with the code. I have one questions though. I have never played with Arduino programming but i'm assuming I can assign outputs to different buttons than the ones in the program? I'm doing another one using a Mini Pro but with the buttons in a different layout. Using the outputs in the current order makes for a busy PCB. I'd be interested swapping a set of PCBs for a program with notes on what to change for different button positions. This next one will be recessed in the 9xr handle. The end buttons are easy to get to in a hurry without moving your hands. By the way you can use a buddy cable from HK for the radio plug.

Thanks sgofferj.
Attachments
101_0204.JPG
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

@not2fast:
In the code there are the LED[] and the BUTTON[] arrays.

Code: Select all

// I/O-Pins
const byte LED[]={0,2,3,4,5,6,7};
const byte BUTTON[]={0,17,16,15,14,12,11};
The arrays contain the pin numbers.
In this case, mode switch 1 is connected to digital pin 17 (=analog in 3), the corresponding LED to digital pin 2.
Mode switch 2 to digital pin 16 (=analog in 2), the corresponding LED to digital pin 3 and so on.
=> Digital pin numbers for analog inputs
The first array value is always 0. I chose to do it that way to make the code more easy to understand, because there is no flight mode 0.
That's the only things you need to change in the code if you change the PCB layout.

Your board looks great! What switches do you use?

As for the buddy cable - I don't know the 9XR. Maybe somebody else can comment on that?

Edit: The PPM output must stay on digital out 10 and out 13 should remain unused because the pins are internally connected to the timer interrupts which control the PPM generation!
Edit2: IIRC, the 9XR has the 2.4GHz antenna in the handle? It might be wise to keep the board a bit away from that. Depending on PCB trace lengths and pattern, either the PCB could interfere with the TX ("suck" the TX energy) and/or the the TX could mess with the Arduino.

@RJM:
Depends on your transmitter. For the 9X, you can use a normal male 3,5mm stereo plug.
Helle
Posts: 577
Joined: Sat Jul 21, 2012 7:08 am
Country: -

Re: Arduino-based mode-switch for APM

Post by Helle »

hy,

look at page #36, #64 and follow
http://fpv-community.de/showthread.php? ... Mods/page4
there is a APM and 7 channel Analog PPM with a Arduino nano3 and it works very well

Arduino Software ist at #36 too
not2fast
Posts: 21
Joined: Fri Dec 21, 2012 4:22 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by not2fast »

sgofferj
Thanks for the short Arduino lesson. I will play with it tonight. I got this unit finished, mounted and connected and it works really well. I am using a FrSky module that has the antenna built in so there shouldn't be an antenna issue although you have a good point. The buttons are from Mouser #612-TL1240G1JC and I used 91 ohm resistors for the LEDs, part no 291-91-RC. I am using a 3C battery connected to the VCC pin. Just by luck the buttons came out in really good positions, all in order from left to right except #6 MANUAL which is in the middle of the right side which is perfect. It's the closest to your right thumb. I took me awhile to get the radio mix to work but once i got though that, wow, I LOVE this little board. I whittled and ground on the lower board until I was able to squeeze it down into the handle and the top board is flat on the handle face. Gen two will be much more compact. The JR buddy cable worked great too. I'm checking into using the Futaba buddy cord as it has two 12 volt terminals in the plug.
Thanks again and i will post the next version when it's presentable.
Attachments
101_0206.JPG
101_0208.JPG
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

When the other version is ready, you might want to post it as a blog post on DIY-Drones. People might be interested in that!
not2fast
Posts: 21
Joined: Fri Dec 21, 2012 4:22 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by not2fast »

I've developed a push button interface for selecting the six flight modes that is very intuitive. Modes can be selected without looking down and verified with just a glance. The original concept was posted by “sgofferj” on OpenRC Forums.com and he deserves all the credit for the program for the Arduino Mini Pro. I just took his idea and ran a bit farther with it. After dozens of proto designs and a pile of boards, switches and LEDs in the trash this is what I ended up with. Originally I had buttons with lights built-in but the light was covered by your finger when it came on and I didn't like that so I added the LEDs beside the button and since the boards are CNC machined changes are easy and I can make one or a hundred any time. The face plate is lift off replaceable so different button names or logos can be custom engraved.
I going to work on a version that will go on my 9x and as soon as I get my Taranis I will design one for that too. Those units should be fairly universal as they all use a wire handle. I’m also going to try this on my Dx7 that I have a 6 position rotary switch on. It should work the same way.
The brains of this is an Arduino Pro Mini with sgofferj’s program burned in it. I’m running it on a 3c battery and the signal is connected to the trainer port. The unit is fastened to the 9xR with double sided foam tape and after programming the radio it's plug and play. I still have some details to work out in the back but I flew this today and no issues. sgofferj mentioned in his post that there may be interference with the stock antenna in the handle but I fly a FrSky transmitter so I can't say.
I'm curious if there is any interest in something like this. I could put together some units if there is enough response.
If you are interested or have questions ask here or email me at [email protected]
Thanks

Here is a link to the original post:
(http://openrcforums.com/forum/viewtopic.php?f=84&t=4010)
Attachments
IMG_0188.JPG
IMG_0189.JPG
IMG_0190.JPG
IMG_0174.JPG
IMG_0168.JPG
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

Very nice work! Now you have to post it on DIY-Drones.com too. :)
Besides, I posted my original version there also: http://diydrones.com/profiles/blogs/ard ... ode-switch
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

Is there any way to power this through trainer port without a lipo pack?
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Arduino-based mode-switch for APM

Post by Kilrah »

Yup, from the Futaba port.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

How about T9X port? may be some mod needed?
I sort of remember you did some mod on the trainer port with a stereo jack?
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

I have a 9x. I steal the power from my FrSky module's serial out. See first post.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

I see. But I have the DHT. I can route a power line from back module pin. but it is still a two plug op.

May be mod the trainer port with a dedicated stereo jack, tip is Tx bat voltage middle is ground, top is signal. and for true plain trainer function, make a special stereo plug on one end with the tip disabled and only the middle and top ring goes to a mono tip and outer ring?
yes, that even solves my wireless trainer port to supply the power to the wireless cppm rx. ;)

hmm, that also can take care of the supply power to my wifi booster from tx 2S power pack. ;)

One stereo socket takes care of 3 things? You guys think this is feasible?
(note: this is for my sky9x board, if it matters)
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Arduino-based mode-switch for APM

Post by Kilrah »

kaos wrote:I sort of remember you did some mod on the trainer port with a stereo jack?
Which I reverted.
Inserting a jack plug causes a temporary short between the contacts, so if you do that you need to use switched power, and ALWAYS remember to only manipulate the jack when the radio is off or risk frying things.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

yep, now I remember. told you my short term memory is getting bad ;)
After reviewing all the trainer port configuration (JR, futaba......). I think what you proposed - Futaba with 6 pins may be the best way to go. all wires are separated.
now I am thinking just add a Futaba trainer port BUT keep the original trainer port as well. this way I can keep using trainer cable with mono jack and when power is needed I can use the Futaba port (just don't use both trainer port at the same time for trainer function ).
This button board with Futaba connector could be a really handy thing with just one plug operation. when flying multi, just plug it in. when flying other thing don't need the 6 button just unplug one cord and remove it. And I can use it to power my wifi booster. ;) while using the original JR trainer port for pan/tilt function from the goggle. ;)

question is where to get Futaba jack and receptacle? Found a lot of place selling Futaba cord, but no luck finding the replacement port.
Helle
Posts: 577
Joined: Sat Jul 21, 2012 7:08 am
Country: -

Re: Arduino-based mode-switch for APM

Post by Helle »

Hy,

you can do much more, not only for APM-Modes switch!

look at a German page
http://fpv-community.de/showthread.php? ... Mods/page4
http://fpv-community.de/showthread.php? ... Mods/page7

there are 6 APM-Modes and 7 Analog input with Sliders, Potis, 3-way-Switch, Joystick or Head tracking

its for an Arduino Nano V3
PCB, shematic and software you will find there in different layouts


input is 5V oder 7-12V
generates 8 Channals PPM 22,5ms, 300us, Positiv
Solder it at the Akkubay of Taranis with a short servocabel
Ground, Batterie, DSC-Jack

Helle
Attachments
CIMG1577.JPG
Arduino Nano APM Mode Schaltbild.jpg
2013-09-28_193628.jpg
Last edited by Helle on Fri Feb 28, 2014 7:00 am, edited 1 time in total.
sgofferj
Posts: 251
Joined: Tue Oct 09, 2012 5:11 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by sgofferj »

@Helle:
I think, we all have seen your product the first time you posted it. You don't have to repeat posting the links every 2 weeks!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Arduino-based mode-switch for APM

Post by jhsa »

Please guys, let's not start anything here, ok? ;)

He is not the only person posting links for products here.. Other people do it more often and no one complained.

I'm sure Helle just wanted to share some info.. at least I took it that way. I didn't even clicked on the links as the info is all here ;) :D

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Arduino-based mode-switch for APM

Post by kaos »

I think it is ok to do it. Like I have missed that post till now. These info are all over the place. I admit I don't read every post out here.
BUT, as a courtesy to the OP, may be starting a dedicated topic and post the link to the topic would be a better approach, and all related will be at the same place. When you read one thread/topic, it can lead you to all related and/or specific area.
sgofferj and not2fast's plan is a very simple straight forward for APM buttons, while Helle's would be an all out approach. Each is applicable to some people's need.
Helle
Posts: 577
Joined: Sat Jul 21, 2012 7:08 am
Country: -

Re: Arduino-based mode-switch for APM

Post by Helle »

Hy

@sgoffery,

Your APM mode is fine!
but someone need a Headtracker
the other a Joystick for the Camera
the third need some more swithes or Analog inputs for his ships or trucks

But all parts need the DSC input

So my intension is to take all together in one circut.
And I have no product to sell, its only a idea with a test PCB
And a simple software for the Arduino nanoV3 and it works fine.

Each can use the parts he need for himself
I use it as a PPM testgenerator with exakt fix and variable impulses

Helle
not2fast
Posts: 21
Joined: Fri Dec 21, 2012 4:22 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by not2fast »

Here's my latest version of my push button set up. It's been a lot of fun perfecting this board. Rev 6 now has MANUAL close to the left thumb. I found that having the MANUAL over the throttle stick was a problem because it's almost impossible to quit trying to control a plane and push the MANUAL button so we came up with this configuration. The MANUAL button has a red LED so your eye goes right to it in an emergency, no reading necessary. Sooo much better than the knob.
Attachments
103_0009.JPG
103_0015.JPG
not2fast
Posts: 21
Joined: Fri Dec 21, 2012 4:22 pm
Country: -

Re: Arduino-based mode-switch for APM

Post by not2fast »

In case anyone was wondering, I got the Futaba buddy cables from HK and all you need to do to make them work is switch the plugs on the buddy cable board inside the 9xr. I plugged the Futaba plug where the JR plug was and it works great. I did not re-install the JR plug because I don't plan to use a buddy cable on this radio. It might work, I can't say. In the Futaba buddy cable the wires go like this.
Black in the cord is 12v and goes to the RAW pin on the Arduino.
White to ground
Yellow to output pin 10
The other three wires are not used.
Have fun!

Post Reply

Return to “General RC Electronic Projects and Discussion”