Driving a servo via USB-Port.
Go to file
2006-11-08 06:36:31 +00:00
circuit First version 2006-10-28 12:40:42 +00:00
commandline First version 2006-10-28 12:40:42 +00:00
common First version 2006-10-28 12:40:42 +00:00
firmware First version 2006-10-28 12:40:42 +00:00
Changelog.txt First version 2006-10-28 12:40:42 +00:00
License.txt First version 2006-10-28 12:40:42 +00:00
Makefile Create PDF-documentation 2006-11-08 06:36:31 +00:00
Readme.txt First version 2006-10-28 12:40:42 +00:00

This file is auto-generated from the content of common/usbservo.h
You'll have more fun if you read the HTML-content in htmldoc or the PDF.


     * [1]Main Page
     * [2]Files

                                   USB-Servo

Introduction

   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

   Both, the firmware and Unix command line tool are built with "make".
   You may need to customize both makefiles.

  Firmware

   The firmware for this project requires avr-gcc and avr-libc (a
   C-library for the AVR controller). Please read the instructions at
   [3]http://www.nongnu.org/avr-libc/user-manual/install_tools.html for
   how to install the GNU toolchain (avr-gcc, assembler, linker etc.) and
   avr-libc.

   Once you have the GNU toolchain for AVR microcontrollers installed,
   you can run "make" in the subdirectory "firmware". You may have to
   edit the Makefile to use your preferred downloader with "make
   program". The current version is built for avrdude with a parallel
   connection to an stk200-compatible programmer.

   If working with a brand-new controller, you may have to set the
   fuse-bits to use the external crystal:

 avrdude -p atmega8 -P /dev/parport0 -c stk200 -U hfuse:w:0xC9:m -U lfuse:w:0x9
F:m

   Afterwards, you can compile and flash to the device:

 make program

  Commandline client and demo application

   The command line tool and the demo application require libusb. Please
   take the packages from your system's distribution or download libusb
   from [4]http://libusb.sourceforge.net/ and install it before you
   compile. Change to directory "commandline", check the Makefile and
   edit the settings if required and type

 make

   This will build the unix executable "usb-servo" which can be used to
   control the device, and the demo application "xservopointer".

Usage

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

  Commandline client

   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:

 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-led-fader 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.

Files in the distribution

     * Readme.txt: Documentation, created from the htmldoc-directory.
     * firmware: Source code of the controller firmware.
     * firmware/usbdrv: USB driver -- See Readme.txt in this directory
       for info
     * commandline: Source code of the host software (needs libusb).
       Here, you find the pure commandline client (usb-servo) and the fun
       demo application (xservopointer).
     * common: Files needed by the firmware and the commandline-client.
     * circuit: Circuit diagrams in PDF and EAGLE 4 format. A free
       version of EAGLE is available for Linux, Mac OS X and Windows from
       [5]http://www.cadsoft.de/.
     * License.txt: Public license for all contents of this project,
       except for the USB driver. Look in firmware/usbdrv/License.txt for
       further info.
     * Changelog.txt: Logfile documenting changes in soft-, firm- and
       hardware.

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 - are 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.

   (c) 2006 by Ronald Schaten - [6]http://www.schatenseite.de
     _________________________________________________________________


    Generated on Sat Oct 28 14:16:28 2006 for USB-Servo by  [7]doxygen
    1.4.7

References

   1. file://localhost/home/rschaten/microcontroller/usb-servo/htmldoc/main.html
   2. file://localhost/home/rschaten/microcontroller/usb-servo/htmldoc/files.html
   3. http://www.nongnu.org/avr-libc/user-manual/install_tools.html
   4. http://libusb.sourceforge.net/
   5. http://www.cadsoft.de/.
   6. http://www.schatenseite.de/
   7. http://www.doxygen.org/index.html