Simple servomotor control over USB

From RoboWiki
Jump to: navigation, search

Author: Pavel, ppetrovic Zavinac.gif

Slovenská verzia

In some applications it may come useful to control one or two small servomotors with low power consumption directly from PC. Examples may include pan-tilt camera control, feeding your pet fish, regulation of sunlight of your favourite pet plant, etc. Such device can be easily built, you only need soldering equipment and a little bit of patience. We are talking here about the classical servomotors that are controlled using a digital PWM signal at TTL level. We will need the following parts:

  • PCB
  • USB cabel
  • USB connector to be soldered into PCB
  • CPU Atmel ATtiny2313 in PDIP (and 20-pin socket)
  • 12MHz oscillator (Q1)
  • Resistors:
    • 150R (R5)
    • 1M (R1)
    • 1k5 (R2)
    • 2x 68R (R3,R4)
  • Capacitors:
    • electrolyt 4u7 (C1)
    • 100n (C2)
    • 2x 18p (C3, C4)
  • LED (D3)
  • 2x diode i.e. 1N4007 (D1,D2)



The placement of the parts is left up to your creativity ;)


Servomotors are connected to the two three-pin terminals. In our case, we use directly the power from the USB port, but obviously, you can use the power from an optional battery pack that you add to your setup, if your motors are not really low-power.

The whole project is based on V-USB from Objective Development. We derived it from the PowerSwitch project that we modified for our needs.

Software consists of three parts:

  • Firmware - program for ATtiny2313, it manages the USB bus and processes the motor requests
  • Driver - program for PC that needs to be installed the first time you plug the device to your PC
  • Control program - allows to send the commands to the device from PC over USB (and determine its state)

The control program is a simple console application (written in Cygwin). Use the parameters to specify the action. Run the program without arguments to get the usage help message. You do not need to install Cygwin, unless you want to modify it or use the manual keyboard control mode (that is based on ncurses and requires Cygwin terminal functionality). We also have a GUI application writtein in Imagine Logo language, that allows one to control the motors using mouse. The bottom part of the window contains memory buttons for storing 5 specific locations.


All parts of the software including short readme.txt file and schematic are available for download here: (996 KB)