# Basic (?) timed servo.

1. Sep 3, 2009

### Zenox

Hey PF.

I just joined, and I got a question. I want to make this 'timed' servo, making it go from -25 to 25 degrees angle spread over 1 or 2 seconds, and then go back and repeat. I know this might be difficult, but if you can help me, please do!

I think I'll have to program a microcontroller for this. Since I haven't done this before, I would like a link to a good tutorial. I can do some coding/scripting, so that will be OK...

Also, if possible, just a little quick scheme... I don't need a PCB design yet, just the scheme :D

Regards

-Dion

2. Sep 3, 2009

### Staff: Mentor

Welcome to the PF, Dion. There are several ways you can do this. Are you sure you need a servo motor? Could you just use a DC motor and relays to control direction?

You can also just control it from your PC, and script something on the PC to talk to a USB or serial motor control widget. I think National Instruments has some things that you could use:

http://search.ni.com/nisearch/app/main/p/q/motor/

Omega also has some motor resources:

http://www.omega.com/search/esearch...ort=rank&search=MOTOR&submit=Search&ori=motor

If a DC motor would work for you (or a geared-down DC motor), you could just put limit switches on the system to stop the drive at the end of each travel.

3. Sep 3, 2009

### vk6kro

Good to hear you are willing to try a Micro to do this.

You might like to try the Picaxe range.
All the chips can do servo commands.
There is a summary of other commands in this link:

The Servo command can run in the background while you do other things.

So, you might send a command for the servo to take a certain position and the background command will keep sending the right pulses to keep it there.
You then do a delay of perhaps 100 mS, then tell the servo to go somewhere else. These delays are the way you control the speed of movement.

The command for the 100 mS delay is
pause 100

The command for the servo is like this:
servo 4,75 ‘ initialise servo
main: servopos 4,75 ‘ move servo to one end
pause 2000 ‘ wait 2 seconds
servopos 4,225 ‘ move servo to other end
pause 2000 ‘ wait 2 seconds
goto main ‘ loop back to start

This is an example from the Picaxe manual 2 which is included in the following download.

You can get the programming editor for this at:
http://www.rev-ed.co.uk/picaxe/

4. Sep 4, 2009

### Topher925

The Basic Stamp II would also be a good choice for this. If you buy Parallax's "What is a microcontroller?" you get a basic stamp, servo, some components, and a book that tells you exactly how to do this. You can find these at your local Radio Shack too.

5. Sep 4, 2009

### famousken

I would use the basic stamp. When I got one the first thing I did was use it to control servos, they made it very easy to do. Radio shack has the stamps as a kit with a few other parts including a servo. They also include a book that gives you some sample code, programming cable, and software. There is a step command in Basic that allows you to program it to move a servo from one position or another slowly or quickly.

6. Sep 4, 2009

### vk6kro

These are some prices on Basic Stamps
BS1.... $29 BS2......$49
BS2E.....$54 BS2P......$79

Here are some prices on Picaxe chips
8M.....$2.65 14M......$3.45
18M......$3.75 20M......$3.45
18X..... $7.95 28X1....$9.95
40X1.....\$9.95

I can understand people suggesting what they have used themselves, but you would need a good reason to ignore the message in those prices.

7. Sep 6, 2009

### Zenox

Sorry for the very late responce...

Thanks for all your tips! I will sure try everything that's needed! Thanks a lot!

-Dion