LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI not understaing Main controls

Hello,

 

I have this LabVIEW project I have been working on in order to get more experienced with LabVIEW. The project consists of a clock application similar to those found in smartphones.

 

My main problem right now is that the stopwatch.vi works perfectly fine on its own, but when I tried to send either one of the play, pause, stop, or lap commands from the Main.vi it seems like the stopwatch.vi its not "seeing" the commands being sent.

 

Since I recently got introduced to how refnums are used, I'm thinking that may solve the issue here but everything is starting to get too convoluted so I preferred to ask here first.

 

This is still an on-going personal project so if you have any tips to make this more formal or better looking please let me know. I was thinking on adding clusters to get rid of the so many separate controls I have in the block diagram.

0 Kudos
Message 1 of 3
(1,365 Views)

It is difficult to give advice unless you tell us exactly how you are running it, how you are interacting, what you see, and what you expect to see instead.

 

In the mean time, you should go back to the tutorials and learn about state machines. A typical program only needs one outer while loop and one case structure with a case for each state. (e.g. looking at your "stopwatch.vi" you have loop inside case inside loop inside case inside loop (whew!). Not good! Not scalable! Too convoluted to debug)

 

You have a stop button on the main VI and on the subVI. When you call the subVI, the boolean goes to the subVI, The new main control will only get read the next time the case executes, i.e. after the subVI has completed. Learn about dataflow! A clumsy way would be to create references instead of values, but there are probably much better ways!

0 Kudos
Message 2 of 3
(1,350 Views)

The way it should work is as follows:

 

If you open the stopwatch.vi and run it, you first have to press play and the stopwatch starts running. Then, "pause" pauses the vi, "stop" stops the vi, and "lap" registers the current time and saves it in an array.

 

The problem is that none of the controls work from the main.vi

 

In the meantime, ill look the statemachines to try to simplify my code:) thanks!

0 Kudos
Message 3 of 3
(1,327 Views)