« Close

Datasheets and User Guides

Software & Driver

 

Example Code/Wrappers

Example Code / Wrappers Overview

There is example code available for all of our devices in multiple programming languages.

LJM Example Code Table

LJM Example Code Table HTML (Referencable)

Example Code/Wrappers: LJM Library

T7 T4 Digit

T7, T4, Digit


Examples In... Windows Mac Linux
C/C++
LabVIEW
Python
Node.js
MATLAB
DAQFactory
Delphi
Java
.NET (C#, VB)
Processing
Visual Basic (VB6, VBA)
LabWindows/CVI
Agilent VEE

There are also direct Modbus TCP examples. Note that some features, such as streaming, are greatly simplified by the LJM library. A list of the available Modbus registers is available on the Modbus Map page.

Example code specifically tailored to the Digit-TL/Digit-TLH can be found in the appendix-b section of the Digit's datasheet.

UD Example Code Table

Example Code/Wrappers: UD Library

U3 U6 UE9

U3, U6, UE9


Examples In... Windows Mac Linux

Modbus TCP Example Code Table

Modbus TCP Example Code Table (Referencable)

Direct Modbus TCP Example Code

T7 T4

T7, T4


Libraries... Windows Mac Linux
LabVIEW
Node.js
Python
C/C++ (Streaming)

To use a 3rd party Modbus program, such as a Rockwell/Allen Bradley application, there is no download - simply follow the instructions on the Modbus Client Applications page.

More information about Modbus as well as some getting started information can be found on the Modbus API Documentation page. A list of the available Modbus registers that the T7 supports is available on the Modbus Map page.

UE9 Native TCP Example Code Table (Referencable)

UE9 Native TCP Example Code

UE9

UE9


Libraries... Windows Mac Linux
LabVIEW
C
Python
PocketPC

The UE9 is also compatible with the direct Modbus TCP examples. A list of the available modbus registers that the UE9 supports is available in the UD Modbus section.

Note that some features, such as streaming, are simplified by the UD library.

Lua Scripting on T7/T4 Devices

Example Code: Lua Scripting On T7/T4

Lua Scripts run on the device rather than on a computer. This allows for unique control of the T7/T4 device, especially useful in time-sensitive applications, digital communication, and standalone operation applications. A wide variety of detailed examples are available for the best starting place for a given application. Lua scripts can use USER_RAM registers to pass data into other programs, giving it a wide range of use.

Lua scripts are uploaded to the T-series device through Kipling, which makes Lua scripting possible across all platforms (Windows, Mac, and Linux)

2 comments

Emanuele Reggiani's picture

Hello,

I am currently using the U6 with a raspberry pi2, firmware updated, libusb installed, built C modules and installed wrappers for python. All works.

Still, I have some simple USB routines based on the usb.core python libraries and I would like to send simple sequence of bytes. The have been tested with other devices and they work.

For example, the AIN24 command  like:

[0x86,0xF8, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x02, 0x00, 0x08, 0x80, 0x00]

is supposed to read a differential input (channel 0 and 1) with gain index 0 (x1) and precision index 8.

Checksum are verified and received packet is as shown:

[0xCA, 0xF8, 0x03, 0x00, 0xCE, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04,0x8a]

How should the last bytes be treated to get to a voltage reading?

Thanks

LabJack Support's picture

First, take a look at the AIN24 low-level documentation. The last 3-bytes in your response is the 24-bit reading as described in the 3-byte response part of that page. Convert those bytes to the 24-bit binary value, and then apply the appropriate calibration constants to get the voltage. So something like this with your response bytes to get the 24-bit value:

binValue = (bytes[11] << 16 ) + (bytes[10] << 8 ) + bytes[9]

For code on getting and applying the calibration contants that converts the binary value reading to a voltage, look at the getCalibrationData and binaryToCalibratedAnalogVoltage methods in the u6.py source code. Also, the Exodriver provides low-level example code which may be helpful.