Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Taking a measurement for x amount of time NI myDAQ

Solved!
Go to solution
Hi, I hope I'm posting this in the right area, this is my first time on these forums and first time working with Labview. I need to measure a voltage sample for a specified time when I click a button. There are two problems with my program... 1. The button has to be pressed before I run the program, but I would prefer the button be pressed after I start running the program 2. The program seems to grab hundreds of samples and each time it does I believe they are just rewriting over each other instead of graphing my data from a full 60 seconds of measurement. Here is my program, sorry if this is choppy, but I'm still learning the basics. Thank you
0 Kudos
Message 1 of 7
(3,406 Views)

Welcome to the forums, paynes2!

This is a good place to get answers for myDAQ, but there is another forum for myDAQ as well you can post in.

 

For now, several of us want to help, but I can't find your program you thought you posted.  Can you post it again?

 

-gaving

 

0 Kudos
Message 2 of 7
(3,400 Views)

Sorry about that I'll try again.

I already fixed the button issue. I just didn't have my whole program in a while loop.

Thanks for your time.

0 Kudos
Message 3 of 7
(3,398 Views)
Solution
Accepted by paynes2

I didn't know which version of LabVIEW you are using, so I just took a picture of the block diagram after I added a few changes.  You should do all of your configuration outside the loop, then just start and stop the task inside the loop.  If you only want to get a second's worth of data, just wire your rate into the "samples per channel" input in the DAQmx Timing (Sample Clock) VI.  When you wire that to the DAQmx Read, you will wait until you get all of the samples.  There's also a "Wait Until Done" that you could use and then read.  Anyway, there are several ways to do it.  I thought I'd just suggest doing the configuration once and then using stop-start in a loop.

 

-gaving

mydaqpushbutton.jpg

Message 4 of 7
(3,381 Views)

So if I wanted to take a sample for a certain amount of time, say 60 seconds, what would I do to modify that?

Thanks for the help I really appreciate this.

0 Kudos
Message 5 of 7
(3,366 Views)

 


@paynes2 wrote:

So if I wanted to take a sample for a certain amount of time, say 60 seconds, what would I do to modify that?


 

The above example takes 1 second worth of data.  This is achieved by wiring the sample rate to the samples per channel.  For instance, if we are running at 1000Hz (or samples per second), we can then ask for 1000 samples.  If you want 60 seconds, you can multiple the sample rate by 60 (be sure to increase the timeout on the DAQmx read to >60 seconds).  Or you could loop on the read and put the start stop outside that loop.  It depends how responsive you want your application to be.  If you just want the data, read 60000 samples once with a big timeout, if you want to see some of the data on the front panel, read smaller increments which eventually adds up to 60000.

 

make sense?

 

-gaving

Message 6 of 7
(3,338 Views)

Thanks,

This makes a lot of sense.

Program is working!

0 Kudos
Message 7 of 7
(3,334 Views)