11-09-2005 11:52 AM
11-09-2005 11:58 AM
@Dave123 wrote:
To get round this I manually write FALSE to the button controls once my LV prog has read them ...
11-10-2005 12:46 PM
11-16-2005 09:48 AM - edited 11-16-2005 09:48 AM
Message Edited by Dave123 on 11-16-2005 03:55 PM
Message Edited by Dave123 on 11-16-2005 03:56 PM
11-16-2005 09:59 AM
11-16-2005 11:32 AM
@Dave123 wrote:
I'd like to use latch when released buttons but I'm using local variables of the buttons so I can read the current values of them in different parts of the program.
So to simulate latch when released I've written my program to set to FALSE the state of the button once it has read that it has been pressed.
This sounds like a very bad idea if other parts of the code need to react on the state of a pseudo-latch action boolean. There is simply no guarantee that other parts of the code even see the transition due to possible race conditions. What if the boolean gets reset before the other code can read it? What if the other code reads the true multiple times because it loops faster than 200ms?
How many other places do you possibly need to read it? Maybe you can use latch action combined with an event structure to cause parallel code to react to the value change? (see attached example, LabVIEW 7.0). Maybe you should rethink your code, there might be better alternatives.
@Dave123 wrote:
Keep the toggle button held down for a second or two, release it and you should see the button goes true again (and is promptly cleared in the case). Why does a mouse button release set the button to true?
11-17-2005 04:04 AM
@altenbach wrote:
@ Dave123 wrote:
I'd like to use latch when released buttons but I'm using local variables of the buttons so I can read the current values of them in different parts of the program.
So to simulate latch when released I've written my program to set to FALSE the state of the button once it has read that it has been pressed.
This sounds like a very bad idea if other parts of the code need to react on the state of a pseudo-latch action boolean. There is simply no guarantee that other parts of the code even see the transition due to possible race conditions. What if the boolean gets reset before the other code can read it? What if the other code reads the true multiple times because it loops faster than 200ms?
How many other places do you possibly need to read it? Maybe you can use latch action combined with an event structure to cause parallel code to react to the value change? (see attached example, LabVIEW 7.0). Maybe you should rethink your code, there might be better alternatives.
- Thanks.
My program is written such that only one part of the program at a time needs to see the button press. The program then moves on and another area monitors the button presses. When a button is pressed and cleared in one part of the program another part of the program is not expected to see it.
@ Dave123 wrote:
Keep the toggle button held down for a second or two, release it and you should see the button goes true again (and is promptly cleared in the case). Why does a mouse button release set the button to true?
Easy! In this case, you should use "switch when pressed" as mechanical action. You use switch until released, which confuses LabVIEW.Switch when released does two things: (1) It switches to true as long as you keep the button pressed. (2) When you release the button, it switches to off. Now, if your code inverts the switch via a local variable while it is still pressed, the release tries to invert the current state and turns it off-to-on again by mistake.This might be a slight flaw (bug) in the LabVIEW code. Releasing the button should force a FALSE to the button, not an iversion of the current state.
11-17-2005 10:28 AM
@Dave123 wrote:
- I agree, writing FALSE to the button should set it to FALSE and not invert it assuming it is still ON.