Simple servomotor control over USB

From RoboWiki
Revision as of 19:21, 14 July 2009 by Palo (talk | contribs) (New page: ''Author: Pavel, ppetrovic Image:zavinac.gif acm.org'' Slovenská verzia In some applications it may come useful to control one or two s...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Pavel, ppetrovic Zavinac.gif acm.org

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)


Schematics:

Usbservo.gif

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

Usbservofinal.jpg

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.

Usbservoimagine.png

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

usbservo.zip (996 KB)