LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HID.dll and "Call Library Function Node" to read from device (PS60 Scale)

I have a weight scale made by "Metler Toledo" model PS60.  This particular scale is a common scale used by FedEx, UPS, and DHL. I am creating a Labview application for my warehouse, and each of these PCs have a PS60 "USB" scale on it.  FedEx, UPS, and DHL can read this scale simultaneously from the XP OS as a HID device.  I can look at the device manager and see the Vendor ID, and the Product ID clearly under the “HID-Compliant Device”.

 

I tried using NI Visa to address the USB scale, and that failed.  After thinking about it, I’ll bet if I created a successful NI Visa driver...Labview would hog the scale resource and not allow FedEx, UPS or DHL to read the scale.

 

I started looking for another solution and I found Labview’s "Call Library Function Node" vi.  I have never used "Call Library Function Node" before, I am lost , and have no idea where to begin.

 

I found this website here:
http://www2.hawaii.edu/~hermany/api.htm

This explains some of the functions, and shows the hid.dll.

 

In order for me to use "Call Library Function Node" with the hid.dll I know I must begin by addressing the USB device.  I have no idea how to communicate to the scale via the HID.dll.  There must be a way to do this…by default Windows XP allows all software to use HID devices.

 

I need some help trying to figure out how to start the communications to the scale via the HID.DLL and "Call Library Function Node" vi.

 

If someone knows a better way to communicate to the scale I am open to new ideas.


Thanks,

 

Doug

 

BTW, I got the idea to use "Call Library Function Node" from an example vi in labview named "Host Name.vi".  Search for "API" in Labview examples. 

0 Kudos
Message 1 of 15
(10,079 Views)

Hi Doug,

from the manual, it should be possible to communicate over RS232 to this device (Appendix: Host Interface). Would this be a solution for you?

 

Mike

0 Kudos
Message 2 of 15
(10,067 Views)

You do not know it yet but you are trying to attempt a project that is sure enough a bit larger than you possibly can anticipate.

 

Obviously VISA can only communicate with devices that are not claimed by an OS driver already. However disabling the HID class device driver is no option on any modern OS as this would render mouse and keyboard input unworkable.

 

So lets look at the other option: Interfacing to HID.DLL is actually the easier part. There is a lot more to it than you can see so far. First you need to enumerate the HID devices in the system. This happens with the SetupDi... API. This is a fairly well documented Windows API but at the same time also fairly complex. Interfacing it with the Call Library Node directly is very complicated and since you need to interface quite a few of those API functions for getting at the right device, I can not recommend to even try to do it. So this is only practical with some intermediate C code in the form of a DLL.

And since we are already busy with creating a DLL, adding the interfacing to HID.DLL into the same DLL is only logical.

 

But with this we are still not at the end of the exercise. If you have come so far, which will be quite a bit of work already, you only get some binary datastreams into LabVIEW. How to interprete them further can be with proper documentation of the actual protocol simply an exercise in byte and bit shuffling, with some boolean logic mixed in, or it can be without documentation of the protocol a trial and error process that can or cannot bring you to any more or less reliably working solution.

 

While I think I could make this work, I would also expect to have to spend quite a few days into this, and maybe not unimportant, I do have quite a bit of experience in interfacing DLLs through the Call Library Node as well as writing intermediate DLLs to translate between the LabVIEW Call Library Node and  some other less LabVIEW friendly API, such as the SetupDi.. API certainly is.

 

I guess what I want to say with this is that this route is only going to work if you have the knowledge or determination to learn the knowledge to go quite a bit into Windows API programming, writing some C code to create your own DLL, and also fiddle around with the resulting binary byte streams that you get into LabVIEW.

 

Otherwise you would be better of by hiring someone to do this for you, or most likely a lot cheaper, look for a ready made ActiveX, .Net or even simply function DLL component that does the interfacing to this device already.

 

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 15
(10,062 Views)

I see actually that the scale seems to have a "normal" RS-232 port too 9you seem to need a special cable because of the modular connector but otherwise it appears normal).

This seems to me the better way to try to communicate with that device from within LabVIEW. Still some work to do although there are likely Mettler Toledo Instrument drivers for LabVIEW you can reuse with not to many modifications.

 

Rolf Kalbermatter

 

 

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 15
(10,058 Views)

Thanks for the responses. 

 

I wrote the program for a scale that had a "Serial" cable on my desk.  Then I went to install in the warehouse, and all of the scales had USB connections only.  Serial programing wasn't too hard to figure out.

 

I really would like to figure out how to communicate with a USB device.  I would like Labview to share the same USB device with other applications.

 

It seems the "Call Library Function Node" vi is the ticket, but I have no idea how to use it.

 

Doug

0 Kudos
Message 5 of 15
(10,040 Views)
what version of labVIEW?

"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 15
(10,036 Views)
Version 8.6
0 Kudos
Message 7 of 15
(10,034 Views)

the easy way is to goto Tools>Import>shared library or DLL.  you will need to select the DLL and its Header file and let LV build the wrappers for you. 

 

If you don't have the header file you will need toconfigur the calllibrary function nodes yourself from a document that contains the function prototypes (tough but rewarding)


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 15
(10,023 Views)

Hi Jeff,


I don't have a HID.h header file.

 

I have a call into NI support too.  Maybe NI Support can think of an idea.  From the looks of the responses this not going to be easy. Smiley Sad

 

Doug

0 Kudos
Message 9 of 15
(10,017 Views)

If you don't use the instrument driver you can use USB to talk to the device like a serial device with VISA. Here's a KBs on the topic: http://digital.ni.com/public.nsf/allkb/E3A2C4FE42D7ED0D86256DB7005C65C9?OpenDocument.

 

If you're using a premade DLL, you need the header information to set up the calls in the DLL. You need the .h file to outline all the parameters (and order) when setting up the Call Library Reference Node. Without that, you're probably out of luck.

Jeff | LabVIEW Software Engineer
0 Kudos
Message 10 of 15
(10,012 Views)