Basic usage is presented here. For further details, see the documentation.
The first step to starting the measurement is to create an acquisition object. Depending on your measurement hardware, you can select the appropriate acquisition class.
In this example, we use the LDAQ.national_instruments.NIAcquisition
class, which is
a wrapper for the National Instruments DAQmx driver. The class accepts the name of the input task (created in NI MAX) as an argument:
acq = LDAQ.national_instruments.NIAcquisition(input_task_name, acquisition_name='NI_data_source')
The acquisition_name
argument is important when using multiple acquisition objects in the same measurement, and when specifying the layout of the
live visualization.
The acq
object can now be added to the LDAQ.Core
class, which handles the acquisition and generation of signals, and the live visualization of the measurement:
ldaq = LDAQ.Core(acquisitions=[acq])
Note
To add live visualization of the measurement, the visualization LDAQ.Visualization
object can be added to the LDAQ.Core
object:
ldaq = LDAQ.Core(acquisitions=[acq], visualization=vis)
Read how to prepare the vis
object in the visualization section.
Often the measurement is started when one of the signal excedes a certain level. This can be achieved by setting the trigger on one of the data sources by calling the set_trigger
method:
ldaq.set_trigger(
source='NI_data_source',
level=100,
channel=0,
duration=11,
presamples=10
)
Where:
source
: the name of the acquisition object on which the trigger is set.level
: the trigger level.channel
: the channel on which the trigger is set.duration
: the duration of the trigger in seconds.presamples
: the number of samples to be acquired before the trigger is detected.
Note
The LDAQ.Core
may seem unnecessary when using a single acquisition source.
However, it enables the usage of signal generation, live visualization and multiple acquisition/generation sources.
The measurement can now be started by calling the run
method:
ldaq.run()
After the measurement is completed, the data can be saved by calling:
ldaq.save_measurement(
name='my_measurement',
root=path_to_save_folder,
timestamp=True,
comment='my comment'
)
Where:
name
: required, the name of the measurement, without extension (.pkl
is added automatically).root
: optional, the path to the folder where the measurement will be saved. If it is not given, the measurement will be saved in the current working directory.timestamp
: optional, add a timestamp at the beginning of the file name.comment
: optional, a comment to be saved with the measurement.
- Add signal generation to the
LDAQ.Core
object. (see generation) - Add visualization to the
LDAQ.Core
object. (see visualization) - Apply functions to measured data in real-time visualization. (see visualization)
- Apply virtual channels to acquisition objects, to perform calculations on the acquired data. (see virtual channels)
- Add multiple acquisition and signal generation objects to
LDAQ.Core
. (see multiple sources) - Define a NI Task in your program and use it with LDAQ. (see NI Task)
- Create your own acquisition class by overriding just few methods. LDAQ support signal as well as video acquisition sources. (see custom acquisition)
- Currently the package supports a limited set of devices from National Instruments, Digilent, FLIR, Basler and devices using serial communication. (see supported devices)