04-21-2017 04:42 PM
I have a pic ring that has about 30+ pics. Also these pics rotate every three seconds or so so that every pic is individually shown at the three second interval. That works fine, but I also want to implement a Forward button that can increment thru the rotating pic ring as well. Right now, the pic rotation works fine, but when I press the Forward button, nothing happens. As well, the boolean value for the button stays True when it should turn False and the button should revert back to its original setting. And finally, my code for the Forward increment works fine alone, but when combined with the code for rotation, everything gums up. My vi. is attached here.
04-21-2017 05:46 PM
You might want to turn on highlight execution so you can better understand how your VI is working and why it isn't working the way you want to.
You hit the button, but what you think is "nothing happens", is that the 3 second wait in the False case is still executing. Not until that ends, the loop iterates again, does the button get read and then the picture advances again.
(By the way, the 1 iteration For Loop and the shift register aren't doing anything in that True case.)
What you need to do is have a single loop with an event structure. Have an event that handles the value change for the button. Have a timeout event with 3000 (for milliseconds) wired to the timeout node. Have the advancement of the picture ring occur in either event. Keep the indicator outside, and use a shift register, and you won't need any of those local variables.
04-23-2017 09:35 AM
Okay thanks. I actually forgot about the Event Structure. I'll try that route. And I do think the hold up has to do with that 3 second delay. I've found the boolean of the button does change back to false eventually but...the picture doesn't change. So....it almost almost works.
04-23-2017 10:17 AM
The picture didn't change because whether you finish waiting the 3 seconds or press the button, the ring increments by 1 either way. The difference is you want the button to increment the picture RIGHT NOW, which is a question of timing and using the event structure allows it to handle that.