Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Basic (?) timed servo.

  1. Sep 3, 2009 #1
    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


  2. jcsd
  3. Sep 3, 2009 #2


    User Avatar

    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:


    Omega also has some motor resources:


    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.
  4. Sep 3, 2009 #3


    User Avatar
    Science Advisor

    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:
    It is a 38 MB download but updates are smaller.
  5. Sep 4, 2009 #4
    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.
  6. Sep 4, 2009 #5
    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.
  7. Sep 4, 2009 #6


    User Avatar
    Science Advisor

    These are some prices on Basic Stamps
    BS1.... $29

    Here are some prices on Picaxe chips
    18X..... $7.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.
  8. Sep 6, 2009 #7
    Sorry for the very late responce...

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

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook