LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up a stop watch

Hi, could somebody please help me with setting up a stopwatch in my program to count time? I've attached my VI and it includes my attempt at trying to set up a stopwatch. The problem is that it is counting but my program doesn't seem to stop and data is aqcuired when the VI is run once. SO I'm not getting continuous data acquisition. Also, I can't seem to stop the program. I have to abort it. I would really appreciate anyone's help on this.
 
Thanks
 
 
 
0 Kudos
Message 1 of 14
(4,340 Views)
Do not keep a seperate Loop for your timing functions
 
Incorporate the tick count function and subtraction inside your acquisition loop itself.
 
By the way, what time do you want to count?
 acquisition time??
time taken for each iteration of while loop??
0 Kudos
Message 2 of 14
(4,325 Views)

Thank you for your reply.

I've done what you've suggested and attached is the modified VI. The only problem now is that the count is not continuous, meaning that when I run the program, the timer starts counting like 2, 4, 6, 7 etc... it isnt continuous. I am basically trying to time the data aqcuisition from from moment the VI is run till the moment it is stopped.

0 Kudos
Message 3 of 14
(4,322 Views)

You are counting the time. What you are seeing is the time it takes for your loop to iterate and that time is something greater than a second. You are doing an awful lot of unnecessary things in each loop. Each of your tasks (analog out, analog in, and digital output) are started and stopped each time the loop repeats. The analog out has an extra start and stop because you have a DAQ assistant there to set the voltage to 0 with each loop. Move the setups for the tasks (channel creation, timing, start task, etc) outside the loop so they run once, when the VI starts. Put the cleanup functions outside the loop so they only run once when the loop finishes.

It's also hard for me to tell how many samples you are taking and the sample rate you are using. It seems that you might be specifying number of samples that is greater than the sample rate.

Also, clean up your wiring a bit. You've got some hidden wires, wires underneath objects, wires that don't go straight to exit tunnels, etc.

0 Kudos
Message 4 of 14
(4,315 Views)
Hello,
 
thank you for your suggestions. I have made the changes and tidied up my block diagram. The stop watch works now but the only issue now is that the interface just displays the results the first time round the data is acquired i.e. when the Vi is run the first time round. The reason why I had put everything in a loop was because everytime  a new set of data was acquired, the interface would display the results and save all the data that is  acquired not only the first set.. Now, I can only save and display the first set of data. Any suggestions to this issue wil be appreciated. I've attached the modified Vi.
 
Thanks
 
0 Kudos
Message 5 of 14
(4,292 Views)
Your while loop with the DAQ has a false constant wired to the termination terminal and the termination terminal is set to 'Continue When True'. That means that the while loop only iterates once. You can place the timing code inside the main loop along with your stop button. Change the mode to Stop When True. You should not have moved the file write and the build graph code outside then loop. They way you have it now, it will only build the graph and write to file when the while loop finishes and even then, you will only get the results from the last iteration.
0 Kudos
Message 6 of 14
(4,280 Views)

Thanks alot for the suggestions but I can't seem to open the file. I am actually using Labview 7.1. Maybe its saved in a different version.

 

0 Kudos
Message 7 of 14
(4,279 Views)
Sorry about that. I wan't paying any attention. Lets try it again.
0 Kudos
Message 8 of 14
(4,268 Views)

Thanks for that. I can now open the VI. I've just tested it using my electrical circuit and it seems to work fine. However, the only issue now is that the timer is not counting the seconds continuously as in like 1, 2, 3 etc. Its counting the seconds in a discontinuous way like 2, 3, 5, 7, 10, 13 etc. Is there a way to make it count continuously?

Thanks

0 Kudos
Message 9 of 14
(4,219 Views)

Actually, I just realised what the problem is. The timer counts depending on how much time it takes for the data to be acquired. For example, depending on how I set my parameters, if it takes 3 seconds for the data to be acquired, then the stopwatch counts every 3 seconds like 3, 6, 9 and so on. If it takes 1 second for the data to be acquired, then the stop watch counts continuously. Is there a way I can implement the stop watch without it depending on the time that data is acquired? I think that the reason its depending on the data acquisition time is because the stop watch is implemented in the same while loop as the data acquisition.

 

Thanks

0 Kudos
Message 10 of 14
(4,217 Views)