loading

PIcaxe servo?

how to i control a servo with the picaxe can someone explain in detail i saw in the command section the servo and servopos commands but didnt quiet get it can someone plzzz explain it to me ang give a eg code for making a servo move from side to side .

sort by: active | newest | oldest
rickharris5 years ago
The servo needs to be connected directly to the Picaxe pins or through 3 100 ohm resistors (to protect the picaxe but not really necessary).

Controlling the servo is easy (ish)

you need to issue a servo command to set things in motion followed by the pin your commanding and the position separated by commas. The position is a number between 75 and 255

init: 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

After you have initialized the servo with the servo command then changes in position are issued via a servopos command as in the example above.

The firmware in the picaxe will take care of issuing the correct frame rate etc for the servo once it is initialized.


servopos 4,75

is the 75 in the above command the angle of the sevo
Yes the servo is connected to pin 4 and the 75 is the position i.e. one end the 255 is the other end - This example scans the servo from one end to the other.
 
Just to clarify Rick's answer, he means 225, not 255 in his comment above.  The Picaxe can go from zero to 255, but most servos only work between 75 to 220 or so - they do vary.  If you try to push them beyond this the mechanics hit the internal endstops and can damage the servo, aspecially the very little ones.  (Don't ask me how I know #;¬)
Bums finger trouble - thanks for the correction :-) i too have bricked a servo driving it over the end
iceng5 years ago
Here is the instruction to position a servo on a Picaxe.

A