Sending again...
I will have a go ...
I am guessing from all I have read on the list that servo's are Pulse Width
Modulated.
You initially set the counter to zero, then turn portA.0 on. The delay is
called and decs counter by 1 so result is 255. So it continues to count
down to 0 and that's when it will return. (This may or may not be 1ms)
On returning you set the counter to 90 and call the delay. (This delay
being 90/256 of the first delay) but the code does NOT turn off PortA.0
i.e. BCF Servo1 after the first Delay Call. I think this is the problem for
Servo1.
To control Servo2 you will need to define as you have for Servo1 and then
add the instructions BSF Servo2 and BCF Servo2 in the right places.
To control them independently, well that's a little more involved. You
could use inputs that when active you change the values that you put into
counter for the delays. i.e. increment or decrement counter values as
required.
I hope this helps, I am reasonably new to this myself so I may be leading
you astray.
Justin
-----Original Message-----
From: Prince Anamalech [mailto:anamalech@HOTMAIL.COM]
Sent: Friday, 4 January 2002 15:06
To: PICLIST@MITVMA.MIT.EDU
Subject: [PIC]: My Servo code that i need help on plz?
Here is my servo code?
i am not sure how good it all is ? as i am new to mplab and assembly
language!
but i think i may have gone wrong with the servo updates somewhere? ??? :)
each servo is on porta.0 and port a.1 of my 16f84? but i have only written
some code for one servo? how do i implement two and get the code to work for
me? eg. backwards,forwards?
Below is the code!
Thankyou all in advance
anamalech
;"SmartBot Servo Test Program - Written By Anamalech"
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 &nb! ! ! sp; ;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
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
Web: www.anamalech.multiservers.com
Email: anamalech@hotmail.com
_____
Send and receive Hotmail on your mobile device: Click Here
-- http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.