Plotting

MegunoLink Pro can plot data sent from a microcontroller by parsing specially formatted messages. Currently two types of plots are supported:

  • Time plots, which are similar to a chart recorder, showing a number plotted against time. Time plots support auto-scrolling, which keeps the edge of the time axis set to the current time so that old values scroll off the left of the plot. All the data is retained though. You can zoom out, or pause the plot, and see the earlier data.
  • X-Y plots, which take two values from the microcontroller. One for the x (horizontal) axis and the other for the y (vertical) axis.
Plot samples

Data sent from an Arduino program is graphed on a time plot (left) and an x-y plot (right) using MegunoLink Pro

Both types of plots support multiple series, so you can show graphs of several different values at the same time. They both also support channels. Channels let you use several different plots in the same project, with different data going to each.

The easiest way to send data to the plots is using the TimePlot and XYPlot classes in our Arduino Library. If you are not using an Arduino compatible device, or prefer to send raw messages, the plotting message reference describes the message format expected by the MegunoLink Pro plot visualizers.

As well as sending plot data, both time and xy plot libraries support setting series styles, axis labels and plot titles.

Articles, and further documentation, may be found at:


29 comments on “Plotting
  1. Sam says:

    Hi Phil,

    I’m trying to plot accelerometer data coming from a Wii Nunchuck, similar to the problem above, but my data is separate and not in an array.

    I was wondering if you would be able to help? MegunoLink is currently only plotting the x data coming in.

    #include
    #include “nunchuck_funcs.h”

    int loop_cnt=0;

    byte accx,accy,accz,zbut,cbut;
    int ledPin = 13;
    unsigned long lastPlotTime = 0;

    void setup()
    {
    Serial.begin(9600);
    nunchuck_setpowerpins();
    nunchuck_init();
    }

    void loop()
    {
    if((millis()-lastPlotTime)>1000 ) { //plot every second
    lastPlotTime = millis();

    nunchuck_get_data();

    accx = nunchuck_accelx();
    accy = nunchuck_accely();
    accz = nunchuck_accelz();

    PlotAccs(accx, accy, accz);
    }
    }

    void PlotAccs(float x, float y, float z){
    Serial.print(“{TIMEPLOT:Acceleration|data|Arduino|T|”);
    Serial.print(x); Serial.print(“|”);
    Serial.print(y); Serial.print(“|”);
    Serial.print(z); Serial.println(“}”);
    }

    • Phil Rowe says:

      Hi Sam, I believe the way you have it there all three accelerometer values will be plotted together in the same series. ie every second it will plot the xvalue, yvalue, and zvalue in order in a single colour. You need separate plotting statements each with their own seriesname. My suggestion is to grab the MegunoLink library available from our downloads section and look at the plotting examples. It should take care of this stuff for you.

      Cheers
      Phil

  2. Max says:

    Hello Phil,

    Is there a way to reset the plot?

    I’m using an accelerometer for doing some simple crash test. But I need to make several measure and plot. I need to trigger the data logging and plot.

    The idea was to keep the board running, but to draw a different plot and store the min/max value for each test via Megunolink, but it seems that the plotter keeps on the same time line until the serial conneciton is reseted, right?

    • Phil Rowe says:

      Hi Max, I think you can use a clear command to reset the plot. {TIMEPLOT:channelName|clear} or {XYPLOT:channelName|clear}. I would use the interface panel to initiate a test, that would tell the arduino to reset the plot, and start sending out data to be logged and plotted. It could also be useful to use the XY plot as you can fix the xaxis to say 0 to 60s and send out time in seconds (from millis() timer). Time could reset to 0 for the start of each test run. Not sure how to store the min-max values, perhaps the arduino keeps track of these and reports them to the logger at the end of a run.

      Will this work?
      Phil

    • Max says:

      Hello Phil,

      I guess it will. I’ll give it a try and let you know.
      By the way, as you guess, I’m newbee in all of this, and I’m wondering where is it possible to find all the command that can be used with Meguno ?

    • Phil Rowe says:

      Hi Max, it’s not your fault. At this stage that command is not listed anywhere I believe. I’ll add a useful commands section to each documentation page asap.

      Cheers
      Phil

    • Max says:

      Hello,

      I’m back on this project after a while…
      The command {TIMEPLOT:G|clear} doesn’t seem to have any effect…
      what would be the exact syntax ?

      Thanx

      Max

    • Paul Martinsen says:

      Hi Max,

      You have the syntax correct to clear data from a channel named ‘G’. You can also use {TIMEPLOT|CLEAR} to clear plots on the default channel.

      Also, make sure you’re using the latest version of MegunoLink Pro; there was a bug that caused problems for clearing plots in earlier versions.

      Have fun,
      Paul

  3. Mohammadroid says:

    Excellent program, very useful and saves a lot of time..

    I want to buy it but it still misses essential feature which is SMOOTHING the plot.

    If you could do it you will help me not going to either Processing or MATLAB anymore..

    I appreciate your work

    • Phil Rowe says:

      Yeah good suggestion, I’ll add it to the feature request list. Basic filtering could be implemented in the hardware itself? Perhaps with a number of settings that can be adjusted from MegunoLink using the Interface Panel?

      Cheers
      Phil

    • Mohammadroid says:

      Mmmm filtering the data doesn’t smooth the plot !

      It just correct the data for you.

      Smoothing requires some statistics algorithms (i studied some in probability course) so that you could see the plot easily.

      These algorithms could be done by MATLAB in a simple line using a specific function.

      Anyway, you will get tired to implement them, but then i will buy the commercial version :-)

Leave a Reply