Society of Robots - Robot Forum
Software => Software => Topic started by: Aaron on October 03, 2010, 01:08:08 PM
-
does anybody know the full source code on how to get a hitec servo to rotate 360 degrees using the axon
i already modified the servo and i know how to chose which pin i want but i don't know the rest of the code
-
If you're using webbotlib, go look up the Servo class, otherwise:
Here's some pseudocode (works on any controller with a decent timer):
repeat every ~20 uS: {
set SERVOPIN HIGH
delay 2000uS // 2000: 100% fwd, 1000: 100% bwkd, 1500: stop, use some linear interpolation
set SERVOPIN LOW
}
You'll have to provide a little more information for any more help than this, I think. I'm assuming you mean rotate continuously in fwd or reverse directions, as if the servo's modified, its positioning feedback is gone... also, 0 = 360deg.
-
that helps but i need to know the entire code all i know is how to identify the servo ports
SERVO(PORTA, 5,360)
-
What library are you using? You obviously have a servo object there...
I'm not familiar with AVRLib, but the $50.00 robot uses code much like my pseudocode:
// other code...
PORT_ON(PORTD, 0);
// turn on the port
delay_cycles(speed);
// delay for speed cycles
PORT_OFF(PORTD, 0);// turn off the port
delay_cycles(200);