LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run continuously when button is pressed down in event structure case

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!

0 Kudos
Message 1 of 6
(4,730 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(4,714 Views)

Thanks for quick reply. The problem I try to solve is identical to this one:

https://forums.ni.com/t5/LabVIEW/Event-Structure-mouse-down-or-value-change-case/m-p/2517928/highlig...

 

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!

 

0 Kudos
Message 3 of 6
(4,696 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 6
(4,687 Views)

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.

Increment.png

 

Message 5 of 6
(4,654 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(4,648 Views)