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.

Urgent help for servo motor forward direction

Status
Not open for further replies.

Wahid2012

Newbie level 2
Joined
Mar 14, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
Hey guys,

I am using pIC16F877A to control two servo motor....i need a program....where my servo motor do as following below

go forward 100cm
turn u-turn or180 degree
go forward

the loop continue for 3 times..



please help guys i have only 13 days before my presentation
 

Hi,

I will start a project with servos too.
I have started to read the following document, it is very useful for me. Take a look, it will give you an idea, for sure.

regards
 

Attachments

  • Servo_Programming.pdf
    2.2 MB · Views: 100

thx.....I had downloaded that pdf a month ago.........the problem is that i just want my servo motors move forward for 5 sec then backward, to show on my poster presentation that my circuit is working.The program i wrote. it just rotate less than 2 sec and stop.


#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //Highspeed Osc > 4mhz
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=20000000) // Sets crystal oscillator at 20 megahertz
#use rs232(baud=9600, xmit=PIN_C6, invert) //Sets up serial port output pin & baud rate



void main(){
int16 pulse_width = 1000;
int i;



while (1) {

output_high(PIN_D3);
output_high(PIN_D2);
delay_us(1500);
output_low(PIN_D2);
delay_ms(20);


}
}
 

Not really an expert in PICs.. but don't you first need to program PIN_D2 as an output pin?
You need to look for a data direction register and set that bit high first, so that the
uC knows that it is an output pin.
You could check with a 'scope that pulses really are being generated.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top