'****************************************************************
'* Name : simuECG_CARE.BAS *
'* Author : prof.martintorres@educ.ar *
'* Notice : Copyright (c) 2017 BioEEAsrl - ETI *
'* : All Rights Reserved *
'* Date : 26/07/2017 *
'* Version : 1.1 *
'* Notes : *
'* : *
'****************************************************************
DEFINE OSC 20
@ DEVICE pic16F877A
@ DEVICE pic16F877A, WDT_OFF
@ DEVICE pic16F877A, PWRT_On
@ DEVICE pic16F877A, PROTECT_OFF
Define LCD_DREG PORTD ;bit de datos del LCD empezando
Define LCD_DBIT 0 ;por D.0 ,D.1, D.2 y D.3
Define LCD_RSREG PORTD ;bit de registro del LCD conectar
Define LCD_RSBIT 5 ;en el puerto E.1
Define LCD_EREG PORTD ;bit de Enable conectar en el
Define LCD_EBIT 4 ;puerto E.2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
ADCON1 = 00000000 'Definir todos los PORTA y PORTE como analógicos
;define ADC_BITS 8 ;CONFIGURO conversión A/D en 10 bits
;Define ADC_CLOCK 3 ;
;DEFINE ADC_SAMPLEUS 50 ;Tiempo de muestreo en uS
TRISA=%11111111
TRISB=%11111111
TRISC=%00000000
TRISD=%00000000
BOTON_MAS VAR PORTB.1
BOTON_MENOS VAR PORTB.2
BOTON_ENTER VAR PORTB.3
BOTON_MENU VAR PORTB.4
BOTON_PARAR VAR PORTB.0
aux var byte
aux1 var byte
aux2 var byte
i var byte
puertos var byte
resto var byte
canal var byte
PAUSE 200
LCDOut $fe, $48, $00, $00, $00, $00, $00, $00, $1F, $1F 'Figura 1.
LCDOut $fe, $50, $00, $00, $00, $00, $1F, $1F, $1F, $1F 'Figura 2.
LCDOut $fe, $58, $00, $00, $1F, $1F, $1F, $1F, $1F, $1F 'Figura 3.
LCDOut $fe, $60, $1F, $1F, $1F, $1F, $1F, $1F, $1F, $1F 'Figura 4.
;********************************************************************
;********************************************************************
ARRANQUE:
LCDOUT $FE,$80," BioEEA - ETI "
LCDOUT $fe,$C0,"Ing. Torres A.M."
PAUSE 900
LCDOUT $FE,1
LCDOUT $FE,$80," - CARE - "
LCDOUT $fe,$C0,"simu ECG beta1.1"
PAUSE 900
LCDOUT $FE,1
;**********************************************************
;**********************************************************
;**********************************************************
menu:
LCDOUT $FE,1
LCDOUT $FE,$80, "Selec Funcion "
barrido1:
IF BOTON_MAS = 0 THEN
WHILE boton_mas=0:WEND
if aux > 5 then aux=5
aux = Aux+1
endif
IF BOTON_Menos = 0 THEN
WHILE boton_menos=0:WEND
if aux < 1 then aux=1
aux=aux-1
endif
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
if aux=2 then normal
if aux=3 then bradicardia
if aux=4 then taquicardia
if aux=5 then paro
if aux=1 then Rescate
endif
if aux=1 then
lcdout $fe,$c0,"EjercicioRESCATE"
endif
if aux=2 then
lcdout $fe,$c0,"-eN1-ECG-Normal-"
endif
if aux=3 then
lcdout $fe,$c0,"-eN2-Bradicardia"
endif
if aux=4 then
lcdout $fe,$c0,"-eN3-Taquicardia"
endif
if aux=5 then
lcdout $fe,$c0,"-eN4-ParoCardiac"
endif
goto barrido1
;******************************************************************************
;******************************************************************************
NORMAL: ;ECGNormal
LCDOUT $FE,1
gosub dolor
LCDOUT $FE,$80, "Func. ECG Normal"
LCDOUT $fe, $C0,"Dolor:"
FOR i=0 TO 299
gosub tabla_pulso
PORTC= puertos
pauseus 2700
NEXT
if i = 255 then gosub tabla_pulso
PORTC = puertos
pause 350
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
goto normal
;******************************************************************************
;******************************************************************************
Bradicardia: ;Bradicardia
LCDOUT $FE,1
gosub dolor
LCDOUT $FE,$80, "Func.Bradicardia"
LCDOUT $fe, $C0,"Dolor:"
FOR i=0 TO 299
gosub tabla_pulso
PORTC= puertos
pauseus 2700
NEXT
if i = 255 then gosub tabla_pulso
PORTC = puertos
pause 1200
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
goto bradicardia
;******************************************************************************
;******************************************************************************
Taquicardia: ;Taquicardia
LCDOUT $FE,1
gosub dolor
LCDOUT $FE,$80, "Func.Taquicardia"
LCDOUT $fe, $C0,"Dolor:"
FOR i=30 TO 280
gosub tabla_pulso
PORTC= puertos
pauseus 2700
NEXT
if i = 255 then gosub tabla_pulso
PORTC = puertos
pause 1
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
goto Taquicardia
;******************************************************************************
;******************************************************************************
Paro: ;Paro cardiaco
LCDOUT $FE,1
gosub dolor
LCDOUT $FE,$80, "FuncParoCardiaco"
LCDOUT $fe, $C0,"Dolor:"
;Se envía sólo una línea por el puerto B y la alarma será un LED conectado al puerto D en el bit 0
PORTC=8
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
goto paro
;******************************************************************************
;******************************************************************************
Rescate:
LCDOUT $FE,1
pause 50
gosub dolor
LCDOUT $FE,$80, "Func.Rescate"
LCDOUT $fe, $C0,"Dolor:"
FOR i=0 TO 299
gosub tabla_pulso
PORTC= puertos
gosub movimiento
pauseus 2700
NEXT
if i = 255 then gosub tabla_pulso
PORTC = puertos
pause 350
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
IF boton_enter = 0 THEN
WHILE boton_ENTER=0:WEND
goto menu
endif
goto Rescate
movimiento:
ADCIN 1, canal
RESTO = (CANAL // 15)
if canal > 200 then
FOR i=30 TO 255
gosub tabla_pulso
PORTC= puertos
pauseus 2700
NEXT
if i = 255 then gosub tabla_pulso
PORTC = puertos
pause 1
endif
return
TABLA_PULSO:
lookup i,[8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,12,12,12,11,11,10,10,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,6,6,5,5,5,4,4,4,4,6,9,13,16,20,24,29,33,38,42,46,49,52,54,55,54,53,51,48,45,41,37,32,28,23,19,15,10,5,1,0,0,0,1,1,2,3,3,4,5,6,6,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,10,11,12,12,12,12,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,13,13,13,12,11,11,10,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8],puertos
return
DOLOR:
ADCIN 1, canal
RESTO = (CANAL // 15)
if canal > 200 then nivel5E
if canal > 150 then nivel4E
if canal > 100 then nivel3E
if canal > 50 then nivel2E
if canal < 45 then nivel1E
return
nivel1E:
pause 5
LCDOut $fe,$CB, 1
return
nivel2E:
pause 100
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
return
nivel3E:
pause 5
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
return
nivel4E:
pause 5
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
return
nivel5E:
pause 5
LCDOut $fe,$CB, 1
LCDOut $fe,$CC, 2
LCDOut $fe,$CD, 3
LCDOut $fe,$CE, 4
LCDOut $fe,$CF, 4
return
end