LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

use DAQmx to write program for synchronizing voltage measurement

Solved!
Go to solution

Sorry to jump in (mcduff should get credit for the solution).  I made a few minor (but important) changes to your code, shown below as a Snippet (you should easily be able to change them yourself on your version). 

ADC SubVI.png

Other than straightening some wires and making things more compact (and in order of importance):

  • I changed Samples/channel for the Timing VI to 125000, or one second of sampling at a time (you specified 2500000, or 20 seconds of sampling).
  • I wired this number to the DAQmx Read's Samples/channel.  This sets the Loop Timer to 1 second (125000 samples / (125000 samples/sec), so I got rid of the 10 msec timer.  You only have to "worry" if the other code in the loop takes > 1 second (which, in your case, it doesn't).  This loop will run at exactly 1 Hz.  If you need more frequent loop updates (say, you want it to update at 50 Hz), take fewer points/sample (e.g. 2500 Samples/channel).
  • The output of the DAQ Read is Array of Waveforms (a good choice!).  It makes no sense to convert them to a pair of Dynamic Data Wires (which should be banned from your code!), only to extract the data.  Better to simply Index Array and send the two Waveforms to be plotted (you can pull out the data if you want, but the plots will lose the "time" information).
  • I turned of the "Show as Icons" for the Indicators and the Stop control (much neater).

The second point is (probably) the one McDuff would suggest you learn first.

 

Bob Schor

Message 11 of 14
(342 Views)

@Bob_Schor wrote:

The second point is (probably) the one McDuff would suggest you learn first.

As would I.  I think the first point is often not particularly important.  For continuous acquisition, DAQmx autosizes up to a larger buffer size  when you request one it considers too small.  Do you find this surprising or non-intuitive?  Consider up-voting my complaint/suggestion about it on the Data Acq Idea Exchange.

 

I'd also amend the second point a bit.  With a high sample rate, I would make my buffer at least 2x as big as the # samples I was going to Read each loop iteration.   I would for sure not make it exactly the same size.  You need to allow a little breathing room for the driver to be transferring new samples into the buffer while your Read call is retrieving the ones you want, else you risk an unrecoverable buffer overflow error.

 

 

-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.
Message 12 of 14
(337 Views)

@Kevin_Price 

 

I'd also amend the second point a bit.  With a high sample rate, I would make my buffer at least 2x as big as the # samples I was going to Read each loop iteration.   I would for sure not make it exactly the same size.  You need to allow a little breathing room for the driver to be transferring new samples into the buffer while your Read call is retrieving the ones you want, else you risk an unrecoverable buffer overflow error.


Depending on the memory in my system I like making the buffer 4-8x the sample rate. Be careful if using the log only mode of DAQmx then buffer needs to be a multiple of the disk sector size.

 

mcduff

0 Kudos
Message 13 of 14
(333 Views)

Kevin and McDuff,

 

     Thanks for the clarification and correction!  I've probably never "pushed" the limits of my DAQ devices ...

 

Bob Schor

0 Kudos
Message 14 of 14
(311 Views)