Let's Make Robots!

PULSOUT problems

I am trying to use the PULSOUT command with a PICAXE 08M and a Futaba S9201 servo.  In using the PULSOUT command I am seeing an approximately 30 degree travel in the servo arm as opposed to approximately 85 degrees using SERVOPOS.  I have read the manual and several past posts on this subject but apparently "just don't get it".   The current test code is attached.   Would someone please steer me in the right direction here?

main:

low 4

pulsout 4,150

pause 19

for b0 = 1 to 100

   pause 10

next

low 4

pulsout 4,75

pause 19

for b0 = 1 to 100

   pause 10

next

goto main

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Ok, thanks to everybody I finally understand how PULSOUT works.  I put Rick100's program in the 08M and the servo would move the full range alright but would jitter badly at both ends of the range.  I had a spare 08M and put it in place and everything worked perfectly.

Thanks to everyone for the help!

this process repeats whenever the button is pushed and the switch activated.  It may happen once a day or once a week.

I just want the servo arm to move between state 1 and state 2 (approx 85 degrees) whenever the button is pushed or the switch activated.

 

Does the device need to actively hold the state 1 and state 2 positions between button pushes?  Is a servo motor the right solution for this applications?

Thanks Rick100.   As CtC requested, the scenario is:

a button activates the PULSOUT command to the servo

minutes or hours later, a switch activates the PULSOUT command to return the servo to its original state

this process repeats whenever the button is pushed and the switch activated.  It may happen once a day or once a week.

I just want the servo arm to move between state 1 and state 2 (approx 85 degrees) whenever the button is pushed or the switch activated.   What would the code look like to accomplish this? 

You said

"I just want the servo arm to move between state 1 and state 2 (approx 85 degrees) whenever the button is pushed or the switch activated.   What would the code look like to accomplish this?"

The short program I posted yesterday will do exactly that . When you push the Normally Open momentary pushbutton attached to input 3 , with the pullup resistor , the servo will move from state 1 to state 2 .When you push it again the servo will move back to state 1 .

You said

"a button activates the PULSOUT command to the servo

minutes or hours later, a switch activates the PULSOUT command to return the servo to its original state"

A single pulsout command only produces 1 pulse and will not position the servo . It takes repeated pulses to drive a servo to a new position and hold it there . When the pulses stop the servo motor stops trying to hold the position .

Cactus ask " Does the device need to actively hold the state 1 and state 2 positions between button pushes?" . If it doesn't you might try sending it a series of 50 pulses with a pause 19 in between each one . After that your program can do something else as long as it moniters the button . If you use this method and something alters the servo position , like an external load or your dog bumps it , the servo will not drive it back into position until you push the button again . I tried this method once and it seemed to work .

If all the picaxe has to do is moniter  the button and change the servo between 2 positions then the program I provided is the better solution .

 

All,

It "pumpkin" hour for me as I get up at 04:30 CDT.   I appreciate the responses so far but am headed for some z's.  I aapreciate any ideas you have   ...  good nite all.

Guys, Thanks for the quick responses.

I get a lot of jitter using the SERVOPOS command and wanted to try the PULSOUT command. The 19ms pause was something I saw in other posts and Rick100 uses it in his code above.   I ahve also seen examples of taking the pulse pin (4) low before issuing the PULSOUT command.   This didn't seem to change the result.   I was expecting the servo arm transition to be the same whether using SERVOPOS or PULSOUT and that is not happening so  ..  seems to me like something else is going on within SERVOPOS.  

You are right about needing the "low 4" command before the pulsout .I changed the post so the program includes it . It makes sure the pin is an output and the pulse is high . The servpos command operates in the background to send a pulse every 20 milliseconds . If you use the pulsout command you have to put it in a loop that takes about 20 milliseconds . This makes it a lot harder to control a servo and do anything else at the same time . I noticed servo jitter when using the servopos command on one of my projects . While researching the problem I found this post on the Picaxeforum .

http://www.picaxeforum.co.uk/showthread.php?t=13357&highlight=servo+jitter

The bottom line is this post from the Picaxe technical support .

"Unfortunately on the lower pin count devices it is not possible to implement all the complexity of all the PICAXE firmware commands and a completely perfect servo command within the very limited memory space available, it is always going to be a compromise between the two. If you want perfect servo operation an intermediate chip dedicated to just servo pulsing, such as the AXE031, is always the best bet.

That said, we have completely rewritten the servo operation on the 18M2 parts to give a better performance with less jitter. It's never going to be 100% perfect, but should be a fair bit more accurate than the older parts like the 08M.
__________________
PICAXE Technical Support"
Also if you're using the serial or pulsin commands along with the servo commands you will get more jitter .
Good luck .

Here is a short program using pulsout to position a servo . It requires a pushbutton on input 3 (physical pin 4) to switch between pulsout values .

symbol btnWrk = b1
symbol Btn = 3        'normally open switch with pullup resistor on physical pin 4

b0 = 150    'initial value
low 4
main:

pulsout 4,b0
pause 19        'approx 50 hertz

button Btn, 0, 255, 20, btnWrk, 0, main      'loops back to main if no button push

if b0 = 150 then
    b0 = 75
else
    b0 = 150
end if
goto main

Is there a problem using the servo and servopos commands instead of the pulsout?

You are only sending one pulse to the servo and then 1 second later sending a different lenth pulse . You have to send around 50 pulses per second to servo . So your servo doesn't get to it's position after the pulsout 4,150 statement . It only moves a little toward the position .