LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Double request on a F9 keypress when using Aquire Input Data.vi

Solved!
Go to solution

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?

 

VISnippet.png

0 Kudos
Message 1 of 6
(2,911 Views)

Keyboard VS Polling Snippet.png

 

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.

Message 2 of 6
(2,892 Views)

@Shane-C wrote:

Keyboard VS Polling Snippet.png

 

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.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 6
(2,884 Views)

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.

 

0 Kudos
Message 4 of 6
(2,834 Views)
Solution
Accepted by Eric1977

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:

 

Polling while not active.png

0 Kudos
Message 5 of 6
(2,823 Views)

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.

0 Kudos
Message 6 of 6
(2,817 Views)