How to use
Bonsai.DAQmx
provides an interface for data acquisition and signal generation on NI hardware using four distinct operators.
In order to use any of the operators, you need to specify a collection of physical channels used to acquire or generate signals using the Channels
property. Depending on whether you are working with analog or digital signals the properties used to configure physical channels are slightly different. Channels can be automatically enumerated by the visual interface as long as you have the device correctly plugged and configured in the host computer.
Working examples for each of these operators can be found in the extended description for each operator, which we cover below.
AnalogInput
AnalogInput
configures and starts a data acquisition task for sampling voltage measurements from one or more physical analog input channels. Samples from each channel will be collected in a sample buffer, where each row corresponds to a channel in the acquisition task, and each column to a sample from each of the channels. The order of the channels follows the order in which you specify the channels in the Channels
property.
If no input source is specified, data will be collected asynchronously every time a new buffer is filled.
Alternatively, if an input observable sequence is provided, a new data buffer will be collected every time a new notification is emitted by the input source.
AnalogOutput
AnalogOutput
configures and starts a task for generating voltage signals in one or more physical analog output channels. Voltage samples for each channel are read from sample buffers in the source sequence, where each row corresponds to one of the channels in the signal generation task, and each column to a sample from each of the channels. The order of the channels follows the order in which you specify the channels in the Channels
property.
Signals can be generated continuously, where a ring buffer is constanty updated with new data arriving from the source sequence.
Alternatively, signals can also be generated with a finite number of samples, in which case the input buffers will provide samples until the specified buffer size is reached. In this case, the operator will wait for the task to finish generating the specified number of samples.
DigitalInput
DigitalInput
configures and starts a data acquisition task for sampling logical values from one or more digital input lines. Logical values will be collected in a sample buffer, where each sample can represent either a single line or a bitmask representing the state of all digital lines in a single port, depending on the configuration of the virtual channel. Each row corresponds to a channel in the acquisition task, and each column to a sample from each of the channels. The order of the channels in the sample buffer follows the order in which you specify the channels in the Channels
property.
Digital lines can be grouped as a port when creating the local virtual channel, either by specifying a range of lines (e.g. Dev1/port0/line0:3
) or by specifying an entire port at once (e.g. Dev1/port0
).
If no input source is specified, samples will be collected asynchronously every time a new buffer is filled.
Alternatively, if an input observable sequence is provided, a new sample buffer will be collected every time a new notification is emitted by the input source.
DigitalOutput
DigitalOutput
configures and starts a task for writing logical values to one or more digital output lines. Logical values for each line are read from sample buffers in the source sequence, where each row corresponds to one of the channels in the signal generation task, and each column to a sample from each of the channels. The order of the channels follows the order in which you specify the channels in the Channels
property.
Each logical value sample can represent either a single line or a bitmask representing the state of all digital lines in a single port, depending on the configuration of the virtual channel. Digital lines can be grouped as a port when creating the local virtual channel, either by specifying a range of lines (e.g. Dev1/port0/line0:3
) or by specifying an entire port at once (e.g. Dev1/port0
).
Signals can be generated continuously, where a ring buffer is constanty updated with new data arriving from the source sequence.
Logical values can also be provided by a source of integers specifying a bitmask with the state of all digital lines in a single port.
Alternatively, signals can also be generated with a finite number of samples, in which case the input buffers will provide samples until the specified buffer size is reached. In this case, the operator will wait for the task to finish generating the specified number of samples.