contolling standard servo from basic to advance movements
sushiandmorihiko
Posts: 40
hi guys--i need some help in controlling unmodified servo that turns 180 degrees. i want it to have full control of its movements like lets say move it by 10 degree and stay still in that position and when i press a button or reset it--it will come back to the center position(eehmm--first of all how do you center the servo?).long and detailed explanation are greatly welcomed in controlling standard servo.thank you for the attention
Comments
2) The Robotics tutorial (download from: www.parallax.com/detail.asp?product_id=28154) discusses servos, both modified and unmodified. For standard servos, you simply produce a logic level pulse with a width of 1.5ms and the servo will center itself. Shorter pulses will move the servo in one direction to a particular position and longer pulses will move the servo in the other direction. The servo requires these pulses to be repeated about every 20ms or it will turn itself off until the pulses resume. Different models of different manufactures may move slightly different amounts for the same pulse width. You have to calibrate your program to the servo you're using. The maximum range is roughly 0.5ms to 2.5ms with the officially acceptable range being 1.0ms to 2.0ms. See the tutorial for sample programs.
i roughly get the answer but some sample codes for each of the explanation would greatly help.
i am still vey noob in contolling standard servo--correct me if i am wrong, i found it very different than controlling continous rotation servo.
so far,i have been controlling standard servo by trials and error without actually understanding it.
here is how i did it:
do
for count = 200 to 1200 step 50
pulsout 1, count <----this "count" represents the increment of the degrees of the servo rotating--am i correct?
pause 50
next
loop
one more question, how do you adjust the speed of the rotation for standard servo ( if continous rotation servo you just have to move the pulsout value away from 750 )
thank you for the time
I don't think you can adjust the speed of rotation of a standard servo. Some servos are faster than others.
it really helps clear my doubt in the degrees of rotation--hhmm too bad i cant adjust the speed
is there manual or any pdf sheet (other than http://www.parallax.com/dl/docs/prod/motors/stdservo.pdf) about controlling standard servo because this topic is very crucial for my project and i need precise movement of servo
thank you
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm doing something similar, but I am using an 8-pin IC interfaced to my BS2e.
The way it works is by sending a 2-byte signal to the IC. These 2 bytes are broken up into <aaaabbbb> <xxxxxxxx> (each pair of brackets is a byte)
Where aaaa (High nibble) is speed between 0-15 (0 = fast, 15 = slow)
Where bbbb (Low nibble) is a command from the list below
' 0 = Send servo 0 to position
' 1 = Send servo 1 to position
' 2 = Send servo 2 to position
' 3 = N/A
' 4 = Report servo 0 position
' 5 = Report servo 1 position
' 6 = Report servo 2 position
' 7 = N/A
' 8 = Report ALL servos
' response will be %BBBB1XYZ where XYZ may be 1 or 0
' depending on whether that servo has reached its end
' point (1) or not (0)- a quick way to read all servos.
' Note that bits B depend on whether the servo is switched ON
' (1) or switched OFF (0) - mask them if you don't know
' by ANDing with %00001111
' 9 = N/A
' 10 = N/A
' 11 = N/A
' 12 = Switch OFF servo 0
' 13 = Switch OFF servo 1
' 14 = Switch OFF servo 2
' 15 = N/A
Sorry for the formatting, comments nicked directly from my code
and xxxx is the position of the servo (127 is centred)
I got it from a UK company called Milford Instruments and it did cost almost $20 US (£10 UK). I don't know where they get them from, but i'll examine the IC tonight for serial numbers, manufacturers etc. and give you an update later.
Meanwhile, here is the link: www.milinst.com/animatronics/animsside.htm
It is the 4th item down, no image, and they call it the Micro Serial Servo Driver Chip
This IC can control upto 3 servo's, comes with sample code for the BS2 series, and it also contains speed control for the servo's (yes it is possible!) as well as range select between 90 and 180 degrees.
Expensive yes, worth it? Definately in my opinion.
It might sound complex, but it is extremely easy to work with thanks to their sample code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.
to mike green advice,it seems like a good idea to increment the degrees by a touch of a button , i might use potentiometer-perhaps it ll work too but little more complex.you guys have any experience in controlling servos using potentiometer?
to bruce bates,--i do notice some of the servos feel like turning less than 180,nevertheless i m still in the mood for servos-hihihi. other reason of course bcos stepper motor is more complex--too bad parrallax doesnt have course kit for stepper motor.
to morrollan--hhhmm--dats some cool kits u got there, i do consider some servo driver too from parallax ,lynmotion and servocity but for now i really wanna brush up my programming skill--doing everything by BASIC codes.
one more thing guys---right away after i reach my home after a 2 hours flight, i finally figured out the speed to control standard servo---hahahha--finally(not bad for a noob hihi)
DO
boom VAR Word
FOR boom = 200 TO 1200 STEP 25
PULSOUT 2, boom
PAUSE 10
NEXT
PAUSE 500
FOR boom = 1200 TO 200 STEP 25
PULSOUT 2, boom
PAUSE 10
NEXT
PAUSE 500
LOOP
man--i bet for experts like you guys already know(piece of cake for you guys hihihi ) however,i just post it here as for people who encounter the same problem like i did.
the "pause 10" that determines the speed(the larger the slower it moves)
the "pause 500" is the delay until it is done reaching one end
the rest is explained by mike green on the above post
thanks--hope this helps
Have you tried gently increasing the pulse length to see how far your servo will go? I use Futaba servos and I can get about 195 degrees before they complain, but I use code to limit them. If you push the servo too far you will hear audio feedback from the servo, sounds like grinding gears but if you take it slowly and in small steps you won't damage it.
I add constants for MinPosition and MaxPosition for my servos - either as Words (i.e. PULSOUT freqs) or using my IC, I use bytes as it expects positions between 0 - 255.
Obviously, the benefit of using constants is that it doesn't take up any RAM space!
I find it a bit safer and it makes me feel better by limiting range like that - I've made mistakes before now and heard horrific noises come from a servo...
I have a circuit at home which uses a potentiometer to control a servo - came pre-built but it's simple so I'll see if I can build a schematic from it - it allows you to manually rotate the servo using a potentiometer, or you can put it into "automatic" mode where it will sweep backwards and forwards, just like your code...
I'll see what I can do!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.
its amazing to see that you are roughly did i wanna do---like you see in my new thread---i did successfully control a servo by potentiometer however i want it to have 2 mode: one is manual whereby you control with the potentiometer(yesh i can do that now), second i wanna it to be controlled automaticlly by a program--lets say connected to the infra red sensor.
i really wanna do this--pls suggest the best way---i thought about having a switch so that i can shift from 1 mode to the other.what do you think? eg, IF PUSHBUTTON1=0 THEN BLABLABLA
You're right - my circuit uses a standard switch, but jumper pins would work well if it wasn't something you wanted to change often. You could have a jumper pin +5V plus current limiting resistor (22R recommended) - into an input on your stamp. Code would simply be:
With 0 being off, 1 being on in binary. Put this is some kind of loop and you're away..
The pullup and pulldown resistor in the circuit below might not be needed, i'm not the best person to ask for that (slight grey area for me!) but you can see by the schematic that you can have a jumper or a switch which switches between 0v and 5v - reading this input through a current-limiting resistor into a pin will enable you to use code to only run automatic mode when the pin receives 5v etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.
"I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image."
Stephen Hawking
Post Edited (Morrolan) : 10/5/2007 3:58:37 PM GMT
anyway--what kind of project did you make to have this 2 servo modes?
The second project won't use servo's but stepper motors, as I'm building a wireless, remotely controlled Paintball gun turret.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.
"I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image."
Stephen Hawking