USB-Servo (aka Mousepointerpointer)

... and you'll never have to search for your cursor again!
The device

The USB-Servo is a device to control a servo via USB. A servo is a motorized device that is commonly used in remote controlled cars and planes. I built this device to activate a toy puppet. The puppet has a button on its bottom, if you press the button the puppet collapses. When the computer is able to press the button, I can use the puppet to signal information like someone's online-state in the Jabber-network: when my friend goes online, the puppet stands up, when he logs off it collapses.

Servos are connected with three-wire-cables. A red and a black one for the power, and a yellow one for the signal. Power has to be between 4.8 and 6 volts, so the 5 volts from the USB-port is in the range. The signal doesn't take much current, so you can connect it directly to the controller. The angle of the servo is controlled with pulse width modulation (PWM). It gets a signal of about 50Hz (one pulse every 20ms), the length of the pulse tells the servo the angle to adjust.

A problem that I didn't really solve is the power consumption: I don't know the current that runs through the motor. It seems to be low enough not to cause any problems, but I don't know how high it will get when the servo is blocked. YOU HAVE BEEN WARNED, I don't feel responsible for USB-ports catching fire... :-/

There are three parts included in the distribution: The firmware for an ATmega8 microcontroller, a commandline-client that can be run under Linux, and the circuits needed to build the device.

This project is based on my USB-LED-Fader, which itself is based on the PowerSwitch example application by Objective Development. Like those, it uses Objective Development's firmware-only USB driver for Atmel's AVR microcontrollers.

Objective Development's USB driver is a firmware-only implementation of the USB 1.1 standard (low speed device) on cheap single chip microcomputers of Atmel's AVR series, such as the ATtiny2313 or even some of the small 8 pin devices. It implements the standard to the point where useful applications can be implemented. See the file "firmware/usbdrv/usbdrv.h" for features and limitations.

Building and installing

The circuit contains only a few standard components. There's no special USB-chip involved.
Circuit

The installation is described in the documentation.

Usage

Connect the device to the USB-port. If it isn't already, the servo will move to the 0-position.

Then use the commandline-client as follows:

usb-servo status
usb-servo set <angle>
usb-servo test

Parameters

  • angle: The angle you want to set the servo to. 0 is full left, 255 is full right.

Examples

Get the status of the servo:

usb-servo status

This will tell you the angle the servo is currently put to.

Current servo angle: 42

Set a new angle:

Behind the scenes
The device from behind
usb-servo set 23

This sets the servo to the angle 23. 0 is full left, 255 is full right, so with 23 the servo will be almost on the left side.

Test the device:

usb-servo test

This function sends many random numbers to the device. The device returns the packages, and the client looks for differences in the sent and the received numbers.

Demo application xservopointer

This is a pure fun thing, nobody will need it. That was reason enough to write it...

To use it, you have to position the servo centered above the screen (with a little tweaking in the source, you can change that position). Then, you attach a pointer to the servo and start the application.

You'll never ever have to search for your mouse cursor in the future. The pointer on the servo will always show you where to search.

Drawbacks

The main drawback is the mentioned power consumption. I tested it with my servo on my notebook, it is not sure to work on other systems. THIS MAY BE HARMFUL FOR YOUR COMPUTER, and nobody but yourself will be responsible for any damages.

Another, not so big problem is the crude implementation of the PWM. I got the timing-values by trial and error, and they might not fit on your servo. On the other hand, I think that servos should be interchangeable. But this is my first and only one, so I can't say anything about that.

Thanks!

I'd like to thank Objective Development for the possibility to use their driver for my project. In fact, this project wouldn't exist without the driver.

About the license

My work - all contents except for the USB driver - is licensed under the GNU General Public License (GPL). A copy of the GPL is included in License.txt. The driver itself is licensed under a special license by Objective Development. See firmware/usbdrv/License.txt for further info.

Download