LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple time measurement

I have a simple question. Is there a resettable clock in LabVIEW 8.0? All I need is a clock that can go from 0 to 2500 ms a number of times but with a fast update time. I know there is the Tick Count but it doesn't update fast enough or start from zero.

Thanks,
Taylor
0 Kudos
Message 1 of 10
(4,123 Views)

What do you mean that the tick count does not "update fast enough"?

Can you explain what you actually want to do, and we will try to help you find a solution. 🙂

What is you OS? Multipurpose or RT?

0 Kudos
Message 2 of 10
(4,115 Views)

There's the Elapsed Time function. Simply set the target time to 2.5 and make sure auto-reset is checked.

Don't quite understand your comment about the fast update rate of the tick count. It will update as often as it is called (as will the Elapsed Time function).

0 Kudos
Message 3 of 10
(4,113 Views)
My problem is I have a cycle and if an external input does not reach a certain value within one second of a new cycle the program is supposed to abort. If it does reach that value within the second I need to record the time it takes from the new cycle to the activation time. I've tried Tick Count and the Elapsed Time but they both appear not to output time quick enough. It's difficult to explain but, is this any clearer?

Thanks,

Taylor
0 Kudos
Message 4 of 10
(4,107 Views)


@TOetelaar wrote:
... is this any clearer?

Sorry, no. It's not clearer!

Could you attach some code for us to inspect?

What kind of cycle? What kind of external input? How fast would be quick enough?

Tick count is fast. For example, the following simple code stops the loop once the current tick count is 1ms higher than the initial tick count. Running it, it does several thousand iterations before stopping. This means that "tick count" can easily execute several thousand times per millisecond.

Do you need a resolution that is better than milliseconds?

What do you mean by "output speed". If your code updates an indicator, this will occur in the UI thread and will not be syncronous with the code (and it does not need to be). Of course you can force "synchronous display" for an indicator, but this usually slows down your code significantly.

Message Edited by altenbach on 06-19-2007 11:09 PM

0 Kudos
Message 5 of 10
(4,103 Views)
Altenbach,

Iam attaching my program. All I need is a something to give me the time from the start of the iteration until the time the pressure switch is activated (under a second) so I can insert that into the build array in the middle of the loop.

Taylor
0 Kudos
Message 6 of 10
(4,072 Views)
Just though of a problem with my setup. How do I ensure the Elapsed Time starts at the begining of the counter output and only then?
0 Kudos
Message 7 of 10
(4,066 Views)

Your code makes no sense for this task (If I read it right).

Apparently, the pressure switch is taken in the upper DAQ train, which executes exactly once before the while loop starts, and then never again. So how can you possibly monitor an change in the switch??? And then meaure the time it took for the change???

From what I understand, both DAQ trains need to be inside the loop. Most likely, you can keep all the configuration outside the loop and only read the data from both tasks at each iteration.

Have you tried a simple tick count subtraction as in my above example image?

There are also many other very strange constructs that will most likely give incorrect and unexpected results. For example have a look at your FOR loop that uses an unititilized (!) shift register. The data you get will be completey unpredictable (e.g. if you run it with few iterations first and then with more iterations in a second run).

Message Edited by altenbach on 06-20-2007 08:58 AM

Message 8 of 10
(4,066 Views)
Altenbach,

I was wondering about the switch reading myself. I moved it inside the loop. And after I uploaded the program, I realized the error with my for loop but thanks anyway.

There are two major parts to my program -- the locking and unlocking of an arm done through the counter output and the reading of the pressure switch. When the arm is locked the pressiure switch is supposed to activate within a second. If it does I record the time from when the arm locks and when the switch activates. If not, the program is supposed to stop and indicate a failure.

Simple enough but it is the specific timing that is hanging me up. I am used to programming where time is not an critical issue.

Any further suggestions?

Thanks for all your help.

Taylor
0 Kudos
Message 9 of 10
(4,050 Views)

Hey!  You won't be able to get better than millisecond resolution using Windows.  However, one thing that you might try is using a counter to count the 100 kHz internal timebase of your card.  You can start the task when you want to initialize and read your count when your event occurs.  You know the timebase you are counting so you can easily convert the count to seconds.  The KB below talks about how to count the 100 kHz timebase available on most of NI's cards.

http://digital.ni.com/public.nsf/allkb/6DEDFD730618DB0286256E6800761910?OpenDocument

Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 10 of 10
(4,018 Views)