Implementation of asynchronous acquisition

Asynchronous Acquisition Card (pymanip.aiodaq)

This module defines an abstract base class for asynchronous communication with acquisition cards. This is used by the live oscilloscope command line tool.

Concrete implementations are:

In principle, other library bindings could be implemented.

class pymanip.aiodaq.TerminalConfig[source]

An enumeration.

class pymanip.aiodaq.TriggerConfig[source]

An enumeration.

class pymanip.aiodaq.TimeoutException[source]
class pymanip.aiodaq.AcquisitionCard[source]

Base class for all acquisition cards. The constructor takes no argument. Channels are added using the add_channel() method, and the clock is configured with the configure_clock() method.

add_channel(channel_name, terminal_config, voltage_range)[source]

This method adds a channel for acquisition.

Parameters
  • channel_name (str) – the channel to add, e.g. “Dev1/ai0”

  • terminal_config (TerminalConfig) – the configuration of the terminal, i.e. RSE, NRSE, DIFFERENTIAL or PSEUDODIFFERENTIAL

  • voltage_range (float) – the voltage range for the channel (actual value may differ)

close()[source]

This method closes the connection to the acquisition card.

configure_clock(sample_rate, samples_per_chan)[source]

This method configures the board clock for the acquisition.

Parameters
  • sample_rate (float) – the clock frequency in Hz

  • samples_per_chan (int) – number of samples to be read on each channel

configure_trigger(trigger_source=None, trigger_level=0, trigger_config=<TriggerConfig.EdgeRising: 0>)[source]

This method configures the trigger for the acquisition, i.e. internal trigger or triggered on one of the possible channels. The list of possible channels can be obtained from the possible_trigger_channels() method.

Parameters
  • trigger_source (str) – the channel to use for triggering, or None to disable external trigger (switch to Immeditate trigger). Defaults to None.

  • trigger_level (float) – the voltage threshold for triggering

  • trigger_config (pymanip.aiodaq.TriggerConfig, optional) – the kind of triggering, e.g. EdgeRising. Defaults to EdgeRising.

possible_trigger_channels()[source]

This method returns the list of channels that can be used as trigger.

async read(tmo=None)[source]

This asynchronous method reads data from the acquisition card.

async read_analog(resource_names, terminal_config, volt_min=None, volt_max=None, samples_per_chan=1, sample_rate=1, coupling_types='DC', output_filename=None, verbose=True)[source]

This asynchronous method is a high-level method for simple case. It configures all the given channels, as well as the clock, then starts the acquisition, read the data, and stops the acquisition.

It is essentially similar to pymanip.daq.DAQmx.read_analog(), except asynchronous and functionnal for other cards than DAQmx cards.

Parameters
  • resource_names (list or str) – list of resources to read, e.g. [“Dev1/ai1”, “Dev1/ai2”] for DAQmx cards, or name of the resource if only one channel is to be read.

  • terminal_config (list) – list of terminal configs for the channels

  • volt_min (float) – minimum voltage expected on the channel

  • volt_max (float) – maximum voltage expected on the channel

  • samples_per_chan (int) – number of samples to read on each channel

  • sample_rate (float) – frequency of the clock

  • coupling_type (str) – coupling for the channel (e.g. AC or DC)

  • output_filename (str, optional) – filename for direct writting to the disk

  • verbose (bool, optional) – verbosity level

read_analog_sync(*args, **kwargs)[source]

Synchronous wrapper around pymanip.aiodaq.AcquisitionCard.read_analog().

read_sync(tmo=None)[source]

This method is a synchronous wrapper around start_read_stop() method. It is a convenience facility for simple usage.

property samp_clk_max_rate

Maximum sample clock rate

start()[source]

This method starts the acquisition

async start_read_stop(tmo=None)[source]

This asynchronous method starts the acquisition, reads the data, and stops the acquisition.

Parameters

tmo (float) – timeout for reading, defaults to None

async stop()[source]

This asynchronous method aborts the acquisition

Concrete implementation with nidaqmx-python (pymanip.aiodaq.daqmx)

This module implements a concrete implementation of the AcquisitionCard class using the nidaqmx module.

class pymanip.aiodaq.daqmx.DAQmxSystem[source]

This class is the concrete implementation for NI DAQmx board using the nidaqmx module.

add_channel(channel_name, terminal_config, voltage_range)[source]

Concrete implementation of pymanip.aiodaq.AcquisitionCard.add_channel().

close()[source]

This method closes the active task, if there is one.

configure_clock(sample_rate, samples_per_chan)[source]

Concrete implementation of pymanip.aiodaq.AcquisitionCard.configure_clock()

configure_trigger(trigger_source=None, trigger_level=0, trigger_config=<TriggerConfig.EdgeRising: 0>)[source]

Concrete implementation of pymanip.aiodaq.AcquisitionCard.configure_trigger()

possible_trigger_channels()[source]

This method returns the list of channels that can be used as trigger.

async read(tmo=None)[source]

This asynchronous method reads data from the task.

property samp_clk_max_rate

Maximum sample clock rate

start()[source]

This method starts the task.

async stop()[source]

This asynchronous method aborts the current task.

pymanip.aiodaq.daqmx.get_device_list()[source]

This function returns the list of devices that the NI DAQmx library can discover.

Returns

dictionnary with board description as key and channels as value

Return type

dict

Concrete implementation with niscope (pymanip.aiodaq.scope)

This module is a concrete implementation of the AcquisitionCard class using the niscope module.

Note

We have tested this module only for with a PXI-5922 card.

class pymanip.aiodaq.scope.ScopeSystem(scope_name=None)[source]

This class is the concrete implentation for NI Scope cards.

Parameters

scope_name (str) – the name of the scope device, e.g. “Dev1”

add_channel(channel_name, terminal_config, voltage_range)[source]

Concrete implementation of pymanip.aiodaq.AcquisitionCard.add_channel().

close()[source]

This method closes the connection to the board.

configure_clock(sample_rate, samples_per_chan)[source]

Concrete implementation for pymanip.aiodaq.AcquisitionCard.configure_clock()

configure_trigger(trigger_source=None, trigger_level=0, trigger_config=<TriggerConfig.EdgeRising: 0>)[source]

Concrete implementation for pymanip.aiodaq.AcquisitionCard.configure_trigger()

possible_trigger_channels()[source]

This method returns the list of possible channels for external triggering.

async read(tmo=None)[source]

Concrete implementation for pymanip.aiodaq.AcquisitionCard.read()

property samp_clk_max_rate

Maximum rate for the board clock.

start()[source]

Concrete implementation for pymanip.aiodaq.AcquisitionCard.start()

async stop()[source]

Concrete implementation for pymanip.aiodaq.AcquisitionCard.stop()

pymanip.aiodaq.scope.get_device_list(daqmx_devices=None, verbose=False)[source]

This function gets the list of Scope device in the system. If NI System Configuration is available, the list is grabbed from this library. Otherwise, the function attempts to use the nilsdev command line tool.

Because nilsdev returns both DAQmx and Scope devices, the list of DAQmx devices is queried to remove them from the returned list. If the user code has already queried them, it is possible to pass them to avoid unnecessary double query.

Parameters
  • daqmx_devices (list, optional) – the list of DAQmx devices.

  • verbose (bool, optional) – sets verbosity level