Sending less than integer pulse widths to servo?

dla_001

New Member
Is it possible to send less than integer pulse values to a servo? I'm having trouble with the servo action being "steppy" and would consider moving the motor in smaller steps by sending a pulse width of, say, 110.25ms, then 110.5, etc. instead of 110ms then 111ms. Is this possible, or is there another way to make the motor move smoothly, while turning somewhat slowly? I'm using a .13s WAIT between pulse increments. Thanks in advance...
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

You could generate your own 'servo frame'; send a pulse of desired width then pause for the rest of the frame time. Your timebase is a little out, the SERVO value is in 100th's of a millisecond so for "SERVO pin,100" that would be a 1.00ms pulse in a frame of 20ms so on a 4MHz PICAXE that's roughly equivalent to ...

Do
PulsOut pin, 100
Pause 1900
Loop

Adjust the PULSOUT time and you've still only got integer steps, but increase the PICAXE speed, double the values to keep the same timing, and each step becomes half what it was.

at 4MHz

PulsOut pin, 100 ' 1.00 ms
PulsOut pin, 101 ' 1.01 ms

at 8MHz

PulsOut pin, 200 ' 1.000 ms
PulsOut pin, 201 ' 1.005 ms
PulsOut pin, 202 ' 1.010 ms

at 16MHz

PulsOut pin, 400 ' 1.0000 ms
PulsOut pin, 401 ' 1.0025 ms
PulsOut pin, 402 ' 1.0050 ms
PulsOut pin, 403 ' 1.0075 ms
PulsOut pin, 404 ' 1.0100 ms

And upwards as you increase speed.
 
Last edited:

BeanieBots

Moderator
Most servos are not fussy about the frame rate so it's not too important to get it spot on, however, I think most would prefer closer to 20mS (pause 20) than nearly 2S (pause 1900);)

To set mid position:

Do
PulsOut pin, 150
Pause 20
Loop
 

dla_001

New Member
Thanks, all...just starting to work with this, lots to learn! I appreciate that there's a place to go to get advice!
 
Top