LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

why cant I control the sample rate?

Solved!
Go to solution

I am sure there is a simple programming answer to this but I am drawing a blank. I would like to slow down my sample rate in the following block diagram, however changing the sample rate at my Sample Clock seems to have no effect. Any ideas? Thanks in advance for your help

 

 

 

help.JPG

0 Kudos
Message 1 of 9
(2,673 Views)

Since you are using the 1Chan 1Samp mode of the DAQmx Read, you are not using the sample clock. Your acquisition is software timed by the loop rate and your loop does not appear to have any timing at all.

 

p.s. If you want to attach an image, at least post it as a snippet (look it up). Hard to debug an image - especially one as hard to read as yours.

0 Kudos
Message 2 of 9
(2,666 Views)

Thanks Dennis,

 

I will look up snippets for the next time. 

 

 

I knew that I was missing an obvious mistake. This VI runs fine, so should I remove all the "Sync timing" and just use the loop for my control?

 

 

0 Kudos
Message 3 of 9
(2,658 Views)

Depends on what you want to do. The software timing is subject to a great deal of jitter so you can't depend on a constant time between samples. If you deploy this VI to a different computer/os, you may get far less or far more samples. for that matter, you might get far more or far fewer on this computer depending on what is going on in the background.

Message 4 of 9
(2,651 Views)

Thanks Dennis,

 

This is for a very slow event and I cant see a need to sample above 100Hz. Based on your explanation, I think I may be okay in this instance. What is the best practice for loop timing control?

 

0 Kudos
Message 5 of 9
(2,644 Views)

@griff32 wrote:

Thanks Dennis,

 

What is the best practice for loop timing control?

 


How about a Timed Loop?  It's one of the main structures.  You can also just drop the Wait.vi (Timing Palette) in your current loop.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 6 of 9
(2,636 Views)

@NIquist wrote:

How about a Timed Loop?  It's one of the main structures.  You can also just drop the Wait.vi (Timing Palette) in your current loop.


I recommend the Wait (ms) function over a timed loop unless you specifically need the timed loop behavior.  I just learned today (looking up something related to a different thread): "Each timed structure on the block diagram creates and runs in its own execution system that contains a single thread, so no parallel tasks can occur."  In a regular while loop, tasks can run in parallel.

Message 7 of 9
(2,624 Views)
Solution
Accepted by topic author griff32

The best practice is to use your hardware for timining.  Unless you are using an FPGA or (maybe) LabVIEW RT, your loop timing will be subject to the vagaries of the operating system, and these can be pretty bad (e.g. one or two second stall as the disk recalibrates or e-mail arrives).  I would highly recommend using a continuous timed acquisition on your DAQ board.  Fetch as often as you need to (every 10 or 100 points, for example).  The buffer size should be long enough to avoid OS problems.

Message 8 of 9
(2,598 Views)

Thanks Everyone for the help. I am going to change my code to use the best practice, which both Dennis and DFGray suggested and use the Hardware for my timing.

0 Kudos
Message 9 of 9
(2,594 Views)