|
-
Jan 10th, 2009, 12:17 AM
#1
Thread Starter
Lively Member
Power on/off usb.
Hi friends,
I have a requirement for my project as stated below:
I am using VB6 for programming.I have an external control card which is connect to my PC's USB port and hence is powered through my CPU. Now the requirement is Can I control the supply of power from my PC's USB port. In other words i should be capable of powering on/off the control connected to my PC USB port.
Do anyone of you know how to control supply from USB port to external devices.
If yes can you please post how to accomplish it.Code bit will be very useful.
Thanks in advance.
With Regards,
Siddaraju.A
-
Jan 10th, 2009, 01:26 AM
#2
Re: Power on/off usb.
Sorry, but the supply line of the USB port is not controllable. It's regulated @ +5V.
Last edited by CDRIVE; Jan 10th, 2009 at 01:27 AM.
Reason: typo
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 10th, 2009, 01:57 AM
#3
Re: Power on/off usb.
Look here:
http://support.microsoft.com/default...;EN-US;Q311272
Try this:
put deveject in your system32 folder and then:
Code:
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
Private Function ShellWait(PathName, Optional WindowStyle As VbAppWinStyle = vbNormalFocus) As Double
Dim hProcess As Long, RetVal As Long
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(PathName, WindowStyle))
Do
GetExitCodeProcess hProcess, RetVal
DoEvents: Sleep 100
Loop While RetVal = STILL_ACTIVE
End Function
Private Sub Command1_Click()
ShellWait Environ("ComSpec") & " /c deveject -EjectName:" & Chr$(34) & "USB Mass Storage Device" & Chr$(34) & " > C:\Temp.txt", vbHide
Dim ff As Integer
ff = FreeFile
' display results
Open "C:\Temp.txt" For Input As #ff
fData = Input$(LOF(ff), ff)
Close #ff
MsgBox fData
Kill "C:\Temp.txt"
End Sub
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jan 14th, 2009, 01:36 AM
#4
Thread Starter
Lively Member
Re: Power on/off usb.
Thanks isnoend07 but i am not finding deveject. I went through the URL you mentioned but i did not get what to exactly do.Please brief a bit more.
-
Jan 14th, 2009, 02:14 AM
#5
Re: Power on/off usb.
 Originally Posted by ajay_vb
Thanks isnoend07 but i am not finding deveject. I went through the URL you mentioned but i did not get what to exactly do.Please brief a bit more.
There is a utility, Google "deveject" lots of resullts
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Jan 14th, 2009, 08:39 AM
#6
Re: Power on/off usb.
deveject looks like a handy utility but I don't see how it can disable the USB supply bus. Of course, I may have misunderstood what you're trying to do.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 15th, 2009, 12:17 AM
#7
Thread Starter
Lively Member
Re: Power on/off usb.
Basically what i wanted to do is, i have a CAN(control area network) controller card attached to USB port of my PC. But whenever power goes off and on then i need to replug the control card cable to USB port. Instead of doing it frequently and spoiling USB port I thought of powering off and on the device from my pc itself so that the control card gets reset. In otherwords whenever i wish to reset the control card i wish to have button press which switches of CAN card and switches it on.This i thought of doing through stopping the +5v supply from USB port and again on the supply.
-
Jan 15th, 2009, 09:13 AM
#8
Re: Power on/off usb.
I was going to suggest utilizing the "Safely Remove Hardware" icon that pops up in the SysTray but that function does not appear for all USB hardware.
I know of no way to disable the USB V+ supply directly through code but I can show you how to do this through MSComm code and some hardware that will effect only your CAN device.
Another Firmware/Hardware alternative would be to utilize a PIC to switch the USB supply to the CAN. This would eliminate the RS232 cable interface that MSComm would require and any additional software on the PC.
Edit: The simplest (bare bones) method would be to build a USB feed through box with a switch on it. All lines would just pass through with the exception of the +5V supply line which would be connected through the switch.
Last edited by CDRIVE; Jan 15th, 2009 at 09:26 AM.
Reason: Add additional info.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 17th, 2009, 02:06 AM
#9
Thread Starter
Lively Member
Re: Power on/off usb.
Thank you cdrive for your suggestions.You had mentioned that you could show how to power off/on USB port through MSCOMM.Can you please post a sample code bit for doing it. Its very urgent pleeeeeeease.
Thanks in advance.
with regards,
Ajay
-
Jan 17th, 2009, 10:09 AM
#10
Re: Power on/off usb.
Are you skilled with basic electronics including wiring & soldering? Ports are not impervious to mis-wiring, so you must be certain of your skills.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|