Skip to main content

Unified methods for LabJacks U3, U6, and T7

Project description

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)'])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labjack-unified-0.0.5.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

labjack_unified-0.0.5-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file labjack-unified-0.0.5.tar.gz.

File metadata

  • Download URL: labjack-unified-0.0.5.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for labjack-unified-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8914be2d5941606440ad0b8266adf76e9c76fe00a6c3b52e6647dac5e4ebe7ae
MD5 e019dbd3ae3e4f571462b45e30f0baef
BLAKE2b-256 ec461cb4b27f7549557e0731a546fda4a8bd50a35347be9a7c126121447d3c4b

See more details on using hashes here.

File details

Details for the file labjack_unified-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: labjack_unified-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for labjack_unified-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f615142d81909b378f5e9be0e2d419d3f79c8f113311f9334e89ea7dbecd19bf
MD5 2101294b4858202ea8c93387c2e7ab57
BLAKE2b-256 091d58e0431b0cceee6264a16320c36be53d37729444bb03ef1da840432340dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page