LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sampling rate problem (beginner)

Hello,

  We are trying to develop a simple program for evaluating tibial strain using strain gauges, and we think we have the right setup as far as using the DAQ assistant and using the "Write to Spreadsheet" vi to extract values to Excel, but we can't seem to figure out how to continuously sample the data until our desired stopping point. Right now, we have the settings at "Continuous Sampling", with Samples Read at 10k and Sample Rate at 1k, and as expected, this only takes data down for 10 seconds. Could anyone tell us how to simply adjust the .vi (attached) for continuous sampling until we hit stop? Thanks so much.

 

 

0 Kudos
Message 1 of 8
(2,896 Views)

Right, if you're taking 10K samples at a rate of 1KHz, you're only going to take 10 seconds worth of data before you have taken them all. Do you really need to have data every millisecond? I'm not terribly familiar with kinesiology, but it seems like you could go a lot slower for that type of measurement. Does your strain gauge even respond that fast? At a sample every tenth of a second, you've got about 2 hours and 46 minutes until you've taken 10K data points. By that time, the subject has got to be tired. I would be, anyway.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 8
(2,888 Views)

What you are trying to do will be much easier if you do not use the Express VI. What you want to do it create a task and set up everything and then capture n sample in a while loop until you want to stop. The Express VI is doing that for you, but everytime you run the loop you will experience the overhead of setting up everything all over again on every loop. This may not get you the performance that you want. Please take a look at the example examples/Hardware Input and Output/DAQmx/Analog Input/Stain - Continuous Input  which is located in the example finder. This will show you how to set up your channel and how to setup your aquisition in a loop.

 

You may come up against a wall if you are trying to write all of your data to a file after aquiring the data before starting another aquisition loop. At that point you will want to look at a Producer Consumer architecture which you can find many tutorials and examples by searching for that term on the NI website.

0 Kudos
Message 3 of 8
(2,886 Views)

Hello Psatkun, and welcome to the forums!

 

You're currently writing to the file once outside of your primary acquisition loop- due to dataflow this means that you'll only export the last loop's worth of data to the file.

 

If you want to continuously record data, you need to either A) write to the file inside the loop (slower), or B) buffer the acquired data and write to the file after a period of time (more memory used).  If you write to the file inside your loop, you'll also want to specify a file path via a control or constant.  Otherwise you'll be prompted to pick a location each iteration.

 

This example does something similar to what I believe you're looking for, but uses the lower-level DAQmx API rather than express functions:

 

LabVIEW Example: Continuous Acquire & Graph Voltage - Write Data to Spreadsheet File (CSV)

http://zone.ni.com/devzone/cda/epd/p/id/5345

 

Searching for examples related to your task on ni.com or Google is often a good idea- a little search-fu goes a long way!

 

Regards,

Tom L.
0 Kudos
Message 4 of 8
(2,880 Views)

As asked before, how fast do you need to sample? What are the specs for the strain gauge? You do need to sample at least twice as fast as your signal, so if the strain gauge responds at 500Hz then 1000S/sec is appropriate. A previous post was a bit incorrect in the math, sampling at 1/10 of second, means 10 samples/sec, so 10,000 samples would be 1000 seconds, a bit closer to 1/2 hour than 2.7hrs.

How long do you need to sample? As the other post said, using ExpressVI's is probably not the way to go. Do a little digging and see how to set up to read your DAQ directly, either using a "Task", which can be set up in MAX, or directly reading the DAQ input using NI-DAQmx vi's from the Measurement I/O palette. You would set up the acquisition outside your loop, where you would set the range and sample speed, but not total samples, then inside your loop you would probably do signal samples and build an array of values, storing on a shift register on the edge of the loop. These values could be displayed on a graph within the loop, and the result then saved to a file when the loop is terminated.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 8
(2,876 Views)

@LV_Pro wrote:

As asked before, how fast do you need to sample? What are the specs for the strain gauge? You do need to sample at least twice as fast as your signal, so if the strain gauge responds at 500Hz then 1000S/sec is appropriate. A previous post was a bit incorrect in the math, sampling at 1/10 of second, means 10 samples/sec, so 10,000 samples would be 1000 seconds, a bit closer to 1/2 hour than 2.7hrs.



Sorry, I slipped a decimal place there, it should have been 16 minutes, 40 seconds. It's been a long day, but I bet if I were pushing hard enough for my tibia to flex measurably against a strain gauge continuously for that long, I bet I'd still be getting tired.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 6 of 8
(2,869 Views)

Or, maybe, you were thinking with your tibia?

 

Lynn

0 Kudos
Message 7 of 8
(2,858 Views)

@johnsold wrote:

Or, maybe, you were thinking with your tibia?

 

Lynn



Hmm, maybe. I did bruise it pretty good last night on a toolbox, and if I were trying to use that damaged organ to think with, things shouldn't be expected to come out right. I have been called a "bonehead" in my day Smiley Very Happy .

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 8 of 8
(2,851 Views)