Society of Robots - Robot Forum

Software => Software => Topic started by: Aaron on October 03, 2010, 01:08:08 PM

Title: axon servo source code
Post 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
 
Title: Re: axon servo source code
Post by: rbtying on October 03, 2010, 02:05:48 PM
If you're using webbotlib, go look up the Servo class, otherwise:

Here's some pseudocode (works on any controller with a decent timer):


Code: [Select]
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.
Title: Re: axon servo source code
Post by: Aaron on October 03, 2010, 02:52:08 PM
that helps but i need to know the entire code all i know is how to identify the servo ports
Code: [Select]
SERVO(PORTA, 5,360)
Title: Re: axon servo source code
Post by: rbtying on October 03, 2010, 02:58:57 PM
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:

Code: [Select]
// 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);