LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change variable value in Labview run mode

Hi,

 

I want to create a user interface to be something like, I can enable/disable variables or options and change values of variables and then push a run button to execute the VI. What I have achieve so far is I can enable/disable variables by engaging a while loop before I hit the run button to execute. What I don't know how to do is change the values of variables under the same condition. In other words, how can I change values of variables in the labview run mode?

 

Thanks for your input.

0 Kudos
Message 1 of 11
(9,460 Views)

Hi yoyolk,

 

what are "variables"? Are you talking about controls and indicators?

 

- Changing controls is easy: just click on them when the VI is running... 😄

- Use local variables of a control when you want to set it's value programmatically...

- Enabling/Disabling is done by using property nodes of those controls. There's a property "Disabled?"

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(9,454 Views)

I guess I did not express my question correctly. What I meant is I can use a while loop to create a dynamic interface. I can activate or disable a variable (control) by push the green botton before I hit the RUN button to continuously execute the VI. However, when I activate the control, for some reason I can not change its value. I just wonder how I can change the value of a control in such a dynamic interface.

 

labview3.jpglabview2.jpglabview1.jpg

0 Kudos
Message 3 of 11
(9,413 Views)

Hi yoyolk,

 

it's never a good idea to hide/delete the names of controls in the block diagram. Would you ever do that with text-based programming languages (like "" := "" + "")???

 

Maybe you should simply attach your VI instead of some pictures, when most of the code is hidden or obfuscated...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(9,410 Views)

@yoyolk wrote:

I guess I did not express my question correctly. What I meant is I can use a while loop to create a dynamic interface. I can activate or disable a variable (control) by push the green botton before I hit the RUN button to continuously execute the VI. However, when I activate the control, for some reason I can not change its value. I just wonder how I can change the value of a control in such a dynamic interface.

 

labview1.jpg


A couple of red flags here:

 

As others have said, since you don't show the labels on the diagram, we cannot tell what's what. We also cannot see what's in the other frames of the sequence. Please attach the actual VI instead.

 

Your "disabled" property is either 1 (disabled), or 2 (disabled&grayed out), never zero (enabled). Unless it is enabled, you cannot operate it!

 

What is the point of your while loop that seems to spin at near infinite rate while consuming all CPU, rewriting he same properties over and over again. A property remains set until changed to something else, thus they only need to be written when the property needs to change.

 

.... and what's the purpose of the stacked sequence, just to hide code even more?

0 Kudos
Message 6 of 11
(9,379 Views)

Here comes the vi. What I want to do is create a dynamic control interface.  

0 Kudos
Message 7 of 11
(9,353 Views)

@yoyolk wrote:

What I want to do is create a dynamic control interface.  


I have no idea what that means! Can you explain how it should function and how it is operated?

 

Vname and Iname are always disabled while smu gets enabled right before the VI stops. Are you using continuous run mode? In that case it would be come disabled again a nanosecond later because the completed VI restarts over. (continuous run is a debugging tool, not a way to run a VI!)

 

Also learn about mechanical action settings. If you would set the run button to "latch when released", the local variable and sequence structure would not be necessary (use the error wire to sequence the property node. Your loop needs a small wait or an event structure....

0 Kudos
Message 8 of 11
(9,343 Views)

Sorry for not make my point clear. Let's start from the beginning.

What I want to do is to create an interactive user interface. It means the controls at the user interface are categorize into different layers. If users make a choice ( a Boolean control, combo string etc) at the first layer, then they can only have certain options in the second layer and so on so forth.

 

The example.vi is a very simple program trying to realize this idea. When users execute the vi, the vi is held by a while loop until the users hit the rectangular RUN button. When the vi is held by the while loop if users activate the round green button, they can change make sections from the combo string control and change values of Vname and Iname. However, if users de-active the round green button they won't have the access to combo strong control or Vname or Iname.

 

My question here is when the round green button is activated, I can not change the values of the combo string or Vname or Iname even these control are enabled. Anyone has idea why this happen and how I can change the values of these controls?  

0 Kudos
Message 9 of 11
(9,306 Views)

You are setting the property to either "Disabled" or "Disabled and  Grayed Out". If you had used the enum for the property, that would have been more obvious. Your converting to numeric and subtracting that from 2 is just wrong. Why don't you simply wire the Boolean to the Select function and switch between the enums? Right click on the property node and select 'Create Constant' to get the enum.

0 Kudos
Message 10 of 11
(9,302 Views)