Skip to main content
Skip table of contents

LabVIEW for LJM - Windows & macOS

This LabVIEW for LJM package provides a set of utility VIs for interfacing with the LJM library as well as many examples. This package is provided as a set of example VIs, not a tool pallet addon. LJM can be added to the function pallete by following the directions in the Adding LabVIEW_LJM to the Function Palette section bellow.

For more information about the LJM Library see here: LJM Library Overview

For more information about LabVIEW see here: http://www.ni.com/gettingstarted/labviewbasics/

Note that using a LabJack in LabVIEW is not identical to using NI hardware in LabVIEW.  NI hardware communicates using the NI-DAQ driver, while T-series devices communicate using the LabJack LJM library.  That means that you will not use measurement & automation explorer, DAQ assistant, or similar NI wizards.

LabView dropping MacOS support.

Warning: LabVIEW has discontinued macOS support for Intel and Arm architectures with the 2023 Q4 release of LabVIEW. In order to use LabView with LJM on macOS you will need to use a supported LabView version and macOS version. See https://www.ni.com/en/support/documentation/compatibility/18/labview-and-macos-compatibility.html?srsltid=AfmBOoqvfuRHIKVHi6TXe_ys2hKzSifkyW5L7mhTAyxmL7Z6_CPy7jzl for more details.

Prerequisites

 

Download - Windows Utility VIs

Details

This is a set of example VIs intended for older versions of LabVIEW. Do not load this package as an add-on, simply open the files as any other VI.

Compatible with LabVIEW 7.1 or higher.

GitHub

Our latest example changes are available in our GitHub repository.

macOS Downloads

Warning: We no longer maintain the package below. LabVIEW no longer supports macOS after the 2023 Q3 release. See https://www.ni.com/en/support/documentation/compatibility/18/labview-and-macos-compatibility.html?srsltid=AfmBOoqvfuRHIKVHi6TXe_ys2hKzSifkyW5L7mhTAyxmL7Z6_CPy7jzl for more details.

macOS Example Package

LabVIEW_LJM_macOS_2021_06_04.zip

Note: requires the LJM from April 2021 or newer

Getting Started

  1. Experienced LabVIEW programmer?  Proceed to next step.  If you are new to LabVIEW, you need to know the basics such as loops, case structures, arrays, clusters, data types, indicators and controls.  Perhaps most importantly you need to understand the "dataflow" concept, which is one of the biggest differences between LabVIEW and a text language.

  2. Go to your device Quickstart Tutorial and follow the steps to install Windows software and confirm basic operation.

  3. Download the LabVIEW_LJM archive (at the top of this page) and extract the entire archive.

  4. In LabVIEW you will be making calls to our LJM Library to write and read registers on the device.  Go to the main LJM Page for an introduction, and proceed to the LJM User's Guide for more details.

  5. For more information about what registers to write and read, see the T-Series Datasheet and the Modbus Map.

  6. Navigate to the folder \LabVIEW_LJM\Examples\Basics and try out "LJM_eReadName Example.vi".

  7. Move on to the very useful example "Write Read Loop with Config.vi".

Communication Overview

Communication through the LJM library is very straightforward, as everything you might want to do with a device is accomplished by writing and/or reading some registers.  Look at the T-series Datasheet or the Modbus Map to determine what registers you need to write and read, then use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers.  The following examples in the Basic folder are a great place to start:

  • LJM_eWriteName Example

  • LJM_eWriteNames Example

  • LJM_eReadName Example

  • LJM_eReadNames Example

  • Write Read Loop with Config

Where is an example to do XYZ?

You will find lots of examples in this archive, but there is not an example for everything the LabJack can do.  The reason for this stems from the "Overview" section above.  Most operations simply involve writing and reading different registers, so you really just need examples that show you how to write and read any register.  If we had examples for every operation, they would just be copies of the example "Write Read Loop with Config" with different registers. The typical workflow to do almost anything beside stream is:

  1. Look at the T-series Datasheet or the Modbus Map to determine what registers you need to write and read.

  2. Use the Register Matrix in Kipling to test writing and reading your desired registers and confirm you see what you expect to see.  This step is optional and not always applicable.

  3. Use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers. Or just use "Write Read Loop with Config", which provides the basic structure used by many user applications.

LabVIEW_LJM Archive Contents

The downloadable zip file LabVIEW_LJM.zip extracts to a single folder called LabVIEW_LJM which contains a few sub-folders. Direct changes to the LabVIEW_LJM VIs are not recommended. If you download new VIs from labjack.com, delete and replace the entire LabVIEW_LJM folder.

The \Functions folder contains simple VIs that do little more than call functions from LJM.  Most of these need a valid Handle input so are intended to be sub-VIs not standalone top level VIs.

The \LVUtilities folder contains VIs that encapsulate some useful functions.  These are used by other VIs from the \Functions\ and \Examples\ folders to handle things unique to LabVIEW.

The \Examples\Basics folder contains core examples that demonstrate the basics of interfacing LabVIEW with our LJM library.  Included here is the very useful "Read Write Loop with Config.vi" example which forms the basis for most customer applications.  Use the device datasheet (and/or Modbus Map) to determine what registers you need to write and read and the plug those register names into "Read Write Loop with Config.vi".

The \Examples\More folder has many more examples that demonstrate specific tasks.  Some of these demonstrate unique techniques, but many are simply variations of the "Write Read Loop with Config.vi" example with different default register names and values.

The \LJM Logging Applications folder and sub-folders such as \LJLogM and \LJStreamM contain the source code for those sample programs.  The executable versions (.exe) are part of the main LabJack software installer for Windows.  Advanced LabVIEW programmers might find this source code useful, but most users are better off starting with a more basic example.

Adding LabVIEW_LJM to the Function Palette

LabVIEW_LJM can be added to the LabVIEW function palette with the following steps:

  1. Download and extract the LabVIEW_LJM.zip archive. All of the LabVIEW_LJM contents should be extracted to a single folder called LabVIEW_LJM.

  2. Find your LabVIEW installation directory. LabVIEW is most commonly installed at C:\Program Files (x86)\National Instruments or C:\Program Files\National Instruments. You should see a folder corresponding to your LabVIEW version.

  3. Place the extracted LabVIEW_LJM folder in the LabVIEW version folder under \vi.lib\addons\, creating the addons folder if it does not exist. Note: LabJack VI icons may not load properly if the LabVIEW_LJM folder is named something different such as LabVIEW_LJM_year_month_day, so ensure that the folder is named exactly LabVIEW_LJM.

  4. Restart LabVIEW to see LabVIEW_LJM VIs in the function palette.

Many people, including LabJack engineers, do not use the palette icons. Instead, VIs can be selected using the "Select a VI..." balloon from the function palette.  The LabVIEW_LJM folder can be placed in any directory using this method.

Code Snippet

LabJack Sample VI for LJM and LabVIEW

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.

Errorcodes

6000 is added to the LabJack errorcodes to shift them into the LabVIEW user range of 5000-9999.  For example, if the open call cannot find the device you requested it will return LabVIEW-LJM errorcode 7227, which is LabJack-LJM errorcode 1227.  Many errorcodes are listed in Section 4 of the LJM User's Guide, but no need to look there for the basic string as every LabVIEW program should use LJM_ErrorToString.vi to convert the errorcode to a readable string.

Debugging Sub-VIs

All sub-VIs, which means everything in the Functions and LVUtilities folders, are set to reentrant execution.  In older versions of LabVIEW, debugging is not allowed when reentrant is enabled, so debugging is disabled in all sub-VIs.

To allow debugging in sub-VIs in older LabVIEW, you will have to disable reentrent execution.  Go to File => VI Properties, set Category = Execution, un-check Reentrant execution, and check Allow debugging.  In newer versions of LabVIEW, you can enable debugging with reentrant enabled.

**Note**:  2 substantial changes were made to the LabVIEW_LJM archive with the 2015_01_23 release:

1.  In LJM function call VIs that have the NumFrames parameter, that parameter is now optional with a default value of -1 which means "Auto-Detect the Number of Frames".  If you do not wire anything to NumFrames, or pass -1, this signals the VI to use the size of aNames or aAddresses to determine the number of frames.  This should not break any code using previous versions of these VIs.

2.  A few changes were made to the inputs & outputs of LJM_eStreamStart.vi, and these changes will break code using a previous version of this VI.  See the front panel of LJM_eStreamStart.vi for more details.

Version History

For version history, see our Github repository.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.