LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

reset control button

Solved!
Go to solution
Highlighted

Can I reset a control button programmatically?  Specifically, I'm wanting to switch a Boolean button back to a false state in response to certain events/conditions. 

 

For example, consider the attached VI.  (It is un-finished, because I don't know how to finish it.) The user can make the counter count by clicking the count button.  What I want to do is stop the counter at some number (10) and reset the count button, so the user has to re-click for a new count. 

 

 

0 Kudos
Message 1 of 12
(1,154 Views)

counting_example_BD.png

also, change the mechanical action of the count switch to "latch when pressed or released"

 

0 Kudos
Message 2 of 12
(1,126 Views)

Check out "Create... > Local Variable"

0 Kudos
Message 3 of 12
(1,117 Views)

@tomlawton wrote:

Check out "Create... > Local Variable"


...and then DON'T create one.  Check out Apok's example instead...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 12
(1,103 Views)

think he wanted the "Count" button to remain pressed in- and the counter to keep counting- until n=10, or whatever- and then have the count button pop back out. In which case, I think he'll want a local...

(Might be wrong of course..!)

0 Kudos
Message 5 of 12
(1,100 Views)
Solution
Accepted by topic author tysonl
08-27-2015 04:09 PM

This is one of those times some additional functions can be your friends.

 

Events, Property nodes and Feedback nodes should be loaded into any developer tool-box ready to replace the "Screw-Hammer" when a better tool exists.

Event Loop 18_BD.png

Count Value change event selects either -1 or 100 for timeout

Stop value change sets the exit condition

 

I renamed Count (I32) to Counts since its not very good to have two objects with the same label

 

EDIT:

I think he wanted the "Count" button to remain pressed in-  I read that too since the true string is "Counting" Still the Local is less desirable since a Val(Signalling) can be beneficial in this case

Message 6 of 12
(1,099 Views)

@tomlawton - That is exactly what I'm wanting. 

0 Kudos
Message 7 of 12
(1,088 Views)

In that case, right-click on your "Count" button terminal, "Create...> Local Variable". That gives you a "second terminal" to your front-panel control... which you can either read from, at a different place on the diagram (sometimes saves messy wires), or in your case, you can change it (with a right-click) to write mode , thus allowing you to force a value to your front panel control.

BUT- huuuuge BUT!- be careful! Use of locals can give rise to race conditions, and all manner of bad things. (Additional copies of data is a common refrain, which would be heinous for a big array, but acceptable for a single boolean). Plus they tend to elicit strong reactions among programmers; along the lines of Dijkstra/ GOTO...

0 Kudos
Message 8 of 12
(1,079 Views)

i believe that Jeff's would be a better solution....

0 Kudos
Message 9 of 12
(1,076 Views)

Undoubtedly- though I have only read the code, not run it (to paraphrase Knuth)

However, it's nothing like as transparent for a beginner to comprehend; and while we should encourage good habits (and discourage bad!), we don't need to intimidate.. ;-) (or optimise prematurely ;-D) 

0 Kudos
Message 10 of 12
(1,067 Views)