Si además quieres enviarnos un Artículo para el Blog y redes sociales, pulsa el siguiente botón:
Pues eso, os dejo este programilla que un día me bajé de otro foro (lo siento pero no tengo datos de donde lo saqué) y que he modificado para hacerlo muy sencillo y simple para los que empiezan como yo a hacer cosillas con los robots. Tengo una duda, para cada cambio de ángulo hay tres variables tres d'xxx' y no se como camiarlos para modificar el ángulo y la velocidad, yo tengo unos servos futaba 3003, a ver quien me hecho una mano
;*************************************************************************************************
;
; PROGRAMA : PRUEBAS DE ANGULOS CON DOS SERVOS.ASM
;
;
;
; Velocidad del reloj : 4 MHz Reloj instrucci¢n: 1 MHz = 1 us, T= 4 us
; Perro Guardian : Deshabilitado Tipo de reloj : XT
; Proteccion del codigo : OFF
;
;
;**********************************************************************************************
LIST P=16F84A ;EL PIC A UTILIZAR.
;************************ IGUALIDADES ***************************************************
w EQU 0X00 ;DESTINO w (REGISTRO DE TRABAJO)
f EQU 0X01 ;DESTINO f (REGISTRO A USADO)
ESTADO EQU 0X03 ;ESTADO, ESTA EN LA DIRECCION 3
RP0 EQU 0X05 ;RP0 EQUIVALE A 5.
PCL EQU 0x02 ;DIRECCION DEL PCL (CONTADOR DEL PC)
PUERTAA EQU 0X05 ;PUERTAA SE ENCUENTRA EN LA DIRECCION 5.
PUERTAB EQU 0X06 ;PUERTAB SE ENCUENTRA EN LA DIRECCION 6.
ALTO_1 EQU 0x0c ;DIRECCION DEL REGISTRO DEL PULSO ALTO
ALTO_2 EQU 0x0d ;DIRECCION DEL REGISTRO DEL PULSO ALTO
BAJO_1 EQU 0X0e ;DIRECCION DEL REGISTRO DEL PULSO BAJO
BAJO_2 EQU 0x0f ;DIRECCION DEL REGISTRO DEL PULSO ALTO
HZ EQU 0x1c ;DIRECCION DEL REGISTRO HZ (50 VECES, PARA FORMAR 50HZ)
;*********** AQUI EMPIEZA EL PROGRAMA. **************************************************
ORG 0 ;ORIGEN DEL PROGRAMA, AQUI EMPIEZA.
goto INICIO ;VA A INICIO PARA SOBREPASAR
;EL VECTOR DE INTERRUPCION.
ORG 5
INICIO bsf ESTADO,RP0 ;Cambio al banco 1
movlw b'00000111' ;2 bit de puerto A como entrada
movwf PUERTAA
clrf PUERTAB ;Puerta B como salida
bcf ESTADO,RP0 ;Cambio al banco 0
clrf PUERTAA ;Borro puerta A
clrf PUERTAB ;Borro puerta B
;************** Leer las entrada para desplazar servo ***********************************
LEE_ENTRADA movf PUERTAA,0 ;Mueve el valor de la entrada al registro w (Lee entradas)
goto AVANZA
AVANZA call SV_0_90
call SV_1_90
call SV_0_180
call SV_1_180
goto LEE_ENTRADA
;****** Rutina para posicionar el servo en los 90° **************************************
SV_0_90 movlw d'13'
movwf HZ
ALTO_90_0 bsf PUERTAB,0 ;Pone a 1 el bit 0 de la puerta A
call AL90
BAJO_90_0 bcf PUERTAB,0 ;Pone a 0 el bit 0 de la puerta A
call BA90
decfsz HZ,1
goto ALTO_90_0
return
SV_1_90 movlw d'13'
movwf HZ
ALTO_90_1 bsf PUERTAB,1 ;Pone a 1 el bit 0 de la puerta A
call AL90
BAJO_90_1 bcf PUERTAB,1 ;Pone a 0 el bit 0 de la puerta A
call BA90
decfsz HZ,1
goto ALTO_90_1
return
;****** Rutina para posicionar el servo en los 180° **************************************
SV_0_180 movlw d'13'
movwf HZ
ALTO_0_180 bsf PUERTAB,0 ;Pone a 1 el bit 0 de la puerta A
call AL0
BAJO_0_180 bcf PUERTAB,0 ;Pone a 0 el bit 0 de la puerta A
call BA0
decfsz HZ,1
goto ALTO_0_180
return
SV_1_180 movlw d'13'
movwf HZ
ALTO_1_180 bsf PUERTAB,1 ;Pone a 1 el bit 0 de la puerta A
call AL0
BAJO_1_180 bcf PUERTAB,1 ;Pone a 0 el bit 0 de la puerta A
call BA0
decfsz HZ,1
goto ALTO_1_180
return
;***** Pulso Alto a 90° **************************************************
AL90 movlw d'44'
movwf ALTO_1
A90 movlw d'8'
movwf ALTO_2
DC1 decfsz ALTO_2,1
goto DC1
decfsz ALTO_1,1
goto A90
return
;***** Pulso Bajo a 90° ***************************************************
BA90 movlw d'45'
movwf BAJO_1
B90 movlw d'92'
movwf BAJO_2
DC2 decfsz BAJO_2,1
goto DC2
decfsz BAJO_1,1
goto B90
return
;***** Pulso Alto a 180º ***********************************************
AL0 movlw d'52'
movwf ALTO_1
A0 movlw d'92'
movwf ALTO_2
DC11 decfsz ALTO_2,1
goto DC11
decfsz ALTO_1,1
goto A0
return
;***** Pulso Bajo a 180° **************************************************
BA0 movlw d'49'
movwf BAJO_1
B0 movlw d'8'
movwf BAJO_2
DC12 decfsz BAJO_2,1
goto DC12
decfsz BAJO_1,1
goto B0
return
END
También tengo el programa para el proteus para los que quieran trastear, si alguien me dice como colgarlo lo subo que vale la pena para empezar a practicar con los servos