servo motor

Status
Not open for further replies.

jayk

New Member
I am using atmega32 micro controller at 8mhz internal freq.I have interface vs2 servo motor with it.I have generated pwm with from 1msec to 2 msec at every 20msec but could not control its angle.it moves in clockwise direction and stays there.I Cant understand the problem.i want help.
 
I have generated pwm with from 1msec to 2 msec at every 20msec
Try generating just 1.5mS pulses every 20mS. Let us know the result.
 
Try generating just 1.5mS pulses every 20mS. Let us know the result.

i have run the following code but still servo is rotating in clockwise direction fully and stops there.what change do u think i have to make?

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

main()
{
sbi(DDRD,5);

while(1)
{
int i;

for(i=10000; i > 0; i--)
{
sbi(PORTD,5);
_delay_ms(1.5);
cbi(PORTD,5);
_delay_ms(18.5);
}



}
 
Check that your micro is running at the speed you think it is.

Perhaps you have to define your oscillator setting somewhere for your delay function? Check that that is correct also.
 
I agree with Gobbledok. Your code looks ok so the micro configuration needs verifying. Presumably PORTD,5 is configured for digital ouput and can provide enough current to the servo? Does the micro supply voltage match the servo supply voltage?
 
Make sure the definition in your project file correctly states the speed the processor is running at, the delay_ms works based on constants created during compile time, if you have the wrong frequency set in the project file it will not work.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…