Shop OBEX P1 Docs P2 Docs Learn Events
Newbie needs help with What's a Microcontroller question ---servos — Parallax Forums

Newbie needs help with What's a Microcontroller question ---servos

skewedToTheLeftskewedToTheLeft Posts: 9
edited 2008-02-10 21:10 in BASIC Stamp
I'm brand new to electronics and the Basic Stamp. I do, however, have experience programming in Visual Basic.

Here is a block of code from the "What's a Microcontroller Book" :

DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
· PULSOUT 14, 1000
· PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
· PULSOUT 14, 500
· PAUSE 20
NEXT
DEBUG "Center 12 o'clock", CR
FOR counter = 1 TO 150
· PULSOUT 14, 750
· PAUSE 20
NEXT

I'm having a problem understanding how the servo works I guess. In the For/next loop the pulsout 14 command sends a burst of electricity out on pin 14 right? And this pulse lasts·X amount of time based on the duration. It seems to me that the more repetitions of the loop would drive the servo further, but the book says that the repetitions cause the wait time between movements to increase. If I have a regular DC motor and have a switch that is cut on and off real fast this would make the motor turn further the more times I pulse it off and on, but this is not how the servo works. Also, what controls the direction of the motor? I have figured out that the motor only turns about 180 degress by observation. The book does not mention this.

If someone could explain how servos work in simple ordinary English or·simple analogies,·I would greatly appreciate it greatly.

Thanks,
·

Comments

  • tpw_mantpw_man Posts: 276
    edited 2008-02-10 18:51
    Servo motors are not just ordinary motors. Servo motors have electronics inside that receive a pulse of a certain width and then turn the motor to the position corresponding to the pulse width. It will go backwards or forwards depending on where it is currently at. Sending the same pulse width over and over again results in the servo keeping the motor fixed at that position. If a pulse is not constantly being sent, the servo can be turned by hand very easily. Hope I have helped!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1010, so be surprised!

    Post Edited (tpw_man) : 2/10/2008 7:18:22 PM GMT
  • skewedToTheLeftskewedToTheLeft Posts: 9
    edited 2008-02-10 20:38
    thanks tpw_man, I sort of figured that but was not sure. One more question, does the pulse value have a direct relationship with angle value. For example, what pulse value would turn the motor all the way counterclockwise as far as it will go and what pulse value will do the same for clockwise limit? This way, if I start out to the extreme clockwise position, I could use simple math to always know what angle the horn is in if my pulse/angle assumption is correct.



    Thanks
  • tpw_mantpw_man Posts: 276
    edited 2008-02-10 21:09
    That depends mostly on the make and model of the servo. I looked at the book(I have it too.) and, I do not know if you saw it, but it says the general limits are between 500 and 1000. You could probably figure it out by entering different values and listening for when the servo starts straining.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1010, so be surprised!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-10 21:10
    Servos were originally designed for use in radio controlled model boats, airplanes, and cars. As such, there was the assumption of visual feedback and some slippage / sloppage in the movement of control surfaces and linkages. The range of pulse widths can vary from servo model to servo model and from manufacturer to manufacturer. The limits of pulse widths tends to be from 0.5ms to 2.5ms with 1.0ms to 2.0ms being a generally accepted minimum range. Different servo models have different mechanical ranges. Most will rotate 180 degrees, but there are some (winch servos for sailboats mostly) designed for 360 degree rotation or sometimes 2 to 2.5 complete turns.

    For your particular servo, you'll have to find a datasheet or try it out. Generally, the servo will hit a mechanical stop if the pulse width range is too large.
Sign In or Register to comment.