LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display and record elapsed time during instrument reading

Solved!
Go to solution
I have been programming Labview for a total of two days so please bear with my inexperience. I have a 9201 module that takes a voltage reading and plots it on a graph. I click a boolean switch and the graph begins reading and saves data every 3 seconds. When I click that same switch i would like to start a timer. Then once the button is clicked again I need to stop the timer and save the elapsed time. I have tried to used the elapsed timer function but cannot figure out how to get it to work inside of my main while loop. I am not sure if I need to use a sub-vi or something else all together. I have attached my entire project which might make the question easier to understand. Thanks in advance for any help.
0 Kudos
Message 1 of 22
(8,444 Views)

I think what you really need is a couple of tick count nodes.  They are in the same palette as the elapsed time VI.

 

Step 1 is to put the first tick count where you want the timer to start.  The one problem with the tick count object is that it doesn't have any other pins, so you might even have to use a flat sequence just to get the order of execution correct.

 

Step 2 is to put the second tick count where you want to know the elapsed time.  Same rules as step 1.  This one will probably be in a loop.

 

Step 3 is to subtract the Step 1 ticker for Step 2.  That will give you the number of milliseconds.  If step 2 was in a loop, the subtraction should be too.

 

Step 4 is to write back if you have more questions.  🙂

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 2 of 22
(8,427 Views)
I checked out the tick counter and that looks perfect for what I want. However I don't understand how to put two counters in loops. In other words how do I trigger the first one, save the value and then trigger the other later (then do the math on the difference). When I place the tick in a loop I can see it counting to an indicator but I just don't understand how to translate that to a variable. Thanks for the guidance.
0 Kudos
Message 3 of 22
(8,421 Views)

I can't look at your code because I only have 8.2 here 😞

 

I thought you only had one loop (the one that takes the data)?

 

What you want to use is the subtract node and connect it directly to the tick count -- don't use variables or altenbach will come in here and beat on you (just kidding).  Actually, I think he would agree that using variables would almost guarantee that you get the wrong answer because of race conditions (but, since I can't see your code, I can't be sure).

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 4 of 22
(8,410 Views)
Maybe this will help, I tried to save as an older version. I am sure there are numerous coding atrocities so feel free to point them out!
Message Edited by icemaker on 05-28-2009 08:54 AM
0 Kudos
Message 5 of 22
(8,389 Views)
Solution
Accepted by topic author icemaker

I have changed your code (personnally I would not have done like that but I don't want too many changes in your code because you are a beginner in LabVIEW !).

 

- Now there are 2 loops : 1 loop for acquisition (while loop) and 1 loop for user interface operations (while loop + event structure : this is a very powerful structure in LabVIEW and you should have a look at some examples to understand the way it works)

- You will find a shift register used by acquisition loop : I explain what it is in the diagram...

- I have given you a VI which is nearly the same than "elapsed time" Express VI : maybe it will be worth trying too understand that when you get more experiment at LabVIEW (you will have to understand "functional global variables" and "reentrance execution" : those 2 stuffs are used by "elapsed time" Express VI (but also by the VI which I have included and which is nearly the same)

 

Note that I have shown the solution for 1 of the 4 graphs : you will need to do the same thing for the 3 others. You will also need to code elapsed time saving.

 

Again, the solution I have given to you is very far from perfection, but with 2 days of LabVIEW practice, it would be too complicated to explain the different architectures and means of communication between loops etc...

Message 6 of 22
(8,376 Views)
Excellent, I have been trying to set up those loops for quite some time with no success. Now I can see how the timing works by using the shift registers. One last question though, what is the best practice for referencing that time for use with the report? When I try to create>reference I can't seem to find any string of num that it is compatible with. Thank you very much for the help.
0 Kudos
Message 7 of 22
(8,365 Views)
I think I figured out the correct reference type, thanks.
0 Kudos
Message 8 of 22
(8,352 Views)

Right click "elapsed time 1 (s)" and then select Create > Property Node > Numeric Text > Text. You will get the string cooresponding to the numeric data.

 

Best,

Message 9 of 22
(8,332 Views)

Can you guys re-post your code in LV 8.0? 

 

"Elapsed Time" is the most worthless VI ever.  

0 Kudos
Message 10 of 22
(8,240 Views)