Skip to main content

labjack-unified

Classes with unified methods to interact with LabJacks U3, U6 and T7.

labjack-unified is implemented upon LabJackPython and labjack-ljm-python and provides classes to interact with any of the LabJack devices listed above, through a set of methods that are device-independent. labjack-unified was developed for the MS Windows platform.

Classes & Methods

Three classes are available (LabJackU3, LabJackU6, and LabJackT7) which have the common methods listed below. These should cover the majority of LabJack applications. There are also device specific methods as well.

Method Description
close Closes the LabJack device
display_info Displays summary info about the device
set_digital Writes digital value to specified port(s)
get_digital Reads digital value from specified port(s)
set_analog Writes analog value to specified port(s)
get_analog Reads analog value from specified port(s)
get_labjacktemp Gets ambient temperature from internal sensor
set_stream Sets LabJack configuration for data streaming
get_stream Gets streaming data
stop_stream Stops data streaming
set_PWM Sets LabJack configuration for PWM output
set_dutycycle Sets duty cycle of PWM output (-100 to 100)
set_quadrature Sets LabJack configuration for encoder A-B-Z input
get_counter Gets edge count from encoder A-B signals
reset_counter Resets edge counter

Install

py -m pip install labjack-unified

Installing labjack-unified will install its dependencies: LabJackPython and labjack-ljm. Plotly will also be installed so graphs can be displayed when running the examples.

Documentation

Comprehensive documentation for labjack-unified is available here.

Examples

Nine examples are available in the documentation, with four of them requiring only a pair of wires to be executed successfully. Below is the code for lj_io_analog.py:

""" lj_io_analog.py 

Uses analog input and output channels.

This example shows how to use analog inputs and outputs in a data acquisition
loop. Accurate time execution of output events can be achieved by the use of a
timer logic in the loop. The voltage measurements are executed as fast as
possible. The main latency source is the LabJack I/O times.

Setup:
    Connect DAC0 to AIN0
    Connect DAC1 to AIN1

The LabJack unified methods in this example are:
    set_analog ....... Writes analog value to specified port(s)
    get_analog ....... Reads analog value from specified port(s)
    close ............ Closes the LabJack device 

"""
import time
import numpy as np
from labjack_unified.utils import plot_line
from labjack_unified.devices import LabJackU3, LabJackU6, LabJackT7

# To use a LabJack U6 or a T7, change the device name
# from LabJackU3 below to either LabJackU6 or LabJackT7
lj = LabJackU3()

# Assigning parameters
tstep = 0.5 # Interval between step changes (s)
t = [] # Output time array
v1 = [] # Output sampled voltage 1 array
v2 = [] # Output sampled voltage 2 array

# Initializing timers and starting main clock
tprev = 0
tcurr = 0
tstart = time.perf_counter()
# Executing acquisition loop
print('Running code for 5 seconds ...')
while tcurr <= 5:
    # Updating analog output every `tstep` seconds
    # with random voltages between 0 and 5 V
    if (np.floor(tcurr/tstep) - np.floor(tprev/tstep)) == 1:
        lj.set_analog('DAC0', 5*np.random.rand())
        lj.set_analog('DAC1', 5*np.random.rand())
    # Updating previous time and getting current time (s)
    tprev = tcurr
    tcurr = time.perf_counter() - tstart
    # Acquiring analog data as fast as possible
    # and appending values to output arrays
    t.append(tcurr)
    v1.append(lj.get_analog('AIN0'))
    v2.append(lj.get_analog('AIN1'))
print('Done.')
# Closing the device
lj.close()
del lj

# Plotting results 
plot_line([t]*2, [v1, v2], yname=['AIN0', 'AIN1'], axes='multi', marker=True)
plot_line([t[1::]], [np.diff(t)], yname=['Sampling Period (s)'])

Metadata

Release files for labjack-unified 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labjack-unified 0.0.5
File Size Uploaded
labjack-unified-0.0.5.tar.gz 30.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for labjack-unified 0.0.5
File Interpreter ABI Platform
labjack_unified-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 60.6 kB

Release files / labjack-unified-0.0.5.tar.gz

Download URL labjack-unified-0.0.5.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8914be2d5941606440ad0b8266adf76e9c76fe00a6c3b52e6647dac5e4ebe7ae
BLAKE2b-256 checksum
How to use checksums
ec461cb4b27f7549557e0731a546fda4a8bd50a35347be9a7c126121447d3c4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / labjack_unified-0.0.5-py3-none-any.whl

Download URL labjack_unified-0.0.5-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f615142d81909b378f5e9be0e2d419d3f79c8f113311f9334e89ea7dbecd19bf
BLAKE2b-256 checksum
How to use checksums
091d58e0431b0cceee6264a16320c36be53d37729444bb03ef1da840432340dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.6.4 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page