You are viewing an older revision! See the latest version
Interfacing with LabVIEW
Here are some building blocks to interface an mbed with LabVIEW, allowing LabVIEW programs to interact with the real world. This could be used for things like:
- data acquisition in LabVIEW via sensors connected to mbed
- controlling actuators connected to mbed from LabVIEW
- LabVIEW programs with hardware-in-the-loop, where sensors and actuators are interfaced with mbed but calculations and control are in LabVIEW
The examples use the mbed USB Serial Port to connect between LabVIEW and mbed.
LabVIEW Setup¶
To use mbed with LabVIEW, you need to have the NI-VISA drivers installed to give access to the USB serial port.
- http://www.ni.com/trylabview/ - LabVIEW trial version
- http://www.ni.com/visa/ - NI-VISA drivers for the serial port
With LabVIEW and NI-VISA installed, you should be ready to go.
mbed Read Interface¶
As a first experiment, we've packaged up some serial interface and helper code in to an "mbed-read.vi":
This provides a component that assumes a simple protocol between mbed an LabVIEW, based on a "packet" of a string of characters ending in a newline. When the mbed-read.vi is run, it reads a line, then outputs it in various useful forms:
- The raw line string
- The string converted to a number
- The string split by commas in to an array of strings
- The string split by commas in to an array of numbers
This assumes that if you send a string, or number, or a comma separated line of either, you'll have a convenient output format to easily grab the desired result.
A simple labview example is included, which looks like:
And here is an example program to send some data:
Note that this example only will display the first AnalogIn, as it uses the single number output. To get the other values, you could use the array outputs and then use the array indexing to pick out particular inputs.
The resulting output once the mbed COM port number has been selected in the VISA control, and when modifying AnalogIn, looks like:
To come:
- mbed-write (output)
- Closed loop example