setfreq m4 and server stability

lazarus

New Member
Hi,

I'm working on a application that uses a small (cheap) servo.

Basically the servo mimics the position of a pot meter. The servo uses a seperate power supply and the
picaxe cirquit uses 2 caps to stabilise the power supply. However I notice a difference in the stability of the servo when I leave out the setfreq m4 command.
without this command the servo is less stable, sometimes it moves a tiny bit like every second. but when I use the setfreq m4 command again it's all smooth and stable.

I thought the setfreq m4 was quite useless since this is the default speed of the Pic but it seems that there are other things happening to. Perhaps something with the servo timer? As I said I'm using a cheap servo so it may play a role also.

Anyway just wanted to share this in case other people see the same behaviour.

Picaxe = 08M2 (5vdc decoupled)
Servo = Basetech ES-05 FUT (6 vdc)

CODE:

setfreq m4 'Leaving this out causes unwanted movements on the servo.
output 2
servo 2 , 75
do
readadc 1, b0
if b0 < 75 then
b0 = 75
else if b0 > 225 then
b0 = 225
end if
servopos 2, b0
loop
 

hippy

Ex-Staff (retired)
SETFREQ will have no affect on the PICAXE as it's already running at 4MHz however the inclusion of the command will shift the alignment of the code tokens in program memory which can alter the code timing slightly.

Try adding a PAUSE into the loop to see if that improves things.
 

lazarus

New Member
You are right :)

a pause of 10 ms in the loop will get rid of the unwanted effect.

Thanks!

CODE:

output 2
servo 2 , 75
do
readadc 1, b0
if b0 < 75 then
b0 = 75
else if b0 > 225 then
b0 = 225
end if
servopos 2, b0
pause 10 'removes unwanted movement of the servo
loop
 

westaust55

Moderator
Hi lazarus,
To put your program listing into a sub window, use the [code] and [/code] tags around the program listing

another way is to select all of the code and then click on the hash (#) button at the right hand end of the middle row of the edit toolbars in the post window (when in edit or full reply but not quick reply mode)
 
Last edited:
Top