From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

nidaqmx usb bnc 2110 trigger speed

Solved!
Go to solution

Hello,

 

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.

 

Cheers

fabi21

 

 

 

import nidaqmx as n
import time
from nidaqmx.constants import (
TerminalConfiguration,
VoltageUnits,
AcquisitionType,
TriggerType,
Edge
)
s_freq = 100000
num_samples = 1


task = n.Task()


task.ai_channels.add_ai_voltage_chan("/Dev3/ai0")

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
task.triggers.start_trigger.cfg_dig_edge_start_trig("PFI0",trigger_edge=Edge.RISING)

 

for i in range(5):
       starttt = time.time()
       task.start()
       print(time.time() - starttt)
       data = task.read(timeout=1.0)
       print(data)
       task.stop()

print(time.time() - startt)
task.close()

0 Kudos
Message 1 of 3
(675 Views)
Solution
Accepted by fabi21

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.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 3
(657 Views)

Hi Kevin,

 

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.

 

Cheers

fabi21

0 Kudos
Message 3 of 3
(643 Views)