Servo command
Go back The Nipkow disk Servo command

How to control 8 servo motors with a PC ?

en français également

 

This document is intended to provide basic yet complete informations to the guy who wants to control up to eight servo motors with one LPT (printer) port. Soldering ability is needed, and some programming skills are needed, although full exe and source is provided for free.

This little project could be used by teachers, as it is quite simple and cheap. With this, you can control 8 independent axis (!) and so build a good robot.

You should use a PC running win95 with Delphi 3.0. But any other computer with precise timer should do the job.

The programming tool used here is Delphi 3.0 (turbo Pascal + windows + object oriented programming) because it's easy and quite as powerful as C.

The cost of this project is max 1$ (wires...) without any servo...

1. Introduction, remarks.

It is in fact very easy to control a servo motor with a computer. Those motors are used in RC (radio command) for airplanes, car and boats. Those motors have built in the whole electronics to control them. All you need is power (5v) and a special signal to adjust there main arm position. They generally have 3 wires :

a positive alimentation (5V) often RED
A ground (0V) often black or white :>(
a data line often brown or violet or...

You need to give them permanent power. Is so, they will stay in one position. To unlock them, turn the power off. To control the arm's position, you need to send , every 20Msec (no critical) a pulse of 1.5 -> 2 Msec length. The length of the signal gives the position of the arm. Sending this signal is exactly what a computer can do. But the most complicated task is to set up a high-res timer (1/100 Msec). Windows provides all the API needed to do so. We'll use the // port of the PC to control up to 8 motors (1 motor for 1 data line)

2. The electronic

No components, just wires !

What you need :

Soldering iron
3m of wire
DB 25 connector
Some connectors for your servo. They normally have 3 pins with 2.54 mm space. Obviously, if you are using 1963 servo's...
Some bread board (3*5 cm)
A power of 5 V (or get some from the PC. Take care !
Some servo motors. those are not really cheap, at least 10$ each ...

You simply have to connect all the grounds and +5V together, and each motor's data line to the LPT port data output. The LPT data lines are pins 2 to 10.

There are no buffer or transistors. You can safely omit them if you are using standard servo. Keep in mind that the computer needs only to control the servo's, through the data line, and that he doesn't need to power them.

3. The "software"

3.1 A basic soft (with Delphi 3.0)

 

No need to break your head against the walls, we only have to make a good delay routine, and a good LPT control routine. Some assembly needed, as win32 doesn't allow  direct outputs controls.

We simply create a timer which sends a signal every 20 Msec of a length between 1.5 and 2 Msec.

This soft is not available for downloading because it's not very useful and because I've lost it. You'd better download the full version...

 

3.2 The full version (also with Delphi)

This one can control up to 4 servo's (upgradable to 8) with the mouse or a joystick. You can program difference steps and save them in a text file.

It's not very useful to add a lot of comments, see the source for details...

servosource.zip (17k) : the Delphi 3.0 sources
servo.zip(162k) : the compiled version (win32 .exe)

 

4. Tests

Branchez tout le bazar et lancez le programme de base:

Si le servo se bloque dans une position et qu’il réagit aux déplacements de la trackbar, bravo, ça marche.
Si rien ne se passe: vérifiez l’adresse du port imprimante, vérifiez vos branchement, vérifiez le servo, vérifiez votre cerveau.
Si un mince filet de fumée se dégage de l’arrière de la machine et qu’une odeur de brûlé atteint vos narines, rappelez-vous: 1. Toujours essayer ce genre d’engin chez un "ami" 2. Je ne peux être tenu responsable de quoiqu’il puisse arriver à vous, à votre ordinateur, à votre maison, à votre chien, qui résulterait de l’utilisations des renseignements fournis ici tels quels. 3. Remarquez d’ailleurs que je ne suis pas plus responsable de la mort du commandant Cousteau... ni d’ailleurs de celle du roi Baudouin

5. D’autres développements?

Ce programme devrait déjà vous permettre de faire des petits essais. Essayez aussi la version plus complète et modifiez - là comme vous le sentez. Il devrait d’ailleurs être possible, avec ce système, de commander un petit robot (max. 8 axes.. pas si mal, et plutôt dur à gérer) ou d’autres choses... A vous de jouer. A ce propos, je serais enchanté d’avoir des nouvelles, des questions, de ceux qui ont expérimenté ce système... Ou d’autres systèmes aussi d’ailleurs.

mailto:philippe.jadin@skynet.be

6. "Légal"

Cette page ainsi que son contenu peuvent être librement distribués. Les programmes disponibles en téléchargement sont évidemment freeware, et le code source peut être modifié ou réutilisé dans un autre projet. Ce serait tout de même sympa de signaler où vous avez obtenu le code...

Je vous propose dès maintenant un service de création de pages Internet à très bon prix.  Visitez le site "Clair et Net" pour vous en convaincre.
Fast and good Web site creation in Belgium ? Visit
my site
Visit my site my site and get convinced
This site has been created by Philippe Jadin. Contact me for any information
Cette page a été créée par Philippe Jadin. Contactez-moi pour toute information complémentaire