LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binding run key to keyboard key

Hi, I am very new to labview. Anyways I have some trigger set up that writes a  "   `    " character when triggered. I would like to set my labview program up so that when it receives this key it begins running, and further pressings of this key do nothing (the program continues until its completed). Is there a simple way to do this? Any help would be greatly appreciated.

0 Kudos
Message 1 of 9
(3,121 Views)
You should take some of the free LabVIEW tutorials. A VI has to be running first before receiving anything. You can use the keyboard function inside a while loop to detect a key press and then do whatever you want. Please explain this trigger with some details.
Message 2 of 9
(3,093 Views)

ah yes, thank you for your reply. I have watched a few of the beginner tutorials. So my current plan was to just put the program within a case structure. The condition then could be an input form the keyboard matching the string constant "   `   ", which would execute once it receives this. I have the input keyboard wired to the acquire input data and use the output from the acquire input data to compare to the string constant "  `   " using the logial equals sign. I would then connect the result of that comparison to the case statement. I now get this error:

These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
The type of the source is 1D array of
boolean (TRUE or FALSE).
The type of the sink is boolean (TRUE or FALSE).

 

 

So it appears like the result I'm getting from the keyboard is not a string, and so it won't let me compare to the string constant. I'm not sure what format the key is in, but is there a way to fix this, perhaps by casting to a string? Thanks very much in advance.

0 Kudos
Message 3 of 9
(3,073 Views)
Sorry, that does not make any sense to me. I have no idea how you would be getting a Boolean array and connecting it to anything at all.
0 Kudos
Message 4 of 9
(3,064 Views)
Forgot to add that you should post an image of the block diagram. And if you are using the keyboard function, it returns a scan code and not an ascii character.
0 Kudos
Message 5 of 9
(3,056 Views)

Hi, yes I realize my Labview terminology might be a bit off. Here is a screenshot of the block diagram

0 Kudos
Message 6 of 9
(3,047 Views)
Frankly, nothing in your program seems to make much sense. First, you need a while loop to continuously read the keyboard. Do not use the run continuous button. Second, turn on context help and look at the description of the read keyboard function. Lastly, the for loop and the code inside seems much more complicated than necessary. What is the purpose?
0 Kudos
Message 7 of 9
(3,037 Views)
Argh, I keep hitting post to early.

Open the front panel of the read keyboard function. For debug purposes, put that into tin continuous mode and press the key you want. You'll see the values. In your main, use an index array and do comparison with the numeric scan code.
0 Kudos
Message 8 of 9
(3,030 Views)

OK, thanks for the help. I realize lots of the code is more complicated than it needs to be. It's partially due to it being a placeholder for the next step and partially, because as I said before, I am new to labview and it is drastically different than text based programming languages. Thanks for the tip about the while loop, that makes more sense.

0 Kudos
Message 9 of 9
(3,011 Views)