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
 

alberto1683

Junior Member level 3
Joined
Jul 13, 2007
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,410
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: 19

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
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);


}
}
 

sky_123

Advanced Member level 4
Joined
Feb 26, 2011
Messages
1,170
Helped
279
Reputation
566
Reaction score
273
Trophy points
1,363
Activity points
9,602
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top