LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm a beginner struggling with a simple task in programming, can someone help?

Very simple, if I can explain it right. OK, Lets say I have a VI with 3 string controls, 3 numeric controls and a Start and Stop button. 8 items total. Now, when I press the start button I want another front panel (separate VI) to open up which will display the 3 strings in string indicators and the 3 numerics in numeric indicators from the first VI. If I press the stop button, I would like to exit Labview (maybe with a double check 2 button dialog asking if the user would really like to quit, before labview actually exits). Can someone maybe walk me through this. I'm struggling with getting my start and stop buttons to execute these functions.
0 Kudos
Message 1 of 5
(3,079 Views)
Hello James,

I hope this helps.

Best regards
Gerd
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,079 Views)
What you�re asking is actually fairly simple. The part you may be having the most trouble understanding is how to get your application to run with a �Start� button rather than LabVIEW�s �Run� arrow on the tool bar. I�ll describe this based on LabVIEW 7, earlier versions should be the same for all of this.

To get your application to run with a start button instead of the run arrow, you�ll have to set the main VI up to run when opened. To do this, open the VI and navigate to the �File� menu and select �VI Properties�. From the �Category� pull down list, select �Execution� and check the box �Run when opened� and click OK and save the VI. Now whenever the VI is opened, it will automatically run. You�ll also need to setup the display subVI to show it�s
front panel when called. Do this by going into the VI properties of the data display subVI and selecting the �Window Appearance� category and click the �Customize� button. In this dialog, place a check mark in the �Show front panel when called� and �Close afterwards if originally closed�. Click �OK� twice and save.

The attached example does what you have described. It uses the event structure to watch for button clicks. The Event structure was introduced in LabVIEW 6.1, so if you have an earlier version, this won�t work for you.

Open the example and before you click any buttons, open the block diagram and turn on execution highlighting (the little light bulb on the toolbar). You�ll the diagram kind of gray out, showing the VI is running and waiting for you to do something. Now with the diagram visible, go back to the front panel and click the �Start� button and watch the diagram. The subVI is called and displays the data from the main VI. The subVI also uses an event structure
to watch for the front panel to be closed. This just keeps it open until you want it closed.

Play around with this a bit and you should get the hang of how it works. Let us know if you have any more questions.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 5
(3,079 Views)
Hi here is an example that shows several program features that you can build on. I tried to comment in the diagram to help explain what is going on. I hope this helps.

Randall
Download All
0 Kudos
Message 4 of 5
(3,079 Views)
> Very simple, if I can explain it right. OK, Lets say I have a VI with
> 3 string controls, 3 numeric controls and a Start and Stop button. 8
> items total. Now, when I press the start button I want another front
> panel (separate VI) to open up which will display the 3 strings in
> string indicators and the 3 numerics in numeric indicators from the
> first VI. If I press the stop button, I would like to exit Labview
> (maybe with a double check 2 button dialog asking if the user would
> really like to quit, before labview actually exits). Can someone
> maybe walk me through this. I'm struggling with getting my start and
> stop buttons to execute these functions.

There are still a couple things that need to be specified. Do you want
the popup panel
to be modal -- requiring acknowledgement before the user
can return to the original panel? Or do you want it to be a parallel
window that just duplicates some of the info from the first window.

Here is some info that will get you started. Make a VI with your three
numerics and three strings and using File>>VI Properties, set it to open
when called. Make an icon, and connector with the strings and numerics
on the connector. Whenever this subVI is called, it will pop open its
panel.

In your original VI, put a while loop, and use either polling or the
event structure to recognize when the start and stop buttons change
value. If the start changes, call the subVI. If the stop changes,
finish the loop. Be sure to put a timer delay of something like 100ms
if you do a polling loop, otherwise you will be checking the buttons
millions of times per second, which is not the best use of CPU time.

If you need more info, please ask more specific questions and post again.

Greg M
cKaskle
0 Kudos
Message 5 of 5
(3,079 Views)