LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting data from a digital caliper USB Keyboard

Solved!
Go to solution

@billko wrote:

@lgc102 wrote:

Tried this method (event handler with Key Down?), got it to work more or less.

 


Can you somehow launch it async?  I know, it's getting uglier and uglier...


Not really. I tried it as a subvi, and it doesn't pick up the keystrokes unless front panel is open and has focus. So, yes I could launch async, but front panel has to open, and that would be a mite confusing to the operators even if I make it hidden. Also starts crossing UI thread, so would slow down execution of stuff - not crucial, but might affect timing of other things.

Could make it happen, but that's a whole glob of new complexity to add...

 

Here's snippet of the (very messy) caliper keystroke listener, just for completeness sake.

0 Kudos
Message 11 of 13
(1,077 Views)
Solution
Accepted by crossrulz

Update, with a workable solution.

Digging around USB RAW stuff, found some beautiful nuggets here and here by Intaris, plus a nice example here and a NI-VISA USB tutorial here. Combining all this and digging into the HID Usage Tables of the USB Standard let met put together a driver subvi that takes non-focus control of a keyboard using NI-VISA, listens and extracts the string of interest, and parses the output. Seems to work pretty well on LV2015sp1.

A bit slow with the caliper: 1.5 to 2 sec per read, same speed that the caliper outputs to a string control using the normal Windows drivers, so this is a device limit not the code.

Of course as soon as I finished writing this, Starrett tech support told me that we had the wrong cable, they have one (not advertised on their web site) that allows direct USB interfacing without the keyboard nonsense, part number PT63388.

 

Anyway, here's the lvlib with the Starrett USB keyboard driver subvi, gratefully based on Intaris's examples in the nuggets. It can be adapted to other things at need. Find your device ID, use the NI-VISA wizard to override the existing drivers, and start tinkering.

0 Kudos
Message 12 of 13
(1,052 Views)

@lgc102 wrote:

Update, with a workable solution.

Digging around USB RAW stuff, found some beautiful nuggets here and here by @Intaris, plus a nice example here and a NI-VISA USB tutorial here. Combining all this and digging into the HID Usage Tables of the USB Standard let met put together a driver subvi that takes non-focus control of a keyboard using NI-VISA, listens and extracts the string of interest, and parses the output. Seems to work pretty well on LV2015sp1.

A bit slow with the caliper: 1.5 to 2 sec per read, same speed that the caliper outputs to a string control using the normal Windows drivers, so this is a device limit not the code.

Of course as soon as I finished writing this, Starrett tech support told me that we had the wrong cable, they have one (not advertised on their web site) that allows direct USB interfacing without the keyboard nonsense, part number PT63388.

 

Anyway, here's the lvlib with the Starrett USB keyboard driver subvi, gratefully based on Intaris's examples in the nuggets. It can be adapted to other things at need. Find your device ID, use the NI-VISA wizard to override the existing drivers, and start tinkering.


Hey, don't forget to mark your post as the solution!  🙂

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 13 of 13
(1,041 Views)