murny_shah
Posts: 5
Joined: Sun May 11, 2014 11:09 am

how to make the usb interface on pi as output

Wed Oct 08, 2014 5:10 pm

hello fellas,

i'm in the middle of doing my final year project about pir sensor... my project is, to switch on the light when motion is detected... i want to use desktop led lamp as the output...as you all know, the desktop led lamp is using usb in order to swtich on... i want to use the usb interface on the raspberry pi to connect it with my desktop led lamp...how am i gonna do that?? is there any suggestion or mybe if there any python coding for that,can you all share it for me... i'll appreciate your help...

thank u...

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6400
Joined: Fri Jul 29, 2011 5:36 pm

Re: how to make the usb interface on pi as output

Wed Oct 08, 2014 5:14 pm

Please don't spam the same topic across the forum. Thanks.

User avatar
Burngate
Posts: 6553
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: how to make the usb interface on pi as output

Wed Oct 08, 2014 5:22 pm

...as you all know, ...
Don't make too many assumptions!

I don't know about your lamp, but others I've come across don't have any control - if there's power on the USB plug, the lamp is lit.
As the Pi's USB sockets are always powered*, you can't control the lamp that way. You'll need to put some electronics into the lamp, and drive it from a GPIO


*not quite true - on the B+, the power goes through a switch-chip, and that's got an enable on it, that comes from the 9514 USB/LAN chip.
But you probably didn't want to know that. ;)

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: how to make the usb interface on pi as output

Fri Oct 10, 2014 12:34 am

murny_shah wrote:as you all know, the desktop led lamp is using usb in order to swtich on...
How exactly was I supposed to know that?

Does the USB connection from the lamp actually have logic on it to switch it on and off over USB, or is it just a USB-powered lamp like Burngate mentioned?

If it has logic on it, check the datasheet and send whatever signal it's expecting to turn off and on. If not, I'd use a GPIO pin to switch a relay or transistor which controls the lamp instead. You'd obviously have to tap into the power wire of the lamp's cord if this is the case.

hippy
Posts: 13826
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: how to make the usb interface on pi as output

Fri Oct 10, 2014 11:49 am

Burngate wrote:on the B+, the power goes through a switch-chip, and that's got an enable on it, that comes from the 9514 USB/LAN chip.
Do you have a link to details on that as the circuit diagram I have for the B+ doesn't show it. Perhaps I haven't got the latest circuit diagram?

User avatar
Burngate
Posts: 6553
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: how to make the usb interface on pi as output

Fri Oct 10, 2014 4:58 pm

hippy wrote:Do you have a link to details on that as the circuit diagram I have for the B+ doesn't show it. Perhaps I haven't got the latest circuit diagram?
Sorry, don't have a link - I prodded around with my meter, used my skill and judgement (AKA guessed) and came up with this - I can't guarantee the accuracy!
USBpower.png
USBpower.png (5.39 KiB) Viewed 8389 times
Note: no component values, and the diode might be reversed!

User avatar
B.Goode
Posts: 14826
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: how to make the usb interface on pi as output

Fri Oct 10, 2014 5:18 pm

murny_shah wrote:hello fellas,
So you don't want to hear from any female readers who might have information for you?

(Or maybe 'fellas' is now gender-neutral, like 'actor'?)

To the point: the power lines in the RPi usb sockets are not themselves (trivially) programmable. Maybe you could take that constant power feed to a chip like those used in motor-control H-bridge circuits, and switch that on and off via a programmable gpio pin? But if this is your final-year project that's as helpful as I am going to be...

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14922
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: how to make the usb interface on pi as output

Mon Dec 15, 2014 7:41 pm

Burngate wrote:
hippy wrote:Do you have a link to details on that as the circuit diagram I have for the B+ doesn't show it. Perhaps I haven't got the latest circuit diagram?
Sorry, don't have a link - I prodded around with my meter, used my skill and judgement (AKA guessed) and came up with this - I can't guarantee the accuracy!
USBpower.png
Note: no component values, and the diode might be reversed!
I can confirm the correctness of the schematic, and can add some values.
Diode is one halve BAV99 with cathode on enable pin, FET = DMG1012T,
resistors from left to right:
1K8 Pullup R48
100K R47 over diode
R50 and R4 both 39K to gnd and to drain FET
R6 100 gate pulldown.
capacitors:
220nF C106 on enable pin, and also on Vin and Vout.
IC U13 = AP2553W6

also the fault signal from/to the LAN9514 is called "USB_OVC_N", and can both be used to sense a fault condition AND to force USB power off! (something I missed at first, but for someone insisting the USB power could be turned off).
The signal goes to pin 14 of the LAN9514.

Return to “Advanced users”