LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick question about latching boolean and event structures

Solved!
Go to solution

Hi, sorry for my lack of details.


I am using latch when pressed.

 

The event structures are definitely executing because the thigns they are meant to do are happening. The code is a horrendous mess (not my mess) and I've just been trying to make it use event structures to execute all of the code (a huge event structure around all of the code).

 

 

0 Kudos
Message 11 of 23
(2,274 Views)

Then there is something else to this story besides what you've already told us.  There is no way we are going to be able to figure it out unless you attach the VI so we can poke around in it.

 

If it is such a horrendeous mess, you might be better off rebuilding it so it gives the same functionality  (actually much better functionality since obviously it is functioning correctly right now), but using a cleaner, more maintainable architecture.

0 Kudos
Message 12 of 23
(2,266 Views)

@nishalc wrote:

 

The event structures are definitely executing because the thigns they are meant to do are happening.


You still have not said what kind of event is associated with the button. Is it "value changed" or something else? Read my previous post once more.

 

(For example if you use a mouse-down event on a "latch/switch when released" boolean, the boolean will still be in the old state when its value is read by the code. it only switches when the mouse is released while the event fires when it is pressed)

Message 13 of 23
(2,252 Views)

Sorry, I'm using the simplest cases. Event action is a value change, and the variables are on 'latch when pressed'. 

The event structures execute when I press the buttons but the buttons don't return back to default state. The program has a while loop around this event structure and the buttons still work again (i.e they are in TRUE state after using once but will execute the event again and then be in the FALSE state). 

0 Kudos
Message 14 of 23
(2,235 Views)

More words won't help us help you.

 

Please attach a VI!

0 Kudos
Message 15 of 23
(2,224 Views)
Solution
Accepted by topic author cna

Well for lack of actual VIs.  Here is the example that works perfectly as expected.  Of course I use a Latch-when-released type boolean.  LV 12.   Now it is up to the original poster to show why her/his situation doesn't work.

 

1. Quick summary, use latch-when-released type booleans to allow resetting to work.

2. They do work.

 

To quote Trillian: “We have normality, I repeat, we have normality.  Anything you still can’t cope with is therefore your own problem.  Please relax.”

LabVIEW ChampionLabVIEW Channel Wires

Message 16 of 23
(2,222 Views)

To be honest I thought it would be something I missed and thus a quick fix but its probably something off with the program

 

I'll try out latch-when-released instead of latch-when-pressed to see if that makes any difference. 

 

Thanks for the overwhelming support!

 

EDIT: So, switching to latch-when-released has fixed the issue. Not quite sure why (as they function the same in the example someone gave/other programs I made).

 

0 Kudos
Message 17 of 23
(2,217 Views)

Yes it will make a difference.  Consider the scenario:

 

Push boolean

it latches

Event fires

Boolean attempts to clear, but still pressed

Exit without boolean clearing.

Release boolean

 

Now if latches when released:

Push boolean

Release boolean

it latches

Event filres

Boolean clears since it is NOT pressed

Exit with cleared boolean

Release boolean

LabVIEW ChampionLabVIEW Channel Wires

0 Kudos
Message 18 of 23
(2,212 Views)

@sth wrote:

Yes it will make a difference.  Consider the scenario:

 

Push boolean

it latches

Event fires

Boolean attempts to clear, but still pressed

Exit without boolean clearing.

Release boolean

 

 


Your explanation doesn't make sense to me.  Latching, when talking about boolean controls, is the clearing of the boolean.  So when you say "Press boolean....it latches", the boolean should be cleared.  There is something else going on in the OP's code because latched when pressed should work.  Maybe there is a local variable being used to NOT the boolean after it has already been cleared.  Unfortunately, no code has yet been shown to find out what the real problem is.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 19 of 23
(2,203 Views)

I do want to come back and follow up with this thread about the "Until Released" options.  To be specific about when a Latch until released is preferable to a switch until released.

 

All three latched types And Switched When Released may use 1, 2 or 4 elements of the Colors[4] and Strings[4] properties.  Switch Until released and Switch When pressed may only use 1 or 2 elements of them.  The other difference is, of course, the ability to Read / Write the Value property from a P-Node.

 

So a Latch Until Released can changed "True" colors  to "True to False" colors until it is read after it is released and from "True to False" to "False" colors after it unlatches.  A Switch Until Released will immediately Change from "True" to "False" colors.  Reading the Text property could be used to indicate "Final Iteration" or a "First Iteration" of a "Dead man's Switch" and place "Go to Idle State" or "Begin State" message out to some asynchronous process.


"Should be" isn't "Is" -Jay
0 Kudos
Message 20 of 23
(2,197 Views)