« Close

Datasheets and User Guides

App Notes

Software & Driver

 

LabVIEW Examples for U12 - Windows

 

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

http://www.ni.com/gettingstarted/labviewbasics/

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

  1. Go through the U12 Quickstart Tutorial.  Among other things this will install the U12 Windows Library and confirm basic operation of the U12.
  2. 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.
  3. 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.
  4. Navigate to the folder \LabVIEW_LJM\Examples\ and open any of the example files.  The code snippet below shows the Wiring Diagram from "LJM_eReadName Example.vi".

The U12 LabVIEW examples are tested on Windows only.

 

Code Snippet

This example uses 5 calls to the LJM library:

    • LJM_OpenS specifies which device you want to open and returns a handle for that device.
    • LJM_GetHandleInfo returns information about the device we just opened.
    • We pass a register name to LJM_eReadName and it reads the value of that register.  In this case we are reading the register named "SERIAL_NUMBER" which returns the serial number of the device.  For more names refer to the T7 Datasheet or Modbus Map.
    • LJM_Close closes the connection to the device so it is available to other processes.
    • LJM_ErrorToString converts the numeric error code to a readable string.

     

    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.

     

     

     

    For further information see the forum topic titled "Getting started with the LabJack U12 in LabVIEW".

    Note that the U12 installer might have already copied LabVIEW examples to your machine if LabVIEW properly reported its current version and location.  Go to your root c:\ folder and search the entire drive for ljackuw.llb.

     

    2 comments

    Does your latest version work for version 8.5 of labVIEW or should I just try to get it working on 7. Additionally any chance of becoming compatible with additional platforms in the future?

    The version included with the normal U12 installation (LabVIEW60_LJU12) should work with LV 8.5, and is recommended for LV8.5, or you can download LabVIEW71_LJU12 above to use with LV 8.5.

    As for additional platforms, do you mean newer versions of LabVIEW?  We support all newer versions.