LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there anyway to make the while loop to execute for only 25ms?

Hi,
 
I need to write data into the DAQ card continously for some 25ms of time. i have kept the Analog output vi inside the while loop to
continously provide the data to the DAQ Card.I want the control of execution inside the while loop should be there for 25ms then it has come out of the while loop. is there any way to do this??
 
Regards
Meenatchi
0 Kudos
Message 1 of 10
(3,013 Views)
You can read the timer value before entering the while loop and in each iteration. If the difference is bigger than 25ms, stop the loop.
0 Kudos
Message 2 of 10
(3,011 Views)
can u please send some sample program for this
0 Kudos
Message 3 of 10
(3,006 Views)
See attached image.
0 Kudos
Message 4 of 10
(3,004 Views)
Hi!
   I think this is not the best way.... Smiley Indifferent

   If you need to acquire 25ms of data, set a fixed number of samples, to have 25ms of acquisition.  For example, if you sample at 100 kS/s, you can set board to sample 2500 Samples. 


   I say this because usually, software timer (the one you use with tick count) is absolutely not accurate, since it is based on operating system tick.

   Hope this can help! Have a nice day!

graziano
Message 5 of 10
(2,999 Views)

My aim is to execute the loop for 25ms of time...even if i use Tick Count..i cant able to set the start time as 0.

 

0 Kudos
Message 6 of 10
(2,990 Views)
Hi!
   Can you clearify your task/needs? Or just post some basic code you've done, and post problems you encountered....

graziano
Message 7 of 10
(2,972 Views)
What DAQ card are you using?  If you can set the sampling rate and number of samples, then Graziano is exactly correct.  The hardware timer will give you the most accurate sampling timing.
Jim

LV 2020
Message 8 of 10
(2,963 Views)

Hi Meenatchi,

Let me check if I understand what you want; you want to write data continuously for 25 ms, so you are going to be setting up Analog Output task that will generate a voltage and you want this voltage to be outputted for 25 ms.  Before trying to help you I will strongly recommend taking a look at this resource: Getting Started with NI-DAQmx: Main Page.

Basically you have two options either you generate enough “samples”  with respect to you “rate” to generate 25 ms in “N Samples” generation mode or you try to control the data from the while loop. The best way of doing this is to change the “samples to write” to a number that will result in 25 ms.  I have attached a code that will help you accomplish this; you will need to adjust the code to meet your needs but is a very good place to start.  Controlling the while loop you will need to setup your task for 1 Sample (on demand or HW timed) and use the tick approach describe by (dan_u); also Instead of the “tick” function you can use the “Get Date/Time in seconds” with the same approach; the problem here is that is going to be software depended and it is not going to be deterministic so you will not get exactly 25 ms.

I either case if you choose to do software timing using "tick" or "Get Date/Time" you can keep posting in the thread, but if you have more question regarding hardware timing I will suggest posting in the "Multifunction DAQ forum".

I hope it helps.

Message Edited by Jaime F on 10-31-2007 02:42 PM

Jaime Hoffiz
National Instruments
Product Expert
Message 9 of 10
(2,923 Views)
What I might do is look at tick count at beginning of loop and on each
iteration of the while loop subtract the current tick count from the
one stored at the beginning. When >= to 25 exit the loop.

0 Kudos
Message 10 of 10
(2,881 Views)