# [Aporte] Brazo robot con servomotores



## CyberLawren (Mar 11, 2012)

aqui les dejo un programita que he realizado en mi proyecto de robotica , funciona perfectamente
 el funcionamiento es via 232 desde un pc, reprogramable, se puede cambiar los angulos de movimiento de los brazos para diferentes funciones. el ultimo dato ingrasdo quedara grabado en la MEM del pic master. cuando el pic master recibe un dato via 232, este lo graba y guarde en su MEM, luego lo transmite a los eslaves el cual estan configurados para recibir datos. asi el master envia 6 datos por bloque en donde cada dato sera para cada eslave, una vez realizado los 6 bloque de tranmision se reinicia y comienza nuevamente la transmision.

;el programa  principal o master, esta solo para el control de 5 servomotores
;si se desea agregar para 6 se utilizara hasta MEM24 y GRABA24

```
LIST P=16F877A
	__CONFIG  3F32
	INCLUDE <P16F877A.INC>
	INCLUDE <MACROPIC.INC>
	INCLUDE <MACRO_LCD.INC>
	CBLOCK	0x20
	VART
	VAR1
	VAR2
	MEM1
	MEM2
	MEM3
	MEM4
	MEM5
	MEM6
	MEM7
	MEM8
	MEM9
	MEM10
	MEM11
	MEM12
	MEM13
	MEM14
	MEM15
	MEM16
	MEM17
	MEM18
	MEM19
	MEM20
	GRABA1
	GRABA2
	GRABA3
	GRABA4
	GRABA5
	GRABA6
	GRABA7
	GRABA8
	GRABA9
	GRABA10
	GRABA11
	GRABA12
	GRABA13
	GRABA14
	GRABA15
	GRABA16
	GRABA17
	GRABA18
	GRABA19
	GRABA20
	ENDC

	ORG		0000H
	goto	INICIO
;=======================
INICIO
	banco 1
	movlw b'11000111'
movwf TMR0
banco 0
CLS
	movlw	.0
	call	LEE_EEPROM
	movwf	MEM1
	movlw	.1
	call	LEE_EEPROM
	movwf	MEM2
	movlw	.2
	call	LEE_EEPROM
	movwf	MEM3
	movlw	.3
	call	LEE_EEPROM
	movwf	MEM4
	movlw	.4
	call	LEE_EEPROM
	movwf	MEM5
	movlw	.5
	call	LEE_EEPROM
	movwf	MEM6
	movlw	.6
	call	LEE_EEPROM
	movwf	MEM7
	movlw	.7
	call	LEE_EEPROM
	movwf	MEM8
	movlw	.8
	call	LEE_EEPROM
	movwf	MEM9
	movlw	.9
	call	LEE_EEPROM
	movwf	MEM10
	movlw	.10
	call	LEE_EEPROM
	movwf	MEM11
	movlw	.11
	call	LEE_EEPROM
	movwf	MEM12
	movlw	.12
	call	LEE_EEPROM
	movwf	MEM13
	movlw	.13
	call	LEE_EEPROM
	movwf	MEM14
	movlw	.14
	call	LEE_EEPROM
	movwf	MEM15
	movlw	.15
	call	LEE_EEPROM
	movwf	MEM16
	movlw	.16
	call	LEE_EEPROM
	movwf	MEM17
	movlw	.17
	call	LEE_EEPROM
	movwf	MEM18
	movlw	.18
	call	LEE_EEPROM
	movwf	MEM19
	movlw	.19
	call	LEE_EEPROM
	movwf	MEM20
;========================
	call	inicio_LCD
	MOVF MEM1,0
	CALL EnviaCarLCD
	MOVF MEM2,0
	CALL EnviaCarLCD
	MOVF MEM3,0
	CALL EnviaCarLCD
	MOVF MEM4,0
	CALL EnviaCarLCD
	MOVF MEM5,0
	CALL EnviaCarLCD
	MOVF MEM6,0
	CALL EnviaCarLCD
	MOVF MEM7,0
	CALL EnviaCarLCD
	MOVF MEM8,0
	CALL EnviaCarLCD
	MOVF MEM9,0
	CALL EnviaCarLCD
	MOVF MEM10,0
	CALL EnviaCarLCD
	MOVF MEM11,0
	CALL EnviaCarLCD
	MOVF MEM12,0
	CALL EnviaCarLCD
	MOVF MEM13,0
	CALL EnviaCarLCD
	MOVF MEM14,0
	CALL EnviaCarLCD
	MOVF MEM15,0
	CALL EnviaCarLCD
	MOVF MEM16,0
	CALL EnviaCarLCD
	MOVF MEM17,0
	CALL EnviaCarLCD
	MOVF MEM18,0
	CALL EnviaCarLCD
	MOVF MEM19,0
	CALL EnviaCarLCD
	MOVF MEM20,0
	CALL EnviaCarLCD
;*****************************************************
;LEE Y ENVIA MEMORIA AL LCD
call inicio_TX
MOVF MEM1,0
CALL TX_DATO
MOVF MEM2,0
CALL TX_DATO
MOVF MEM3,0
CALL TX_DATO
MOVF MEM4,0
CALL TX_DATO
CALL RET2
MOVF MEM5,0
CALL TX_DATO
MOVF MEM6,0
CALL TX_DATO
MOVF MEM7,0
CALL TX_DATO
MOVF MEM8,0
CALL TX_DATO
MOVF MEM9,0
CALL TX_DATO
MOVF MEM10,0
CALL TX_DATO
MOVF MEM11,0
CALL TX_DATO
MOVF MEM12,0
CALL TX_DATO
MOVF MEM13,0
CALL TX_DATO
MOVF MEM14,0
CALL TX_DATO
MOVF MEM15,0
CALL TX_DATO
MOVF MEM16,0
CALL TX_DATO
MOVF MEM17,0
CALL TX_DATO
MOVF MEM18,0
CALL TX_DATO
MOVF MEM19,0
CALL TX_DATO
MOVF MEM20,0
CALL TX_DATO
	ENTER
		PUT 'C'
		PUT 'A'
		PUT 'M'
		PUT 'B'
		PUT 'I'
		PUT 'A'
		PUT 'R'
		PUT '.'
		PUT '.'
		PUT 'S'
		PUT '/'
		PUT 'N'
       	call inicio_RX
;PREGUNTA SI PULSO *S*
		PREGUNTA
		CALL WAIT_RX
		MOVWF VAR2
		cje VAR2,'S',SIGUE
		cje VAR2,'N',TRANSMITE
		GOTO INICIO 
       	SIGUE
		CLS
        CALL WAIT_RX
		movwf GRABA1
		CALL WAIT_RX
		movwf GRABA2
		CALL WAIT_RX
		movwf GRABA3
		CALL WAIT_RX
		movwf GRABA4
		CALL WAIT_RX
		movwf GRABA5
		CALL WAIT_RX
		movwf GRABA6
		CALL WAIT_RX
		movwf GRABA7
		CALL WAIT_RX
		movwf GRABA8
		CALL WAIT_RX
		movwf GRABA9
		CALL WAIT_RX
		movwf GRABA10
		CALL WAIT_RX
		movwf GRABA11
		CALL WAIT_RX
		movwf GRABA12
		CALL WAIT_RX
		movwf GRABA13
		CALL WAIT_RX
		movwf GRABA14
		CALL WAIT_RX
		movwf GRABA15
		CALL WAIT_RX
		movwf GRABA16
		CALL WAIT_RX
		movwf GRABA17
		CALL WAIT_RX
		movwf GRABA18
		CALL WAIT_RX
		movwf GRABA19
		CALL WAIT_RX
		movwf GRABA20
		
CLS
PUT 'O'
PUT 'K'

CAMBIARCODIGO;-------------------------------------
; grabamos en memoria la nueva clave
	mov		DIRECCION_EE,00H
	movr	DATO_EE,GRABA1
	call	GRABA_EEPROM
	mov		DIRECCION_EE,01H
	movr	DATO_EE,GRABA2
	call	GRABA_EEPROM
	mov		DIRECCION_EE,02H
	movr	DATO_EE,GRABA3
	call	GRABA_EEPROM
	mov		DIRECCION_EE,03H
	movr	DATO_EE,GRABA4
	call	GRABA_EEPROM
	mov		DIRECCION_EE,04H
	movr	DATO_EE,GRABA5
	call	GRABA_EEPROM
	mov		DIRECCION_EE,05H
	movr	DATO_EE,GRABA6
	call	GRABA_EEPROM
	mov		DIRECCION_EE,06H
	movr	DATO_EE,GRABA7
	call	GRABA_EEPROM
	mov		DIRECCION_EE,07H
	movr	DATO_EE,GRABA8
	call	GRABA_EEPROM
	mov		DIRECCION_EE,08H
	movr	DATO_EE,GRABA9
	call	GRABA_EEPROM
	mov		DIRECCION_EE,09H
	movr	DATO_EE,GRABA10
	call	GRABA_EEPROM
	mov		DIRECCION_EE,10H
	movr	DATO_EE,GRABA11
	call	GRABA_EEPROM
	mov		DIRECCION_EE,11H
	movr	DATO_EE,GRABA12
	call	GRABA_EEPROM
	mov		DIRECCION_EE,12H
	movr	DATO_EE,GRABA13
	call	GRABA_EEPROM
	mov		DIRECCION_EE,13H
	movr	DATO_EE,GRABA14
	call	GRABA_EEPROM
	mov		DIRECCION_EE,14H
	movr	DATO_EE,GRABA15
	call	GRABA_EEPROM
	mov		DIRECCION_EE,15H
	movr	DATO_EE,GRABA16
	call	GRABA_EEPROM
	mov		DIRECCION_EE,16H
	movr	DATO_EE,GRABA17
	call	GRABA_EEPROM
	mov		DIRECCION_EE,17H
	movr	DATO_EE,GRABA18
	call	GRABA_EEPROM
	mov		DIRECCION_EE,18H
	movr	DATO_EE,GRABA19
	call	GRABA_EEPROM
	mov		DIRECCION_EE,19H
	movr	DATO_EE,GRABA20
	call	GRABA_EEPROM
CLS
PUT 'R'
PUT 'E'
PUT 'S'
PUT 'E'
PUT 'T'
PUT ' '
PUT 'P'
 	       CALL WAIT_RX
		movwf VAR1
		cje VAR1,'P',INICIO
		GOTO $-1
TRANSMITE
call inicio_TX
MOVF MEM1,0
CALL TX_DATO
MOVF MEM2,0
CALL TX_DATO
MOVF MEM3,0
CALL TX_DATO
MOVF MEM4,0
CALL TX_DATO
MOVF MEM5,0
CALL TX_DATO
MOVF MEM6,0
CALL TX_DATO
MOVF MEM7,0
CALL TX_DATO
MOVF MEM8,0
CALL TX_DATO
MOVF MEM9,0
CALL TX_DATO
MOVF MEM10,0
CALL TX_DATO
CALL RET2
MOVF MEM11,0
CALL TX_DATO
MOVF MEM12,0
CALL TX_DATO
MOVF MEM13,0
CALL TX_DATO
MOVF MEM14,0
CALL TX_DATO
MOVF MEM15,0
CALL TX_DATO
MOVF MEM16,0
CALL TX_DATO
MOVF MEM17,0
CALL TX_DATO
MOVF MEM18,0
CALL TX_DATO
MOVF MEM19,0
CALL TX_DATO
MOVF MEM20,0
CALL TX_DATO
GOTO INICIO

RET2
CALL RET
CALL RET
RETURN
RET
          movlw D'255'
          movwf VART
          LAZO
          MOVLW D'10'
          MOVWF TMR0
          btfss INTCON,2
          goto $-1
          bcf INTCON,2
          decfsz VAR1
          goto LAZO
          return
       INCLUDE <LCD.ASM>

	INCLUDE <RETARDO.ASM>
	INCLUDE <EEPROM.ASM>
	INCLUDE <UART.ASM>
	INCLUDE <ARITH.ASM>
	ORG		2100H
	DE		"G123AA"
       END 



;PIC SCLAVO 	
		LIST	P=16F876A
		__CONFIG	3F31
		INCLUDE		<P16F876A.INC>
		INCLUDE		<macropic.INC>
		CBLOCK		0X20
		VAR1
		VAR2
		VAR3
		VARX
		RX1
		RX2
		RX3
		ENDC
		ORG			0000H
		GOTO INICIO

		ORG 0004H
		GOTO INTERRUPCION

INICIO
banco 1
		CLRF	PORTB
		MOVLW	.6
		MOVWF	ADCON1
BSF INTCON,GIE
BSF INTCON,PEIE 
BSF PIE1,RCIE
banco 0
		MOVLW	.49
		MOVWF	T1CON
		CLRF	TMR1H
		CLRF	TMR1L
		CLRF	PORTB


call inicio_RX  ;CONFIGURA A 9600 



ANGULOS
		cje	VARX,'0',ANGLE0
		cje	VARX,'1',ANGLE10
		cje	VARX,'2',ANGLE20
		cje	VARX,'3',ANGLE30
		cje	VARX,'4',ANGLE40
		cje	VARX,'5',ANGLE60
		cje	VARX,'6',ANGLE70
		cje	VARX,'7',ANGLE90
		cje	VARX,'A',ANGLE120
		cje	VARX,'B',ANGLE130
		cje	VARX,'C',ANGLE140
		cje	VARX,'D',ANGLE150
		cje	VARX,'E',ANGLE160
		cje	VARX,'F',ANGLE170
		cje	VARX,'G',ANGLE180
		GOTO	ANGULOS

ANGLE0
		MOVLW	.100
		MOVWF	VAR1
		CALL	CERO
		GOTO	ANGULOS			
ANGLE10
		MOVLW	.100
		MOVWF	VAR1
		CALL	DIEZ
		GOTO	ANGULOS			
ANGLE20
		MOVLW	.100
		MOVWF	VAR1
		CALL	VEINTE
		GOTO	ANGULOS	
ANGLE30
		MOVLW	.100
		MOVWF	VAR1
		CALL	TREINTA
		GOTO	ANGULOS	
ANGLE40
		MOVLW	.100
		MOVWF	VAR1
		CALL	CUARENTA
		GOTO	ANGULOS			
ANGLE60
		MOVLW	.100
		MOVWF	VAR1
		CALL	SESENTA
		GOTO	ANGULOS	
ANGLE70
		MOVLW	.100
		MOVWF	VAR1
		CALL	SETENTA
		GOTO	ANGULOS	
ANGLE90
		MOVLW	.100
		MOVWF	VAR1
		CALL	NOVENTA
		GOTO	ANGULOS	
ANGLE120
		MOVLW	.100
		MOVWF	VAR1
		CALL	CVEINTE
		GOTO	ANGULOS	
ANGLE130
		MOVLW	.100
		MOVWF	VAR1
		CALL	CTREINTA
		GOTO	ANGULOS	
ANGLE140
		MOVLW	.100
		MOVWF	VAR1
		CALL	CCUARENTA
		GOTO	ANGULOS	
ANGLE150
		MOVLW	.100
		MOVWF	VAR1
		CALL	CCINCUENTA
		GOTO	ANGULOS	
ANGLE160
		MOVLW	.100
		MOVWF	VAR1
		CALL	CSESENTA
		GOTO	ANGULOS	
ANGLE170
		MOVLW	.100
		MOVWF	VAR1
		CALL	CSETENTA
		GOTO	ANGULOS	
ANGLE180
		MOVLW	.100
		MOVWF	VAR1
		CALL	COCHENTA
		GOTO	ANGULOS		
		
CERO	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'C6'		
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'75'		
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CERO
		RETURN	

DIEZ	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'BA'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'80'
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		DIEZ
		RETURN	
VEINTE	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'AF'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'8C'
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		VEINTE
		RETURN	
TREINTA	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'A3'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'97'
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		TREINTA
		RETURN
CUARENTA	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'97'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						

		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'A3'
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CUARENTA
		RETURN
			
SESENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'80'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF			
		BCF			PORTB,0
		
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'BB'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		SESENTA
		RETURN
SETENTA	
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H			
		MOVLW		H'75'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
						
		BCF			PORTB,0						
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'C0'
		MOVWF		TMR1L
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		SETENTA
		RETURN	
		
NOVENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H		
		MOVLW		H'61'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'D9'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		NOVENTA
		RETURN
		
CVEINTE
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'56'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'DE'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CVEINTE
		RETURN

CTREINTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'45'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F6'
		MOVWF		TMR1H			
		MOVLW		H'F5'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CTREINTA
		RETURN

CCUARENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'39'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F7'
		MOVWF		TMR1H			
		MOVLW		H'01'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CCUARENTA
		RETURN

CCINCUENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'29'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F7'
		MOVWF		TMR1H			
		MOVLW		H'11'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CCINCUENTA
		RETURN

CSESENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'0E'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F7'
		MOVWF		TMR1H			
		MOVLW		H'2C'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CSESENTA
		RETURN

CSETENTA
		BSF			PORTB,0
		MOVLW		H'FF'
		MOVWF		TMR1H	
		MOVLW		H'00'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F7'
		MOVWF		TMR1H			
		MOVLW		H'3A'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		CSETENTA
		RETURN

COCHENTA
		BSF			PORTB,0
		MOVLW		H'FE'
		MOVWF		TMR1H	
		MOVLW		H'F2'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF	
				
		BCF			PORTB,0
		MOVLW		H'F7'
		MOVWF		TMR1H			
		MOVLW		H'4A'
		MOVWF		TMR1L			
		BTFSS		PIR1,TMR1IF
		GOTO		$-1
		bcf			PIR1,TMR1IF
		DECFSZ		VAR1
		GOTO		COCHENTA
		RETURN

;RECIBE UN DATO SEGUN NUMERO DE ESCLAVO

		INTERRUPCION
		BCF PIR1,RCIF
		CALL  WAIT_RX
		MOVWF VARX		;VARX ES LA VARIABLE QUE DEFINE EL ANGULO DE GIRO
		CALL  WAIT_RX
		MOVWF RX1		;RX1,RX2,RX3,RX4 SE IGNORA 
		CALL  WAIT_RX
		MOVWF RX2
		CALL  WAIT_RX
		MOVWF RX3
		RETFIE
	

	INCLUDE <UARTESCLAVO.ASM>
	END
```
 el programa del slave es el mismo para todos solo se varia en la parte de INTERRUPCION el orden para recibir datos.


----------

