05-14-2009 09:15 AM
I would like to create an event which responds to a button on my front panel and a text entry box which tells the event how often to repeat the code which is inside in the event I have specified.
The event should begin executing the code as soon as the button is pressed and repeat the event for example every 100mS until the button is released again.
If anyone has any ideas I would be glad to hear them. I use LabView 7.0
Solved! Go to Solution.
05-14-2009 09:51 AM
You need to event cases:
1. Button:value change: In this case you set the time out value for the time out case to either 100ms or -1.
2. Timeout: In this case you excute youre code.
Default timeout value is -1.
You'll need to shift registers.
One to hold the timeout value and one to hold the state (execute/not execute).
Once the button is pressed the timeout is set to 100ms and the timeout case will begin executing every 100ms.
After a second button press you set the value of the timeout event to -1, thus preveting the excution of that event.
05-14-2009 11:03 AM
I still dont undertand exactly,I should create 2 events ? the first one responds to the click of my button but how can I trigger the second event from this timeout?
And my Control( 100ms 200ms etc) which handles how often to repeat the event where should I connect that ?
Im not very experienced in LabView so excuse my ignorance.
I also couldnt find any shift registers.
Eoin
05-14-2009 12:52 PM
here is an example of a simple event:
also to make a shift register right click you for or while loop and click the add shift register
05-14-2009 01:03 PM
because I cannot save it in a previous version that low:
here are pictures of the block diagram:
05-14-2009 01:13 PM
I would like to only use one button.
I have attached a shot of my VI, with it like this it executes the code in this window every 500ms, but the problem is it gets stuck and will not respond to the button which should end the while loop or the "POLL" button which means I have to click abort execution for it to stop.
05-14-2009 01:21 PM
well normaly you don't put a while loop within an event structure because if this is event driven than it has to have some sort of event running it (i.e mouse click, value change)
and a while loop would just continuosly run and would cause your other buttons not to work:)
so I would take the while loop out of your event structure.
05-14-2009 03:41 PM - edited 05-14-2009 03:42 PM
05-14-2009 03:44 PM - edited 05-14-2009 03:49 PM
05-15-2009 04:39 AM