From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to take this simple timing VI and make it a state machine? HELP please....

Here's the structure I'm fond of (has the three states I need user controlled; Start, Pause, Reset in a handy 3-position slider).  I'd like to incorporate this into a state machine that has a boolean input for the 'fatal error' which would enable a fourth state, another 'pause' if you will, that would not restart unless a button was pressed AND the boolean condition was reset to false.
 
Can someone give me some detailed guidance?  My back is to the wall and I've been chipping away at the big picture for over a month now.  I really need to get this implemented and don't have the time left to truly learn shift registers and the other things needed for a state machine...  Help...  Please....  I wish I had the time to go back and learn shift registers and such from the ground up but this has to be implemented ASAP.
 
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 1 of 9
(3,037 Views)
Can you included the subvi stopwatch??

Thanks

Kenny
Kenny

0 Kudos
Message 2 of 9
(3,025 Views)
Will do in the morning.  Thanks for your assistance!
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 3 of 9
(3,015 Views)
Actually Kenny, I got it from this other thread..  This should link right to that subVI: http://forums.ni.com/attachments/ni/170/189528/1/Stopwatch.vi
 
Thanks SO much!
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 4 of 9
(3,013 Views)
Here is my best guess at what you want.  I added a button to try and clear the error state and an led to indicate being in the error state.  I also wiped out your while loop around the fatal error because it was not necessary.
 
Good luck,
Belzar
0 Kudos
Message 5 of 9
(3,006 Views)
Belzar!  That is exactly what I wanted and it works GREAT as a stand-alone timer.  However, when I use multiple instances of it at once, the sliders seem to lose some functionality and the boolean 'fatal error' being transferred via local variable doesn't seem to enact the stop as it should.  Are there additional considerations when using more than one of these state machines/sliders?
 
I've attached my complete VI for reference.  I'm not sure what to change to give each control/boolean input/timer individual funtionality.
 
What's happening right now:
 
Any slider/selector will reset and start all 6 instances of timers
The boolean condition 'true' from my '...current overtemp' does not stop the timers
None of the 'pause' functions seem to work.  It will pause ALL the timers for a couple of seconds and then they all continue.
 
Seems that somehow I'm missing some kind of separation, and I'm not quite sure how to get that discreet control that I need.  It worked GREAT alone but in a multiple setting has lost some control.  I'm really, really under pressure to have this thing running today, please advise!
___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 6 of 9
(2,992 Views)
Ralph,

Since you use the same Stopwatch VI for all the timers, it gets reset whenever one instance is reset. You may be able to get around this by making it reentrant. (VI Properties >> Execution >> Reentrant execution). This creates its own set of issues and will require some thought and planning to make it work. Each instance of a reentrant VI has its own data space, so the four copies in each of the loops would operate independently of each other, which is not what you want, I think.

Another approach is to make a different Stopwatch VI for each loop. (StopwatchR3H5.vi, StopwatchR2H1.vi, etc.) Just do Save as with new names (and be careful about replacing all copies in memory). The replace the Stopwatch VIs in each loop with the appropriate copy. This is probably the fastest way in the short term and you said you have a deadline.

Still another way would be to eliminate the loop in the Stopwatch VI and put shift registers in each of the independent loops in the main program for the Puased, Elapsed Time and Absolute Time variables for that loop. The Stopwatch VI would still perform the Start, Pause, Reset functions in the case structure but would not save the data locally.

You have no means of stopping the independent loops. Do not get into the habit of using the Abort button for that purpose. It is there to let the programmer force a VI to stop while developing. You should have a Stop button on the front panel that shuts everything down in an orderly manner (resets external hardware to a known, safe condition, closes files, etc.)

Lynn
0 Kudos
Message 7 of 9
(2,987 Views)
I've attached a new stopwatch vi and your original vi with the top left timer set up to use this new timer.  It follows the suggestion in Lynn's third paragraph.  You'll have to duplicate it for the other timer loops.

I wired sloppily, but it should function.

Good Luck,
Belzar
Download All
0 Kudos
Message 8 of 9
(2,980 Views)

Thanks guys.  I *think* once I get this transferred over to the actual DAQ pc that I'll have a functioning setup, even though it's a processor hog right now.  At least I can get it up and running today to get the boss happy and then I can relearn and refine on the laptop in my personal time.  When it comes to software I have to know it implicitly before I'm happy so my learning isn't going to stop at this point simply because the project is up and running.  You guys bailed me out big time and now I can breathe a bit and dive into the 'right' way to do this stuff.

Fingers are crossed, I'll be dropping in the DAQ and NI-Switch stuff this afternoon and hitting the go button.  Hopefully everything goes smoothly!  THANKS!

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 9 of 9
(2,974 Views)