Introduction

The UL for Linux Python library allow users to access and control supported Measurement Computing hardware using the Python language over the Linux platform. Python 2.7 and 3.4+ are supported.

The Python package name is uldaq. The uldaq package is implemented in Python as an interface to the UL shared object library.

The UL for Linux library provides structures and enumerations to manage connected devices, obtain information about device capabilities, and configure hardware settings.

Note

For performance reasons, data is returned in the Python library as arrays instead of lists.

The uldaq package is available on the GitHub.

Installation

Refer to the README file for information about how to download the UL for Linux package and install the library.

Creating a Python program

When creating a UL for Linux program in Python, import the uldaq package to use in your code: import uldaq

Refer to the example programs and the API documentation in the Python Library Reference for more information.

Example programs

UL for Linux includes example projects you can run with MCC hardware. The example projects are installed into into an examples folder as part of the project make, and are ready to run. Connect a supported Measurement Computing DAQ device to your system before running an example.

To run a UL for Linux example:

  1. Open a terminal window in the UL for Linux examples folder directory.
  2. Enter ./filename. For example, enter ./AIn to run the analog input example.

Users can also choose to import the example code into an IDE, such as Eclipse, and run the examples from that environment.

The UL for Linux package includes the following example projects:

Method Description
a_in Reads an A/D input channel. Demonstrates a_in().
a_in_scan Scans a range of A/D input channels, and stores the data in an array. Demonstrates a_in_scan() and scan_stop().
a_in_scan_with_events Performs an A/D scan using events to determine the data in an array. Demonstrates when data is available or when the acquisition is complete. The example also demonstrates how to retrieve the data when it becomes available. Demonstrates enable_event(), a_in_scan_wait(), and scan_stop.
a_in_scan_with_queue Creates a queue that sets individual channel ranges for an A/D scan. Demonstrates a_in_load_queue(), a_in_scan(), and scan_stop().
a_in_scan_with_trigger Scans a range of A/D channels when a trigger is received, and stores the data in an array. This example shows how to obtain and configure trigger options. Demonstrates a_in_scan() and scan_stop().
a_out Writes a specified value to a D/A output channel. Demonstrates a_out().
a_out_scan Performs a D/A scan. Data can be viewed with an oscilloscope or meter. Demonstrates a_out() and scan_stop().
c_in Sets the initial value of a counter and counts events. Demonstrates c_in() and c_clear().
c_in_scan Scans a range of counter channels. Demonstrates c_in_scan(), c_load() and scan_stop().
c_in_scan_with_encoder Scans a range of encoder channels. Demonstrates c_in_scan(), c_config_scan(), and scan_stop().
daq_in_scan Simultaneously acquires analog, digital, and counter data. Demonstrates daq_in_scan() and scan_stop().
daq_in_scan_with_trigger Sets up a trigger function, and simultaneously acquires analog, digital, and counter data when the trigger is received. Demonstrates daq_in_scan() and scan_stop().
daq_out_scan Simultaneously outputs analog and digital data. Demonstrates daq_out_scan() and scan_stop().
d_bit_in Configures multiple digital bits for input, and reads the bit values. Demonstrates d_config_bit() and d_bit_in().
d_bit_out Writes a specified value to multiple digital output bits. Demonstrates d_config_bit() and d_bit_out().
d_in Configures a port for input and reads the port value. Demonstrates d_config_port() and d_in().
d_in_scan Configures a port for input and continuously reads it. Demonstrates d_config_port(), d_in(), and d_in_scan_stop().
d_out Configures a port for output and writes a specified value. Demonstrates d_config_port() and d_out().
d_out_scan Configures the port direction and outputs digital data. Demonstrates d_config_port(), d_out_scan(), and d_out_scan_stop().
tmr_pulse_out Generates an output pulse at a specified duty cycle and frequency. Demonstrates pulse_out_start() and pulse_out_stop().

Support

Measurement Computing Corporation
508-946-5100
Technical Support: www.mccdaq.com/support
Knowledgebase: kb.mccdaq.com