Introduction: Arduino to MATLAB GUI - Live Data Acquisition (& Plotting) of RC Transmitter Stick Positions

About: I'm an aerospace research engineer with a B.S. in Aeronautical Engineering and an M.S. in Mechanical Engineering. I have a *tremendous* interest in Radio Control (RC) aircraft and have developed many skills i…

I have created a program, using an Arduino, to do live data acquisition and plotting directly into MATLAB. I think this is very useful, and can help out a lot of people wondering how to interface Arduino & MATLAB, so I am posting it here on Instructables for your benefit. The YouTube demo video is posted above, and the direct link to it is here.

I would also like to note that I am greatly indebted to many individuals online who have previously posted little snippets of info, or brief example codes, which have been so instrumental in helping me to get the Arduino talking to MATLAB. Though I have gone way beyond the examples I have seen, they were key in helping me know how to get started, especially in making Arduino & MATLAB communicate via serial. Thank you all!

If you like this article, please add it to your Favorites.

Before you continue, be sure you've watched my video above! It explains & shows this demo pretty well. Next, I'll briefly explain how you can download my code and get this to work yourself, assuming you have access to MATLAB of course.

Note: due to the fact that MATLAB is expensive & highly proprietary, I do plan on eventually porting this to a free programming environment such as FreeMat (a free, open-source MATLAB clone) or Processing (a Java "wrapper" originally meant for beginners just getting into coding), for all to use!

Step 1: Download the Software

Click Here to Download

(Optionally) donate, & download via the link just above, or by clicking here then choosing the appropriate download. Once you have downloaded the zip file, extract the files, and you will see an "Arduino" folder and a "MATLAB" folder. Follow the directions in the README, and upload the Arduino code to your Arduino. Note that the code is intended for use on Arduinos that use the ATmega 328 microcontroller.

Step 2: Buy an Arduino or Arduino Kit

You're going to need an Arduino based on the Atmel ATmega328 microcontroller for this project, as well as some jumper cables. For this project I recommend the Arduino Uno or Nano. My favorite kits are the Elegoo Arduino kits. They are sold for a great price on Amazon, so I recommend you choose from one of the kits in this Amazon search here for "Elegoo Arduino kit."

Step 3: Hook Up Your Radio-Control Transmitter Trainer Output Port (PPM Signal Out) to Your Arduino!

First, find out what the pinout is for your particular radio. You can find a nice description of trainer port pinouts here: http://www.mftech.de/buchsen_en.htm. You need to know where the PPM_out signal is, and where the Ground is.

For my setup, I am using the Futaba square trainer plug, which has pin 1, per the diagram above, as the PPM output (labeled "signal") and pin 2 as the ground (labeled "GND").

For a Spektrum or JR-brand radio, which uses the simple 3.5mm mono audio jack as the trainer port, the tip of the plug is the PPM out, and the base is Ground.

Note that on the Spektrum/JR radios, the PPM signal is only OUT if the Transmitter power switch is in the OFF position, and the trainer cord is plugged in. Otherwise, it is a PPM input. On the Futaba radios, however, the pin 1 always outputs the PPM signal.

For safety, to protect against accidentally touching the wrong pin to the wrong place, I recommend running the PPM signal THROUGH a 1k resistor and then into the Arduino D2 pin. The resistor will protect against mistakes (ex: accidentally touching the wire to a high voltage), while letting the PPM signal pass through freely.

This is what my pictures show above. I have the resistor in the breadboard next to the Arduino nano. In the photo of the jumper cables, I am simply showing the various jumpers I'm using to get a line long enough to easily reach the Arduino while still giving the transmitter plenty of slack to work with. Notice that the jumpers to the upper-right in the picture are the "cheaper" ones, and they have smaller diameter wires which fit very nicely into the square Futaba trainer jack, so I highly recommend you use those when actually plugging into the jack.

Step 4: Run the Code!

Turn on your transmitter, and run the MATLAB file called "MATLAB_to_Arduino_GUI_driver.m" Ensure you type in the correct COM port to your Arduino, then press the "Start" button in the GUI, and watch the magic!

Happy Arduino-datalogging-plotting-to-MATLAB!

Step 5: Don't Forget to Add This Article to Your Favorites!...and...Here Are a Few of My References

Don't forget to click the "Favorite" button above if you like this article. Thanks again!

Also, check out many other articles I've written on my website here: http://electricrcaircraftguy.blogspot.com/

Also, special thanks to the following sources, in addition to many others:

  1. http://robocv.blogspot.com/2012/01/serial-communic...
  2. http://robotgrrl.com/blog/2010/01/15/arduino-to-ma...
  3. http://allaboutee.com/2011/07/04/how-to-send-data-...

Sincerely,

Gabriel Staples

http://electricrcaircraftguy.blogspot.com/