07-08-2022 06:25 AM
you can find my python code below. I'm currently trying to trigger a ni usb bnc 2110 daq card to acquire some data. The only code I could come up with is shown below. When testing it in this configuration it is working fine. However reading out the elapsed time gives me roughly 10 ms until the trigger is armed again because I restart the whole task. I the desired application I expect a trigger of 5 kHz. Does anybody has an idea if this works with the card and if it works how to accelerate the program. I thought so far about using a stream or using the trigger of 5 kHz as external clock to acquire data untriggered but according to the external clock. I have no idea if this external clock idea is possible neither how to implement it or how to implement the stream. If someone could help me with an example or an additional idea I would be very greatful.
import nidaqmx as n
from nidaqmx.constants import (
s_freq = 100000
num_samples = 1
task = n.Task()
startt = time.time()
task.timing.cfg_samp_clk_timing(s_freq, sample_mode=n.constants.AcquisitionType.CONTINUOUS, samps_per_chan=num_samples)
task.triggers.start_trigger.trig_type = TriggerType.DIGITAL_EDGE
for i in range(5):
starttt = time.time()
print(time.time() - starttt)
data = task.read(timeout=1.0)
print(time.time() - startt)
Solved! Go to Solution.
07-08-2022 11:36 AM
The BNC-2110 is just a terminal block with a cable to connect it to a desktop or PXI data acq board. It's the data acq board that determines the functionality. That said, odds are rather high that the data acq board at the other end is capable of supporting what you want. It's probably some variety of multifunction board, and AFAIK, they'd all be capable.
I don't know the Python API, but I *can* tell you that it's important to realize that DAQmx makes a clear distinction between a start trigger (which is a one-time event) and a sample clock (which is used to capture measurements from the A/D converter). The fact that you're configuring to capture 1 sample per task run suggests to me that you want your external signal at PFI0 to be used as a sample clock instead of a trigger.
You'll probably need to modify your call to "cfg_samp_clk_timing()" to include a parameter that designates PFI0 as your sample clock source and also configures a decent estimate of the sample clock rate (5 kHz?). You'd be changing your "num_samples" parameter too.
(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
07-11-2022 03:50 AM
thanks a lot for your answer. Indeed you are completely correct I somehow didn't recognize it within the function. In the cfg_samp_clk_timing() there is a source instance which allows you to take a external signal as sample clock.