Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Stopwatch/Timer for front panel (resetable)

Solved!
Go to solution
Hi,

I am fairly new to Labview and programming in general, but I'm slowly learning the basics and am setting up a jet engine test cell engine monitoring system using a Daytronic System 10 acquisition unit.  I am almost finished with the VI that I have created (it works, too!), but now I am trying to set up a simple, real-time, running clock and stopwatch/timer for use, not in timing system events, but for timing external events.  We are currently using a handheld stopwatch, but it would be much easier to have something on the screen in front of the engine operator that we could click on to start/stop, and reset.  It seems that all the included VIs are for timing events in the VIs.  Any help would be appreciated!

Todd Munsell
Turbine Engine Test Cell Tech
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 1 of 26
(39,254 Views)
Hi Todd,

Since you want your stopwatch to be responsive to user input, it makes most sense to have this part of your application on your host computer.  This way you don't have to worry about any delays caused by network communication.  I put together a simple example that uses computer's system clock and an event structure to allow the user to have simple stopwatch functionality.  Hopefully you can adapt this to meet your needs!

Edit: I reread your post and noticed that you wanted start/stop and reset.  I'm guessing this means that you would like to be able to pause and resume your measurements, which my example doesn't allow for.  You could accomplish this by temporarily storing the value of the stopwatch when the stop button is pressed.  You would then add this value to the values obtained after the clock is restarted.  Clicking the reset button would reset this temporary value to zero.
I don't have time at the moment to implement these changes, but hopefully you can figure it out.  If not, let me know and I'd be happy to make the changes for you.

Regards,


Message Edited by Devin_K on 01-14-2008 05:40 PM
Message 2 of 26
(39,236 Views)
Thank you!  This will work perfectly.

I do have one more question..... I have been wanting to draw some lines on the front panel to seperate areas.  The help says to use the decorations pallette, but I cannot find it on the menu.  Maybe it wasn't loaded during installation.  If not, is there a way to load it without reloading the entire program?

Thanks again!

Todd
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 3 of 26
(39,233 Views)
Todd,

I'm glad that helped!

In regards to the decorations palette, you should be able to access these by right-click on the block diagram or going to View >> Controls palette and then navigating to Modern >> Decorations.  If the palette isn't there, I would try repairing your LabVIEW installation by going to Windows' control panel, double clicking Add or Remove Programs, going to National Instruments in the list of software, clicking Change/Remove, going to LabVIEW, and clicking Repair.
0 Kudos
Message 4 of 26
(39,216 Views)
Once again, thanks for the help.  I was able to find the decorations.  This task has definitely been a learning experience for me!  Of course, I've always like venturing into the unknown. LOL  I'm also a self-taught mechanic, machinist, welder, and PC repair technician (for 22 years), among countless other hobbies.  Reading a lot of literature helps, but so does the assistance I receive in forums like this one.  The more I learn about LabVIEW, the more I realize that I'm just scraping the tip of the iceburg with a toothpick when it comes to it's capabilities.  I've got a new book and DVD on order which should help out, too.

Thanks again!  Your help has saved me hours of searching for answers.  Kudos!

Take care,

Todd

PS, I had to do a bit of tweaking on the timer to display time in just minutes and seconds, but that was easy.  I've added it to the front panel of the project and it's working fine.  I may have a few more questions in the near future.


Message Edited by tmunsell on 01-15-2008 03:35 PM

Message Edited by tmunsell on 01-15-2008 03:36 PM
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 5 of 26
(39,213 Views)
Todd,

You're very welcome.  You'll find that these forums are a great place to learn for both beginners and more experienced users!  Good luck in the rest of your application!
0 Kudos
Message 6 of 26
(39,196 Views)
I've got one more question....

Why is it that when I insert the timer subVI into my main VI, the main VI won't run continously?  It will update when I click abort then run, but then stops updating the data.  I tried placing the timer vi both inside and outside the main vi's while loop with the same results.

Thanks.
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 7 of 26
(39,150 Views)
Todd,

Can you attach your main VI?  It makes sense why your main VI would not continue to run if the sub-VI was located in the main VI's while loop, since execution of the loop would not continue until the sub-VI is closed.  However, it would be easier to see your application to figure out what is going on in the case where the sub-VI is outside of the loop.

A good tool for debugging your applications is the "Highligh Execution" button on the block diagram toolbar (looks like a little lightbulb).  This allows you to follow the flow of your program and determine why things happen like they do.
0 Kudos
Message 8 of 26
(39,118 Views)
Sure,  I've attached a copy.

I'm also still working on the problem with the data becoming "scrambled" whenever I run another application on one of the other PCs that is accessing the Daytronic unit.  If I just run the Labview app, it works fine.  If I start either the system using the Wonderware DDE software, or the Autonet system, the Labview gets garbled data.  I'm thinking that it has to be something with the Daytronic settings, but then why would the other PCs work fine together?  I'm stumped on this one.....

Thanks.

PS.  This copy of the VI has had the timer removed already.


Message Edited by tmunsell on 01-22-2008 06:07 PM
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 9 of 26
(39,116 Views)
Todd,

I have no experience with your Daytronic hardware, so I'm afraid I can't be of any help with that problem.  I see you've created another thread on that topic, so hopefully you receive some help there.

The problem you were having with the sub-VI is due to the priority levels you have set for your main VI (go to File >> VI Properties and then Execution from the drop-down list).  The way you have it set up, your main VI is set to high priority and your sub VI is set to normal priority.  High priority code will always execute before lower priority sections.  In order to allow lower priority code to execute, you would need to make your high priority code "go to sleep".  You can accomplish this by using a timed loop or adding a Wait function inside your loop.  The way it is set up now, as soon as a loop iteration in your main VI finished, the next iteration will start, allowing no processor time for the sub-VI.  The same principles apply when you are setting up real-time code (you should only have one time-critical loop, with other lower priority loops for communication, data logging, etc..), and it becomes even more important there to consider how higher priority threads can monopolize the processor if they aren't put to sleep long enough for other code to execute.

My advice would be to change both your main and sub-VI to normal priority, and to call the sub-VI outside of your main loop (otherwise you will run into the problem I described in my previous post).  You should also consider adding a short delay (Wait (ms) VI or Wait Until Next ms Multiple VI) at the end of your main loop to ensure it is allowing parallel code to execute, and to make it more responsive to your input.  Who knows, it's possible that the repeated access to your Daytronic hardware is causing the other problems you are having.  Slowing down the rate at which your loop executes might help things.

0 Kudos
Message 10 of 26
(39,093 Views)