06-01-2018 11:42 AM
Hi all,
I'm sure someone has asked this question before, and I tried googling it, but I can't find an exact answer. I hope you can help me.
I have a set of Boolean button controls inside a cluster on the front panel. I need the buttons to have latch mechanical action (i.e. reset after click). When I check the mechanical action properties it says "Latch when released". But the button stays "on" after the click, and when I click again to release it, it triggers another event, which I don't want.
Is this a standard feature? How to get around it, and have a button latch instead of staying "ON"?
Thanks.
06-01-2018 12:08 PM
Where in your block diagram do you place the terminal of your cluster?
A latched Boolean will only reset after its value has been read out. Because of this it is common practice to place latched booleans inside the case ot the event structure in which the value change event is handled.
SInce your booleans are part of a cluster you cannot do this. The next best is to place the terminal of the cluster alongside the event-structure. Of course you now need events the reset of the booleans works only in an acceptable way if the source code inside your event-structure does not take much time to process.
For further analysis please post your VI.
Regards, Jens
06-01-2018 01:02 PM
@abvenk wrote:
I have a set of Boolean button controls inside a cluster on the front panel. I need the buttons to have latch mechanical action (i.e. reset after click).
I believe the Mechanical Action you are describing is Switch Until Released (i.e. a Push-Button, True while you push it, otherwise False). What "Latch" means is "remember the switched (almost always "True") value until I read the terminal associated with the Switch, then reset to your Default value ("False"). The latch lets LabVIEW "remember" the value of the Switch until you read it, just in case you were busy processing other code during the button press and didn't get around to checking its value while it was pressed.
Bob Schor
06-01-2018 01:34 PM
@JensG69 wrote:
Where in your block diagram do you place the terminal of your cluster?
A latched Boolean will only reset after its value has been read out. Because of this it is common practice to place latched booleans inside the case ot the event structure in which the value change event is handled.
SInce your booleans are part of a cluster you cannot do this. The next best is to place the terminal of the cluster alongside the event-structure. Of course you now need events the reset of the booleans works only in an acceptable way if the source code inside your event-structure does not take much time to process.
For further analysis please post your VI.
Regards, Jens
Hi Jens, can you please explain what you mean by "place the terminal of the cluster alongside the event structure"? I tried creating an indicator from the cluster typedef and put in on the event structure panel. Is that what you mean? It didn't work though.
06-01-2018 01:35 PM
@Bob_Schor wrote:
@abvenk wrote:
I have a set of Boolean button controls inside a cluster on the front panel. I need the buttons to have latch mechanical action (i.e. reset after click).
I believe the Mechanical Action you are describing is Switch Until Released (i.e. a Push-Button, True while you push it, otherwise False). What "Latch" means is "remember the switched (almost always "True") value until I read the terminal associated with the Switch, then reset to your Default value ("False"). The latch lets LabVIEW "remember" the value of the Switch until you read it, just in case you were busy processing other code during the button press and didn't get around to checking its value while it was pressed.
Bob Schor
Hi Bob, I tried all of the available mechanical actions, including Switch Until Released. It doesn't work at all. The button stays "ON".
06-01-2018 02:11 PM
I mean something like this, the terminal of the Cluster needs to be placed alongside of the event-structure, so that LabVIEW can "read" its value:
Again, it would be much easier to help and answer you if you would upload your actual VI.
Regards, Jens
06-01-2018 03:11 PM
Sorry, I didn't quite "get" your original question. Are you trying to use your Cluster inside an Event Structure, and have it "fire" when any of the Buttons is pressed? That's trivial and certainly does work, as evidenced by this code:
Here, Buttons is a Cluster with an OK, a Cancel, and a Stop (all "Latch when Released") controls. When you push one Control, it "fires" and returns (in New Val) the Control that fired, resetting them all to Off. Both the outputs Buttons 2 and NewVal will show the Control that was pressed.
Bob Schor
06-02-2018 08:30 AM
@JensG69 wrote:
I mean something like this, the terminal of the Cluster needs to be placed alongside of the event-structure, so that LabVIEW can "read" its value:
Again, it would be much easier to help and answer you if you would upload your actual VI.
Regards, Jens
I do not understand why keep saying that the cluster should be alongside the event structure. No, put the cluster control inside the event case, as simple as it is.
06-02-2018 01:21 PM - edited 06-02-2018 01:24 PM
There is clearly a confusion that both the Original Poster and, perhaps, JensG69, have about Latched Booleans and Event Structures. In addition, the Principle of Data Flow appears to have been neglected!
I offer the following "Teaching Example" -- I created a Cluster of three Latched-When-Released Boolean Controls that "look like" LED Indicators (this is perfectly legal in LabVIEW, and makes them stand out) and made a TypeDef out of it. I then created two Demo VIs with a two-frame sequence (so I can "know" the order of operations). In the first, I write the Control into an Indicator, followed by creating a Value Change Event and saving the NewVal in a second indicator. In the second, I reverse the order, doing the Value Change first and reading the Control second.
Here is the starting Front Panel, after I deliberately "turned on" the first Latch before running the two Demos (both Front Panels look the same) (by default, all the Latches are off). Next to it is the Block Diagram of Latch Order 1.
So here how the demo works -- before you run it, Control 1 is on. There are three parts to this "quiz":
Don't fret that you will probably get this wrong -- it involves some fairly subtle points (it is possible to make it even more difficult, but let's not go there).
So here is the second Demo's Block Diagram -- it's Demo 1 with the order of the Frames reversed:
Same setup, same three questions. This, I hope, you get right.
Final quiz -- this is the Code that JensG69 posted:
Is this more like Demo 1 or Demo 2? If you answered "Demo 1", you are wrong. If you answered "Demo 2", you are also wrong. If you answered "Using the Principle of Data Flow, you cannot answer the question", then you got the right answer. And that was the point that Blokk was making.
Bob "Long-Winded" Schor
06-03-2018 02:22 AM
Hi,
I keep saying "alongside" since my example contains several events for the differents latched buttons inside the cluster.
We all agree that a latched button will only reset when LabVIEW according to dataflow accesses the terminal. Since my example contains several events I cannot place the cluster inside every event case. Only solution: Place it parallel to the eventstructure (or in a flat sequence after the eventstructure) and hope that the code inside the events does not wait.
Cf. attached VI:
Regards, Jens