Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Servo control problem

Status
Not open for further replies.

nagsaver

Junior Member level 1
Joined
Jun 27, 2012
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,395
Hi,
I am using a ATMega32a to control VTS-08B servo motor.I am using the microcontroller with a 16MHz external crystal.
Low fuse byte=0XFF High Fuse byte=0XC9.Here is the code..


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

void main()
{
   //Configure TIMER1
   TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);        //NON Inverted PWM
   TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10); //PRESCALER=64 MODE 14(FAST PWM)

   ICR1=4999;  //fPWM=50Hz (Period = 20ms Standard).

   DDRD|=(1<<PD4)|(1<<PD5);   //PWM Pins as Out

   while(1)
   {

      OCR1A=125;   //0 degree-0.5ms pulse
      _delay_ms(1000);

     OCR1A=316;  //90 degree-1.264 ms pulse
     _delay_ms(1000);

     OCR1A=650;  //180 degree-2.6 ms pulse
    _delay_ms(1000);  
   }
}

What happens is when the servo is powered it rotates to 0 degree initially from wherever it starts....after that it doesnt move at all.but I do get a weak sound of something vbrating inside the servo...What may be the problem?Or is it something wrong with the pulse duration?

- - - Updated - - -

I have reposted the thread in the appropriate forum.The moderator may remove this thread if necessary.
 

Your code wont work with servos. If you have an oscilloscope attach one channel to OC1A pin and see the produced PWM and compare it with the graphs from the picture attached. I wont give you code for this instead I'll give a link to a video that will help you understand the operation of servo motors and also help you write your own code that will meet your project's specifications.
https://www.youtube.com/watch?v=dmjvHvw3Rc8
servo timing.jpg
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top