How would I control the output of the power in USB ports in Linux?

18,908

Solution 1

The USB voltage is fixed at a nominal 5 volts and cannot be controlled.

The behavior of USB devices regarding their current draw is well defined in the USB specifications. USB devices are supposed to draw up to 1 unit load (100mA) unless they have negotiated a higher load from the USB host. It's quite likely that the servo motors that you have are going to need to draw higher currents than that, and wouldn't be able to request it without being a USB device and negotiating with the host.

It's also likely, depending on the servo motor that you are trying to control, that you'll need to either provide a PWM signal or an analogue voltage to control motor position. USB hosts are not intended to provide either of these.

Your best options to drive your motor from your PC are:

  1. Get a dedicated USB controller for your servo motor (if one exists)
  2. Make your own, based on a small microprocessor (eg. using an arduino)
  3. Choose a different port on the PC. If available, PC parallel ports can be controlled to provide control for motor drivers.

Solution 2

The answers here seem to say it is a hardware issue, but I think this is a software issue. ASUS has Ai Charge which more then doubles the volts to charging Apple products from a standard 2.0 usb port.

USB 1.0, 2.0 and 3.0 Specs (All at 5 volts) 4 Wires (2 Data and 2 dedicated power)

Voltage Breakdown: USB 1.0 and USB 2.0 = 0.5A or 500 mA = 2.5 watt USB 3.0 = 0.9A or 900mA = 4.5 watt Wall wart = 1.5A or 1500 mA = 7.5 watt Ai Charge = 1.2A or 1200mA = 6 watt

Ai Charge works on ASUS and non-ASUS motherboards and is a program you can install in Windows.

Personally I HATE Apple so I want to figure out a way to do this 1.2A usb 2.0 output trick for my netbook while running Linux.

Solution 3

you need to use PWM to control motors speed, to do that you need a micro controller, PIC18F series supports USB communication, there are plenty of code samples available internet how to use USB in PIC18F series, also you need a transistor array or H-Bridge to control mortors from PIC.

The simplest way to communicate is, program a USB serial in PIC18F micro controller, and when you plug that 18F to your computer, it will detect USB serial port, so you can send the commands to serial port to control speeds.

Solution 4

I don't believe it is possible to directly manipulate the USB voltages. They are designed to provide a +5V output at all times unless power is diminised with other hubs.

You might be better served posting this question on http://electronics.stackexchange.com

Solution 5

I dont think its possible, and even if it was, consider this: The USB port is not suposed to power motors because you can burn the USB port. USB is limited to 500mA (or there abouts) and any power device like a motor can potentially require more than that.

Another thing is that servos should be driven with constant voltage, and the speed is controlled by timing impulses on the control wire. http://en.wikipedia.org/wiki/Pulse-width_modulation

You should use a driver (hardware) to power the motor with an external power source.

Share:
18,908
Chris
Author by

Chris

I am an iOS developer.

Updated on June 16, 2022

Comments

  • Chris
    Chris almost 2 years

    I built a robot from a thin client pc (can run Windows CE or Linux) and two servo motors. I put USB ends on the servo motors, so when they are plugged in to the thin client they continuously run. In Linux, how could I set the amount of current or voltage going from the USB ports to the servo motors? Would I be able to run a shell script to set the power of a certain USB port to slow down a motor or stop one? If this cannot be done through software, what is the easiest way to do this through hardware without having to buy too much?

  • Gabe
    Gabe over 12 years
    He's trying to change the power. Since the voltage is always constant, he needs to vary the current.
  • Ben Voigt
    Ben Voigt over 12 years
    Of course, a large number of devices just try to pull more current without negotiation, which is probably the case here.
  • Chris
    Chris over 12 years
    Thanks, but my thin client doesn’t have a parallel port. Could I control it through an rs-232 port. Also, with the arduino, would I have to program it and then run a program to control my motors or would it work as a usb controller because from what I’ve been researching, arduinos actually cost drastically less than servo motor usb controllers.
  • Andrew Edgecombe
    Andrew Edgecombe over 12 years
    @Chris - Yes, you would have to run code on the Arduino to actually drive the servo motor. To allow the thin-client to "control" the servo either program the Arduino as a usb device or, as a simpler option, use the rs232 port from the thin-client to the arduino and implement your own control protocol.