COLABORATIVO 2 INSTRUMENTACION MEDICA.pdf
-
Upload
john-sanchez -
Category
Documents
-
view
44 -
download
2
Transcript of COLABORATIVO 2 INSTRUMENTACION MEDICA.pdf
TRABAJO COLABORATIVO 1
INSTRUMENTACION MEDICA
Estudiantes
JOHN ALEXANDER SANCHEZ N, cod 11276394
Tutor
SAULO ANDRES
UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA UNAD
INGENIERIA ELECTRONICA
ZIPAQUIRA
2015
INTRODUCCION
El presente documento contiene el desarrollo de la guía correspondiente al trabajo
colaborativo #1, en el cual se presenta el diseño de un circuito microcontrolado por medio
del PIC 16F877A del cual se ha utilizado el módulo ADC para capturar una señal analógica
que provee un sensor de temperatura para una mejor interpretación gráfica y oportuna.
Además se ha implementado un LCD que nos permite visualizar si el paciente tiene en el
momento de la medición hipotermia, hipertermia o si esta normal su temperatura. Además
de ello dependiendo de la temperatura se implementan unos led y un Buzzer que detecte
visualmente o clarifique al operador del sistema el estado de la temperatura.
En el presente documento también se presenta un diseño electrónico realizado y simulado
en el software Proteus ya que es una herramienta útil para el desarrollo de tales
propósitos. Para el desarrollo del código que exige la guía en assembler, se ha utilizado el
software MPLAB que nos brinda además de herramientas de ayuda, una plantilla guía para
que nuestro código sea más fácil de elaborar.
DIAGRAMA DE FLUJO
CIRCUITO RESPECTIVO
PROGRAMA FINAL
A continuación se presenta el desarrollo del código en assembler en el software
MPLAB:
list p=16f877A ; list directive to define processor
#include <p16f877A.inc> ; processor specific variable definitions
#include <Macros.inc>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF&
_CPD_OFF
errorlevel 1,-302
errorlevel 2,-306
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;*************************************************************************
;**********************************************************************
; Definición de constantes
;**********************************************************************
#Define Carfin 0X00
;**********************************************************************
;******PIN DEFINITION*******
#Define RS PORTE,0
#Define RW PORTE,1
#Define E PORTE,2
#DEFINE reloj PORTA,1
#DEFINE LEDVERDE PORTD,1
#DEFINE LEDAMARILLO PORTD,2
#DEFINE LEDROJO PORTD,3
#DEFINE BUZZER PORTD,0
;***VARIABLE DEFINITIONS****
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving
PDel0 EQU 0x20
PDel1 EQU 0x21
PDel2 EQU 0x22
FLAG EQU 0x23
Caracter EQU 0X24
Instruc EQU 0X25
Num_Men EQU 0X26
Con_Ref EQU 0X27
Reg_Test1 EQU 0X28
Reg_Test2 EQU 0X29
Reg_Test3 EQU 0X2A
Flag EQU 0X2B
Cont EQU 0X2C
Unidad EQU 0X2D
Decena EQU 0X2E
Num EQU 0X2F
Number EQU 0X79
AddressLCD EQU 0X7A
DatoLCD EQU 0X7B
Cont_Car EQU 0X7C
AUX EQU 0X7D
AUX1 EQU 0X7E
RegAux EQU 0X7F
;**********************************************************************
ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto CONFIGURES ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
;**********************************************************************
TableASCII
addwf PCL,F
retlw '0'
retlw '1'
retlw '2'
retlw '3'
retlw '4'
retlw '5'
retlw '6'
retlw '7'
retlw '8'
retlw '9'
;**********************************************************************
; Numeración de mansajes
;**********************************************************************
#Define M_TERMOMETRIA .0
#Define M_HIPOMETRIA .1
#Define M_HIPERMETRIA .2
#Define M_NORMAL .3
;**********************************************************************
CONFIGURES
Banksel ADCON0
clrf PORTA
movlf b'01000001',ADCON0 ;A/D conversion Fosc/8
Banksel ADCON1
movlf 0X2B,TRISA ; CMCON=7 inhibir los comparadores
movlf b'00000000',TRISB
movlf b'10101101',TRISC
movlf b'00000000',TRISD
clrf TRISE
movlf b'00000111',OPTION_REG ;TMR0 preescaler, 1:156
movlf b'00000100',ADCON1 ;A/D (Chanel0,Chanel1 y Chanel3)
Banksel ADCON0
CLRF PORTA
call Ret_1Seg
call Ini4b_LCD
clrf PORTB
PPAL
CALL Ret_20ms
movlw 0X01
call Env_Com
movlw M_TERMOMETRIA
movwf Num_Men
movlw 0X80
call Mensaje
;**********************************************************************
Loop_hipo
;**********************************************************************
movlf b'01000001',ADCON0 ;A/D conversion Fosc/8
Wait_hipo
BSF LEDVERDE
bsf ADCON0,GO ;Empezar la conversion A/D
WaitFuseBlue
btfsc ADCON0,GO ;ADCON0 es 0? (la conversion esta completa?)
goto WaitFuseBlue ;No, ir _espera
call Ret_20ms
movf ADRESH,W ;Si, W=ADRESH
movwf PORTB ;Muestra el resultado en PORTB
movff PORTB,RegAux
BSF LEDVERDE
t19
xorlf .19,RegAux
btfss STATUS,Z
goto HIPER
goto Temp_normal
HIPER
movlw .20 ;(50 led Azul)Valor ADC correcto
subwf RegAux,W
btfss STATUS,C
goto FuseBlueMenor
FuseBlueMayorIgual
movlw .18 ;(100 Led Azul)Rango del 5% por encima
subwf RegAux,W
btfsc STATUS,C
goto FuseBlueMayor
goto FuseBlueMenor
FuseBlueMenor
movlw 0X01
call Env_Com
movlw M_TERMOMETRIA
movwf Num_Men
movlw 0X80
call Mensaje
movlw M_HIPOMETRIA
movwf Num_Men
movlw 0XC0
call Mensaje
BCF LEDVERDE
BSF LEDAMARILLO
BSF BUZZER
CALL Ret_1Seg
BCF LEDAMARILLO
CALL Ret_1Seg
BSF LEDAMARILLO
CALL Ret_1Seg
BCF LEDAMARILLO
CALL Ret_1Seg
bCf BUZZER
goto Wait_hipo
FuseBlueMayor
movlw 0X01
call Env_Com
movlw M_TERMOMETRIA
movwf Num_Men
movlw 0X80
call Mensaje
movlw M_HIPERMETRIA
movwf Num_Men
movlw 0XC0
call Mensaje
bcf LEDVERDE
BCF LEDAMARILLO
BCF LEDVERDE
BSF LEDROJO
BSF BUZZER
CALL Ret_1Seg
BCF LEDROJO
CALL Ret_1Seg
BSF LEDROJO
CALL Ret_1Seg
BCF LEDROJO
CALL Ret_1Seg
bCf BUZZER
goto Wait_hipo
Temp_normal
movlw 0X01
call Env_Com
movlw M_TERMOMETRIA
movwf Num_Men
movlw 0X80
call Mensaje
movlw M_NORMAL
movwf Num_Men
movlw 0XC0
call Mensaje
BCF LEDAMARILLO
bcf LEDROJO
BCF BUZZER
BSF LEDVERDE
call Ret_1Seg
goto Wait_hipo
;***************************
pulso_reloj
; CALL Ret_20ms;Ret_1Seg
nop
nop
nop
bsf reloj
nop
bcf reloj
nop
nop
nop
; call Ret_20ms;Ret_1Seg
Return
;--------------------------------------------------------------------------------------
Ini4b_LCD ;Inicialización del LCD a 4 lineas
;--------------------------------------------------------------------------------------
bcf RS
bcf E
bcf RW
movlf 0X20,PORTD
bsf E
call Ret_5ms
nop
nop
nop
bcf E
call Ret_5ms
movlf 0X20,PORTD
bsf E
call Ret_5ms
nop
nop
nop
bcf E
call Ret_5ms
movlf 0X80,PORTD
bsf E
call Ret_5ms
nop
nop
nop
bcf E
call Ret_5ms
movlw 0X28
call Env_Com
movlw 0X08
call Env_Com
movlw 0X0C
call Env_Com
movlw 0X04
call Env_Com
movlw 0X01
call Env_Com
return
;---------------------------------------------------------------------------------------
Env_Com
movwf Instruc
bcf RS
bcf RW
movf Instruc,W
andlw 0xF0
movwf PORTD
bsf E
nop
bcf E
swapf Instruc,W
andlw 0xF0
movwf PORTD
bsf E
nop
bcf E
call Ret_5ms
return
;---------------------------------------------------------------------------------------
Env_Dato
movwf Caracter
bsf RS
bcf E
bcf RW
movf Caracter,W
andlw 0xF0
movwf PORTD
bsf E
nop
bcf E
swapf Caracter,W
andlw 0xF0
movwf PORTD
bsf E
nop
bcf E
call Ret_5ms
return
;**************************************************************************
Ret_1Seg
movlw .22
movwf PDel0
PLoop2
movlw .134
movwf PDel1
PLoop3
movlw .211
movwf PDel2
PLoop4
clrwdt
decfsz PDel2,1
goto PLoop4
decfsz PDel1,1
goto PLoop3
decfsz PDel0,1
goto PLoop2
PDelL40
goto PDelL50
PDelL50
clrwdt
return
;**************************************************************************
Ret_20ms
movlw .110
movwf PDel0
PLoop0
movlw .181
movwf PDel1
PLoop1
clrwdt
clrwdt
decfsz PDel1,1
goto PLoop1
decfsz PDel0,1
goto PLoop0
PDelL1
goto PDelL2
PDelL2
goto PDelL3
PDelL3
clrwdt
return
;-------------------------------------------------------------------
Ret_5ms
movlf .44,PDel0
PLoop5
movlf .141,PDel1
PLoop6
clrwdt
decfsz PDel1,1
goto PLoop6
decfsz PDel0,1
goto PLoop5
PDelL6
goto PDelL7
PDelL7
clrwdt
return
;**********************************************************************
Org 0X700
;**********************************************************************
Mensaje
movwf Instruc
call Env_Com
clrf Cont_Car
Env_Men
bcf PCLATH,4
bcf PCLATH,3
call Car_Men
clrf PCLATH
movwf Caracter
movlw Carfin
xorwf Caracter,W
btfsc STATUS,Z
return
call Env_Dato
incf Cont_Car,f
goto Env_Men
;***********************************************************
Org 0X710
;***********************************************************
Car_Men
movlf 0X07,PCLATH
movf Num_Men,W
addwf PCL,F
goto Car_Men1
goto Car_Men2
goto Car_Men3
goto Car_Men4
goto Car_Men5
goto Car_Men6
goto Car_Men7
goto Car_Men8
goto Car_Men9
goto Car_Men10
goto Car_Men11
goto Car_Men12
goto Car_Men13
goto Car_Men14
;***********************************************************
Car_Men1
movf Cont_Car,W
addwf PCL,F
retlw 'T'
retlw 'E'
retlw 'R'
retlw 'M'
retlw 'O'
retlw 'M'
retlw 'E'
retlw 'T'
retlw 'R'
retlw 'I'
retlw 'A'
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men2
movf Cont_Car,W
addwf PCL,F
retlw 'H'
retlw 'I'
retlw 'P'
retlw 'O'
retlw 'T'
retlw 'E'
retlw 'R'
retlw 'M'
retlw 'I'
retlw 'A'
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men3
movf Cont_Car,W
addwf PCL,F
retlw 'H'
retlw 'I'
retlw 'P'
retlw 'E'
retlw 'R'
retlw 'T'
retlw 'E'
retlw 'R'
retlw 'M'
retlw 'I'
retlw 'A'
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men4
movf Cont_Car,W
addwf PCL,F
retlw 'N'
retlw 'O'
retlw 'R'
retlw 'M'
retlw 'A'
retlw 'L'
retlw ' '
retlw 0X00
;***********************************************************
Car_Men5 ; M_InspVisual
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men6
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men7
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men8
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men9
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men10
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men11
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men12
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men13
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;***********************************************************
Car_Men14
movf Cont_Car,W
addwf PCL,F
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw 0X00
;**************************************************************************
END ; directive 'end of program'
CONCLUSIONES
Se ha logrado desarrollar el objetivo cumpliendo con el diseño del instrumento
medidor de temperatura.
Se ha logrado interpretar módulos del Pic como lo son el conversor análogo a
digital y la comunicación con la pantalla LCD
Se elaboró el diseño y simulación de un circuito en Proteus
Se realizó el código en lenguaje ensamnblador en MPLAB
BIBLIOGRAFIA
Módulo de Instrumentación Medica Unad.