LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I programmatically control USB with LabVIEW?

I have a requirement to test a USB device. The test includes powering several of the devices off and on, i.e., power cycling for several hours. My plan is to accomplish by using a USB hub, breaking out the power circuit and running it through a relay inside of a DAQ. A neater solution would be to programmatically turn the USB device off and on. I know that the computer communicates with the device under test via USB and not the USB port itself. So I’m wondering if it’s possible with LabVIEW to accomplish this.

 

Thank you.

 

 

0 Kudos
Message 1 of 10
(6,512 Views)

Depending on the current consumption of the device, you may be able to toggle power without going through a relay... use a driver or enable line on a 5V regulator going to the DUT.  A little less headache on the electrical side of things doing that than using relays.

 

Are you testing hardware or software/drivers?  Microsoft has tools that'll let you control device manager through a commandline (use the system_exec.vi to do this), but it obviously won't cut 5V power to the device and force discovery/re-enumeration when the device comes online again.

 

 

Message 2 of 10
(6,502 Views)

I'm testing six high grade isolated low current (350mA) CAN-to-USB converters simultaneously, with power cycling being part of the test. I'm planning  on taking the converters USB from a USB hub attached to the computer. Attached to the CAN side of the converters will be the CAN side of a NI CAN-to-USB converter (six in all), and the NI USB side will come back to the computer via another hub. This way I can transmit and receive messages and verify that communications are good. My plan is to power cycle the high grade converters by running the five volt line from the converters hub through a relay card on a DAQ.

0 Kudos
Message 3 of 10
(6,482 Views)

Hi chuck72352,

 

If you mean a way to control the USB hub functionality (like disable the USB ports to power it off) there is no such native functionality; if you want to get into that you may start thinking on checking if ActiveX allows you doing such thing and start working with its implementation.

 

Regards,

 

Eric NI

Message 4 of 10
(6,445 Views)

I'm not very familiar with active X, but I'll  look into it. Do you know a good resource for getting up to speed with active x?

 

Thank you.

0 Kudos
Message 5 of 10
(6,410 Views)

I'm not exactly sure what Eric was referring to as far as ActiveX. If it's with respect to the operating system, you're not going to find any ActiveX interface with the OS to do this. Unless he was referring to software programmability of the hub? Don't know.

 

With respect to power-cycling, a USB port can be disabled using OS calls. Thus, if you want to just turn off the whole hub you can disable the USB port that the hub is connected to. On Windows you can use a command-line utility called devcon to do this (search the forum as this has been mentioned before). The limitation is that devcon is not redistributable. This means that you cannot include it if you're giving this software to a customer. If, on the other hand you need to selective turn off the ports on the hub (i.e., to test individual devices), then you'd have to go back to the manufacturer of the hub and find out if they have a software interface to do this. Otherwise, it's the external power on/off approach via a relay or via a regulator as suggested by SnowMule.

 

EDIT: Additional caveat: devcon may not work under Windows 7. You did not indicate what operating system you're using. However, the OS calls that devcon makes are still there.

Message 6 of 10
(6,405 Views)

For my application disabling/ enabling the entire hub via LabVIEW would do the job. I'll research "devcon".

 

Thank you.

0 Kudos
Message 7 of 10
(6,398 Views)

Hi smercurio_fc, thanks for the clarification, I was actually thinking on disabling the USB hub programatically but I did not know if there was an ActiveX control to do that.

0 Kudos
Message 8 of 10
(6,374 Views)

Did you ever solve this with Devcon?

0 Kudos
Message 9 of 10
(5,464 Views)

Hey Srapoport,

 

If you have a question or something you’d like help with, it would be a better idea to create a new thread about your issue. You’re much more likely to get some help that way, this thread’s been inactive for a while.

 

Also, it’d be a great idea to include some basic info were you to create a new thread: LabVIEW version, O/S, any hardware you’re using (possibly the USB device(s) you’re concerned with) and any steps or attempts you’ve taken so far. That’ll give people a more thorough background and make things smoother.

 

Respectfully,

Cason - NI

Cassandra Longley
Senior Technical Support Engineer - FlexRIO, High Speed Serial and VRTS
0 Kudos
Message 10 of 10
(5,378 Views)