I have a USB-6212 board and a 200 kHz digital trigger signal from a laser. I am looking for a sequence that allows me to acquire four data points (analog voltage measurement from a photodiode at full sampling rate) after each trigger peak. Then, the card should wait until the next trigger peak and measure again four points. It should do this until a preset number of samples is acquired and then export them as an 1D-array without the need to permanently restart the measurement using a loop. It should be performed as much hardware-sided as possible to increase the effective rate of measurements.
I already read that the more expensive X series cards can perform retriggering relatively easy but I didn't figured a structure for my purpose. It would be very great if you could help me.
Thank you very much!
Solved! Go to Solution.
There's a workaround for your device that involves using its 2 counters to generate a hardware-retriggerable finite pulse train which the AO task can use as its sample clock. A high-level diagram of the idea can be found in item 3 over here. A simple working example can be found over here. (For that matter, just within the past few days I posted some partly-related code over here, though the other example will be a more fully relevant starting point for you).
Thank you, Kevin!
Your message was very helpful and I could implement the structure into my current measurement application. What is still unclear to me is how I can preset the number of the samples, that are acquired in total before the measurement stops. As far as I understood, the variable "samples per trigger" defines the number of samples that are acquired after a single external trigger signal is detected. But where do I select the number of samples that should be acquired in total?
Thank you very much and best regards
Probably the simplest way to pre-determine the total # samples to accumulate is to configure the AI task for Finite Sampling. If you wanted to collect 4 samples per 200 kHz trigger for 2 seconds, you'd configure DAQmx Timing for 4*200k*2 = 1.6 million samples.
You could start your tasks, call DAQmx Read with the same request for 1.6 million samples, and 2 seconds later it would return them to you. Because it's a Finite Sampling task, it would stop sampling on its own after acquiring the 1.6 million samples.
Really, you could also do pretty much the same thing using Continuous Sampling. You'd just have to manually stop the task yourself after reading the samples. However, at relatively high rates like yours, Continuous Sampling leaves open the potential for DAQmx to throw a buffer overflow error. It would be functionally irrelevant, but liable to be confusing or at least annoying. Best to avoid it with Finite Sampling.
Meanwhile, there's another way you could approach this task without need for the counters. Briefly: configure the 200 kHz signal to act as an external sample clock. Then construct a task where the channel list consists of the same one channel listed 4 times. You may also want/need to explicitly set the "convert clock" rate with a DAQmx Timing property node. (This is the clock that controls the multiplexer as the board selects each channel in the task in sequence. You'd be tricking it by selecting the same channel 4 times in a row, but the clocks don't know the difference.)