>Hi, my name is Dave, and I am trying to get a couple of servo's working with
>a pic16f84, but am not having much luck. I was able to get the servos
>working with this article
>
>
http://www.rentron.com/servo.htm
>
>but I want to modify the source, and I don't have their c compiler. So, I
>went about to make my own program, but since this is one of my first pic
>programs, I am looking for a little help. What I have so far is at the end
>of this message. (the servo's are modified for continuous rotation). All
>I am trying to do with this right now is when B1 goes high, start the servo
>for a period of time, and stop it before the period expires if B0 goes high.
>
>But, it doesn't work. That's why I'm mailing the list of course :)
>
>Any help would be greatly appreciated.....
>
>(Trust me, I've searched the archives plenty, and couldn't find the awnser
>or any other servo controller that suited my needs....)
>
>
>-Dave watson
>---------------------------------------------------
>
> LIST P=16F84 ; tells which processor is used
> INCLUDE "p16f84a.inc" ; defines various registers etc. Look it
>over.
> ERRORLEVEL -224 ; supress annoying message because of tris
> __CONFIG _PWRTE_ON & _LP_OSC & _WDT_OFF ; configuration switches
>
>w equ 0 ;in byte instructions, use w & f
>
>f equ 1 ; instead of 0 & 1, it s much clearer
>
>
>;-----------------------------------------------------------------------;
>; Here we set up our own registers start at the 1st free address ;
>;-----------------------------------------------------------------------;
> CBLOCK H'0C'
> dlycount ; counter used in delays
> speedright
> speedleft
> lcnt
> wcnt
> tempright
> templeft
> d1
> d2
> ENDC
>
> ORG 0 ; start a program memory location zero
>
>;-----------------------------------------------------------------------;
>; First we set up all bits of PORT A and B as outputs ;
>;-----------------------------------------------------------------------;
> movlw B'00000000' ; all a output 0,1 are servos
> tris PORTA ; contents of W copied to PORT A ...
> movlw B'11111111' ; all b input
> tris PORTB ; and PORT B
> movlw B'00000000' ; port B pull-ups active
> option
> movwf PORTA
> movwf PORTB
>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>;MAIN
>
>mainloop:
> btfss PORTB,1 ;if porta.1 is one, then do this func
> goto skipa1
> movlw B'11111111'
> movwf speedright
> movwf speedleft
> call motor
>skipa1:
> goto mainloop
>
>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>;MTOTOR function
>motor:
> movwf wcnt
>mloopw:
> movlw B'00011110'
> movwf lcnt
>mloopl:
> btfsc PORTB,0
> goto endmotor
>
> movf speedright,w
> movwf tempright
> movf speedleft,w
> movwf templeft
>
> bsf PORTA,0
>rightmotorl:
> goto $+1
> goto $+1
> goto $+1
> nop
> decfsz tempright,f
> goto rightmotorl
>
> bcf PORTA,0
>
> bsf PORTA,1
>leftmotorl:
> goto $+1
> goto $+1
> goto $+1
> nop
> decfsz templeft,f
> goto leftmotorl
>
> bcf PORTA,1
>
> ;wait
> ;13625 cycles
> movlw 0x34
> movwf d1
>Delay_00
> movlw 0x56
> movwf d2
>Delay_01
> decfsz d2, f
> goto Delay_01
> decfsz d1, f
> goto Delay_00
>
> ;40 cycles
> movlw 0x0d
> movwf d1
>Delay_10
> decfsz d1, f
> goto Delay_10
>
> ;2 cycles
> goto $+1
> ;end wait
>
> decfsz lcnt,f
> goto mloopl
> decfsz wcnt,f
> goto mloopw
>endmotor:
> return
>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>;END of prog
> END
>_________________________________________________________________
>Get your FREE download of MSN Explorer at
http://explorer.msn.com
>
>--
>
http://www.piclist.com hint: PICList Posts must start with ONE topic:
>[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
>
>