PDA

View Full Version : servo control



sudarshan
07-27-2009, 05:31 PM
can any one help me modify the program below it is a servo motor control program with avr board with atmega32.i wnt to make it move maximum left,center and right.i use winavr and stk200 programmer. also provide me some info about servo motor control with pc.

for(i=0;i<=100;i++)
{
sbi(PORTA,3);
_delay_us(750);
cbi(PORTA,3);
_delay_ms(20);
}
for(i=0;i<=100;i++)
{
sbi(PORTA,3);
_delay_ms(2);
cbi(PORTA,3);
_delay_ms(20);
}
thank you

milindshastri
07-29-2009, 12:54 AM
Sudarshan, check out this image; it describes how your PWM wave must be. Try to keep the period consistent, it gives lesser glitches.
http://www.acroname.com/robotics/info/articles/servo/servo_pwm1v3.jpg
Check out this page on TRIs website, its got good info for an 8051
http://www.thinklabs.in/resources/?p=77

I tried controlling an RC servo with my computer a few years ago with a java program controlling the parallel port. The result was a very shaky servo, because the code then was loop based(like yours) and not interrupt based and secondly, I dont think parallel ports still exist. Eventually the best way is to control your servo with a uC and send data from your PC to the uC for the desired angle. Thats how many readily available 'rc servo motor contollers' work (simply google it). You can buy one too depending on your budget; check this http://robokits.co.in/shop/index.php?main_page=product_info&cPath=1&products_id=230

Milind
homepage: http://milindshastri.googlepages.com/