views:

94

answers:

5

I have a little USB-powered light. I'd like to be able to turn it on and off with software. I'll be attaching it to a Linux computer. I have an Atmel ATtiny2313 from a previous project, but I'd rather do this with a simple hack than repurpose my microcontroller.

Is this possible? I suspect this can't be done as the computer won't talk to a device without some kind of USB-compliant firmware?

I found this question, which has a comment suggesting that the OP use an LM317 voltage regulator to change the voltage of the USB out. I don't think this is applicable to me, but thought I'd mention it.

Update:

Looks like I could maybe put USBtiny on my microcontroller, then I could wire it up to the light, then I could write an app to control the controller. Sounds like a lot of work, though. I'd rather do a simple hack, but I lack experience with USB.

+2  A: 

I don't think it is possible, because the power (Vcc) line on USB is always-on--it is not intended to be a control line.

Unless your USB light already provides a way to control itself via USB data, you are out of luck. I do not recommend trying to change the voltage of the USB power line.

Patrick Szalapski
But can I manipulate the data output from the computer and use that as input to a transistor or microcontroller? Then I can control whether to let the 5V through to the light. I just don't know if I can manipulate the data pins on the USB port if the device on the other end isn't a legitimate USB device.
sidewaysmilk
So you would shunt the data lines on the usb port to your own microcontroller? I suppose there is a way, but then you'd have to learn the USB hardware layer and how to write a driver for it.
Patrick Szalapski
@Patrick: Yeah! I think you're mostly right, but [USBtiny](http://www.xs4all.nl/~dicks/avr/usbtiny/) should fit on my microcontroller, and should fill this role for me. I'm probably going to learn the USB hardware layer anyway for fun.
sidewaysmilk
+1  A: 

Maybe you can tell the USB controller to cut off power to the USB port. I've seen this option on the power saving settings on my PC.

jdv
I don't think I can do that. Especially if the device is dumb.
sidewaysmilk
+2  A: 

Your best bet is probably to buy something like an FTDI interface cable, available from Digi-Key for $20. That gives you +5, ground, and four wires you can switch high or low under software control. The software's easiest if you use the thing as a logic-level serial port with rx/tx/rts/cts. The manufacturer part number is TTL-232R-5V-WE (go to digikey.com and type that number into the part search box). Digi-Key has links to the manufacturer data sheets and web site.

supercat
+1 DigiKey is a damn good resource for serious electrical/computer engineering.
Hamish Grubijan
This looks cool. I think that my current USB/serial bridge may be able to help me here. I have a [PL-2303 ](http://www.prolific.com.tw/eng/products.asp?id=59) USB/serial adapter. Think that'll do it?
sidewaysmilk
@supercat: I appreciate your suggestion and +1 it, but it doesn't really answer my question. Thanks for the DigiKey and FTDI tips, though! I especially appreciate the part number.
sidewaysmilk
A: 

I'm going to use my PL-2303-based USB/serial bridge and an ATtiny2313 microcontroller running a USB stack--possibly USBtiny. It'll work like this:

  • The USB light is attached directly to the microcontroller--not the computer
  • An app/driver controls the microcontroller via USB
  • The microcontroller sets the voltage for the USB light

I'll look into wiring it so there are some resistors on some outputs so I can set the light to different brightnesses, and if I want to do patterns or anything, I'll do them in software.

sidewaysmilk
A: 

Would it be possible to rewire the usb connector so that instead of being connected to VCC the power of the usb light would be connected to the data of the usb port?

Then maybe you could control that and specify if it was 0 or 5 volts.

Not sure if that's even possible, I know nothing about usb.

dioltas
I considered this, but I doubt I'll be able to talk to the data wire of the USB port if the device at the other end isn't doing USB communication. I also know very little about USB. I think I'll know quite a bit by the end of this project, though. :)
sidewaysmilk