LabVIEW Examples for U12 - Windows

LabVIEW is one of, if not the, most popular programming languages used by our customers. LabVIEW is a graphicalprogramming language, as demonstrated in the code snippet below, but understand that it is still a programming language not a simple software tool.

Note that using a LabJack in LabVIEW is not identical to using NI hardware in LabVIEW. The NI hardware is talked to through the NI-DAQ driver, while the U12 is talked to through the LabJack U12 Windows Library. That means that you will not use measurement & automation explorer, DAQ assistant, or similar NI wizards.

Prerequisites

Getting Started

Go through the U12 Quickstart Tutorial. Among other things this will install the U12 Windows Library and confirm basic operation of the U12.

In LabVIEW you will be making calls to the U12 Library to write to and read from the device. The U12 Library is documented in Section 4 of the U12 Datasheet.

Download the applicable LabVIEW##_LJU12 archive (attached below) and extract the entire archive. You can store this folder anywhere, but if you want shortcuts in the LabVIEW function palette (optional) copy the "LabJack" sub-folder to the \vi.lib\addons\ folder in your LabVIEW directory.

Navigate to the folder \LabVIEW##_LJU12\ and open any of the example files. The code snippet below shows the Wiring Diagram from "simple eanalogin loop with chart.vi".

Code Snippet

EAnalogIn is called in a loop that iterates every 100 milliseconds. The loop stops if their is an error or if the stop button (on the front panel) is pressed.

GetErrorString converts the numeric U12 errorcode to a readable string.

Short Video Tutorial

A short tutorial for how to use the U12 LabVIEW libraries is published on YouTube:

LabVIEW Can't Find Sub-VIs

We provide VIs that call all the U12 functions defined in Section 4 of the U12 Datasheet. These VIs are located in a VI library called ljackuw.llb, so if LabVIEW is looking for any of the basic U12 functions point it to the llb file.

If LabVIEW is looking for other sub-VIs, point it to the extracted folder (downloaded below) or perhaps the "sub" folder below that. If the sub-VI is not found there it might be a feature not supported by your version of LabVIEW.

LJlogger & LJstream

The main U12 installer includes executable versions of LJlogger & LJstream. The source for these is included in the LabVIEW archive attached here, but most users looking to build a custom LabVIEW application should start with one of the simpler examples in the archive, or perhaps LJsimplelog.

LabVIEW Function Palette

You can extract the LabVIEW##_LJU12 archive anywhere, but if you want U12 shortcuts in the LabVIEW function palette (optional) then take the following extra step.

When you extract the LabVIEW##_LJU12 archive (attached below) you will get a folder of the same name with various sub-folders including one called "LabJack" which contains a dir.mnu file (function palette definitions) and ljackuw.llb (a VI library with VIs that call the various U12 Library functions). Move this "LabJack" folder to the \vi.lib\addons\ folder in your LabVIEW directory.

Note that as of September 2016, the main U12 installer no longer includes the LabVIEW examples. Rather they are available below as a separate download.