go away spammer

Author Topic: Servo motor control. help needed  (Read 5460 times)

0 Members and 1 Guest are viewing this topic.

Offline captchaTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Servo motor control. help needed
« on: January 22, 2009, 05:18:20 AM »
Iam using Atmega16 micro controller and AVR dude software. Can anyone help me how to control a servo motor for different angular position?

i tried this basic program for PWm for a servo motor but it did not respond. can anyone guide with either a material or a program for the same.

#include<avr/io.h>
#include<util/delay.h>

int main(void)
{
DDRD = (1<<DDD4)|(1<<DDD5);
PORTD=(0<<PD4);
TCCR1A = ((0 << COM1B1)|(0 << COM1B0)|(1 << COM1A1)|(0 << COM1A0)|(1 << WGM11)|(1 << WGM10)); /* phase correct 10 bit pwm, non-inverted */
TCCR1B = 0x0B;
OCR1A = 0xC8;
return 0;
}

Offline yerbie

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: Servo motor control. help needed
« Reply #1 on: January 22, 2009, 07:13:27 AM »
which servo are you trying to control?  most servos require a 20ms frequency with a 1s-2s pulse. 

You should also start here.  This is a great tutorial on PWM.
http://www.societyofrobots.com/member_tutorials/node/231

Offline captchaTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: Servo motor control. help needed
« Reply #2 on: January 22, 2009, 08:38:34 AM »
We are using RC servo motor with 1.5ms width for mean position and 1.25ms and 1.75ms as other extreme position.
i want a program for Atmega16 to check the extreme movements for the motor. my previous program is basic what edition is suppose to be done in that to make it work?

Offline captchaTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: Servo motor control. help needed
« Reply #3 on: January 22, 2009, 08:47:18 AM »
Other doubt is we have a serial pony programmer interfaced to the pc's serial port and avr dude running on the pc to program a Atmega16 microcontroller which has other set of pins for OCR1a and OCR1b can we burn the program into a Atmega8. i cant i suppose but do u have any suggestion to modify and make it work for Atmega16.

Offline yerbie

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: Servo motor control. help needed
« Reply #4 on: January 22, 2009, 09:05:18 AM »
there are a few possible issues.  first i didnt look at your datasheet, so i'm not sure what all the settings you are trying to do.  for me, I usually do fast pwm for servo control.

1. looks like you didnt set the TOP value in ICR1.
2. not sure what you are trying to do on ICR1A
3.  your main method is exiting.  try putting it on a continuous loop at the end instead of return 0; for(;;);

again make sure you read that tutorial throughly.  it's a very good tutorial and shows you everything you need to know.

 


Get Your Ad Here