Menu

 
Home

Meet Artemus

Servo Motors

Voice Synchronization

Androids and Robots in the News

Links Page
 

  

Robotics, Circuits, Mechanics, Servo Motors, Motion Controls and etc 

Notes by Kathi Stringer


UNITS OF TIME

Millisecond  -  Milli - One Thousandth of a Second

  • 1/1000 of a second = A millisecond.
  • There are 1000 milliseconds in a SECOND.
  • 500 milliseconds = 1/2 SECOND.
  • 750 milliseconds = 3/4 SECOND.

Microsecond - Micro - One Millionth of a Second

  • 1/1,000,000 or a second = A microsecond
  • Microsecond is abbreviated as ms.
  • There are 1000 microseconds in a millisecond!
  •  Greek symbol for micro is μ
  • Thus, 1 microsecond can be shorted in handwriting to 1μs

FACT: 1ms = 1000μs

 


Servo Motors

  • Servo Motors are activated by a series of pulses.
  • The series of pulses are very brief high signals 1ms to 2ms in duration and about 20ms apart.
  • Series of pulses is called a TRAIN __|ŻŻ|_______20ms_________|ŻŻ|_______20ms_________|ŻŻ|
  • At this rate of (2ms + 20 ms)= 22ms, Ref: (22/1000)=45 pulses per second
  • 45 pulses will be sent to the servo every second.
  • Usually hobby servos have 3 wires. 
    • 1 Positive;
    • 1 Negative;
    • 1 Pulse Input

IMPORTANT NOTE for Controlling Servo is determined by each of the following:
#1. Where to Go -
        Length of Pulse will send the servo motor to a position.
How Long to Stay -
#2.   Repetition for sending the pulse determines how long the servo motor will hold that position.

This may be a helpful analogy of how the LENGTH OF PULSE controls servo position and how REPETITION of sending that pulse keeps the servo in that position, until and new LENGTH OF PULSE is sent.  Think of a piano keyboard.  Each key represents a pulse duration.  Say one key might be 1001ms, the next key 1002ms, the next key 1003ms and etc.  With each key press the servo moves a fraction of a degree. Lets say Middle "C" was 1,500ms.  With the first first key press of Middle "C" the servo swings to the 12 o'clock position and maintains that position with every key press of Middle "C."  Lets say we move down the key board several keys and press one.  The servo will swing into a new position and hold it as long as the same key is pressed.  Now imagine if a pianist played a song for us, pressing different keys and holding them down in different durations.  The corresponding servo may be animating the eyes of an android.  

The instruction manual for the BASIC STAMP2 recommends sending pulses between 1ms to 2ms (1/1000 to 2/1000 of a second) to control the kit servo motor that comes with the manual. 

However, my results were different from .410ms to 2.25ms. 

Study Method:

I mounted a PARALLAX hobby servo to an Erector Set platform.  Next, I made a graphic in Coral Draw that consisted of a 1/2 circle marked with 180 degrees in 10 degree segments.  After printing and cutting out the graphic, I mounted it on top of the servo horn.  Then I mounted a pointer over the degree paper graphic. I turned the servo horn to far clockwise position (right) and then lined up the paper graphic with zero deg to the pointer. 

Next I sent different lengths of pulses until the servo went to the 0 deg position (9 o'clock).  I found that less then 1ms of only .410 ms zeroed the servo into the start position.  Next after hit and miss, 1.330ms lined up the servo motor to the 90 deg position (12 o'clock).  I did the math and I noticed that it took another 920ms to move the servo from 0 deg 90 deg.  Thus 410ms + 920ms = 1,330ms.  In order to get the servo to move another 90 deg to the 180 deg position (3 o'clock) I added another 920ms to 1,330ms for a total of 2,250ms. 

Thus I found the following length of milliseconds (ms) to move the servo to the following positions below: 

Servo Motor is labeled PARALLAX
Servo Swing max = 0 to 180 deg.

  • 0 deg = .410ms (or 410μs)
  • 90 deg = 1.330ms (or 1330μs)
  • 180 deg = 2.250ms (or 2250μs)
  • Conclusion: 10μs moves the servo about 1 deg.  Ref: (920μs/90deg=10μs)
  • A range of 1840μs moves the servo 180 degrees.  Ref: (2250μs-410μs) = 1840μs

The program below is for the BASIC STAMP2 made by Parallax.  I wrote this program for sending pulses to a servo motor. 

REPEAT IMPORTANT NOTE for Controlling Servo is determined by each of the following:
#1. Where to Go -
        Controlled by PULSOUT command:  Length of Pulse in ms will send the servo motor to a position.
How Long to Stay -
#2.   Controlled by FOR / NEXT command:  Repetition for sending the pulse determines how long the servo motor will hold that position.

Note the Basic Stamp2 Syntax:
PULSOUT
[I/O Pin#], [Duration in 2 Microseconds]
            The PULSOUT command is a bit confusing since a PULSOUT of 1 is really a UNIT of 2 Microseconds.
          
 Example: PULSOUT 14, 250    'Means send a pulse out to PIN 14, for 500 Microseconds.
PAUSE [Duration in Milliseconds]  
            The PAUSE command is in Milliseconds and NOT in Microseconds. 
            Example: PAUSE 20   'Means pause the program for 20/1000 of a second.
FOR / NEXT loop sends the PULSOUT repeatedly to the specified number.

'What's a Microcontroller - ServoTest.bs2
'Test the servo at three different position signals.
'{$STAMP BS2}
'{$PBASIC 2.5}

counter VAR Word

DEBUG "Start Zero Position", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 205                     'Pulse to .410ms = beg zero deg.   Ref: (205 * 2) = 410 or .410ms
    PAUSE 20                                 '20 milliseconds or 20/1000
NEXT
 
DEBUG "Go To 90deg Position", CR
    FOR counter = 1 TO 150
    PULSOUT 14, 665                 'Pulse to 1330ms = to 90 deg.   Ref: (665 * 2)=1330 or 1.33ms
    PAUSE 20                               '20 milliseconds or 20/1000
NEXT
 

DEBUG "Center 180deg Position", CR
FOR counter = 1 TO 150
PULSOUT 14, 1125                     'Pulse to 2250ms = to 180 deg.   Ref: (1125 * 2)=2250 or 2.25ms
PAUSE 20                                 '20 milliseconds or 20/1000
NEXT

DEBUG "All Done!"
END