02-27-2006 04:44 PM
02-27-2006 04:49 PM
Hi Trevor,
There is no way to programmatically change the mechanical action of a Boolean. I recommend that if you need this functionality, you have two booleans on your front panel, and make one or the other visible depending on which mechanical action you need.
Good luck,
-D
02-28-2006 07:06 AM
02-28-2006 08:47 AM
I would second the event structure. With dynamic event registration you can now really control the mechanical action of a button do do almost anything. you want to handle the mouse down, mouse up, and value change events (possibly filtering events) to do what you need. Using 2 buttons can complicate your logic in the longrun and break the data flow. also polling architectures can miss events and cause some difficulty if you want to do multithreaded concurrent programming.
Paul
08-12-2010 06:31 AM
Hi,
I was searching the forum for a dynamical mechanical button and found this thread, which is exactly what I was looking for.
I have created a small vi with an event structure and a button which acts either as a push button or a switch. I have used local variables in this vi. How can I avoid using local variables?
08-12-2010 06:49 AM
I have modified the example a little.
08-12-2010 10:47 AM - edited 08-12-2010 10:50 AM
no help?
08-12-2010 01:22 PM
@johanneshoer wrote:
I have created a small vi with an event structure and a button which acts either as a push button or a switch. I have used local variables in this vi. How can I avoid using local variables?
You could use the CtlRef terminal and a property node to write to the Value property of the Boolean. But, this is actually worse than using a local. Locals are not inherently evil, and in a case like this a simple wire won't work.
Once you drop an Event Structure onto a BD, most if not all dataflow bets are off. Locals are an effective band-aid in this case and a small price to pay for the power of the Event Structure.
Your warriness is good. As I typically say, locals are to be understood, respected, but not feared. And although they may save your bacon here, let's not allow them to be your new best friend...
08-12-2010 02:41 PM
I think you should start with to question yourself about wheter why you need such control, because you proberbly made a flaw during the design of your program.
09-29-2010 08:57 AM
@WouterG wrote:
I think you should start with to question yourself about wheter why you need such control, because you proberbly made a flaw during the design of your program.
I stumbled upon this string because I'm trying to do the same thing, namely have a front panel button at times act like a "Latch" and at times like a "Switch".
I'm writing a VI that acts as a test/control routine for part of a fairly large and complex Real Time system implementing a psychophysical experiment. We are asking people to localize a sound source, with the stimulus consisting of either a brief train of 5 pulses, or a continuous train. In the first case, we want to send a "trigger" to the sound-generator (i.e. a brief pulse whose rising edge starts the sound), in the second we want to send a "gate" (a signal that is High as long as we wish the sound to keep playing). The sound generator "knows" whether it's getting a trigger or gate based on the number of pulses we ask it to send (we use "0 pulses" to mean an infinite train, until we say "stop").
My tester VI has a front panel with a button called "Stim" and a dial called "Number of Pulses", ranging from 0 to 10. If the number of pulses is 0 (i.e. "Go as long as Stim is True"), I want the Stim control to act like a switch -- push once for True (On), once for False (Off). However, for a finite train of pulses, I want it to generate a trigger, which the "Latch" behavior will facilitate (push to turn On, read in Event Structure which automatically turns it off).
Bob Schor