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.

Help In Programming Servo Motors Using C programming. Urgent

Status
Not open for further replies.

nsw1216

Member level 3
Joined
May 7, 2010
Messages
60
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,667
I am trying to write a program to control the rotation of a servo motor using the C programming with the Microcontroller of AT89S52.

I have written a source code which ask the servo motor to rotate anti-clockwise. But no matter how i programmed it, it is also rotate clockwise only. My source code is attached below.

Anyone can help me to check for it and provide me some guidance on how to modify the source in order to make the servo motor rotate to the anti-clockwise.

Your help will be appreciated and welcome your comments or ideas on it. Thank you.

Code:
#include <reg51.h>
sbit Servo1=P1^0;  //crystal frequency is 33MHz

bit on=1;
bit off=0;

void main()
{
	int x,y;
	
	Servo1=off;

	for(x=0;x<20;x++)
	{
		
		Servo1=on;
		for (y=0;y<500;y++)//250 for 0.5 ms
		{;}
		
		Servo1=off;
		for (y=0;y<9500;y++)//10000
		{;}
	}

	PCON=0xFF;
}
 

Hi, what IC to driver motor? I think your wave is just control the velocity. The direct needs another IO port.
 

i am using Microcontroller to control the servo motor.
What do u meant using another IO port ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top