10-29-2014 07:12 AM
Hi, I'm trying to find a way to make a button with the following functionality:
Has anyone made something similar? I have had a few attempts with no success at achieving all the functionality.
Thanks,
10-29-2014 07:42 AM
What have you tried? Seems like a good event structure with some shift registers to hold the value and tick counts should do it.
10-29-2014 08:54 AM
I've tried using an event structure and generating an event, then using the event time to determine how much time has passed. As below:
This suceeds in meeting the button change but does not give an inidcation (via the boolean display) that the time has passed.
I've also tried manipulating the value of the button using property nodes and using a FGV counter to time:
This gives user indication that the time has passed via the boolean but is inconsistent with updating the button state.
NOTE: to run these snippets, you need to replace the bool Refnums controls with references to the button.
I've also tried having two buttons, one latch and one switch, and making one invisible, then switching which button is displayed, but this seems a bit convoluted.
Ideally, I want it to be self contained so I can drop it in to a GUI and not have to update existing event structures etc.
10-29-2014 09:33 AM
@NEILBH wrote:
I've tried using an event structure and generating an event, then using the event time to determine how much time has passed. As below:
This suceeds in meeting the button change but does not give an inidcation (via the boolean display) that the time has passed.
Use the Timeout. You can dynamically set what the timeout should be by using a shift register wired to the Timeout of the Event Structure. I don't see a need for the User Event.
10-29-2014 09:39 AM
Here is my attempt, see attached
10-29-2014 09:40 AM
Is it required for you to use latch vs switch?
10-29-2014 10:30 AM - edited 10-29-2014 10:31 AM
TToolDev01, your solution is close to what I want, I have modified it so that the button depresses on mouse down so that the user knows they have pressed the button, snippet below.
However, I was under the impression it is bad practice to execute code in the timeout case. In this simple example it is OK, but to integrate this into a larger VI, I can not guarantee the timing of the execution of the timeout case, due to user generated events, locking the front panel etc.
Crossrulz, I think you are suggesting I utilise the timeout case as well, so I am happy to be persuaded that code in the timeout case is OK!
Natasftw, I'm not sure what you mean, but I am effectively wanting the boolean to change mechanical action based on time held, i.e. to latch initially, and then only after it has been held for a certain amount of time (say 2 seconds) change a switch action so it stays depressed.
The purpose is to prevent the user from accidently pressing this button and invoking the action; they have to conciously hold it (e.g. for 2 seconds) to invoke the response. But I want the user to realise the button can be pressed and is not disabled, hence the state of the button changing when it is pressed for less than the time, but not invoking the response.
10-29-2014 10:41 AM
You can remove a lot of that logic that is inside of your Timeout case by actually setting what the timeout should be. So you key on the button's value change event. With the button going true, you set your timeout to 2000 (2 seconds). You then perform the desired actions on that timeout. So when the button goes false, you set your timeout to be -1 (never time out). You should also set the timeout to be -1 in the timeout case.