LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to autoinitialize controls to default value at run?

Solved!
Go to solution

Hello all

 

I am trying to initialize default values to controls right after the run button is hit. It is working only if the control is loaded with default values before running. I am an amature and any kind of help will be truly appreciated.

0 Kudos
Message 1 of 7
(4,056 Views)

In block diagram, over the control icon: left click -> create property node -> value
Then you can wire some constant and put before all your code.

 

For more help, use Save for previus version. Some still use older version of LabVIEW

 

Regards

Message 2 of 7
(4,052 Views)
Solution
Accepted by topic author chips

Your VI is silly. You have to understand dataflow. You have no idea if the control is going to write to the indicator first or if the case statement will execute. What will you eventually be doing with your program. I would hope that you have some sort of while loop (do NOT use the run continuous button). Then the method would just be outside the loop and execute once - no need for a case statement. You could also place it inside the first state of a state machine.

Message 3 of 7
(4,046 Views)

Thank you Dennis for your crtical remarks. I used a while loop and removed the case structure. The vi works as desired. Still i have loads to learn.

Thanks 🙂

0 Kudos
Message 4 of 7
(4,034 Views)

Thank you mahu.It took me sometime to figure out how to wire. Now its working perfect.

0 Kudos
Message 5 of 7
(4,024 Views)
  • You have a race condition, because you don't specify that the property writes should execute before the while loop. Wire the error out of the property nodes to the loop boundary to create a data dependency.
  • Your loop consumes all CPU because it spins millions of times per second. Us a small wait (e.g. 10-100ms). Better would be an event structure.
  • Use a latch action boolean and "stop if true" to end the loop. (Else you would need to reset the switch before every run).
  • ...
0 Kudos
Message 6 of 7
(4,007 Views)

wow this is do much fun. Thanks alten Smiley Very Happy

0 Kudos
Message 7 of 7
(3,982 Views)