05-30-2017 04:09 PM
I wanted your opinions on the Aquire Input Data.vi and how it behaves in the below scenario. My scenario is that my program sits in the background waiting for a key press. If it sees F9, that triggers a print request to a RS-232 device. What I am seeing is a double reading from my device and my hunch is that the While Loop with the Aquire Input Data.vi is seeing two F9 key punches since my device acquires data relatively quickly and the While Loop spins so fast. If I put in a 250ms wait, I was wondering if it will not query the keyboard again for a F9 key press. Thoughts?
Solved! Go to Solution.
05-30-2017 04:53 PM
Why use polling when you could use events? Check out the difference between these two. Top one should yield results more like what you want.
05-30-2017 04:58 PM
@Shane-C wrote:
Why use polling when you could use events? Check out the difference between these two. Top one should yield results more like what you want.
Ahh, you beat me to it. 😉
05-31-2017 07:03 AM
If I use an Event, the EXE (or VI) must have the focus for the event to be triggered. 95% of the time the VI or EXE will not have the focus.
05-31-2017 09:25 AM
Glad I asked the why then, sounds like a legitimate reason. I guess you have a couple options then. You could try to follow one of the suggestions in this post:
https://forums.ni.com/t5/LabVIEW/key-down-event-in-background/td-p/2444810
Or try out something like this. Testing this the indicators increment the way you describe even while not active:
05-31-2017 11:04 AM
Shane - Your VI Snippet & the link you provided helped quite a bit. By looking at your snippet, I used something very similar to that to get the desired effect I wanted. Thank you.