Newbie with Picaxe 18 and a Servo

manic

New Member
Hi there,

Ok I got a picaxe 18 starter kit a couple of days ago and started learning the prog language and was off to a great start. Since yesterday I've hit a wall.

I got a servo hooked up to a 5v dc adaptor. The board is run off a battery power pack 4.5v and both power sources share the boards ground point.

I can upload the code to the pic via serial but cannot get the servo to respond.

The servo is a dynam b2232 with brown, red, orange lines which im guesing in same order is neg, live, control

With the servo on seperate power I've placed the servos orange(control) line on output 1+ and send a pulse like so.

Code:
opnlight:
	low 1
	pulsout 1,750
	pause 20
	goto opnlight
Nothing happens. I have also tried numerous variations of this and scoured the forums but as im an absolute novice I fear I may not be looking at things in the right way.

I notice that the 18 has no servo command so perhaps I've gone and got me a chip I cant work with?

Any help much appreciated.
 

goom

Senior Member
Your pulse width is out of range for a hobby servo. Try something between 110 and 190.
The servo and servo and servopos commands are indeed not valid for the -18 (only the -18A and -18X).
I think that your wiring is correct.
You can always connect an LED (and resistor) to the output to check that for pulses. If you increase the pause to 1000 you should see the LED flashing. Pause 20 should be a good value for the servo.
Welcome to the Picaxe world.
 

westaust55

Moderator
Welcome to the PICAXE forum.

You might also like to have a read of the Servo tutorial that I put together a while back. It includes some basic code and explanation about typical pulse durations. As per your own example with a basic PICAXE 18 (not 18X) you will need to you the pulsout command as you are doing and is also covered in my tutorial.

Tutorial is posted here:
http://www.picaxeforum.co.uk/showthread.php?t=12120
 

BeanieBots

Moderator
As pointed out by goom, your pulse should be about 150 for a servo center position.
Also, you do not need the "low 1" in your loop

This should work.
do
pulsout 1,150
pause 20
loop

Do you have the servo connected DIRECTLY to the PICAXE output pin?
If it is via a darlinton driver or the FET output (not sure which project board you have) the pulse will be inverted and will not work.

either, connect direct to the PICAXE output.
OR, fit a pull-up resistor to 5v (4k7) and invert the pulse.

This code will invert the pulse.
High 1
do
pulsout 1,150
pause 20
loop
 
Top