Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help required with servo motor controller

Status
Not open for further replies.

mayhem

New Member
Hey i have built a servo motor commader using the PIC16F84 microcontroller however its giving me some problems although the servos are moving when im giving the command from the compter...they are not reseponding to their respective impulses....when i move the knob for servo 1 and servo 2 on the computer only servo one moves wheres it has no connection to knob since it is connected to a diff pin of the ic..the following is a part of the vb code i have used
For the PIC16F84:

Include "modedefs.bas" ' Include serial modes

si var PORTA.0 ' Set portA.0 as our serial input pin
pos var byte ' Define our storage location for the servo position information.
servo var byte ' Define our storage location for the servo number to move.
cont var byte ' Define a variable to hold the count.

trisb = 0 ' Make all of port B outputs to send position information to each servo.

start:
serin si,N2400,servo,pos ' Get the servo# and position for that servo.
for cont = 0 to 50
pulsout servo,pos ' Send servo# ? to position ?.
pause 15 ' Wait 15 ms.
next cont ' Next pulse.
goto start ' Return to get more serial input

According to this it cant send the same impulse to 2 i/o points so i cant figure out whats wrong and plus i have checked my cicuit for any shorts and none are there....any suggestions???????/
 
I would suggest that:
A> you place a statement to print out to a debug port the parameters recieved back from the serial-in statement before the cont loop. Maybe the initial state is incorrect.
B> you make the "pause 15" statement a "pause 2048" which will pulse once per 2 seconds and watch the number of pulses sent to the servo with an oscillascope (assuming your got one).

Cheers. G.
 
From your description, it is hard to tell what's going on. I think you are saying that you can only command servo #1 and not #2. Right? An O'Scope would be very helpful but even without one you can solve this probelm.

Have you written a very simple program to test out the hardware? No serial input, just command one servo to go left, pause 2 seconds, go right, pause 2 seconds then center for 2 seconds and then repeat. Then do the same with the other servo.

If that works, then verify that your serial input is working correctly and you are actually getting valid values for the 2 variables.

In general, you should decompose your problem into smaller problems to isolate the location of the defect. Follow a logical progression and the solution will become clear. claro?
 
Is the serial input port buffered? Do you know if it received the second command?

And like WP said, bump the delay a little in case the pulsout command is still running when you start the next command (not sure how your compiler handles pulsout).
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top