LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect sampling when using DAQmx AI sample clock source

Hi everyone!
I would like your help in solving the following problem:
With the help of a Multifunction I/O counter, I want to output a finite number of N (for example 3) pulses to the output terminal of the counter (for example PFI4) and take exactly N samples from the analog input of the card. To do this, the output terminal of the counter is selected (connected) to the Sample Clock Source terminal of the card's Analog Input.
To generate the pulses I use the example VI 'Counter - Finite Output.vi' (added 'idle status') and to measure the analog input I use 'Voltage - Continuous Input.vi' (added 'Active edge' and 'AvailSamplPerChan property') from LabVIew -> Help -> Find Examples -> DaqMX ..
I first checked the counter with a scope and connected to the ai0 channel of the I/O card - here also Sample Clock Source == OnboardClock. The counter outputs the pulses well to its output terminal (PFI4). Then I switched the Sample Clock Source terminal to the counter output terminal (PFI4) and monitored the arrival of samples using the DAQmx Read AvailSamplPerChan property node. I saw the following:

- Instead of the three expected samples only two samples arrived at the AI!

- If I set the number of samples on the counter to two then two samples arrived on the AI.

- If I set the number of samples on the counter to one then not a single sample arrived!

- I even observed that in the case of several set samples, one sample does not arrive at the AI per pulse rising edge, but two at the same time with every other rising edge. Tried with several settings and on two cards, I experienced the same thing....

I have attached the source files.

 

Badsamplingfromextclocksource.pnge VI (LabVIew -> Help -> Find

 

Thanks in advance for your help. Merry Christmas...

Download All
0 Kudos
Message 1 of 2
(993 Views)

It sounds like you're probably thinking about this well and doing *most* of the right kinds of things, but perhaps there's just one little thing or two that needs to change.  Some more observations & thoughts below:

 

1. You should for sure start up the analog input VI before starting the counter output VI.  Maybe make an indicator for the iteration terminal 'i' in the loop where you query for "available samples"?  You should see that iteration count increasing rapidly while "available samples" remains zero for as long as you *don't* start running the counter output VI.

 

2. Then run the counter output VI.  It should run to completion on its own and then stop.  If set to generate 3 pulses, you should see the analog input VI show 3 available samples.

 

3. The analog input VI will wait for you to click one of your stop buttons, and then it will attempt to repeatedly read a hard-coded 10 samples per iteration until you click the *other* stop button.  This scheme is definitely not robust.  It'd be better to use the wire value from the "available samples" query to do a single one-time call to DAQmx Read that retrieves them.   No second loop for repeated reading.

 

Try doing things in this order with those changes and report back on how it went.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 2
(954 Views)