LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get latch mechanical action on boolean button inside a cluster

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.

 

 

0 Kudos
Message 1 of 17
(5,638 Views)

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

Kudos are welcome...
Message 2 of 17
(5,627 Views)

@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

Message 3 of 17
(5,618 Views)

@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.

0 Kudos
Message 4 of 17
(5,612 Views)

@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". 

0 Kudos
Message 5 of 17
(5,611 Views)

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:

grafik.png

Again, it would be much easier to help and answer you if you would upload your actual VI.

Regards, Jens

Kudos are welcome...
0 Kudos
Message 6 of 17
(5,604 Views)

 

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:

Latching Cluster.png

 

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

Message 7 of 17
(5,598 Views)

@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:

grafik.png

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.

0 Kudos
Message 8 of 17
(5,576 Views)

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.

Latch Order FP.pngLatch Order 1 BD.png

So here how the demo works -- before you run it, Control 1 is on.  There are three parts to this "quiz":

  1. When you push the Run button, what happens to Latches, Latches 1, and Latches 2?
  2. When you push and hold Latches Button #2, what happens to Latches, Latches 1, and Latches 2?
  3. When you release Latches Button #2, what happens to Latches, Latches 1, and Latches 2?

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:Latch Order 2 BD.png

Same setup, same three questions.  This, I hope, you get right.

 

Final quiz -- this is the Code that JensG69 posted:

JensCode.png

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

Message 9 of 17
(5,563 Views)

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

 

Kudos are welcome...
0 Kudos
Message 10 of 17
(5,544 Views)