Society of Robots - Robot Forum

Software => Software => Topic started by: airman00 on October 20, 2007, 05:46:33 PM

Title: PULSOUT with servo
Post by: airman00 on October 20, 2007, 05:46:33 PM
I am using the PIC16F616
I modified two HS425BB servos for continuous rotation and I cannot get them to go counterclockwise. Every pulse that I give makes the servo spin clockwise ( but at different speeds based on the pulse).

the servos and microcontroller are powered by a 5V 1A regulator.
What can I do to make it go counterclockwise????


' PIC BASIC Program
Define OSC 8

symbol servo1=portc.3
symbol servo2=portc.2
x var byte
b var byte

pause 20
x = 50
b = 250
main:
pulsout servo1,x
Pulsout servo2,b



goto main
Title: Re: PULSOUT with servo
Post by: creedcradle on October 20, 2007, 05:53:11 PM
is it 1 in pic basic means 1us?

if that is so then from 1us to 1000us that is a clockwise
Title: Re: PULSOUT with servo
Post by: airman00 on October 20, 2007, 05:55:58 PM
A 1 in picbasic represents 10uS

is it possible that a servo only turns in one direction??
Title: Re: PULSOUT with servo
Post by: creedcradle on October 20, 2007, 06:03:10 PM
then 50x10=500us = clockwise
250x10=2500us - this is beyond 2ms,

so try 200x10 =2ms: this should reverse the servo

remember for standard servo : 2ms means counterclockwise and 1 ms is clockwise
standard refresh rate is 20ms but other servo has 20-30ms refresh rate.
Title: Re: PULSOUT with servo
Post by: airman00 on October 20, 2007, 06:07:31 PM
No dice,


does the Hs-425BB go backwards at all??

any other things I should try???
Title: Re: PULSOUT with servo
Post by: airman00 on October 20, 2007, 06:13:23 PM
If I were to open up the servo and reverse the wires going to them motor it would go backwards, right??

Also, would I need to reverse the wires on the pot also to make it go in reverse?
Title: Re: PULSOUT with servo
Post by: paulstreats on October 20, 2007, 06:19:22 PM
The servo must go both ways.
the unmodified version can go -45 degrees and +45 degrees (forwards and backwards)

what speed crystal are you using on the pic, and is pic basic calibrated for this speed?

http://www.servocity.com/html/hs-425bb_super_sport_bb.html (http://www.servocity.com/html/hs-425bb_super_sport_bb.html)
Title: Re: PULSOUT with servo
Post by: airman00 on October 20, 2007, 06:24:54 PM

Thanks paul

when i set the oscilaltor to 4mhz it worked!

thanks a lot!!!!


I'm guessing that the servo cannot run of a PIC set to 8mhz even if the program is set to be run at 8mhz.

Title: Re: PULSOUT with servo
Post by: airman00 on October 21, 2007, 05:28:11 AM
IF you are running the PIC at  8 mhz then a 1 in the pulsout represents 5uS instead of the 10us it represents in a 4mhz PIC.
Title: Re: PULSOUT with servo
Post by: paulstreats on October 21, 2007, 07:02:40 AM
another thing you may want to check is that the port pin you are using is definately set to low before you run the pulsout command. the pulsout only toggles the port twice, so if the port pins initial state is high, it will pulse the pin low for your desired time. I had a bit of trouble with this once, it took me ages to work out why it was working properly.
Title: Re: PULSOUT with servo
Post by: airman00 on October 21, 2007, 07:13:22 AM
Thanks,

I'll add that to my program.