t r o n i x s t u f f

fun and learning with electronics

Improving Arduino to PC Interactions with MegunoLink

Introduction

Through a colleague I was introduced to a new piece of software for the Windows environment which comprises of useful tools that interact with an Arduino-style board (or other MCU with serial data). The software is called MegunoLink, from BlueLeafSoftware in New Zealand. Megunolink has many useful features, and we’ll run through them briefly in this article. They include:

  • Serial port monitoring – that doesn’t reset the MCU
  • The ability to capture serial port data to a text file
  • A tool to graph formatted data sent from the Arduino in real time
  • “George” the serial monkey! (see below)
  • Enable building Arduino projects using ATMEL AVRstudio
  • And Megunolink can also act as a graphical interface for AVRdude to upload compiled code to an Arduino

Installation was simple and straightforward. The installation is only ~1.5 megabytes and not taxing at all. We only have a Windows 7 64-bit machine, so haven’t tested this in emulation under MacOS or Linux. Before moving ahead, note that the software is free. However the developers do ask for a US$10 donation, and if you use the software more than once this is a very fair amount to pay for such a featured piece of software. Now for a look at each of the features.

Serial Data monitoring

As with the Serial Monitor in the Arduino IDE, you can monitor the data from the Arduino, and also send it back through the serial line. Just click the ‘Monitor’ tab and you’re set, for example:

However unlike the Arduino IDE, opening the monitor does not reset the Arduino. But if you do need to perform a reset, a button on the toolbar is provided as shown below:

Capturing Serial Data to a file

Very useful indeed, much quicker than dumping data to a microSD card and then bringing it back to the PC. Just click the ‘Log’ tab, specify a file location and name, then click ‘Enabled’, for example:

You can also append data to an existing text file. When creating the output format in your Arduino sketch, be mindful to have separators such as commas or colons – which make it much easier to delimit the data once imported into a spreadsheet or database application.

Plotting and Graphing Serial Data

Plotting data to a graph is very simple. You simply format the data you’d like to plot using Serial.write commands, and Megunolink takes care of the rest – just click the ‘Plotter’ tab and you’re off.  The data must be formatted as such:

{a, T, b}

Where ‘a’ is the name of the series. T tells MegunoLink to plot the actual real time, and b is the data as a number in string form. Here is a very simple example:

void setup()
{
 Serial.begin(9600);
}
int a=0;
float b,c;
void loop()
{
 for (int a=0; a<100; a++)
 {
 b=a/2;
 c=a*2;
 Serial.print("{a,T,"); 
 Serial.print(a);
 Serial.println("}");
 Serial.print("{b,T,");
 Serial.print(b);
 Serial.println("}"); 
 Serial.print("{c,T,");
 Serial.print(c);
 Serial.println("}"); 
 delay(100);
 }
 for (int a=100; a>0; --a)
 {
 b=a/2;
 c=a*2;
 Serial.print("{a,T,"); 
 Serial.print(a);
 Serial.println("}");
 Serial.print("{b,T,");
 Serial.print(b);
 Serial.println("}"); 
 Serial.print("{c,T,");
 Serial.print(c);
 Serial.println("}"); 
 delay(100);
 }
}

which resulted with:

Here is another example, it is the “SendSineCurve” sketch from the Arduino Graphing library:

You can always save the graph as an image in the usual formats as well as in .emf vector image file format.

“George” the Serial Monkey

This is a serial protocol simulator tool which is useful for testing the control of serial-based devices. You can setup George so that it listens for a particular pattern in the serial output from an Arduino – and then sends back a response of your choice to the Arduino. For example:

For a more detail explanation and detail tutorial on how to control George, see the MegunoLink website.

Arduino Development with AVR Studio 

Using MegunoLink you can develop Arduino projects with Atmel AVRStudio software. As some people find the Arduino IDE somewhat limiting, this option gives you access to the more programmer-friendly Atmel IDE, for example:

Although there is a small amount of tasks to make this possible, it is straightforward to do so, and an easy to follow tutorial has been provided at the MegunoLink website.

Upload compiled .HEX files to Arduino

For those using avrdude to upload compiled .hex files to an Ardiuno, you can also do this using the GUI MegunoLink interface. This is also used for uploading the compiled files generated in AVRStudio, for example:

As with all the other MegunoLink features – there is a relevant tutorial available on the website.

Conclusion

MegunoLink works well, is easy to use, and the price is right. It has to be the simplest tool available for plotting data from a microcontroller, or capturing it to a file without any extra hardware. So download it and give it a try, it won’t cost you anything and I’m sure you will find a use for it in the near future. And remember – if you’re using MegunoLink, please consider making a donation towards the development of further versions. Thanks to Freetronics for the use of their top-notch Arduino-compatible hardware.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

June 27, 2012 - Posted by | arduino, megunolink, software review | , , , , , , ,

9 Comments »

  1. Seems interesting the MegunoLink software, but I wish I cld be as optimistic as you. Installation was weird: afetr it had been done, I found an entry for the software in my programlist but that turned out to be empty. Anyway, a search found me theprogram on my disk, started it and though I have a university degree and looked at the manual, I could not figure it out. Uploading a hexfile? maybe when you get it entered somewhere. No doubt it is all my fault and ignorance, but I dont think I’ll be shelling out a 10 bucks donation soon

    Comment by Mikkel | June 29, 2012 | Reply

    • See here for .hex file uploads – http://www.blueleafsoftware.com/Resources/EmbeddedSand/Uploading_Programs_to_Arduino and have another look around their site, the instructions are quite good.

      Comment by John Boxall | June 30, 2012 | Reply

    • We’ve simplified uploading hex files. You can now set the source file directly in the upload window either using the Browse button, or by dropping a file from Windows Explorer. The project properties editor still works, and lets you set relative paths too.

      MegunoLink will automatically detect the new version & let you install it.

      Haven’t been able to duplicate the Start Menu short-cut problem though. Please get in contact if you are still having this problem.

      Comment by Paul | July 8, 2012 | Reply

  2. When you program your arduino via this program do you overwrite the bootloader on the chip required by the arduino IDE?

    Comment by David Liddell | July 11, 2012 | Reply

    • See Phil’s reply :)

      Comment by John Boxall | July 17, 2012 | Reply

    • The bootloader remains intact. This programs the Arduino using the same tools the standard Arduino tools use.

      Comment by Phil | July 18, 2012 | Reply

      • thank you for this reply Phil.

        Comment by David Liddell | July 18, 2012

  3. wow, this software is FREAKING AMAZING! it works flawlessly and it is such a time saver! the plotting and logging functionality is sometimes essential for a project and instead of messing with serial port programming, it’s served on a plate lol

    I’m so glad I found it, otherwise I would spend precious time writing matlab code just for a simple plot

    Comment by Steve | August 1, 2012 | Reply

  4. I am very impressed with the logging, I just stuck a MAX232 between the newSoftSerial Tx and Rx pins and the 9 pin din into my port1 serial port on the back of the PC, and away it went ( when I remembered the ground pin :-)

    Is there a way to have this running in the background of the PC, and updating a normal spreadsheet realtime?

    Comment by John Smith | August 12, 2012 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 3,841 other followers

%d bloggers like this: