FIRMWARE v1.3 (01/04/2020)
'*************************************************************************
'* Name : - PVP v1.3 - (Pandemic Ventilator Projet) *
'* Author : prof.martintorres@educ.ar - Alejandro Martin Torres *
'* : *
'* Notice : Copyright (c) 2020 - ETI (Educacion Tecnica Informal) *
'* : All Rights Reserved *
'* Date : 01/04/2020 *
'* Version : 1.3 *
'* Notes : En esta version de firmware, sumamos los aportes de la Doc.*
'* : Rocio S., que son para el control de tiempo de Inhalacion y*
'* : Exhalacion. Es importante controlar los perdiodos para man-*
'* : tener una frecuencia respiratoria estable, es por ello que *
'* : sumamos en el set config,los pasos para poder programar los*
'* : tiempos de la electrovalvula 2 (Inhalacion) y electrovalvu-*
'* : la 3 (Exhalacion). *
'* : *
'* : [---------Frec.Respiratoria----------] *
'* : [------tEv2------] [------tEv3------] *
'* : [-----ACCION Ev3 es condicional------] *
'* : *
'* :-VP normal (Volumen Pulmonar o volumen del aire respirado *
'* :durante el aliento): 500mL *
'* :-Fr normal (Frec respiratoria o tasa de respiración): Aprox.*
'* :12 respiraciones por minuto *
'* :-Inspiración: alrededor de 1.5 a 2 segundos *
'* :-La exhalación normal es de 1.5 a 2 segundos, seguida de una*
'* : pausa automática (sin respirar por 1-2 segundos). *
'* : _Frecuencias repiratorias mas comunes *
'* : ADULTO:12-20 por minuto *
'* : RECIEN NACIDO:40/60 *
'* : LACTANTE: 30/40 *
'* : HASTA 5 AÑOS: 20/30 *
'* : HASTA 11 AÑOS:18/25 *
'* : *
;=========================================================================
;==== LOGICA DE CONTROL ====
;=========================================================================
;PASO1: Cierra E.valvula 2 y Abre la E.válvula 1 de llenado ambu. Esta se
; cierra dependiendo de los sensorores magneticos superior e inferior que
; detecta el nivel del fuelle. Solo si el fuelle esta lleno, pasa al paso2
;=========================================================================
;=========================================================================
;PASO2: cierra la E.válvula 1, E.valvula 3 permanece cerrada e inicia el
; temporizador "t1" que controla apertura de la E.válvula 2 de inhalacion.
;transcurrido este tiempo, se cierra la E.valvula 2 y salta al paso3
;=========================================================================
;=========================================================================
;PASO3: con la E.válvula 2 cerrada, se inicia el temporizador "t2" que se
; encarga de controlar apertura de la E.válvula 3 de exhalacion.
;transcurrido este tiempo, se cierra la E.valvula 3 y salta al paso1
;=========================================================================
;=========================================================================
;PASO EN SEGUNDO PLANO: En todo momento se monitorea el nivel del fuelle y
;se acciona la E.valvula 1 para llenar de oxigeno el fuelle (ambu) segun el
;PASO en el que se encuentre el proceso. Como condicional, tenemos que
;nunca se podra abrir E.valvula1, si se encuentra la E.valvula2 abierta.
;=========================================================================
'* : _Se suma manómetro *
'* : _Se Necesita una fuente de aire comprimido regulado para *
'* :ejecutarlo. La presión ideal seria aproximadamente 10 psi. *
'* :Cuanto mayor sea la presión *
'* : de entrada, mayor es la posibilidad de que el fuelle se *
'* :infle demasiado rápido para que lo detecte el interruptor de*
'* : nivel superior. Si esto *
'* : sucede, puede explotar la bolsa del fuelle. *
'* : _El peso en el fuelle proporciona la presión para inflar *
'* :los pulmones del paciente. El peso del fuelle debe ser mayor*
'* :que el peso o fuerza de la exalacion. *
;*************************************************************************
;*************************************************************************
DEFINE OSC 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE CCP1_REG PORTC
DEFINE CCP1_BIT 2
Define ADC_BITS 8 ' Establece el número de bits en el resultado
Define ADC_CLOCK 3 ' Ajuste el reloj de origen (rc=3)
Define ADC_SAMPLEUS 50 ' Establezca el tiempo de muestreo en uS
;OPTION_REG=%10000010
CMCON=7
TRISA = 1
ADCON1 = 0
ADCON0 = %11000001
TRISB=%00000011
TRISC=%11111000
s_sup var PORTB.0
s_inf var PORTB.1
EV_ambu var PORTC.0
EV_exhalacion var PORTC.1
EV_inhalacion var PORTC.2
;BOTON_ON_OFF VAR PORTC.3
BOTON_MAS VAR PORTC.4
BOTON_MENOS VAR PORTC.5
BOTON_ENTER VAR PORTC.6
BOTON_MENU VAR PORTC.3
x VAR BYTE ' BYTE for MPX4250AP output
y VAR BYTE ' BYTE for depth variable
Kpa var byte ; MPX4250AP
banderaEV1 var byte
banderaEV2 var byte
banderaEV3 var byte
banderaEV1_est var byte
banderaEV2_est var byte
banderaEV3_est var byte
tiempo var byte
miliSEGUNDOS var word
SEGUNDOS var byte
SETSEGUNDOS_EV2 var byte
SETmiliSEGUNDOS_EV2 var word
SETSEGUNDOS_EV3 var byte
SETmiliSEGUNDOS_EV3 var word
;********************************************************************
;********************************************************************
ARRANQUE:
PAUSE 200
LCDOUT $FE,1
LCDOUT $FE,$80,"COVID-19 PVPv1.3"
LCDOUT $fe,$C0,"Resp. ARTIFICIAL"
LOW EV_ambu : banderaEV1=0
LOW EV_exhalacion : banderaEV3=0
low EV_inhalacion : banderaEV2=0
PAUSE 1000
LCDOUT $FE,1
INICIO:
LCDOUT $FE,$80,"INICIO pres.(E)"
LCDOUT $fe,$C0,"CONFIG pres.(M)"
IF BOTON_ENTER = 0 THEN ;iniPROGRAMADO
WHILE BOTON_ENTER =0 : WEND
LCDOUT $FE,1
GOTO PASO_1
ENDIF
IF BOTON_MENU = 0 THEN
WHILE BOTON_MENU = 0 : WEND
LCDOUT $FE,1
GOTO CONFIG_t2
ENDIF
goto INICIO
;*************************************************************************
;*************************************************************************
PASO_1:
GOSUB DISPLAY
segundos=0
miliSEGUNDOS=0
low EV_inhalacion : banderaEV2=0
IF s_inf = 0 THEN ;Si SENSOR SUPERIOR detecta el AMBU lleno, pasa al 2do PASO
high EV_ambu
banderaEV1_est=1
banderaEV1=1
endif
IF s_sup = 0 THEN ;Si SENSOR SUPERIOR detecta el AMBU lleno, pasa al 2do PASO
low EV_ambu
banderaEV1_est=0
banderaEV1=0
GOSUB DISPLAY
goto PASO_2
endif
IF BOTON_MENU = 0 THEN
WHILE BOTON_MENU = 0 : WEND
LOW EV_ambu : banderaEV1=0
LOW EV_exhalacion : banderaEV3=0
low EV_inhalacion : banderaEV2=0
segundos=0
miliSEGUNDOS=0
goto ARRANQUE
endif
goto PASO_1
;*************************************************************************
;*************************************************************************
PASO_2: ; Control eVALVULA_2 de INHALACION
LOW EV_ambu : banderaEV1=0 : banderaEV1_est=0
LOW EV_exhalacion : banderaEV3=0 : banderaEV3_est=0
high EV_inhalacion : banderaEV2=1 : banderaEV2_est=1
IF BOTON_MENU = 0 THEN
WHILE BOTON_MENU = 0 : WEND
LOW EV_ambu : banderaEV1=0
LOW EV_exhalacion : banderaEV3=0
low EV_inhalacion : banderaEV2=0
segundos=0
miliSEGUNDOS=0
goto ARRANQUE
endif
GOSUB CRONOMETRO
GOSUB DISPLAY
IF SETSEGUNDOS_EV2 = SEGUNDOS AND SETMILISEGUNDOS_EV2 = MILISEGUNDOS thEN
LOW EV_inhalacion
banderaEV2_est=0
banderaEV2 = 0
SEGUNDOS = 0 : MILISEGUNDOS = 0
GOTO PASO_3 ; ir a Control eVALVULA_3 de EXHALACION
ENDIF
GOTO PASO_2
;*************************************************************************
;*************************************************************************
PASO_3: ;Control eVALVULA_3 de EXHALACION
high EV_exhalacion
banderaEV3_est=1
IF s_inf = 0 THEN ;Si SENSOR SUPERIOR detecta el AMBU lleno, pasa al 2do PASO
high EV_ambu
banderaEV1_est=1
banderaEV1=1
endif
IF s_sup = 0 THEN ;Si SENSOR SUPERIOR detecta el AMBU lleno, pasa al 2do PASO
low EV_ambu
banderaEV1_est=0
banderaEV1=0
endif
IF BOTON_MENU = 0 THEN
WHILE BOTON_MENU = 0 : WEND
LOW EV_ambu : banderaEV1=0
LOW EV_exhalacion : banderaEV3=0
low EV_inhalacion : banderaEV2=0
segundos=0
miliSEGUNDOS=0
goto ARRANQUE
endif
GOSUB CRONOMETRO
GOSUB DISPLAY
IF SETSEGUNDOS_EV3 = SEGUNDOS AND SETMILISEGUNDOS_EV3 = MILISEGUNDOS thEN
LOW EV_exhalacion
banderaEV3_est=0
banderaEV3 = 0
SEGUNDOS = 0 : milisegundos = 0
GOTO PASO_1
ENDIF
goto PASO_3
;**************************************************************************
;****************** sub programa para el displayLCD ***********************
;**************************************************************************
DISPLAY:
;rutina sensor MPX
ADCIN 0,Kpa
y = Kpa/3 - 30
LCDOUT $fe,2,"V1:",DEC banderaEV1_est," V2:",DEC banderaEV2_est," V3:",dec banderaEV3_est
LCDOUT $fe,$C0,"P:",#Kpa," T:",DEC2 SEGUNDOS,":",DEC4 miliSEGUNDOS
RETURN
;**************************************************************************
;****************** sub programa para el cronometro ***********************
;**************************************************************************
CRONOMETRO:
miliSEGUNDOS = miliSEGUNDOS + 10
iF miliSEGUNDOS = 1000 THEN
miliSEGUNDOS = 0
SEGUNDOS = SEGUNDOS + 1
IF SEGUNDOS = 60 THEN ; consigna: si variable segundos es = a 60, entonces
SEGUNDOS = 0
endif
endif
pause 10
return
CONFIG_t2:
LCDOUT $fe,2,"Prog t2 (ENTER)"
LCDOUT $fe,$C0,"Ev2: ",DEC2 SETSEGUNDOS_EV2,":",DEC4 SETmiliSEGUNDOS_EV2
IF BOTON_MAS = 0 THEN
WHILE BOTON_MAS = 0 : WEND
SETmiliSEGUNDOS_EV2 = SETmiliSEGUNDOS_EV2 + 100 ; incrementar 1 en variable segundo
IF SETmiliSEGUNDOS_EV2 = 1000 THEN ; consigna: si variable segundos es = a 60, entonces
SETmiliSEGUNDOS_EV2 = 0
SETSEGUNDOS_EV2 = SETSEGUNDOS_EV2 + 1
IF SETSEGUNDOS_EV2 = 60 THEN
SETSEGUNDOS_EV2 = 0
ENDIF
ENDIF
endif
IF BOTON_Menos = 0 THEN
WHILE BOTON_Menos = 0 : WEND
SETmiliSEGUNDOS_EV2 = SETmiliSEGUNDOS_EV2 - 100 ; incrementar 1 en variable segundo
IF SETmiliSEGUNDOS_EV2 =0 THEN ; consigna: si variable segundos es = a 60, entonces
SETmiliSEGUNDOS_EV2 = 0
SETSEGUNDOS_EV2 = SETSEGUNDOS_EV2 - 1
IF SETSEGUNDOS_EV2 = 0 THEN
SETSEGUNDOS_EV2 = 0
ENDIF
ENDIF
endif
IF boton_ENTER = 0 THEN
WHILE boton_ENTER = 0 : WEND
LCDOUT $FE, 1
PAUSE 50
GOTO CONFIG_t3
ENDIF
GOTO CONFIG_t2
CONFIG_t3:
LCDOUT $fe,2,"Prog t3 (ENTER)"
LCDOUT $fe,$C0,"Ev3: ",DEC2 SETSEGUNDOS_EV3,":",DEC4 SETmiliSEGUNDOS_EV3
IF BOTON_MAS = 0 THEN
WHILE BOTON_MAS = 0 : WEND
SETmiliSEGUNDOS_EV3 = SETmiliSEGUNDOS_EV3 + 100 ; incrementar 100 en variable milisegundo
IF SETmiliSEGUNDOS_EV3 = 1000 THEN ; consigna: si variable segundos es = a 60, entonces
SETmiliSEGUNDOS_EV3 = 0
SETSEGUNDOS_EV3 = SETSEGUNDOS_EV3 + 1
IF SETSEGUNDOS_EV3 = 60 THEN
SETSEGUNDOS_EV3 = 0
ENDIF
ENDIF
endif
IF BOTON_Menos = 0 THEN
WHILE BOTON_Menos = 0 : WEND
SETmiliSEGUNDOS_EV3 = SETmiliSEGUNDOS_EV3 - 100
IF SETmiliSEGUNDOS_EV3 =0 THEN
SETmiliSEGUNDOS_EV3 = 0
SETSEGUNDOS_EV3 = SETSEGUNDOS_EV3 - 1
IF SETSEGUNDOS_EV3 = 0 THEN
SETSEGUNDOS_EV3 = 0
ENDIF
ENDIF
endif
IF boton_ENTER = 0 THEN
WHILE boton_ENTER = 0 : WEND
LCDOUT $FE, 1
PAUSE 50
GOTO inicio
ENDIF
GOTO CONFIG_t3
HARDWARE
Aun estamos trabajando en la confeccion del PCB y diagramas completos par poder brindarles. Mientras tanto compartimos los bosquejos de los diagramas funcionales en los laboratorios virtuales. Recuerda que puedes sumarte a este grupo para ayudar.
Version PIC-MICROCHIP