1.Overview

Welcome to MegunoLink.

We’ve got everything you need to take your Arduino experience to a whole new level. Plot graphs from sensors or send data to tables or maps and get a new understanding of your measurements. Working on a radio project? Monitor the serial port of all your nodes to see what your network is doing. Build a user interface and use buttons to send serial commands to control your latest creation.

Download a free trial of MegunoLink, run the installer and let’s get started with an overview of MegunoLink.

A demo of MegunoLink Pro in action can be seen in the video below. You can download the example Arduino program used in this demo here.

Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

2.Getting Started

Get started with MegunoLink by downloading and running our installer program. You can download the installer here. Read through the guides below and visit our forum to join in the discussion.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

2.1.What is a Visualizer?

The Visualizer is the centerpiece of the MegunoLink interface. They are literally windows on your data. Whether it comes from a serial port, Ethernet UDP or XBee connection, MegunoLink’s visualizers decode messages and presents the data to you as a graph, table, map or as raw data.

Selection of MegunoLink visualizers

MegunoLink visualizers provide literal windows on your data. Here an interface panel (top-left), table (middle-left), monitor (bottom-left) and time-plot (right).

Creating Visualizers

There are three ways to open a new Visualizer; pick whichever one is most convenient to you. Create a new visualizer by selecting it from the:

  1. Start page that appears when you open MegunoLink
  2. Visualizer menu on the main toolbar
  3. Visualizer toolbox, normally docked to the right side of the MegunoLink window. Click the pin on the toolbox title bar and the toolbox will collapse to free up screen space. If you close the toolbox, you can get it back again by clicking the Visualizer button on the main toolbar
Create a new visualizer

Open a new visualizer using the Start page (left), Visualizer menu (center), or Visualizer toolbox (right).

Organizing Visualizers

Open as many visualizers as you like and organize them within the MegunoLink window by grabbing the visualizer tab title and dragging it. Visualizers can be docked next to each other, or on top of each other to create the layout that’s most convenient for your project. Visualizer tabs can be renamed to help you keep track of the information they display.

Visualizer Tools

Each visualizer has a toolbar with relevant tools. Some tools are common across most visualizers including the source selector and channel selector.

MegunoLink can open connections to many different devices at the same time. The source selector tool chooses which source each visualizer will use for the data it displays. Click the button to open/close the connection to a source and the arrow at the end of the button to choose the active source. Use the connection manager to configure and manage the available sources.

Many visualizers support channels. Channels are “virtual” connections to a single device that group common data together. They let a single Arduino send data to several different graphs, tables or message monitors withing MegunoLink.

The channel selector allows you to choose the channels a visualizer will include. By default, all channels are included. Select the channels you want to include using the channel selector.

Visualizer tools

The source selector (left) lets you choose which connection a visualizer uses as a data source. The channel selector (right) lets you select the channels to include from the source.

Sending data to Visualizers

Visualizers receive data from the serial stream by looking for messages in a specific format. For example, a time-plot will look for messages like {TIMEPLOT:Battery|data|Voltage|T|12.2}.

Our Arduino library provides tools to format and send these special messages for you. Refer to the documentation for each visualizer for more details.

Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

2.2.Arduino Integration

MegunoLink is a stand-alone program but it can work with the Arduino IDE in a couple of ways:

  • We have a standard Arduino library for sending data to MegunoLink graphs, tables, maps and interfaces. This saves you from building the messages yourself.
  • MegunoLink can hook the Arduino upload process.

On many devices, the Arduino IDE uses the same serial port for uploading new sketches that MegunoLink uses for monitoring data. Both programs can’t be using the serial port at the same time so this can cause a conflict.

Our upload-hook is triggered when the Arduino IDE uploads a program to your Arduino. MegunoLink releases the serial port so the upload can continue. When the upload completes, MegunoLink will reconnect to the serial port to monitor your data.

Installing Arduino Integration

Install Arduino Integration

Select Setup Arduino Integration from the Gear menu to install the upload-monitor and Arduino libraries

You can install and remove the integration features from the gear menu.

  1. Select Setup Arduino Integration from the gear menu to get started. Windows may prompt you for permission. MegunoLink has to write files into the Arduino folder to install the integration features so you will need to click the Yes button to continue.
  2. Browse to the folder where you installed the Arduino IDE. This folder contains Arduino.exe. MegunoLink will guess where the Arduino IDE is installed if you’re run it before.
  3. Select the Install option for the MegunoLink library and the Upload Monitor.
  4. Click Update Installation.
Setup Arduino Integration

Install our Arduino libraries and Upload Monitor for integration between MegunoLink and the Arduino IDE

You can remove the Arduino integration features through the same process. Select the Remove action for the component you want to remove, then click Update Installation. Please let us know about any problems you run into so we can fix them for everyone.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

2.3.Making a Serial Connection

The first step to seeing serial data in MegunoLink is making a serial connection. The most common connection is a serial port over a USB cable. This is the connection used with the Arduino Serial library for commands such as Serial.println("Hello").

The Serial Connection Manager

MegunoLink can receive data from many serial ports, Ethernet UDP ports and XBee devices. The Connection Manager is used to manage the active connections.

Open a Connection Manager by selecting it from the visualizer tool, Visualizers docker, or start page. By default, you will see a single serial connection. You can change the port and baud rate of the connection. Make sure that the baud rate selected matches the value set when your Arduino program calls Serial.begin(9600). The most common value is 9,600 baud.

Serial Connection Manager

Make a serial connection to your Arduino with the Connection Manager visualizer

Connect to the port by clicking the Connect button.

Each serial connection has a name: Arduino Uno, in the screenshot above. It is especially useful to help you remember what is connected to each port if you have many serial devices connected. If you were working on a wireless project, for example, you could have one connection to the transmitter and one to the receiver. To add additional connections, click on the Add Connection button on the connection manager’s toolbar.

Check out the main documentation page for more information about the Connection Manger, including making connections to Ethernet/UDP and XBee devices.

The first step to seeing serial data in MegunoLink is making a serial connection. The most common connection is a serial port over a USB cable. This is the connection used with the Arduino Serial library for commands such as Serial.println("Hello").

Connection Manager

Open a Connection Manager using the Visualizer menu. The connection manager lets you edit serial connection properties.

Connecting a Visualizer to a Serial Source

Visualizers — such as monitors, plots and tables — take data received by a serial connection and present it in different forms. The simplest visualizer is a Monitor, which shows the raw data received by MegunoLink.

Open a Monitor visualizer using the menu on the main toolbar, the start page, or the Visualizers window docked to the right side of the MegunoLink window.

Select the connection used by the Monitor, or any visualizer, by clicking on the arrow at the end of the Connection Selector on the toolbar of any visualizer. Select the connection you want from the menu. You can also connect and disconnect from the selected port by clicking on the Connection Selector button.

Each serial connection can be used by any of the other visualizers. You don’t need to create a separate connection for each visualizer. This lets you quickly change the physical COM port a connection uses without updating each visualizer separately.

Select a Serial Connection

Select the connection used by a visualizer with the Connection Selector drop down menu

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

2.4.Plotting Data

MegunoLink gets data for plotting from special commands sent by your Arduino. A typical command looks like this: {TIMEPLOT:Battery|data|Voltage|T|12.2}.

Using these special commands means MegunoLink can easily separate the different kind of data you want to send it.

You don’t have to remember the special commands though. We’ve made a library to send them.

An Arduino Sketch to Plot Data

Here’s an Arduino sketch to read a sensor value and send it to MegunoLink for plotting. In this example, the sensor is attached to analogue port 0.

To build this sketch you’ll need to install the MegunoLink library and the Arduino IDE (or the development environment for whatever device you are using).

The first line of the sketch loads in the MegunoLink library, which contains support for easily sending data to MegunoLink.

Next up, we create a TimePlot variable named MyPlot. This represents a plot in MegunoLink. When you send data to this variable, it will take care of sending the right information down the serial link to MegunoLink. Check out the reference material on plotting for sending data to different plots.

Most of the rest of the sketch is standard Arduino code to initialize the serial port and read data from an analogue sensor.

The next interesting bit is on line 14, where we use the TimePlot variable.

The SendData function sends the value measured by the analogRead function (SensorValue) to MegunoLink. It uses a series name of "My Sensor".

MegunoLink can plot data from many different measurements on one graph. Each one will get drawn with a different colour and name. These are called series. So you could plot battery voltage, temperature and humidity all on one graph.

Plotting the data in MegunoLink

When you build and run the analogue plot sketch it will start spitting out serial messages like this:

To see this data plotted in MegunoLink, all you need to do is open a Time Plot visualizer and attach it to the serial port your Arduino is connected to:

  1. To open a time plot, select Time Plot from the visualizers’ menu on the toolbar, the start page or visualizer dock.
  2. Select the connection you want to use from the source selector. If you don’t have a connection yet, choose Edit sources… and setup a new source with the Connection Manager.
Get ready for plotting data

Select Time Plot from the visualizers’ menu on the main toolbar, then the connection your Arduino is using to plot data with MegunoLink.

Plotting data with MegunoLink

The MegunoLink Time Plot visualizer plotting data received from an Arduino

In the plot visualizer, you can change axis labels, the chart title and edit the colours and styles used by each series. For more information on plotting and serial communication check out:

  • Plotting Reference: plotting multiple series, changing plot properties, sending plot properties from the Arduino, exporting a graph, exporting graph data
  • Connection Manager: connecting to multiple devices, using UDP communication with MegunoLink, preventing reset when connecting to your Arduino sketch.
  • Reporting: save graphs to files periodically
Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

2.5.Process Serial Commands with an Arduino

Our command handler is one of the easiest ways to receive and process serial commands in your Arduino sketch. The command handler is an Arduino library, bundled with MegunoLink, to simplify receiving and decoding serial commands. It supports setting the value of variables in your program and calling functions when a command is received.

To use the command handler, you need to:

  1. install the MegunoLink Arduino library
  2. #include "CommandHandler.h"

You can send the commands with any serial tool including MegunoLink. Use an MegunoLink interface panel to build a simple panel to send settings and commands to your Arduino program.

Blink-Interface

A simple user interface created with MegunoLink Pro’s interface panel for a Blink program.

Arduino Serial Processing Example

Here is an example sketch that uses the command handler library to control a blinking LED. The sketch accepts these commands to change the amount of time the LED spends on and off, and to print the current settings:

  • !OnTime 40\r\n Sets the time the LED remains on to 40 ms
  • !OffTime 100\r\n Sets the time the LED remains off to 100 ms
  • !ListAll\r\n Lists the current setting of all parameters

Example Walk-through

The first line imports definition for the command handler form the MegunoLink Arduino library. And the next line creates a command handler (SerialCommandHandler) that will look after receiving serial data and figuring out what to do with it.

You need to put the <> in when making a CommandHandler because it is a template. By default the command processor will handle up to 10 commands and 10 variables. The template takes extra parameters if you need to expand (or reduce) this. See the command handler documentation for more details.

Next, define variables to keep track of which pin the LED is attached to and how long the LED should remain on and off.

The delay function used in the original blink sketch stops the program for a short time. Using delay blocks the program getting in the way of processing serial data. So in the new blink program, a variable (LastBlink) keeps track of when we last turned the LED on. This time gets used later on to decide if the LED should still be on, or it should be turned off. Check out our tips for Arduino programs for more on this trick.

The commands and variables the SerialCommandHandler will process are setup in the Arduino setup() function. The AddVariable function registers variables, while the AddCommand registers functions that will be called when a command is received. Calling SetDefaultHandler registers a function that will be called if an unknown command is received. This is really useful in debugging!

Each call to AddVariable will register a variable with the command handler that can be set and printed using a serial command. The variable is set using a command like !OnTime 10\r\n and printed using !OffTime ?\r\n.

If you are entering the command using the monitor visualizer, the carriage return and line feed (\r\n) characters are added automatically, provided the +CR and +LF boxes are checked. If you are building an interface panel to send the commands, you’ll need to include them. Leaving off the carriage return is the most common reason for commands not being processed by the Arduino.

Each call to AddCommand will register a function with the command handler. This function will get called whenever the command is received. So here, the Cmd_ListAll function will get called whenever you send the !ListAll\r\n command from MegunoLink. This function is going to print out the values of all the variables, and is defined below.

Putting F("…") around each variable and command name — the first parameter to the AddVariable and AddCommand functions — stores the name in program memory. This helps save RAM, which is in short supply on most Arduinos. Check out our tips for Arduino programs for more on this trick.

Adding SerialCommandHandler.Process() handles the serial commands. That one line is all you need in the sketch loop for the command handler library to receive, decode and dispatch serial commands!

This is the function that will be called when the !ListAll\r\n command, registered on line 20, is received. You must include CommandParameter &parameters as a parameter, even if you don’t use it in the function. For more complex commands, you can use parameters to retrieve parameters that were sent with the command. Check out the command handler documentation for more details.

More Information

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

2.6.Build an Arduino Interface

Sometimes you need an interface for your Arduino project but you don’t want to add a separate screen and buttons to your project.

MegunoLink’s Interface Panel visualizer lets you build a simple interface and send commands to your Arduino sketch via the serial port. The interface can include a variety of controls including buttons, text boxes, number controls, graphs, etc.

Let’s walk through an example. We all start with the classic Arduino blink sketch:

The time delays are fixed in this program. If you want to change settings, you need to rebuild and upload a new sketch. That’s not very convenient.

For more flexibility, you could build an Interface Panel in MegunoLink to control the amount of time the LED is on and off like this:

Arduino Interface

A simple user interface created with MegunoLink Pro’s Interface Panel for a Blink program. It sends serial commands like !SetInterval 1200 to the Arduino to modify the time the LED is on (duration) and off (interval) when the control values are changed. Or the Set All button is clicked.

Command Format

You can send commands in any format you like with MegunoLink, but we recommend something like: !SetDuration 40\r\n.

Placing a special character, such as ! at the start of the command makes it easy to find when other serial messages are being exchanged.

Using a long command name, such as Duration or Interval, makes it easier to remember what the commands are for later.

Using a carriage return (\r) and line-feed (\n) characters to mark the end of the command will make sure they are nicely formatted in any serial monitoring tool you use for looking at raw serial messages.

To process the serial commands, you can roll your own command handler or use serial command handler that we built!

Building the Interface

While you can send commands to your Arduino from the Arduino IDE or MegunoLink serial monitor, that quickly becomes tedious if you have a lot of commands or parameters to remember. MegunoLink’s Interface Panel lets you attach the commands to buttons and other controls for a more convenient interface.

Layout

Get started by opening a new Interface Panel visualizer by selecting Interface Panel from the visualizer menu on the main toolbar, then click the Designer button on the interface panel toolbar to open the visual designer.

Create a new interface panel

Create a new interface panel by selecting Interface Panel from the main toolbar, then open the visualizer designer by clicking the Designer button on the interface panel toolbar

Build up the user interface by dragging controls from the Toolbox onto the design surface. Use Label controls for headings and labeling controls. Button controls will send a message to the Arduino when they are clicked. TextBox and NumericUpDown controls are good for getting user input for settings and parameters.

Build a user interface

Drag controls from the Toolbox onto the design surface to build up your user interface in the Interface Designer.

Setting Properties

Each control has a variety of properties that can be set in the property editor, which is normally docked on the right-side of the Interface Designer. The most useful properties are:

  • Name sets the name of the control. These names are used to include control values when sending messages. Each control must have a different name.
  • Text sets the text displayed on Label and Button controls. Sets the default text for TextBox controls
  • Value, Minimum and Maximum set the default value and range of allowed values for NumericUpDown controls
  • OnClickSend sets the message send to your Arduino when a button is clicked.

Sending Commands

Each button has an OnClickSend property to set the message that should be sent whenever a button is clicked. The message can include special characters such as tabs (\t), carriage returns (\r) and new-line (\n) characters.

Messages can also include simple expressions and use values from other controls on the form. The easiest way to build expressions with control values is to use the Command Editor. To open the command editor, click the value for the OnClickSend property, then click the ellipsis button which appears.

Command Editor

Open the Command Editor to include values from other controls.

Use the component selector button to add expressions for other controls on the form. Expressions are enclosed in square brackets in the message. The expression will be replaced by its value when the button is clicked. For example: !OnTime [numOnTime.Value]\r\n will include the current value of the numOnTime control when the message is sent to the Arduino. Check out the Interface Panelreference for more information on messages and expressions.

Applying the Design

Click the Apply button in the Interface Designer to apply changes to the Interface Panel visualizer. When the serial connection attached to the visualizer is connected, you can click buttons and change controls to send messages to your Arduino.

Once the design has been applied, you can close the designer. Click the Designer button on the Interface Panel visualizer’s toolbar to edit your design.

Apply interface design

Click the Apply button in the Interface Designer to apply changes to your design to the Interface Panel visualizer.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

3.Arduino Upload Monitor

Most Arduino’s are programmed and communicate with the same serial port. That can cause conflicts if you want to upload a new program while MegunoLink is, say, busy plotting data it is receiving from the same port. MegunoLink’s Arduino upload monitor helps share that port between MegunoLink and the Arduino IDE.

When the upload monitor is installed, MegunoLink will automatically disconnect from the serial port when it detects the Arduino IDE is trying to upload a new program. When programming is complete, MegunoLink will automatically reconnect so you don’t miss any serial communications.

Check out a demo in this short video:

Installing the Arduino Upload Monitor

The Arduino upload monitor is included with MegunoLink but not installed by default. To install the upload monitor, choose Setup Arduino Integration from the gear menu.

Install Arduino Upload Monitor through the gear menu

Select Setup Arduino Integration from the Gear menu to install the upload-monitor and Arduino libraries

Select the folder where you installed the Arduino IDE and the Install action in the Arduino Upload Monitor group. Press the Update Installation button to continue.

Setup Arduino Upload Monitor

Install our Arduino libraries and Upload Monitor for integration between MegunoLink and the Arduino IDE

You can also install our MegunoLink Arduino library using this dialog box. Check out the Arduino Integration article for more information.

Using the Upload Monitor

There’s nothing special you need to do once the upload monitor is installed. MegunoLink will automatically detect when the Arduino IDE starts uploading a program using a port that it has open. MegunoLink will quickly close the serial port so the uploader can use it. When the upload is finished, MegunoLink will reconnect to continue receiving serial data.

MegunoLink will only release the port needed for programming. So other devices you have connected will not be interrupted.

How does the Arduino Upload Monitor work?

The secret is AVRDude. AVRDude is the program used by the Arduino IDE whenever it wants to upload a new program to your Arduino hardware. AVRDude needs to know which serial port to use, so that information is supplied by the Arduino IDE as a command-line parameter.

When you installed the MegunoLink upload monitor, we renamed AVRDude and dropped the monitor program in its place.

Since nobody told the Arduino IDE, it still calls AVRDude to do the update. But now, it runs the monitor program which quickly notifies MegunoLink that the port is needed and passes the upload command onto the real AVRDude. When the upload has finished, the monitor notifies MegunoLink that it is safe to use the port again and communication continues.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

4.Connection Manager

connection_manager_new1
MegunoLink Pro’s Connection Manager visualiser allows you to manage UDP, COM, XBee Series 2, and text file serial data connections. Simply hit the add connection button to add a new connection, fill out the details giving the connection a name and specifying its options.

Once a connection is specified you can then point each visualiser to it using the selector at the top left of each visualisers tab. This means that when the connection is active this visualiser will be listening for commands relevant to it.

COM Serial Connection Settings

connection_manager_advanced_reducedIn addition to the standard settings which are compatible with the majority of platforms including Arduino, we also offer additional advanced settings. These include specifying the number of data bits, various handshaking schemes, and the specification of parity and stop bits.

The final setting is very useful with the Arduino platform. Several board including the Mega and Uno reset whenever you connect to their COM ports. By disabling the DTR signal you can prevent this from happening. This is great when you don’t want your system to reset every time the connection is made. The only issue to be aware of is that some boards such as the Leonardo and Esplora require the DTR signal for correct operation.

 

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

5.Interface Panel

Using a variety of controls (including buttons, text boxes and number boxes), the Interface Panel visualiser lets you build a custom user interface to control an Arduino, or other embedded, program. The Interface Panel will send user-defined serial messages when buttons are clicked, or control values are changed. And, by adding a MLPUIMessageProcessor to the design, the Arduino program can send messages to update controls on the panel.

Visualizer

Example interface panel - The popup menu in the Interface Panel visualizer can be used to show or clear error messages.

The Interface Panel visualizer is a MegunoLink Pro window that displays a custom user interface. The interface can be modified using a designer (see below). Use the port selector to choose the serial source the panel is linked to. Any messages sent by controls on the panel will use this serial source.

The status bar, at the bottom of the visualizer window, displays the last error message. Use the popup menu in the status bar to review previous errors, or clear the message history.

Designer

Open the Interface Panel designer

Click the designer button on the Interface Panel toolbar to open the designer window.

The Designer is used to add controls and components to an interface, layout the panel and set properties for controls and components. Open the designer window by clicking on its icon in the Interface Panel visualizer (right).

Designer Window

There are 4 main areas in the Interface Designer window:

  1. The design surface where controls are placed. Controls are set out as they will appear in the Interface Panel visualizer.
  2. The toolbox: a collection of controls, containers and components that can be placed on, or used by, the interface panel. Double-click tools, or drag them from the toolbox onto the design surface to place on the interface panel
  3. The properties window, which lists the properties available for the selected control. Colours, fonts, images, size and location are all set using the properties window
  4. The component tray, a region where components used by the interface panel that don’t have a user interface (such as the Message Library and Message Processor) live

When you are happy with a design, click the Apply button to load it into the Interface Panel visualizer. You can easily modify a design by clicking on the designer button in the visualizer toolbar and making changes in the design window.

Screen-shot of the interface panel designer

The interface designer provides a collection of tools that can be placed on the panel design surface where they can be configured and applied to the Interface Panel visualizer.

Names

All controls and components have names. These names are used to refer to controls when sending messages from MegunoLink Pro or, for some controls, for setting property values from a serial device. Names can include numbers, letters and the underscore (_) character. Names can’t include spaces.

Change control names using the (name) property in the property editor, or with the smart-tag attached to most controls.

Setting control names

Set control names with the smart-tag or property browser. Names can use a-z, A-Z, 0-9 or _. No spaces!

Editing Serial Messages

Show the serial message editor

Click the ellipsis (…) button  to display the message editor.

Many controls can send messages to a serial device when an event occurs — such as clicking a button or changing a control value. The property name depends on the type of message to send: a button has the OnClickSend property, while a text box has the OnValueChangedSend property. The available events are described below.

In each case, the message sent is set using the property editor, or in the smart tag attached to most controls. You can type the message directly into the property text control, or use the Message Editor. Click the ellipsis (…) button to display the Message Editor.

Messages can include plain text, control values and expressions. Control values and expressions, which must be enclosed in square brackets, will be evaluated when the message is sent. This lets you use controls to send settings to your serial device. Available control properties, and common expressions, are available on the variable popup menu. Use the Test to see the message that will be sent (using current control values). The test message can be displayed as plain characters (ASCII) or hexadecimal format.

Message Editor Window

Enter the command to be sent on a control event using the Message Editor window.

Sending Serial Messages

Many Controls and components on the MegunoLink Pro Interface Panel can send messages to a serial device, such as the Arduino, when an event — such as clicking a button, or selecting an item from a list-box — occurs. Messages can contain text, LEDOn for example, or values taken from controls on the interface panel: Setpoint [numSetPoint.Value]. Messages can also contain simple expressions. For example, if you multiply a temperature set-point by 10 to increase precision but still use integer variables, the scaling can be included in the message sent by MegunoLink Pro: SetTemperatureSP [numTemperature.Value * 10]. Our Serial Command Handler in the MegunoLink Pro Arduino library is useful for processing serial messages on the Arduino side.

The message sent when an event is triggered on a control can be a mix of text, escape codes, expressions and control values. Control values and expressions must be surrounded by square brackets (‘[‘ and ‘]’). Escape codes start with a ” character and include ‘n’, ‘r’ and ‘t’.

Examples

  • You clicked me!n: Sends the text You clicked me!, followed by a new line character
  • Setpoint=[SetPoint.Value]: sends the text Setpoint= followed by the current value of the SetPoint control
  • Setpoint=[SetPoint.Value*100]: sends the text Setpoint= followed by the current value of the SetPoint control multiplied by 100
  • Setpoint=[Tools.ToInt(SetPoint.Value).ToString(‘X4’)]: sends the text Setpoint= followed by the current value of the SetPoint control as a 4 character hexadecimal value

Events

The events that trigger messages depend on the control or component and are listed in the table below. The text set for each property will be sent when the event occurs. For example, if the OnClickSend property of a button control is set to Hello World then the text Hello World will be sent to the serial device each time the button is clicked.

ControlPropertyAction
ButtonOnClickSendThe button is clicked
Numeric up/downOnValueChangedSendArrows are used to change the value, or enter is pressed after typing a new into the box or the control loses focus
Text boxOnTextChangedSendThe text in the control is changed
Value listOnSelectionChangedSendA new item is selected from the list
Check boxOnCheckChangedSendThe box is checked or unchecked
Radio buttonOnCheckChangedSendThe radio button is checked or unchecked
Track bar with indicatorValueChangedCommandNameThe slider or numeric control value is changed
TimerOnTickSendThe selected interval has passed

Referencing Control Properties

Control and component properties or methods can be referenced in messages using square brackets. For example [MyTextBox.Text] sends the current content of a text-box named MyTextBox while MyTextBox.FixedTextLength(10) sends exactly 10 characters from MyTextBox; if the text-control contains less than 10 characters MegunoLink Pro pads the messages with enough spaces to ensure exactly 10 characters are sent.

The control and component properties available are listed in the table below:

ControlPropertyTypeRead OnlyDescription
Text boxTextStringnThe text displayed in the control
TextLengthIntegeryThe length of text displayed in the control
NameStringyThe name of the control
Numeric up/downValueDecimalnThe current value displayed in the control
MinimumDecimalyThe minimum value allowed
MaximumDecimalyThe maximum value
NameStringyThe name of the control
Value listSelectedIndexIntegernThe index of the selected item in the list. First item is index 0. -1 if no items selected.
SelectedNameStringyThe name associated with the selected item. Only supported for single selection lists.
ValueUnsigned IntegernThe value associated with the selected item. When multiple items are selected, returns the values of each selected item or'ed together.
NameStringyThe name of the control
CheckboxCheckedBooleannThe current check state of the control
NameStringyThe name of the control
RadiobuttonCheckedBooleannThe current check state
NameStringyThe name of the control
Trackbar with IndicatorValueIntegernThe current value shown in the control
MinimumIntegeryThe minimum value
MaximumIntegeryThe maximum value
NameStringyThe name of the control
Progress barValueIntegernThe current value shown by the control
MinimumIntegeryThe minimum value
MaximumIntegeryThe maximum value
NameStringyThe name of the control
PictureBoxVisibleBooleannWhen false, the control is hidden. If true the picture box is visible.

The methods available on Interface Panel controls and components are summarized in the table below:

Control/ComponentMethodTypeDescription
Text boxFixedTextLength(…)StringReturns the text from the control with a fixed width.
Message libraryGet(MessageName)StringReturns the named message
GetData(MessageName)Byte[]Returns the named message

Expressions

Messages can use simple expressions by including them in square brackets. For example, [5*3+2] sends the text 17.

Expressions are most useful when combined with control values. It is common to store scaled values in a microcontroller to avoid floating point arithmetic. For example, a set-point temperature might be entered to 1 decimal place, 14.3 for example, using a numeric up/down control named SetPoint but stored as the integer 143 in an Arduino program. The scaling could be applied automatically by MegunoLink Pro when the message was sent using: [SetPoint.Value * 10]

The operations available in expressions are: +, -, *, /, !, <, >, <=, >=, ==, !=, &&, ||, ?:

Tools

The Tools object makes a number of useful functions are available in expressions including:

  • ToInt(Decimal Value): Converts a decimal value, from a numeric up/down control for example, to an integer. This is useful for formatting numbers in hexadecimal as decimal values can’t be converted directly. Instead use Tools.ToInt(Number.Value).ToString(X) .
  • Choose(Integer Index, String s0, String s1, …, String s9): Select a string based on a number. For example: Tools.Choose(3, A, B, C, D) would return C. Up to 10 strings can be used with the Choose function.

Embedded Plots

Starting with the Time Plot, we are starting to add support to embed other visualizers within the Interface Panel. This means you can place a Time Plot control in the designer and have a plot show on your panel. Embedded plots don’t need the message processor (see below). They pull data from the serial stream in the same way plots in separate windows, so you can use the MegunoLink Library or raw serial commands to add data to embedded plots.

Updating Controls from a Serial Device

Control values on an Interface Panel can be changed by sending specially formatted commands from the embedded device. These message are processed by a MLPUIMessageProcessor and be used to update or request control values. For more information see the:

  • Arduino Interface Panel library documentation, which describes an Arduino library to send messages that update Interface Panel controls
  • Message Processor component documentation, which describes the MegunoLink Pro interface panel component and the messages you can send to it.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

5.1.How to Update Interface Panel Controls from your Arduino

Update interface panel controls by sending serial commands from the Arduino to MegunoLink Pro. The article How to Quickly Make a User Interface to Control Your Arduino Program talks about making a new interface panel to send commands to your Arduino. In this article we look at how your Arduino program can send commands to MegunoLink to update text, numbers, progress bars and other controls on an Interface Panel.

Install the library to update interface panel controls

Install the MegunoLink Pro library into your Arduino libraries folder. You can download the library from GitHub.

To make it easier to send the right commands to MegunoLink Pro, we’ve built an Arduino library to control the MegunoLink Interface Panel. Download the MegunoLink Pro Arduino Library from GitHub and copy it into a sub-directory of the libraries folder in your Arduno installation. The Arduino website has more information on Installing Arduino Libraries. To start using the MegunoLink Pro library, you’ll need to include it in your Arduino project. To include the library, add #include "MegunoLink.h" at the top of your Arduino program.

Sending Values to Update Interface Panel controls using the library

The InterfacePanel class exposes functions for sending data to MegunoLink Pro. To use these functions, first declare an InterfacePanel variable at the start of your program. The variable needs one parameter: the channel used by the message processor on your interface panel, more on that below:

The InterfacePanel variable has a bunch of functions that can be used to set controls:

  • SetText(ControlName, Value): sets the text displayed in a text box
  • SetProgress(ControlName, Value): sets the value shown by a progress bar
  • SetNumber(ControlName, Value): sets the value shown by numeric up/down and slider controls
  • SetCheck(ControlName, Value): checks or unchecks a check-box control

Each function takes two parameters:

  • ControlName: Identifies the name of the control on the interface panel. Find the control name using the properties browser in the interface designer. It is labeled (name).
  • Value: The new control value to set. It is a string for SetText, an integer for SetProgress and SetNumber, and a boolean (true/false) value for SetCheck

Preparing an Interface Panel to Receive Data

For a Interface Panel to handler serial commands you need to add a MLPUIMessageProcessor component to your Interface Panel. The MLPUIMessageProcessor component looks for the text in the serial message that is used to set control values. You can find it in the Communications section of the Interface Designer toolbox. After placing the MLPUIMessageProcessor, set the channel name. This is the same channel name that is passed to the InterfacePanel::Set* functions. The message processor only decodes messages with matching channel names. This lets you have several different interface panels in one MegunoLink Pro project without them interfering with each other. Set the channel name on the MLPUIMessageProcessor properties in the Interface Designer.

A UI processor is used to update interface panel controls

To set control values from an Arduino program, add a MLPUIMessageProcessor component to your interface design. Then set the channel the Arduino program will use when communicating with the Interface Panel.

Pulling it Together

The data receiver demo is a MegunoLink Pro project and an Arduino program which demonstrates setting Interface Panel controls from an Arduino program. You can download a zip file with the MegunoLink Pro Project and Arduino Program.

Update interface panel text, number and progress controls

The Arduino program will set values of the text box (2), number (3) and progress bar (4) controls.

The Interface Panel for the demo receiver project has four controls and one component:

  1. A label control for the title
  2. A text box for status updates; name=’Status’
  3. A numeric control showing the current value; name=’Current’
  4. A progress bar control showing progress; name=’Progress’
  5. A MLPUIMessageProcessor component to decode messages sent by the Arduino; channel = ‘Test’

The Arduino program sets the values shown in the text box, numeric and progress bar controls once per second as part of its main loop:

Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

6.Logging Data

Log to File

Save serial data to a log fileUse the log to file visualizer to save all data received from a serial connection to a text file. MegunoLink automatically flushes the file whenever you switch to a new window so if you have the log file open in your favorite editor you can immediately see the latest changes (if you don’t have a favorite editor yet, check out PSPAD).

Using a Log File

Open a Log to File visualiser, select a connection that you have set up in the Connection Manager, choose a file and enable logging using the Enable button on the visualizer’s toolbar. Any data being sent to your computer on that connection will be added to the file as it arrives. The Enable button will flash briefly whenever new data is written.

You can erase the current log file to start a new one by clicking the Clear button on the toolbar.

To time-stamp each line that is written to the log file, select one of the options from the time-stamp menu on the visualizer’s toolbar.

Add the time or date to your log file

Select an option from the time-stamp drop-down to add the current time and/or date to each line of data written to the log file.

Message Logger

message_loggerThe message logger picks out specially formatted messages from the serial data and writes them to a log file.

By using a message logger, your Arduino program can select which data should be written to the log file. You’ll get a cleaner log containing only the data you need. It won’t get cluttered by other messages like commands for plotting data.

Using the Message Logger

Open a Message Logger visualizer and choose a file. the Message Logger supports MegunoLink’s channel tags. If you want to log only a single channel of messages then choose the channel before enabling the logger.

Enable the logger using the button circled in the screenshot.

To send data, for example Hello World! to the message logger, use a command like Serial.println("{Message|data|Hello World!}");

If you want to send the message to a specific channel use: {MESSAGE:Secret|data|Boo!}

Arduino Example

This Arduino function allows you to send time and temperature separated by a comma through a specified message channel. This can then be logged and easily displayed in software like Microsoft Excel, FreeMat or MATLAB.

Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

7.Mapping

MegunoLink Pro’s mapping visualiser lets you collect location data from GPS sensors and report it on a map giving a visual representation of the reported location. We like to use this GPS library along with a GPS receiver such as this one from Sparkfun.

mapping screenshot

Usage

Coordinates are sent from your embedded device using a text based serial protocol. MegunoLink Pro’s Mapping visualiser will interpret the data and display the location on a map. Mapping serial messages should follow the format below. Replace DEVICENAME with a unique identifier for the device gathering GPS data, replace LATITUDE and LONGITUDE with the coordinates you want show on the map. The command beginning and end markers are the braces, { and }.

{MAP|SET|DEVICENAME|LATITUDE|LONGITUDE}

Example Arduino Code

This example shows calls to two functions given below. This allows an Arduino to send coordinates to MegunoLink Pro by specifying the coordinates as either a string or alternatively as floats.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

8.Monitoring Data

Monitor Visualizer

Like the Arduino serial monitor, MegunoLink’s Monitor visualizer shows you all the data sent by your Arduino and send commands to your Arduino. Data that’s received will be drawn in black; messages you send will be drawn in orange.

Like most of MegunoLink’s visualizers, select the connection you want to monitor using the connection drop-down on the visualizer’s toolbar.

Select text and copy it using the drop-down menu on the visualizer toolbar, or save directly to a text file.

Copy text when monitoring data

Copy some or all of the text in the monitor

If you turn on auto-scroll (), the serial-monitor will scroll to show new text at the bottom of the window as it arrives. You can also double-click in the text view to turn on auto-scrolling.

MegunoLink keeps track of the time that it receives each line of text. Toggle the time on and off using the Show Line Time and Show Line Date buttons on the visualizer’s toolbar. Click the clear button to discard the current buffer.

serial-monitor time stamp

Use the show-date and/or show-time buttons to display the time stamp for each line in the serial monitor window

Check out our Getting Started with Arduino Serial Monitoring article for step-by-step instructions on setting up connections for serial monitoring.

Extra Tips

  • There are a number of escape codes you can use including \n (newline), \r (carriage return), \t (tab), \\ (slash) and \xnn (send hex value, n=digit)
  • Carriage returns and new line characters, typically non-printable, are shown in MegunoLink’s monitor as left pointing and down pointing arrows, respectively.
  • Other non-printable characters show up as a diamond symbol.
  • The down facing arrow (autoscroll) on the toolbar toggles autoscroll. This prevents automatic scrolling as new data arrives.

Message Monitor Visualizer

The Message Monitor allows you to separate messages from all the other data that is coming across the connection to the micro. These messages can also be tagged to further group and filter from other messages. For example you could specify a channel as ‘Debug’ where only debug messages will be displayed.

Like the standard monitor, the text box at the bottom allows you to send manually typed messages, in this case, ‘HelloWorld!’.

The Message Monitor has one final trick up its sleeve, text to speech. Simply enable it using the speech bubble icon and each message received will be read aloud.

Usage

Send a serial string in either of these formats to your computer:
{MESSAGE|data|Hello World!}
{MESSAGE:Secret|data|Boo!}
{MESSAGE:Secret|clear}

An example Arduino code function is shown for sending Messages to MegunoLink Pro (pass an empty string (“”) for channelName for no channel):

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.Plotting

MegunoLink Pro can plot data received from an Arduino, or any serial source, 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 data against time, or xy

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.

Exporting Plot Data and Plots

MegunoLink has two options for exporting data from plots:

  1. as an image of the plot, or
  2. as the data values that are plotted.

In each case the exported image or data can be saved to a file or copied to the clipboard.

To copy or save an image, right click on the plot and choose Copy or Save Image As…. You can also use MegunoLink’s scheduled reporting tool to save an image of the graph periodically — every few minutes, hours, or whenever you select Send reports now from the reporting menu.

To export the plot data, select the Copy Chart Data button on the plot toolbar; select the Save Chart Data button to save the plot data to a file. In each case the data is exported as comma separated values that can be imported into software such as Microsoft Excel or Matlab for further analysis.

Save/copy plot data

The save/copy plot data buttons can be found on the plotting visualizer toolbar

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.1.Time Plot

Use the Time Plot visualizer to send measurements from your Arduino to MegunoLink for plotting. Time, for the x-axis, can either be supplied by MegunoLink as it receives your data, or included in the message sent from the Arduino (from a real-time clock, for example).

Time plots are useful for testing new sensors such as accelerometers, temperature, force and many more. Just read the sensor, send the data to MegunoLink using functions from the TimePlot library and it will appear on screen. You can zoom, edit styles, auto-scroll and export data to the clipboard or a file.

Arduino data plotted using MegunoLink Pro TimePlot

MegunoLink Pro plots data received over the serial port from an Arduino or any microcontroller

To create a new time plot, select the time-plot visualizer from the Visualizers panel. Click the Visualize icon on the main toolbar to show the Visualizers panel.

Adding a Time Plot

Select Time Plot from the Visualizer Panel to create a new time plot visualizer in MegunoLink Pro.

The chart will automatically scroll to show the latest data when auto-scroll, on the visualizer’s tool-bar, is turned on.

Check out this instructable for a step-by-step guide to using plotting with MegunoLink Pro.

Sending Data from an Arduino

We’ve created a library for Arduino to make it easier to send data to MegunoLink for plotting. After you install the Arduino library,

  1. Add #include "MegunoLink.h" to the top of your Arduino program
  2. Create a TimePlot variable
  3. Call SendData to send data to MegunoLink Pro for plotting

This simple example sets the graph titles and sends a the current value from analog channel 0 to MegunoLink.

Channels

MegunoLink Pro plots support channels, a short text string for grouping series together. Channels let you have several plots in a project, sending different data to each.

Channel selector

The channel selector on the plot toolbar can be used to select a collection of series to display on the plot. Leave it blank to show the default channel.

Refer to the Arduino Library documentation and the message format reference for more information on setting up channels in your microcontroller.

Use the channel selector on the plot toolbar to choose which channel the plot should show. The channel selector is automatically populated with channels as they are detected.

User Interface

Plot properties and series styles can be set using buttons on the plot toolbar. Along with tools to select and remove series, zoom and pan, you can also hide or show the plot legend and toggle visibility of the summary table. The summary table lists the series which have been detected along with useful statistics including the minimum, maximum and average value received for each series.

Chart controls

All chart properties can be adjusted using the plotting toolbar.

Reference

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.2.XY Plot

Our XY Plot visualizer lets you send x,y pairs through your microcontroller’s serial port to view plots of the data.

XYPlot

MegunoLink Pro plots x-y data sent from a microcontroller, such as the Arduino, over a serial, or UDP, port.

To create a new x-y plot, select the X-Y visualizer from the Visualizers panel. Click the Visualizer icon on the main toolbar to show the Visualizers panel.

Create XY Plot

Select X-Y Plot from the Visualizer Panel to create a new xy plot visualizer in MegunoLink Pro.

Reference

  • Arduino XYPlot library reference: for details on plotting data using our Arduino Library
  • Raw plotting message reference: for details on the raw message format for sending data to MegunoLink Pro for plotting. It is usually easier to use the Arduino library than creating raw messages if you are on the Arduino platform.

Sending Data from an Arduino

We’ve created an Arduino library to make it easier to send data to MegunoLink Pro for plotting. After you install the Arduino library:

  1. Add #include "MegunoLink.h" to the top of your Arduino program
  2. Create a XYPlot variable
  3. Call SendData to send data to MegunoLink Pro for plotting

This simple example sets the graph titles and plots points using analog channel 0 for the x-axis and analog channel 1 for the y-axis.

Channels

Channel selector

The channel selector on the plot toolbar can be used to select a collection of series to display on the plot. Leave it blank to show the default channel.

MegunoLink Pro plots support channels, a short text string for grouping series together. Channels let you have several plots in a project, sending different data to each.

Refer to the Arduino Library documentation and the message format reference for more information on setting up channels in your microcontroller.

Use the channel selector on the plot toolbar to choose which channel the plot should show. The channel selector is automatically populated with channels as they are detected. You can also type a channel name directly into the selector’s text box.

User Interface

Plot properties and series styles can be set using buttons on the plot toolbar. Along with tools to select and remove series, zoom and pan, you can also hide or show the plot legend and toggle visibility of the summary table. The summary table lists the series which have been detected along with useful statistics including the minimum, maximum and average value received for each series.

XY Plot Chart Controls

All xy plot properties can be adjusted using the plotting toolbar.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.3.Time Plot Reference

The TimePlot class provides a convenient set of methods for settings properties and sending data to the MegunoLink Pro Time Plot visualizer.

To use the TimePlot functions:

  1. Install the MegunoLink Pro Arduino library
  2. Add #include “MegunoLink.h” to the top of your Arduino program
  3. Create a TimePlot variable
  4. Call methods on the TimePlot variable

Example

This example sends the current voltage on analog channel 0 to MegunoLink Pro every 200 ms.

Description

The TimePlot shows numerical data on a graph with time as the x-axis. Data sent with the library uses the computer’s time when the message is received. Custom time strings can be sent using the raw message format.

Multiple plots are supported using channels. Each plot visualizer in MegunoLink Pro shows the series for one channel. The channel used when sending commands is specified in the TimePlot constructor. Channels are optional. If not specified, the default channel is used and all data will appear on any plot that doesn’t have a specific channel selected.

Data is collected together in series for plotting with new values appended as it arises. Series names are used to identify each collection of data and to set the line and marker styles for plotting.

Methods

TimePlot(ChannelName — optional ) (constructor)
SendData(SeriesName, YValue, SeriesProperties — optional )
SendData(SeriesName, YValue, Color, LineStyle, LineWidth, MarkerStyle)
SendFloatData(SeriesName, YValue, DecimalPlaces, SeriesProperties — optional )
SendFloatData(SeriesName, YValue, DecimalPlaces, Color, LineStyle, LineWidth, MarkerStyle)
SetTitle(Title)
SetXLabel(Label)
SetYLabel(Label)
SetSeriesProperties(SeriesName, Color, LineStyle, LineWidth, MarkerStyle)
SetSeriesProperties(SeriesName, SeriesProperties)

Style Types

Colors = { Red, Green, Blue, Yellow, Black, Magenta, Cyan, White }
LineStyle = { Solid, Dashed, Dotted, DashDot, DashDotDot, NoLine }
MarkerStyle = { Square, Diamond, Triangle, Circle, Cross, Plus, Star, DownwardTriangle, NoMarker }

Detailed Descriptions

TimePlot(ChannelName — optional )

Constructs a time plot variable, with an optional ChannelName.

SendData(SeriesName, YValue, SeriesProperties — optional )

Send the YValue, a number, to MegunoLink Pro where it will be added to the series SeriesName. A series property string may be specified to set the series style.

SendData(SeriesName, YValue, Color, LineStyle, LineWidth, MarkerStyle)

Send the YValue, a number, to MegunoLink Pro where it will be added to the series SeriesName. Also sets the color, line-style, line-width and marker style used for plotting.

SendFloatData(SeriesName, YValue, DecimalPlaces, SeriesProperties — optional )

Send the YValue, a floating point number, to MegunoLink Pro where it will be added to the series SeriesName. DecimalPlaces sets the number of decimal places to use when the data is sent. A series property string may be specified to set the series style.

SendFloatData(SeriesName, YValue, DecimalPlaces, Color, LineStyle, LineWidth, MarkerStyle)

Send the YValue, a floating point number, to MegunoLink Pro where it will be added to the series SeriesName. DecimalPlaces sets the number of decimal places to use when the data is sent. Also sets the color, line-style, line-width and marker style used for plotting.

SetTitle(Title)

Sets the plot title.

SetXLabel(Label)

Sets the label displayed on the plot’s x-axis.

SetYLabel(Label)

Sets the label displayed on the plot’s y-axis.

SetSeriesProperties(SeriesName, Color, LineStyle, LineWidth, MarkerStyle)

Set the color, line-style, line-width and marker style used for plotting the given series.

SetSeriesProperties(SeriesName, SeriesProperties)

Sets one or more of the color, line-style, line-width and marker style used for plotting the given series with a series property string

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.4.XY-Plot Library Reference

The XYPlot class provides a convenient set of methods for setting properties and sending data to the MegunoLink Pro X-Y Plot visualizer.

To use the XYPlot functions:

  1. Install the MegunoLink Pro Arduino library
  2. Add #include “MegunoLink.h” to the top of your Arduino program
  3. Create a XYPlot variable
  4. Call methods on the XYPlot variable

Example

This example sends the voltage from the first two analog channels as x and y values to MegunoLink Pro every 200 ms.

Description

The XY Plot shows pairs of numerical data on a graph.

Multiple plots are supported using channels. Each plot visualizer in MegunoLink Pro shows the set of series for one channel. The channel used when sending commands is specified in the XYPlot constructor. Channels are optional. If not specified, the default channel is used and all data will appear on any plot that doesn’t have a specific channel selected.

Data is collected together in series for plotting with new values appended as it arises. Series names are used to identify each collection of data and to set the line and marker styles for plotting.

Methods

TimePlot(ChannelName — optional ) (constructor)
SendData(SeriesName, XValue, YValue, SeriesProperties — optional )
SendData(SeriesName, XValue, YValue, Color, LineStyle, LineWidth, MarkerStyle)
SendData(SeriesName, XValue, YValue, DecimalPlaces, SeriesProperties — optional )
SendData(SeriesName, XValue, YValue, DecimalPlaces, Color, LineStyle, LineWidth, MarkerStyle)
SetTitle(Title)
SetXLabel(Label)
SetYLabel(Label)
SetSeriesProperties(SeriesName, Color, LineStyle, LineWidth, MarkerStyle)
SetSeriesProperties(SeriesName, SeriesProperties)

Style Types

Colors = { Red, Green, Blue, Yellow, Black, Magenta, Cyan, White }
LineStyle = { Solid, Dashed, Dotted, DashDot, DashDotDot, NoLine }
MarkerStyle = { Square, Diamond, Triangle, Circle, Cross, Plus, Star, DownwardTriangle, NoMarker }

Detailed Descriptions

XYPlot(ChannelName — optional )

Constructs an x-y plot variable, with an optional ChannelName. This variable can be used to send data to MegunoLink Pro plots.

SendData(SeriesName, XValue, YValue, SeriesProperties — optional )

Send (XValue, YValue), a pair of numbers, to MegunoLink Pro where it will be added to the series SeriesName on an X-Y Plot. A series property string may be specified to set the series style.

SendData(SeriesName, XValue, YValue, Color, LineStyle, LineWidth, MarkerStyle)

Send (XValue, YValue), a pair of numbers, to MegunoLink Pro where it will be added to the series SeriesName. Also sets the color, line-style, line-width and marker style used for plotting.

SendData(SeriesName, XValue, YValue, DecimalPlaces, SeriesProperties — optional )

Send (XValue, YValue), a pair of floating point numbers, to MegunoLink Pro where it will be added to the series SeriesName. DecimalPlaces sets the number of decimal places to use when the data is sent. A series property string may be specified to set the series style.

SendData(SeriesName, XValue, YValue, DecimalPlaces, Color, LineStyle, LineWidth, MarkerStyle)

Send the (XValue, YValue), a pair of floating point numbers, to MegunoLink Pro where it will be added to the series SeriesName. DecimalPlaces sets the number of decimal places to use when the data is sent. Also sets the color, line-style, line-width and marker style used for plotting.

SetTitle(Title)

Sets the plot title.

SetXLabel(Label)

Sets the label displayed on the plot’s x-axis.

SetYLabel(Label)

Sets the label displayed on the plot’s y-axis.

SetSeriesProperties(SeriesName, Color, LineStyle, LineWidth, MarkerStyle)

Set the color, line-style, line-width and marker style used for plotting the given series.

SetSeriesProperties(SeriesName, SeriesProperties)

Sets one or more of the color, line-style, line-width and marker style used for plotting the given series with a series property string

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

9.5.Plotting Message Reference

MegunoLink Pro gets information for plotting data from specially formatted commands in serial streams. Each command must be surrounded by braces (‘{‘ and ‘}’). Any text that is not within braces is ignored by the MegunoLink Pro plot handler.

The general format of plot messages is: {PLOTTYPE:channel-name|command|command data}

  • The PLOTTYPE parameter is required. It sets the type of plot that the message is for and may be either TIMEPLOT or XYPLOT
  • The :channel-name parameter is optional. It sets the plotting channel.
  • The command parameter is required and sets the action that will be taken by MegunoLink Pro. Supported commands include: SET, DATA, DATA-STEP, D, DS, CLEAR. Commands are described in more detail below
  • command data is the data used by the commands. Not all commands require data

Examples

  • {TIMEPLOT|data|My series name|T|23}: adds the value 23 to a series named “My series name” on all time-plots
  • {TIMEPLOT:Battery|data|Voltage|T|12.2}: adds the value 12.2 to a series named “Voltage” on time-plots with the channel named “Battery” selected
  • {TIMEPLOT:Battery|data|Current:r-2s2|T|0.12} : adds the value 0.12 to a series named “Current” on time-plots with the channel named “Battery” selected. The series is shown using a 2 pixel thick red, dashed line with square markers of size 2.

Plot Type and Channel

MegunoLink Pro currently supports two plot types: time-plots and xy-plots. The x-axis of a time plot is time, while the x-axis of an xy-plot is a number. Time-plots can pan automatically to show the current time on the x-axis, much like an old chart recorder. XY-plots remain stationary. The plot type is the first part of the message and may be TIMEPLOT or XYPLOT.

The plot type is optionally followed by a channel, with the plot type and channel separated by a colon (:). Channels group series together and allow several plots of the same time in a single project with each channel appearing on a different plot. Channel names can include any characters except colon, pipe and closing brace ( :, |, } ). Channel names should be 15 characters or less.

The plot type and channel (if required) must be included in all plot messages.

Examples

  • {TIMEPLOT|DATA|My series name|T|23}: sending data to the default time-plot channel
  • {TIMEPLOT:Battery|DATA|Voltage|T|12.2}: sending data to the Battery time-plot channel
  • {XYPLOT:Waveform|SET|TITLE=Measured Waveform} : set the title of an xy-plot displaying the Waveform channel

Sending Data to Plots

There are two commands to send data to plots: DATA and DATA-STEP. They can be abbreviated to D and DS, respectively. Both require a series name and a set of data, which is added to the plot. The series name and data values should all be separated by ‘|’ characters. For example: {XYPLOT|DATA|Series|1|12.3|2|15.3|3|11.2}.

A series names the collections which MegunoLink Pro adds data to as the data is received from the serial stream. Each series is plotted on the graph with all points (optionally) connected by a line and having the same marker style and colour. By using different series names, ‘Voltage’ and ‘Current’, for example, you can plot multiple sets of data on a single plot. Series properties can be specified after the series name, but they are not required. When series properties are included, they override the current plot setting in MegunoLink Pro.

The data-values for the DATA (or D) command is a list of x-y pairs, each separated by a ‘|’ character. For example: {XYPLOT|DATA|SeriesName|1|12.3|2|15.3|3|11.2} would add the values (1,12.3), (2,15.3), (3, 11.2) to an x-y plot.

When sending data to a TIMEPLOT, the x-value may be replaced by a ‘T’ to use the computer’s current time for the x-value.

The data-values for the DATA-STEP (or DS) command is an x-value (x0), a step size (Δx) and a sequence of y-values. The x-value for the ith y-value is calculated from:
xi = x0 + Δx × i
If x0 = ‘T’, the step size is given in seconds. Otherwise, it is in the same units as x. For example:
{TIMEPLOT|DATA-STEP|SeriesName|T|60|12.3|15.3|11.2}
would add the values (T, 12.3), (T + 60 seconds, 15.3), (T + 120 seconds,11.2) to a time plot, where T represents the current computer time when the message was received.

You can specify the time used on the TIMEPLOT’s x-axis using one of the following formats:

  • yyyy-MM-dd H:mm:ss
  • yyyy-MM-dd H:mm
  • yyyy-MM-dd H:mm:ss.FFF
  • yyyy-MM-dd
  • H:mm:ss
  • H:mm
  • H:mm:ss.FFF

Where:

  • yyyy is a four digit year, such as 2015
  • MM is a two digit month between 01 and 12
  • dd is a two digit day between 01 and 31
  • H is the hour part of the time between 0 and 23
  • mm is the minute part of time between 00 and 59
  • ss is the second part of time between 00 and 59
  • FFF is millisecond part of time between 000 and 999

Clearing Plot Data

Data from all series on a plot can be cleared by sending a clear command. The clear command takes no parameters.

  • {TIMEPLOT|CLEAR}: clears all data from a time plot
  • {XYPLOT:Power|CLEAR}: clears all data from xy-plots showing the Power channel

Plot Properties

Plot properties include axis and plot titles. The command for setting plot properties is SET. The property name and value are specified on the command data, separated by ‘=’.

The properties available are:

Property NameDescription
titleSet the plot title
x-labelSet the label for the x-axis
y-labelSet the label for the y-axis

Examples

  • {TIMEPLOT|SET|Title=My Title}: set the title of a time plot to My Title
  • {TIMEPLOT|SET|X-Label=Time}: set the x-axis (horizontal) label of a time plot to Time
  • {XYPLOT|SET|Y-Label=Voltage}: set the y-axis (vertical) label of an xy-plot to Voltage

Series Properties

Series properties include the colour, line-style, marker type and marker size used for drawing series on the plot. Series properties can be included with data messages or set separately. Including the series properties with a data message means the series formatting will be available even if MegunoLink Pro was not connected to the device when formatting was set, however it does make the messages a little longer.

Series properties can be set using the STYLE command: {TIMEPLOT|STYLE|Series name:PropertyString}, where PropertyString defines the properties as described below.

Series properties can be sent with a data command by including the property after the series name: {XYPLOT|DATA|Series name:PropertyString|22|0.12}. Again, PropertyString defines the properties as described below.

Property Strings

Property strings are used to set the desired property as a combination of line and marker styles and size. A typical property string could be r-2s3. This sets the line colour to red (r) and dashed (-) with a width of 2. It sets square markers (s) with size of 3.

All parts of the property string are optional. If a value isn’t supplied, the related property on the plot remains unchanged.

Property strings consist of characters from the tables below.

Color

Colours apply to both the line style (if any) and marker shape. It isn’t possible to set different colours for markers and lines using serial commands.

Property String CharacterDescription
rred
ggreen
bblue
yyellow
kblack
mmagenta
ccyan
wwhite

Line Style

Property string characters to set the line style:

Property String CharacterDescription
_solid line
-dashed line
:dotted line
;dash dot line
%dash dot dot line
#no line
Number following line style gives line width

Marker Style

Property string characters to set the marker style:

Property String CharacterDescription
ssquare
ddiamond
^triangle
ocircle
xcross
+plus sign
*star
vdownward triangle
nno symbol
Number following marker gives marker size
Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

10.Program Device

MegunoLink Pro’s Program Device visualiser can be used to program Arduino based hex files. This visualiser utilizes the same programming tools distributed with your standard Arduino installation.

We currently support these Arduinos

  • Arduino Uno
  • Arduino Duemilanove w/ATmega328
  • Arduino Mega 2560 or Mega ADK
  • Arduino Mini w/Atmega328
  • Arduino Pro or Pro Mini (3.3V, 8MHz) w/ATmega328

We also support these chips using the AVR MK2 ISP or AVR Dragons

  • ATmega644p
  • ATmega328p

Usage

MegunoLink Pro Setup

The first time you use MegunoLink Pro’s programmer you need to point it towards the standard Arduino installation so that it can modify AVRDUDE allowing our auto-disconnect feature to work. This lets you program from the standard Arduino software without having to manually disconnect the serial port in MegunoLink first. Perfect for speedy development.

setupnew

Adding Hex Files

programmerHit the little + button at the top left and it will add a programmer window. You can have as many programmers as you want. In this example you see three programmers. Each one has a description to help you remember what each programmer does. Specify a path to the .hex file and configure the programmer parameters. In the above example you see the first uses the standard Arduino serial bootloader, the second uses AVR Dragon and the third uses the AVR ISP Mk2.

Advanced

MegunoLink Pro supports a special file-format called a programming package. This special file format can be used to upload bootloaders and adjust fuses on the device. Learn more about Programming Packages.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

11.Scheduled Reporting

MegunoLink Pro has built in scheduling that allows you to, at periodic intervals export images of plots, and save table data to separate files. This is perfect if you have a system running somewhere remote, simply send reports to a Dropbox folder allowing you to keep up with what is going on from afar.

Configure Reporting

Configure Reporting

Renaming visualizer tabs for easy identification in scheduled reporting.

Modify plot report settings

Adjusting the individual settings for each visualizer you want to report.

Modify destination for reports

Adjusting the path and schedule for reporting

To begin with its useful to name the visualizer windows in order to easily identify them from the reporting configuration menu. Once your visualizers are named click on the arrow next to the small scroll icon on the main toolbar, click configure reporting. This opens up the configuration window and you can see a list of the current visualizers. In the example you can see that the visualizer named Sine Waveform has been ticked and we have clicked on it to see its current configuration. In this case where the visualizer is a plot you can configure the size of the captured images, its resolution, and the naming sequence you require. For the table you can set the output format and the naming sequence.

The final step is to set the destination directory for where you want the reports to go. You also need to set the frequency at which you want the reporting to occur. Once this is configured close the reporting window.

You can manually send a report using the hotkey “F2”, this is perfect for testing that you have set everything up correctly. Once you have checked that your report is working you need to enable the scheduling, this is done by clicking on the scroll icon on the main toolbar.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

12.Table

table

MegunoLink Pro’s Table visualiser lets you display data in tabular form. Simply send serial messages matching the format below. You can both set and get corresponding values from the table. You can also clear the table or individual records.

Usage

Default Table

From arduino end, for default table:
{TABLE|SET|Name|Value}
{TABLE|GET|Name}
{TABLE|CLEAR}
{TABLE|CLEAR|Name}
{TABLE|DESCRIPTION|Name|Description}

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

13.XBee Manager

MegunoLink Pro now supports XBee series 2 radios modules operating in API mode using the XBee connection in the connection manager. XBees running in transparent mode can still be used with the traditional serial (COM) connection.

With MegunoLink’s XBee Series 2 connection you can now:

  • Receive serial data transmitted from remote XBees to a connected local XBee.
  • Send serial data from the local XBee to individual remote nodes.
  • Change some of the basic settings on local and remote XBees.

Useful Resources

XBee is a wireless communication module that Digi built to the 802.15.4/ZigBee standard. If you are unfamiliar with XBees and/or the ZigBee protocol, refer to the following links to get you started:

Robert Faludi has written a great book on ZigBee mesh networking called Building Wireless Sensor Networks which goes into great detail on XBees and has a number of xample projects which use XBees in conjunction with Arduino hardware.

Things you might need:

XBee Configuration

To use your XBee Series 2 modules with MegunoLink you require the following:

  • XBee series 2 (or Pro S2B) modules.
  • An adapter to connect your XBee to your computer.
  • XCTU for programming the XBee modules with the correct firmware versions.

To get started with your Xbee project you will first need to connect your XBee module to your computer and use XCTU to program it with the correct firmware. Note, all ZigBee mesh networks require one (and only one) device to act as a coordinator for the network. What firmware?!!

MegunoLink Pro

To use your XBee with MegunoLink Pro you need to first open MegunoLink and add an XBee Series 2 connection in the Connection Manger visualiser. You will need to select the COM port the XBee is connected to and adjust the baudrate to match (default is 9600). After the configuration is complete click the Connect button.

MegunoLink Pro - Xbee Series 2 - Connection Manager

XBee Series 2 connection inside of MegunoLink Pro’s Connection Manager visualiser

You should now have a connection with your XBee. To confirm communication with the XBee, open the XBee Manager visualiser and set the source to your new XBee Connection. Click the Get button in the Local XBee tab. If the local XBee and its connection has bee configured correctly it will retrieve some of the useful settings exposed by MegunoLink.

The local settings include:

  • Firmware version – this can be updated and changed using XCTU.
  • Hardware version – the version identifier for the XBee hardware.
  • RSSI – the signal strength from the last packet the local XBee received.
  • Operating Channel – the channel the XBee network is operating on. This is determined automatically by the coordinator when establishing a network.
  • PAN ID – this is the personal area network ID. It’s a hexadecimal value between 0x0 and 0xFFFF. XBees can only communicate with each other if they are on the same PAN ID.
  • Baud rate – this is the baud rate of the physical communication layer (serial connection).
  • Escaped Characters – this determines whether the XBee packets use escape characters or not.
  • Node Identifier – this is a human-readable name to give your XBee. It can be up to 20 characters in length.

The buttons at the bottom control the XBee manager:

  • Get – retrieves the settings from the local XBee.
  • Set – this will update the local XBee with the currently selected settings. These settings are volatile until the Write button is pressed.
  • Write – this will commit the updated settings to non-volatile memory so power cycling will not reset them to a previous state.
  • Fac. Reset – this will carry out a factory reset initialising the settings to their default values.

Local Settings tab of the XBee Manager visualiser freshly populated with the retreived settings.

 

Remote XBees

The XBee manager also lets you easily retrieve and change settings on remote XBees on the local XBee’s network. To retrieve or change remote settings first click the remote settings tab in the XBee Manager visualiser. Click the Node Discover button at the top of the XBee Manager visualiser. This will populate the remote address drop-down menu with all of the available remote XBees. Remote XBees can be configured in the same way as the Local XBee was. Simply select the address, update the settings then Set/Write them into the remote XBees local memory.

Remote Settings tab of the XBee Manager visualiser.

 

Sending Data to Remote XBees

All of the traditional approaches for sending data in MegunoLink should work with the XBee Series 2 connection including the Monitor and Interface Panel. There is also a Transmit Payload tab on the XBee Manager to send short messages when testing your wireless networks. Simply type a string or byte and add it to the packet. Select the destination address and hit send. The packet size is limited to 72bytes.

MegunoLink Pro - Xbee Series 2 - XBee Manager Transmit Payload

Transmit Payload tab of the XBee Manager visualiser with the string ‘Test’ ready to be sent to a remote router XBee.

Things to Note

  • MegunoLink expects recieved packets to have escaped characters added. Your XBees should have escaped characters set to yes (AP = 2 if using XCTU to configure the XBee). Check out the article called Escaped characters and API Mode 2 on the Digi website for more information on escape characters.
  • If you change the baud rate of the local XBee you will also have to change the baud rate of the XBee connection in the Connection Manager visualiser. If you change the baud rate of the remote XBees you can still communicate wirelessly with MegunoLink however it will likely cause a problem between the remote XBee and whatever it was talking to.
  • If you perform a node discover then disconnect a Xbee on the network (or add a new XBee) you will need to perform another node discovery to update the address list.
  • Changing the PAN ID of a coordinator will cause it to create a new network on a new operating channel. If you want your remote XBees to join this new network you will also need to update their PAN ID and then perform a network reset.

 

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

14.1.Sending data to MegunoLink

The Arduino library bundled with MegunoLink provides classes to send data to our visualizers. There is one visualizer class for each visualizer, as shown in the table below. The classes provide methods for sending the data in the right format.

Using the Library

To use a visualizer class in your Arduino sketch:

  1. Install the MegunoLink library into your Arduino library folder
  2. #include "MegunoLink.h" — to make the library available to the sketch
  3. Create an instance of the visualizer class. This just means creating a variable such as TimePlot MyPlot;
  4. Call methods on the instance variable when you want to send data. For example: MyPlot.SendData("ADC Value", analogRead(0));

The visualizer class variable can be in the global scope (at the top of your sketch), or in the function right before you use it. Generally it is easier to place it in the global scope, especially if you are using channels.

Channels and Serial Ports

The methods of each visualizer class send data to the default channel on the standard Arduino Serial port. Include the channel name and Serial port in the constructor when you create the visualizer class variable to send data to a different channel or port.

For example, to send data to a channel named SetPoints on Serial1 declare your TimePlot variable as:

Visualizer Class Reference Pages

Visualizer Library Reference
Time Plot Time Plot Library
X-Y Plot X-Y Plot Library
Interface Panel Interface panel Library
Message Monitor Message Monitor Library
Table Table Library
Map Map Library

Example

Here is a simple example that generates a cosine function and sends it to a time plot.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

14.2.Command Handler Reference

For a detailed walk through see Getting started processing serial commands

Overview

The serial command handler is an Arduino library to process commands sent to the Arduino using a serial port by MegunoLink (or any serial program). When the library receives a command it can either:

  1. Call an Arduino function
  2. Update an Arduino variable

By default, commands start with a ‘!’ character and end with a carriage return (‘\r’) though both can be customized. Parameters can be included in the serial message and are separated using a space. Example commands:

  1. !SetPoint 4\r
  2. !StartMotor\r
  3. !TurnLEDsOn 1 2 3\r

To use the serial command handler in your program you need to:

  1. Install the MegunoLink Arduino Libraries
  2. #include "CommandHandler.h" to make the library available to your program
  3. Create a CommandHandler<> SerialCommandHandler; variable
  4. Add the commands you want to handle
    • To call a function when a command is received use SerialCommandHandler.AddCommand(F("CommandName"), Cmd_FunctionToCall)
    • To update a variable when a command is received use SerialCommandHandler.AddVariable(F("CommandName"), VariableName)
  5. Implement the command functions. Each must take a single CommandParameter reference, even if it isn’t used.
  6. Call SerialCommandHandler.Process() in your main loop function to receive and decode commands

For a detailed walk through see Getting started processing serial commands

The MegunoLink Interface Panel and Message Monitor visualizers can both be used to send commands.

The serial command handler is included in the MegunoLink Pro Arduino library.

CommandHandler Reference

The CommandHandler is implemented as a C++ template:
template class CommandHandler

It uses a fixed size array to store the command names and functions to call. By default 10 commands can be added to the handler. This can be changed using the first template parameter. You would need to increase this if you want to handle more commands. You could decrease this to save a little bit of memory. Each command slot uses 4 bytes.

The CommandHandler uses a fixed-size buffer to store characters as they are received from the serial port until a complete message is received. By default this buffer is 30 characters long. This can be changed using the second template parameter. You could increase this if you are sending long commands, or commands with lots of parameters. You could decrease this to save memory. The buffer has to be large enough to contain the start of message character (‘!’) and the terminator (‘\r’) and all the characters in between.

The CommandHandler uses a fixed-size buffer to store the map from command name to variable. By default 10 variables can be added to the handler. This can be changed using the third template parameter. You’d need to increase this if you want to handle more variables. Decreasing this would save a little bit of memory. Each command slot uses 4 bytes.

Command Handler construction

The CommandHandler constructor takes three (optional) arguments:
CommandHandler(Stream &SourceStream = Serial, char StartOfMessage = '!', char EndOfMessage = '\r')

  • SourceStream the serial port that the command handler should listen to. Normally this is Serial, the Arduino’s default serial port. But some devices (such as the Mega support additional ports. To receive data on the second Mega serial port, you’d pass Serial2 as the first argument when creating the command handler variable,
  • StartOfMessage is the character that the command handler looks for to mark the start of a new message. By default it is a ‘!’. Whenever the command handler encounters the start character it will discard whatever it has so far and begin building a new message. So you need to make sure the start character will never be found in the message itself.
  • EndOfMesasge is the character that marks the end of a message. By default it is a carriage return (‘\r’). When the end character is found, the command handler tries to match the command it has received and call the matching function. You need to make sure the end character is never found as part of the message itself.

Example Serial Command Handler declarations

Declaration Maximum number of Commands Maximum command length Maximum number of Variables Start of Message End of Message
CommandHandler<> SerialCommandHandler; 10 (default) 30 characters (default) 10 (default) ! \r
CommandHandler<15> SerialCommandHandler; 15 30 characters (default) 10 (default) ! \r
CommandHandler<12,20> SerialCommandHandler; 12 20 characters 10 (default) ! \r
CommandHandler<10, 30, 15> SerialCommandHandler; 10 (default) 30 characters (default) 15 ! \r
CommandHandler<> SerialCommandHandler(Serial1); 10 (default) 30 characters (default) 10 (default) ! \r
CommandHandler<> SerialCommandHandler(Serial2, '#', '^'); 10 (default) 30 characters (default) 10 (default) # ^

Adding Commands

To add a command, call SerialCommandHandler.AddCommand(F("CommandName"), Cmd_CommandFunction);. This would typically be used in the setup function of your program.

CommandName is the text the command handler will look for between the start of a command message and the first space (or end of the command message). Normally a ‘!’ marks the start of the command message and a ‘\r’ marks the end of the command message. So, for example, On is the command in each of these messages: !On\r, !On 23\r. But not in this one: !Onguard 12\r.

Cmd_CommandFunction is the Arduino function in your program that will be called whenever the command message is found. It can have any name you like, but it must take one parameter, a CommandParameter &. So the function should look like this:

The parameter variable lets you get any parameters that came with the command. See working with parameters below.

Adding Variables

To add a variable, call SerialCommandHandler.AddVariable(F("VariableName"), Variable);. This would typically be used in the setup function of your program.

VariableName is the text the command handler will look for between the start of a command message and the first space (or end of the command message). Normally a ‘!’ marks the start of the command message and a ‘\r’ marks the end of the command message.

Variable is the variable you want the command handler to update when the variable name in the command matches a registered variable. This variable should be in the global scope of your program. For example, a variable declared at the top of your program outside any functions.

So, for example, if you register SerialCommandHandler.AddVariable(F("SetPoint"), SetPoint) the command !SetPoint 20\r would update the SetPoint variable to 20.

The following types of variables are supported:

  • float
  • double
  • byte
  • short
  • int
  • long
  • uint8_t
  • uint16_t
  • uint32_t
  • int8_t
  • int16_t
  • int32_t

Default Handler

When first setting up a new program it can be helpful to know if messages are received that don’t match any known commands. This can point to errors in the commands you are sending, differences in spelling or case (capital vs lower case letters) or too many commands/variables were registered (by default only 10 commands and 10 variables are supported).

Use SerialCommandHandler.SetDefaultHandler(UnknownMessageHandler); to register a default message handler. UnknownMessageHandler is a function in your program that will be called whenever an unrecognized command is encountered. It shouldn’t take any parameters. A typically unknown message handler would be:

Clearing Registered Commands

You can clear all the registered commands using the SerialCommandHandler.ClearCommands(); function.

Working with Parameters

When the handler matches a command it will call the function registered for that command. This function must take a single parameter, a CommandParameter &. So a typical command handler function would look like this:

You need to include the parameter, even it is not used in the command handler function. Otherwise your program won’t build.

The CommandParameter provides access to any parameters that were included in the serial message. Parameters are separated by spaces.

A CommandParameter supports the following methods:

  • NextParameter() returns the next parameter (as text) in the serial message
  • RemainingParameters() returns the rest of the message as text
  • NextParameterAsInteger(Default) interprets the next parameter as an integer (16 bit) value; returns Default if the next parameter isn’t a valid integer
  • NextParameterAsLong(Default) interprets the next parameter as an long (32 bit) value; returns Default if the next parameter isn’t a valid integer
  • NextParameterAsUnsignedLong(Default) interprets the next parameter as an unsigned long (32 bit) value; returns Default if the next parameter isn’t valid
  • NextParameterAsDouble(Default) interprets the next parameter as an double value; returns Default if the next parameter isn’t valid

Example

Sending !SetTurtleCount 5\r from MegunoLink Pro will update the NumberOfTurtles variable in this simple example.

Sending !GetTurtleCount\r will print the current value of the NumberOfTurtles variable to the serial port.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

14.3.EEPROMStore

Overview

EEPROMStore is an Arduino library to look after saving and loading data from the EEPROM. Data in the EEPROM is not lost when the device loses power, or is reset, so it is a good place for storing program configuration. A check sum is stored with your data so the library can detect an EEPROM that hasn’t been initialized, or may contain invalid data. The EEPROMStore is part of the MegunoLink Arduino library.

The EEPROMStore works with data that lives in a structure. A structure is one kind of complex type. But it isn’t very complicated; a complex type is just a collection of simple types. And a simple type is something like an int, or long, or a byte. The structure groups them together so we can refer to them as a single thing.

Here’s a simple structure that has two members: temperature and humidity set points:

A struct is used for the EEPROMStore to make it easy to load and save a group of values all together.

A structure used with the EEPROMStore must also define a reset method. The reset method is called by the library whenever it detects invalid data. Typically this occurs the first time your sketch is run…because you haven’t saved any data at that point. The Reset method gets called to initialize all the variables in the structure.

So, to store a humidity and temperature set-point for a green house controller, we might declare a structure like this:

EEPROMStore Reference

The EEPROMStore is a template that takes a single argument: the name of the structure type to store. You’ll also need to include the library header file to use it:

The last saved value will be loaded automatically when your sketch starts. If there is no previously saved value (because this is the first time the sketch has been run) the default value is set using the Reset() function.

Data Property

The EEPROMStore variable has a Data property. With the type of the structure you’re storing. You could print the current values using something like this:

And set a new value like this:

Changing the value in the Data member doesn’t change the value stored in the EEPROM. You need to call the Save method.

Saving

To save the current value of data to the eeprom, call the Save method.

Loading

To overwrite the current value of the data with the value last saved in the EEPROM, call the Load method:

Reset

To replace the current value of the data with the default value, call the Reset method:

This doesn’t update the value in the EEPROM however. Call the Save method to do that.

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

14.4.Arduino Timer

The ArduinoTimer class in our Arduino library is a simple wrapper around the Arduino’s millis() to make it easier to run code periodically.

Using the millis() timer directly, you need to write something like:

Using the ArduinoTimer class you can write:

The methods supported by the ArduinoTimer are:

  • Reset(); Resets the timer to the current value of the millis timer
  • EllapsedMilliseconds(); Returns the number of milliseconds that have passed since the timer was last reset
  • EllpasedSeconds(); Returns the number of seconds that have passed since the timer was last reset
  • TimePassed_Milliseconds(Period, AutoReset — optional); Returns true if Period milliseconds have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Seconds(Period, AutoReset — optional); Returns true if Period seconds have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Minutes(Period, AutoReset — optional); Returns true if Period minutes have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • TimePassed_Hours(Period, AutoReset — optional); Returns true if Period hours have elapsed since the timer was last reset. If AutoReset is true, or not present, the timer will be reset if the period has passed
  • StartTime(); The value of the millis counter when the timer was last reset
Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful

15.Frequently Asked Questions

Have a question not answered below? Get in touch and we’ll do our best to help.

How do I plot multiple data streams at once?

Simply use the same channel name but a different series name. Each series can be enabled and disabled using the “show summary table” button found on the plotting toolbar.

How can I resolve a w5100.h error when compiling?

Go to the project properties page, find the Arduino tab and remove ethernet from the list of libraries. There is a bug which needs to be fixed. If you actually need the ethernet library copy the .cpp and .h files directly in to the project.

What is a suitable data rate for plotting?

We recommend a plotting rate ranging from 10-100Hz depending on your application. If you require a higher rate you could cache data and plot in blocks using your own timebase.

Which embedded systems are supported?

MegunoLink Pro will work with any micro-controller, in fact any system big or small, that can send serial messages. MegunoLink Pro will receive serial messages via RS232 and UDP (Ethernet).

The Arduino microcontroller has a special place in our hearts so we’ve build an Arduino library you can use to send data from your Arduino program directly to MegunoLink Pro.

Don’t feel left out if you’re not using an Arduino though. Let us know what other microcontroller platforms you’d like us to build libraries for. In the mean time, the Arduino library can be easily adapted to other microcontrollers. Our reference pages document the simple serial protocol that MegunoLink Pro uses.

Was this helpful? Yes No Suggest edit
1 of 1 users found this section helpful

16.Uninstall Instructions

MegunoLink can be uninstalled by:

  • Opening the Windows Control Panel
  • Select ‘Programs and Features’
  • Find MegunoLink in the list of programs and double click it
  • Click ‘Yes’ to confirm

Was this helpful? Yes No Suggest edit
0 of 0 users found this section helpful
Suggest Edit