Servo commands

ColinP

New Member
Perhaps I am just been a bit thick but I seem to be having trouble with the servo command. I have a tried several fully working PICaxe 18x's, and have tried the following with several servo's I know are working fine. The circuit is built on a 'normal' breadboard. The servo has its own 6V power supply (common ground with PIC power supply) all unused inputs are also grounded. It is driven via 330 - Ohm resistor from an output. The circuit works fine for everything but the servo commands. I have tried several outputs.

servo 0,150- on its own does nothing (for any position value). I thought this was meant to send a pulse chain until stopped for example by setting the output low?

servo 0,150
pause 1000
- Also does nothing

loopit:
servo 0,150
pause 1000
goto loopit

- moves it to the required position – the servo command seems to need looping in order for it to work?

loopit: -
servo 0,225
goto loopit

- Take out the pause and nothing happens – presumably the servo command is 'interrupting' itself?

servo 0,150
servopos 0,150
pause 1000

this works – but if you reduce the pause it only moves until the pause finishes!!

servo 0,225
servopos 0,225

does nothing

does anyone have any ideas about what is going on????

very bewildered

Colin
 

BeanieBots

Moderator
If your program gets to the "End", then servo pulses are stopped.
You must keep a loop going.

eg

servo pin,150
do
loop
 
Last edited:

hippy

Ex-Staff (retired)
Also, repeatedly issuing SERVO commands resets the 20ms frame sequence which can affect things. Make sure there is a reasonable period between issuing SERVO commands or use the SERVOPOS command.
 

Wrenow

Senior Member
As already noted above, and on the Picaxe Yahoo Group,

What is going on (methinks):

The Servo command is a background command - once activated, keeps
running in the background until halted. This results in the following
behaviors:

If you enter the servo command without an appropriate pause, as in:

Main
Servo 0, 150
Go to main

It will be constantly interrupting the servo command and will not work.

If you have posted your whole program (not just part of a routine), I
would suspect that:

servo 0,175
or
servo 0,175
pause 1000

are the equivalent of:

Main:
servo 0,175
End

or

Main:
servo 0,175
pause 1000
End

and the signal is killed by the Picase on termination of the program.

As for
loopit:
servo 0,175
goto loopit

You are again interrupting the servo command with a new servo command
before it has a chance to execute (remember, the servo command uses a
20ms frame to issue the pulse, as is standard in RC stuff). I believe
your issues with the new servopos command are the same.

I hope that helps clear this up a bit.

Also: WARNING: I changed the above to 150 or 175, as 225 may be a bit close to the hard stop - and you might damage your servo. You might want to play around with the 125-175 range before you get too cocky with any particular servo.

A lot of this is discussed at length elsewhere on this Rev-Ed forum, (feel free to search the archives) and I believe it is also described pretty well in the manual.

Cheers,

Wreno
 
Top