LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Mouse acquisition.

Solved!
Go to solution

My objective is to create a lab view program that tests the functionality (buttons, scroll wheel, table tracking) of a USB mouse that is plugged into the USB port and so I am trying to deal with the raw data that the mouse sends out.

 

I currently have a wireless USB mouse and I am trying to get button and axis information in Labview.  For some reason or another, when I try to create a VISA driver from the "Driver Wizard" and update the driver so that my USB dongle uses that driver instead of the standard HID driver, the device comes back with an error saying "Device cannot start" in the Device Manager.  Is there something special that I need to do when creating the driver?  I am using the correct VID and PID that the wizard is asking me for.  I have done this in the past for other USB devices (game controllers) but this wireless USB mouse is giving me a headache.

 

Are there other methods of getting the USB mouse raw data in labview aside from using the VISA driver method that I have used in the past?  I have also tried using the "Input Device Control" VIs from the function pallate but the problem is, I cannot have 2 USB mouse plugged in (mouse for controlling the program and mouse under test) because while the "test" is running, either mouse can be used to affect the test.

 

Thank you in advance for your help.

0 Kudos
Message 1 of 18
(8,034 Views)

This helped me out a lot when I had the same problem:

 

USB and VISA

 

One thing to note is you might want to play with the timeout value to get your data in in full chunks.

0 Kudos
Message 2 of 18
(8,030 Views)
Thanks Zenthoef for the reply but unfortunately, I cannot even get my device to enumerate as a VISA driver.  I have gone through the Driver Wizard multiple times in the past on other USB devices and have worked flawlessly.  But for some reason, this particular USB mouse is giving me a difficult time.  I am getting the error "device cannot start" in the device manager and so I cannot even communicate to the device in labview.  Are there any other methods of getting raw data from a USB device?
0 Kudos
Message 3 of 18
(8,023 Views)

I missed that the first time... If you can't get this mouse to work with the driver wizard there is only one other thing I can think of. That is using the hid.dll with a code interface node to try and get this data. I believe doing this will involve more than using the hid.dll though. I've never even started to do it because I thought it would be too hard compared to the VISA RAW stuff.

 

I know its almost a silly question, but when you used the driver wizard the VID And PID were correct for that mouse when the driver was built, right? I can't image what else would cause the "device cannot start" error in device manager.

0 Kudos
Message 4 of 18
(8,017 Views)

Yeah.  The VID PID are correct.  I have always used the VISA RAW stuff in the past but this silly dongle (along with other dongles made by the same company) are giving me a headache.  I am running out of ideas on how else to get this to work.

 

Thanks for your help anyway.  Anyone else have any ideas?

0 Kudos
Message 5 of 18
(8,010 Views)

Does having multiple endpoint ins and multiple endpoint outs have anything to do with the issue I have when I am trying to create a VISA driver for my USB mouse?

0 Kudos
Message 6 of 18
(7,995 Views)

Your dongle may have multiple interfaces which would make it a compound device.

 

If your device can also interface to, say, a keyboard, then it is a compound device.  Try plugging in a normal USB mouse (with cable) to get that up and running first before going back to wireless again.

 

I have never been able to get a compound device up and running with VISA RAW.  I wrote the nugget linked to earlier by the way.

 

That might get rid of one or two problems you currently have.

 

Shane.

0 Kudos
Message 7 of 18
(7,950 Views)
Solution
Accepted by topic author Gormander

Thank you all for your comments.  I finally got it to work using the VISA driver method after a few hours of playing around with other methods (using Hid.dll, library nodes, etc).

 

You are right Intaris that it is a compound device.  The trick is to indicate that it is a compound device when creating a driver with the correct number of interfaces.  Then when you go to update the driver, you have to chose the correct "USB Human Interface Device" in the Device Manager (under Human Interface Devices list) to update.  For example, the USB dongle is using USB Interface 0001 to communicate with my mouse, so I had to update the "USB Human Interface Device" that corresponds to that correct interface.

 

All I can say is that It finally works.

 

Thank you everyone for all your help.

 

I have encountered another problem but I will try to play with it before I come to the forums for some help 🙂

0 Kudos
Message 8 of 18
(7,920 Views)

Gormander,

 

glad you got it working.

 

Can you give a short feedback how you got it working, including VID and PID of the mouse you were using so that I can maybe add to my previous nuggets.  I personally have been unable to get any compound devices working under VISA.  I'm probably doing something silly, so I'd appreciate your help if possible.  I'm no USB expert, I learned by doing (and a lot ofblood, sweat and tears).

 

Shane.

 

 

0 Kudos
Message 9 of 18
(7,888 Views)

Sure no problemo. So what I found is that the USB dongle can communicate with both a keyboard and mouse, which is the reason for a compound device. I believe (dont quote me on this) that the keyboard communicates on interface 0000 and mouse communicates on interface 0001.

 

To create the driver, I did what the steps ask me to do. Start Menu --> All Programs --> National Instruments --> Visa --> Driver Wizard.  Once the driver wizard opens up...
1) Select USB and press Next
2) Input all the information asked.
3) Check the Compound Device check box and select the correct number of interfaces your device has. (I used USBView.exe to find out that information).
4) Click Next and name ur driver name and location and your set.

 

Because I am only testing the mouse, I only want to update the correct "USB Human Interface Device" that corresponds to the correct interface. You can easily find that by opening up the properties of "USB Human Interface Device" going to the "Details tab" and looking at the "Device instance Id" information. The information looks like the following "USB\VID_046D&PID_C521&MI_01\6&21C372B&0&0001"

 

Now dont ask me what all that stuff means cause I dont really know. I just know how to get the VID, PID and Interface off that information line. The 0001 at the end is the interface number. Once I figured out about which interface to update the driver on, it was easy peasy.

At first I updated the "USB Human Interface Device" with interface 0000 at the end but it did nothing in my VI. Since that didnt work, i tried updating the device with interface 0001 and it worked.

 

I hope this helps.  It may be a little more detailed then what you had asked (or not enough).  Let me know if you need more information.

0 Kudos
Message 10 of 18
(7,859 Views)