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.

Controlling servo motor using pic16f877a with mikrobasic as language

Status
Not open for further replies.

msmarian

Newbie level 5
Joined
Feb 3, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
I am making a car robot, . .i am using PIC16F877a with mikrobasic as the language. . .

i am having problem in controlling the servo. . .i dont have enough background in making a car robot, . .

can you plz help me in controlling the servo, . .??

plz. . .plz. .. plz. . ..
 

. . .helo. . .sorry for the late reply. . .i just visited my post today. . .
here's the diagram. . .i got it from a site. . .
fig02.gif


here's the code also. . .:

<original>
Symbol B1 = pw
pw = 100
sweep: pulsout 0,pw
pause 18
pw = pw + 1
if pw > 200 then back
goto sweep
back: pulsout 0,pw
pause 18
pw = pw - 1
if pw < 100 then sweep
goto back

i got this from the same site. . .

<modified code> (i used pic basic pro in compiling because there is no pulsout in mikrobasic. . .):
pw var byte
pw = 100
sweep:
pulsout 0,pw
pause 18
pw = pw + 1
if pw > 200 then
goto back
endif
goto sweep
back:
pulsout 0,pw
pause 18
pw = pw - 1
if pw < 100 then
goto sweep
endif
goto back

i am using TowerPro MG995 servo motor.. . .
and i also want to use mikrobasic as the programming language. . .

can u help me???



the problem with the code:
the servo will not reverse its rotation, . .
 

hi

details of servo required. you will require at least two IO line one for steps and the other for direction.
 

. . .how to do that???

---------- Post added at 10:57 ---------- Previous post was at 10:55 ----------

. . .the servo motor i got has only 3 connectors. .. 1 for ground, 1 for 5V, and the other 1 for the signal. .
 

i meant the servo controller circuit.
 

. . .can you give me the schematic for the controller circuit of servo??? i have no idea about it. . .
 

to Chulla:
ahhhhmmm. .. i am using mikrobasic. . .the program in the link has so many error. . .
then i tried it also in pic basic pro. . .just the same. .. it has also so many error. . .i already corrected some of the errors. . .the following are left.. . because i dont know what is their function and what are they for, , ,

Symbol porta = 5 <syntax error>
Peek porta,b0 <output parameter must be a variable>

If bit0 = 0 Then sweepl

If bit1 = 0 Then sweepr


the line with bit1 and bit0 is a bad expression. . .that's the error. . .

the statement inside the less and greater than symbol is the error of that line. . .

btw, i am using pic16f877a. . .is it the same process with that pic16f84???
 
Last edited:

:) Actually these all errors are SYNTAX or VARIABLE INTIALIZATION...

Frankly! am not well in mikrobasic . working with C for programming.
and About 16F84 instead of 16F877. Yes! off course both can be used.
 

Guys, listen to what I am going to say.... Servo motors is controlled by providing pulse with in more than 20ms... It means that for every 20ms, you should provide pulse depending on the SERVO requirements. Most of the SERVO is controlled using 1ms to 2ms pulse w/c is equivalent to -90 to +90 degrees...
See simple code using Mikrobasic @ 8 MHZ...


Here's the code:

program SERVO_Control

dim i as word

main:
trisb = 0
portb = 0


while true
for i = 1 to 20 step 1
portb.b0 = 1
delay_us (995)
portb.b0 = 0
delay_ms (19)
next i

delay_ms (500)

for i = 1 to 20 step 1
portb.b0 = 1
delay_us (2000)
portb.b0 = 0
delay_ms (19)
next i

delay_ms (500)

wend

end.



Don't forget to thank me on my email ok?
--> brix102778@gmail.com
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top