01-29-2015 06:28 AM
In the main file (main.VI) I have a Event Structure and I have a problem to create a action to run continuously when the button is pressed down and stop when the button is released. The continuouing operation is to increment a value by one with shift register and increment function.
Thanks for any ideas!
01-29-2015 07:12 AM
Set your button to use the Switch Until Released mechanical action. Now use a shift register to set the timeout of the event structure. When your button's value chnages to FALSE, the timeout should be -1 (wait forever). When your button's value changes to TRUE, you should set the timeout to be whatever rate you want the increment to go at. In the Timeout event case, increment your shift register value.
01-29-2015 07:57 AM
Thanks for quick reply. The problem I try to solve is identical to this one:
but I am quite a new user I do not understand the solution. I have also attached the file, in the file I tried to make a solution you suggested, but I missed something (it is not working as wanted) and I would like to ask you to take a look.
Thanks!
01-29-2015 08:08 AM - edited 01-29-2015 08:09 AM
1. Use the Value Changed event on your button. That is what will set the timeout value.
2. Be sure to wire your timeout through all of your event cases. If you don't, it will become 0 on you, which I'm sure you don't want.
3. Increment the value in the Timeout case.
01-29-2015 01:50 PM - edited 01-29-2015 01:56 PM
Would an easier way not to be simply putting a boolean controlled case structure inside the timeout function?
I agree your way is probably best overall but for the sake of a beginner surely a simply case structure would be best.
EDIT
Actually I had a better idea, skip the case structure all together and just go with a select.
01-29-2015 02:00 PM
ogk.nz wrote:Actually I had a better idea, skip the case structure all together and just go with a select.
Well, if this button is the only requirement for the program, we don't even need the event structure. Just use a Wait inside of the loop instead.