Searching \ for '[PIC]: Robot Servo control Code wont work?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=servo
Search entire site for: 'Robot Servo control Code wont work?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Robot Servo control Code wont work?'
2002\01\19@020355 by Prince Anamalech

picon face


Dear PICsters,

please help me out with this servo ontrol code for my robot, i will rewrite the code to suit two servos after i get it to work with one. the code compiles but it doesn't work?

here is my single servo control code


;"SmartBot Servo Test Program - Written By Daniel"
;This program control a single servo.
INCLUDE "P16F84.INC"

BSF     STATUS,RP0         ;Set register bank 1
CLRF    TRISA      ;Set All PORTA Pins to outputs

Counter         EQU     0Ch             ;Servo delay counter register
Position        EQU     0Dh             ;Servo Position register

#DEFINE  Servo1  PORTA,0  ;Defines Servo (A.0) I/O Pin on PIC16F84


Servo           MOVLW   0               ;Load Counter with # of cycles for
                MOVWF   Counter         ;1 ms Servo Delay
                BSF     Servo1          ;Activate the Servo output
                CALL    Delay           ;Wait for 1ms to pass
                MOVF    90,0            ;Load W with servo posi tion
                                        ;00 & FF=extremes, 128=centre
                MOVWF   Counter         ;and store in Counter for next delay
                CALL    Delay           ;Keep servo active for position delay
                GOTO Servo  ;Create Loop

Delay           ;Servo time delay
                NOP                     ;Pad the loop with one cycle
                DECFSZ  Counter         ;Counter=Counter-1
                GOTO    Delay           ;If Counter is not 0, repeat
                RETURN                  ;If 0, return

END

       
Thankyou

Anamalech

 
Web: www.anamalech.multiservers.com
 
Email: anamalech@hotmail.com


MSN Photos is the easiest way to share and print your photos: Click Here
-- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.

2002\01\19@055904 by Jinx

face picon face
After the code has executed 90 position delays, it does it again. And
again. And again...... You need something to get you out of the Servo
routine once it's been done

The DECFSZ COUNTER could be better written DECFSZ COUNTER,F
but it compiles OK as it is

The BSF STATUS,RP0 should be followed by a BCF STATUS,RP0
for normal program operation

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\01\19@134554 by Dale Botkin

flavicon
face
Yeah, what Jinx said, plus you need around a 20ms delay between pulses.
The servo needs a pulse at about a 50Hz rate, give or take a little.

Dale
--
"Curiosity is the very basis of education and if you tell me that
curiosity killed the cat, I say only the cat died nobly."
         - Arnold Edinborough

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...