Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: robotcoder on July 13, 2009, 12:13:06 AM
-
I just modified 2 servos (HS-311) to rotate in 360 and I can get one of them to move clockwise and counter clockwise, but the other servo only moves in one direction. Any ideas on what I can do to correct this?
-
does the servo stop if you send a 1.5ms pulse (center)?
-
you probably did not properly center the servo(s). The potentiometer inside the servo has to be fixed at its neutral position to fool the servo.
http://www.societyofrobots.com/actuators_modifyservo.shtml (http://www.societyofrobots.com/actuators_modifyservo.shtml)
step 5
-
I am new to all of this, so I am not sure exactly how to send 1.5ms. I am using the sample code for the $50 robot, so to move the servo's I am using, for example C7(500); If you have a code example of how to send 1.5ms to the servo that would help. Thanks for the reply.
-
set the pin high, wait 1500us, set the pin low.
if i can find the code anywhere ill upload it for you.
EDIT: here it is http://www.societyofrobots.com/downloads/hold_servo.hex (http://www.societyofrobots.com/downloads/hold_servo.hex)
-
one time the cord that connects to the mcu board had a break in one of the lines there for only span one way
it is most likely not that, mabey .0000000000005 % chance
the reason it happened to me is i had a box or carbon fibre sheets fell onto my servo box which pearced the servo cable, if that ever happens hold you shipper accountable.
good luck finding the problem
-
a servo works by listening for a 50Hz pulse. The length of he pulse is ~ from 1 to 2 ms. 1500us or 1.5ms is the pulse length to make the servo go t the center position.
So essentially
set pin HIGH
_delay_us(time)
set pin LOW
_delay_us(20000-time)
time equates to the pulse time of 1 to 2 ms that is the general idea.
-
I just found this example code, I will try this and see what the servo does.
int main()
{
int i;
DDRB = 0xff;
PORTB = 0xff;
while(1)
{
//Hold the motor in neutral for 2 seconds (Each signal is 20ms, so repeating that 100 times = 2000 sec
for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(1.5);
PORTB = 0x00;
_delay_ms(18.5);
}
//Turn 90deg clockwise for 2 sec
for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(2);
PORTB = 0x00;
_delay_ms(18);
}
//Turn to -90deg ccw, while passing the neutral state for 2 sec
for(i=0;i<101;i++)
{
PORTB = 0xff;
_delay_ms(1);
PORTB = 0x00;
_delay_ms(19);
}
}
return 1;
}
-
what pin do you have the servo connected to? Do you have anything else connected to PORTB?