start a multi-凯发k8网页登录
this example shows how to set up and start a multi-trigger acquisition on an external event. in this instance, the device is configured to start acquiring data on a rising edge signal.
create a dataacquisition and add analog input channels
create a dataacquisition object, and add an analog input channel with the voltage
measurement type, using an ni pcie 6363, with id dev4
.
dq = daq("ni"); addinput(dq,"dev4","ai0","voltage");
configure the dataacquisition to start on an external trigger
configure the device to acquire data on the external trigger. a trigger that starts an acquisition is called a start trigger. in this example, the switch is wired to terminal pfi0
on device dev4
. represent this physical connection (between the switch and terminal pfi0
) as a start trigger.
add digital start trigger
a trigger has a trigger type (digital
). the allowed value for the digital
trigger type is starttrigger
.
a trigger has a source and a destination. in this example, the source is the switch (choose 'external'
as the source). the destination is the pfi0
terminal on dev4
('pfi0/dev4'
). use addtrigger
to add this trigger on the dataacquisition.
addtrigger(dq,"digital","starttrigger","external","dev4/pfi0"); dq.digitaltriggers
ans = digitaltrigger with properties: source: "external" destination: 'dev4/pfi0' type: 'starttrigger' condition: 'risingedge'
set trigger parameters
by default the dataacquisition waits for 10 seconds for the rising edge digital trigger. increase the timeout to 30 seconds using digitaltriggertimeout
property.
dq.digitaltriggertimeout = 30;
you can configure a dataacquisition to receive multiple triggers, when it should respond to multiple events. in this example, two external trigger signals are expected, enabling the device dev4
to start acquiring scans on receipt of the second trigger.
dq.numdigitaltriggersperrun = 2;
start the acquisition
use read
to acquire scans on receipt of each configured digital start trigger. the specific sequence of events is:
the dataacquisition starts
one second of actual acquisition begins on receipt of the first trigger unless the timeout period expires
one second of actual acquisition begins on receipt of the second trigger unless the timeout period expires
data is returned
[data, starttime] = read(dq, seconds(1));
plot the data
observe the discontinuity based on the time between the two trigger starts.
plot(data.time, data.variables, '.')