A Basic Question

zamanizamani Posts: 4
edited 2004-11-06 - 15:00:53 in Robotics
Hi fellows.
I am a new member and new to this area. I was doing the servo tutorial in WAM. After completing the chapter I am still not sure about two things
Typical loops are

FOR counter = N1 TO N2
··· PULSOUT 3 duration
··· PAUSE time

What is the relation between "duration" and the number of degrees that the horn turns?
What is the relation between N1,N2 and "time" with where the horn ends up.

It seems that I don't know much about the servos. Can you suggest a simple reference readily available.



  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-06 - 14:51:36
    Servo rotation is directly related to "duration." As WAM explains, a typical servo requires a command pulse from 1 millisecond (full left) to 2 milliseconds (full right), with 1.5 milliseconds being dead center. On the BS2, PULSOUT is expressed in units of 2 microseconds, so a centering pulse would be:

    PULSOUT ServoPin, 750

    ... as 750 times 2 microseconds is 1.5 milliseconds.

    Servos need to be periodically refreshed; the typical period is 20 milliseconds. This is the value you'll usually see for 'time' in your loop example.

    Finally, N1 and N2 allow that loop to run for a given number of iterations. If, for example, you wanted to move the servo horn full right for about 1 second, you might you values of 1 for N1 and 45 for N2. Why 45? Well, full right means a 2 millisecond pulse to the servo, plus I have a 20 millisecond pause between pulses. So each loop iteration takes about 22 milliseconds. If I divide 1000 milliseconds (1 second) by 22 you get 45.

    Keep pressing through with WAM. It's a great book and when you're done you'll know a lot a be very confident in your skills.

    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • zamanizamani Posts: 4
    edited 2004-11-06 - 15:00:53
    Thanks a lot Jon. This explanation was very useful.
Sign In or Register to comment.