Codigo del 16f84A para servomotor

he intentado hacer un codigo para mantener un servomotor estable a un angulo constante... para ello elabore el siguiente codigo...

Lo que no comprendo es porque.. al quemarlo en el Pic.... y probarlo.... el servo no hace algo... le quito y pongo de forma rapida el cable que va la linea de control del servo... y se mueve un poco... muy poco... y luego se para.. mhmhmhm.... ya estoy frustrado... porque no tengo idea de que podria ser.. estoy usando el servo HITEC 311.... el PIC16F84A, un oscilador de 4 Mhz.....

y para probar que todos mis componentes estan bien... tome un programa de ejemplo de otra pagina.... posteo... el programa que elabore y el programa que vi..... Si alguien podria ayudarme.... se los agradeceria muxisimo...

PROGRAMA QUE ELABORE......................... ops: :cry:

STATUS EQU 03H
PORTA EQU 05H
TRISA EQU 05H
PORTB EQU 06H
TRISB EQU 06H
ALTO EQU 0CH
BAJO EQU 0DH
BGRAL0 EQU 0EH
BGRAL1 EQU 0FH
CPYALTO EQU 10H
CPYBAJO EQU 11H
ALTO500 EQU 12H
W EQU 0
F EQU 1
OPCION EQU 1h ;Registro OPCION
RBPU EQU 7h ;Bit R de polarizaci¢n
#DEFINE BANCO0 BCF STATUS,5
#DEFINE BANCO1 BSF STATUS,5

ORG 00H
GOTO INICIO
GOTO 05H

INICIO ;Ponemos entradas y salidas
BANCO1
MOVLW b'00000000'; Puerto A como entradas
MOVWF TRISA
MOVLW b'00000000'; Puerto B como salidas
MOVWF TRISB
;Iniciamos valores de alto y bajo
MOVLW .155
MOVWF ALTO
MOVLW .100
MOVWF BAJO
BANCO0
CLRF PORTB


;------------------------------------------------------------------
;Comienza el ciclo de alto
BSF PORTB,1
;------------------------------------------------------------------
REPITE MOVF ALTO,W
MOVWF CPYALTO
;500 microsegundos
MOVLW .100
MOVWF ALTO500
CALTO500 CLRWDT
CLRWDT
DECFSZ ALTO500,F
GOTO CALTO500

;CicLo de alto manipulado
CALTO CLRWDT
NOP
NOP
CLRWDT
NOP
DECFSZ CPYALTO,F
GOTO CALTO
;------------------------------------------------------------
;Comienza el ciclo de bajo
;BCF PORTB,1
;------------------------------------------------------------
;Ciclo de Bajo
MOVF BAJO,W
MOVWF CPYBAJO
CBAJO CLRWDT
NOP
NOP
CLRWDT
NOP
DECFSZ CPYBAJO,F
GOTO CBAJO

;Comienza el ciclo de bajo general ( independiente )
MOVLW .66
MOVWF BGRAL1
CBGRAL1 MOVLW .50
MOVWF BGRAL0
CBGRAL0 CLRWDT
CLRWDT
DECFSZ BGRAL0,F
GOTO CBGRAL0
DECFSZ BGRAL1,F
GOTO CBGRAL1

GOTO REPITE

END



PROGRAMA QUE TOME DE INTERNET... Este si funciona perfectamente ya lo probe.. y todo.....
ops: :cry:
; ===================================================================
; Del libro "MICROCONTROLADOR PIC16F84. DESARROLLO DE PROYECTOS"
; E. Palacios, F. Remiro y L. López.
; Editorial Ra-Ma. www.ra-ma.es
; ===================================================================ç

; Manejar el de servo FUTABA S3003 conectado en RB0, el servo
; se movera a dos posiciones (0º-180º) dependiendo del estado del interruptor
; colocado en RA0.
;
LIST P=16F84

w EQU 0 ;Destino W
f EQU 1 ;Destino registro
RA EQU 05h ;Puerta A
RB EQU 06h ;Puerta B
PORTA EQU 05h ;Puerta A
PORTB EQU 06h ;Puerta B
TRISA EQU 5h ;Registro triestado de Puerta A
TRISB EQU 6h ;Registro triestado de Puerta B
STATUS EQU 03h ;Registro STATUS
OPCION EQU 1h ;Registro OPCION
RBPU EQU 7h ;Bit R de polarizaci¢n
RP0 EQU 05h ;Bit 5 registro STATUS
PDel0 EQU 0Ch
PDel1 EQU 0Dh
ALTO EQU 0EH
BAJO EQU 0FH
;
;************************* Seccion Codigo de RESET **************************
;
ORG 00h ;Direccion del Vector de RESET
GOTO Inicializa ;Comienza el programa
ORG 05h ;Una posicion detras del Vector Interrupcion
;
;**************************** Seccion Inicializa ****************************
;

Inicializa BSF STATUS,5 ;Seleccion Banco 1
MOVLW b'00000000' ;Carga W
MOVWF TRISB ;Bit0 Puerta B salida
MOVLW b'00000010' ;Carga W
MOVWF TRISA ;Bit0 Puerta A entrada
MOVLW .48
MOVWF ALTO
BCF STATUS,5 ;Seleccion Banco 0
CLRF RB


LeerEntrada BTFSC RA,1 ;Comprueba estado interruptor en RA0
GOTO Servo_pos_1 ;Si ra0 = 0 salta y pone el servo en pos. 2
GOTO Servo_pos_2 ;Si ra0 = 1 no salta y pone el servo en pos. 1
GOTO LeerEntrada ; Bucle infinito


;************* Pulso de 0,2 ms para poner el servo en 0º ********************

Servo_pos_1 BSF RB,1 ;Pone a 1 la salida Rb0

;------------------Bucle retardo duracion pulso a 1--------------

PDelay movf ALTO,w ; 1 set number of repetitions
movwf PDel0 ; 1 |
PLoop0 clrwdt ; 1 clear watchdog
decfsz PDel0, 1 ; 1 + (1) is the time over?
goto PLoop0 ; 2 no, loop

PDelL1 goto PDelL2 ; 2 cycles delay
PDelL2 clrwdt ; 1 cycle delay
;----------------------------------------------------------------
BCF RB,1 ;Pone a 0 la salida Rb0

;-------------Bucle retardo duracion resto onda hasta 20 ms--------------
PDelayR movlw .86 ; 1 set number of repetitions (B)
movwf PDel0 ; 1 |
PLoop1R movlw .45 ; 1 set number of repetitions (A)
movwf PDel1 ; 1 |
PLoop2R clrwdt ; 1 clear watchdog
PDelL1R goto PDelL2R ; 2 cycles delay
PDelL2R clrwdt ; 1 cycle delay
decfsz PDel1, 1 ; 1 + (1) is the time over? (A)
goto PLoop2R ; 2 no, loop
decfsz PDel0, 1 ; 1 + (1) is the time over? (B)
goto PLoop1R ; 2 no, loop
;----------------------------------------------------------------
GOTO LeerEntrada

;************* Pulso de 2,2 ms para poner el servo en 180º ********************

Servo_pos_2 BSF RB,1 ;Pone a 1 la salida Rb0

;------------------Bucle retardo duracion pulso a 1--------------
PDelay_2 movlw .4 ; 1 set number of repetitions (B)
movwf PDel0 ; 1 |
PLoop1_2 movlw .136 ; 1 set number of repetitions (A)
movwf PDel1 ; 1 |
PLoop2_2 clrwdt ; 1 clear watchdog
decfsz PDel1, 1 ; 1 + (1) is the time over? (A)
goto PLoop2_2 ; 2 no, loop
decfsz PDel0, 1 ; 1 + (1) is the time over? (B)
goto PLoop1_2 ; 2 no, loop
PDelL1_2 goto PDelL2_2 ; 2 cycles delay
PDelL2_2 clrwdt ; 1 cycle delay
;----------------------------------------------------------------

BCF RB,1 ;Pone a 0 la salida Rb0

;-------------Bucle retardo duracion resto onda hasta 20 ms--------------
PDelayS movlw .17 ; 1 set number of repetitions (B)
movwf PDel0 ; 1 |
PLoop1S movlw .205 ; 1 set number of repetitions (A)
movwf PDel1 ; 1 |
PLoop2S clrwdt ; 1 clear watchdog
clrwdt ; 1 cycle delay
decfsz PDel1, 1 ; 1 + (1) is the time over? (A)
goto PLoop2S ; 2 no, loop
decfsz PDel0, 1 ; 1 + (1) is the time over? (B)
goto PLoop1S ; 2 no, loop
PDelL1S goto PDelL2S ; 2 cycles delay
PDelL2S
;return ; 2+2 Done
;----------------------------------------------------------------
GOTO LeerEntrada

END
ops: :cry:
 
encontre el error.... jejeje... un error.... muy chafa..... jejejje..... primera puse punto y coma.. en BCF PORTB,1 y segunta la etiqueta REPETIR.... iba una linea antes......
 
ey ey saludos...oye yo estoy haciendo el mismo circuito, pero en lugar de moverlo de 0° a 180° yo requiero moverlo de 0° a 90°...por favor me podrias decir como seria el codigop para el pic y como lo sacaste? gracias de antemano
 
Atrás
Arriba