...................(1)
Para el diseo del filtro pasa altas, se busca eliminar al mximo, las posibles aportaciones
de DC por lo que de igual forma se utiliza un filtro pasivo RC.
Los clculos de los valores de los componentes se fijan de la siguiente manera:
o Se propuso una frecuencia de corte de 0.5Hz
o Se fija el valor de C
1
a 2.2 uF.
o A partir de la ecuacin 2 se calcula el valor de R
1
:
...................(2)
Finalmente se coloc una etapa con un amplificador seguidor, por lo que se fijanlos valores
de las resistencias R
3
y R
4
a 1K.
Acondicionamiento en el sensor de temperatura
El sensor LM35 entrega 10mV/C y, puesto que, la temperatura promedio corporal oscila
entre los 34C y los 40C aproximadamente, el intervalo de voltajes entregado se muestra en
la Tabla 3.2:
Tabla 3.2 Respuesta del sensor LM35
C Voltaje Salida(V)
34 0.34
34.5 0.345
35 0.35
35.5 0.355
36 0.36
36.5 0.365
37 0.37
37.5 0.375
Etapa de acondicionamiento Captulo 3: Desarrollo del instrumento
33
38 0.38
38.5 0.385
39 0.39
39.5 0.395
40 0.4
Debido a que los voltajes resultantes se encuentran en el rango de los mV, es necesario
colocar un amplificador a la salida del sensor (Figura 3.3), para obtener un nivel de voltaje
ptimo. Los clculos de los valores de los componentes, se fijaron de la siguiente manera:
o Se considera una ganancia de 10 para el diseo del amplificador no inversor, la cual
est dada por:
...................(3)
o Se propone R
1
de 10K, por lo tanto:
...................(4)
Figura 3.3 Amplificacin en el sensor de temperatura
Etapa de potencia Captulo 3: Desarrollo del instrumento
34
3.2 Etapa de potencia
Para el control de la bomba de aire y de la electrovlvula, es necesaria una etapa de
potencia (Figura 3.4), esto debido a que la corriente suministrada por el microcontrolador, no
es suficiente para alimentar a ambos dispositivos, ya que cada uno de stos requiere una
corriente de 120mA para su funcionamiento.
Es por ello que se utiliza el transistor 2n3904, el cual soporta una corriente mxima de
200mA, suficiente para suministrar los 120mA a los diferentes dispositivos, se utiliza una
resistencia de base de 5.8k, suficiente para suministrar al transistor una corriente de
saturacin.
...................(5)
...................(6)
Figura 3.4 Etapa de potencia
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
35
3.3 Programacin del
microcontrolador(Funcionamiento del programa)
El programa del microcontrolador cuenta con diferentes bloques de programacin, los cuales
se describen a continuacin.
LCD(Pantalla de cristal lquido)
Para el despliegue de caracteres en la LCD es necesaria una inicializacin previa para
configurar los parmetros con los que se trabajar, como lo son, el nmero de lneas, el
nmero de bits de datos, y el borrado inicial de la pantalla. Esta inicializacin es dada por el
fabricante del dispositivo, y su proceso se muestra en elDiagrama 3.1
Diagrama 3.1 Diagrama a bloques de la inicializacin de la LCD
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
36
Adems de la inicializacin, se cuenta con 3 funciones, las cuales nos permitirn enviar
algn comando, dato o imprimir algn carcter en la pantalla. Estas funciones reciben el
nombre de: Comando_LCD, Dato_LCD y Mensaje.
Convertidor analgico-digital
La herramienta Processor Expert incluida en el software Code Warrior, permite configurar de
una manera ms accesible los diferentes registros del convertidor analgico digital, esta
configuracin se realiza seleccionando las caractersticas deseadas, como el nmero de
canales, la velocidad de conversin y la resolucin. La configuracin utilizada se muestra en
la Figura 3.5.
Figura 3.5 Configuracin del convertidor analgico digital
De esta forma, nicamente se requiere utilizar los mtodos de recepcin de datos del ADC,
inicio de conversin y habilitacin del convertidor.
Comunicacin Serial
Para la configuracin de la comunicacin serial, se utiliz, al igual que para la configuracin
del ADC, la herramienta Processor Expert, por lo que nicamente se tuvieron que asignar los
valores deseados para la comunicacin. La configuracin se muestra en laFigura 3.6
Configuracin de la comunicacin serial
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
37
Figura 3.6 Configuracin de la comunicacin serial
Men
Para que el usuario pueda manipular el instrumento, se program un men, en el cual se
manejarn 5 opciones diferentes:
1. Chequeo (Medicin de presin arterial y temperatura corporal simultneamente)
2. Tomar temperatura
3. Tomar presin
4. Conexin a PC
5. Salir
Con estas opciones, se podr realizar un chequeo completo (medicin de temperatura y
presin) al usuario, o simplemente tomar una muestra de alguna de las dos variables de
forma individual. Adems de contar con una opcin la cual permite al instrumento establecer
una comunicacin inalmbrica para su control va PC. El men se encuentra descrito en el
Diagrama 3.2 y en el Diagrama 3.3.
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
38
Diagrama 3.2 Men principal (parte 1)
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
39
Diagrama 3.3 Men principal (parte 2)
Algoritmos de medicin
Para efectuar la medicin de la presin, se debe considerar la etapa del control del inflado y
desinflado de la bomba, ya que el brazalete debe inflarse hasta llegar a una presin de
160mmHg, y posteriormente comenzar a disminuir la presin poco a poco, para permitir al
microcontrolador registrar los valores de la presin sistlica y diastlica. Los pasos para
lograr la medicin de la presin, se enlistan a continuacin:
1. Se infla la bomba hasta medir una presin de 160mmHg en el sensor MQX5050DP.
2. Se detiene el inflado para disminuir la presin del brazalete lentamente.
3. Una vez alcanzados los 20mmHg se activa la electrovlvula, permitiendo el escape de
la presin restante en el brazalete.
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
40
En el Diagrama 3.4 y el Diagrama 3.5se muestra el algoritmo utilizado para la obtencin de las
presiones sistlica y diastlica.
Diagrama 3.4 Mximos y mnimos
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
41
Diagrama 3.5 Medicin Sistlica-Diastlica
Diseo del circuito impreso
Una vez que se realiz el diseo de los diferentes bloques del instrumento, se elabor el
circuito impreso (Figura 3.7), el cual est montado en una placa de cobre de doble cara de
8x10cm. Para el diseo del circuito se utiliz el software PCB Wizard, y se realiz de forma
manual, debido a que, aunque el software contiene un sistema automtico para la
elaboracin del circuito impreso, ste no se adecuaba a las necesidades del instrumento.
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
42
Figura 3.7 Diseo del circuito (1) Figura 3.8 Diseo del circuito (2)
Fuente de alimentacin utilizada
Para la elaboracin de la fuente de alimentacin simtrica, se utiliz un diseo de laFigura
3.9, en el cual se utilizan los reguladores LM337 y LM317, esto debido a que para la etapa
de los filtros, es necesario contar con voltajes tanto positivos como negativos.
Figura 3.9 Fuente de alimentacin
En este circuito los potencimetros R1 y R4 fueron sustituidos por resistores fijos, ya que se
busca tener una alimentacin de 5v. Los materiales utilizados para la fuente fueron los
siguientes:
o R1 2.2 k
o R2 240
o R3 240
Programacin del microcontrolador Captulo 3: Desarrollo del instrumento
43
o R4 2.2 k
o C1 2200 f
o C2 2200 f
o C3 1 f
o C4 1 f
o C5 1 f
o C6 100 f
o C7 1 f
o C8 100 f
o BR1 puente rectificador de 2A
o U1 LM317
o U2 LM337
o Transformador 24V 1
Descripcin general Captulo 4.- Diseo del software
44
Captulo 4 .-Diseo del software
Dentro este captulo se habla del diseo de la aplicacin para PC, su funcionamiento, y la
descripcin de cada uno de los algoritmos utilizados dentro de la interfaz grfica, con sus
respectivos diagramas de flujo.
Las interfaces grficas son un medio, que facilita el ingreso de informacin, as como el
despliegue en forma ms ilustrativa y exacta. Asimismo, son intuitivas y en la mayora de los
casos, no requieren de indicaciones.
4.1 Descripcin general
La interfaz grfica, permite visualizar las mediciones enviadas de manera inalmbrica, por el
instrumento. Adems, realiza un diagnstico preliminar con base a estos resultados, y los
almacena en un documento de texto. De esta manera, se forma paulatinamente un historial
de los signos vitales medidos. Asimismo, la interfaz permite el registro de varios usuarios.
La interfaz grfica est formada por los siguientes elementos principales:
Cargar datos previamente almacenados.
Registro y edicin de usuarios.
Lista de usuarios registrados.
Visualizacin de datos personales del usuario seleccionado.
Visualizacin del historial del usuario activo.
Visualizacin de la medicin ms reciente y control remoto del instrumento.
La informacin que se maneja durante el programa, es almacenada y leda de un archivo de
texto de Microsoft Office Word. Se almacena de esta forma, debido a que la informacin a
manipular no requiere de un gran espacio de memoria, por lo tanto, puede ser almacenada
sin problemas en un documento de este tipo. Adems, al ser un programa de uso habitual,
resulta ms prctico para los usuarios el acceder a sus resultados, y poder fcilmente
imprimirlos y enviarlos, entre otras acciones.
Visual Studio permite la interaccin con Microsoft Office Word, de esta forma se pueden
utilizar funciones, para crear y editar documentos utilizando esta aplicacin.
4.1 Descripcin general Captulo 4.- Diseo del software
45
Para poder interactuar con Microsoft Office Word, es necesario agregar la biblioteca
Microsoft.Office.Interop.Word la cual permite acceder a las propiedades y funciones de la
aplicacin. De esta manera, se pueden realizar tareas, como: crear un documento nuevo,
abrir uno ya existente, editar un documento, escribir y leer texto, cambiar el formato del
contenido, agregar tablas, etc.
4.2 Cargar datos previamente almacenados
Al iniciarse el programa, ste verifica si en el documento Historial.docx hay informacin
almacenada. Cuenta el nmero de tablas existentes, y carga en la lista de usuarios de la
ventana principal, los nombres de los usuarios de las tablas encontradas (Diagrama 4.1).
Diagrama 4.1Funcionamiento de la funcin Load
Registro y edicin de usuarios Captulo 4.- Diseo del software
46
4.3 Registro y edicin de usuarios
Ilustracin 4.1 Ventana inicial de la interfaz
Para el registro de nuevos usuarios, se encuentra un botn en la ventana principal
(Ilustracin 4.1), que abre un segundo formulario. Este formulario cuenta con varias cajas de
texto, en las cuales, el usuario puede ingresar sus datos personales.
Ilustracin 4.2 Ventana de Datos personales
Registro y edicin de usuarios Captulo 4.- Diseo del software
47
Al presionar el botn cancelar, la ventana simplemente se cierra y cualquier informacin que
el usuario haya ingresado es ignorada. En cambio, al presionar el botn de Aceptar, el
programa indica si alguno de los rubros se deja vaco, y el proceso no puede concretarse
hasta que todos los campos hayan sido llenados, como se muestra en la Ilustracin 4.3
Ilustracin 4.3 Ventana de datos personales despus de verificar los campos
Si se aprueba la etapa de verificacin, se llama a la funcin Nuevo(), para que agregue una
tabla al documento Historial.docx, le d el formato deseado y almacene la informacin del
nuevo usuario, como se muestra en laIlustracin 4.4. Finalmente, guarde los cambios en el
documento y cierre, tanto el documento como, la aplicacin Microsoft Office Word.
Ilustracin 4.4 Documento "Historial.docx" despus de registrar al primer usuario
Registro y edicin de usuarios Captulo 4.- Diseo del software
48
A continuacin, en el Diagrama 4.2se muestra el funcionamiento de los botones que
intervienen en el registro de nuevos usuarios.
Diagrama 4.2 Funcionamiento de las funciones de la ventana de Datos personales
Los datos pueden ser editados, al presionar el botn de Editar, el cual abre nuevamente el
formulario de Datos personales, pero esta vez, en las cajas de texto aparecen los datos que
el usuario haya proporcionado anteriormente. Con base en el nmero de usuario, edita la
tabla del documento de Word cuyo ndice corresponda al usuario, y escribe la informacin
editada en las celdas correspondientes.
Visualizacin de datos del usuario seleccionado Captulo 4.- Diseo del software
49
4.4 Lista de usuarios registrados
En la parte izquierda de la ventana principal, se muestra la lista de los usuarios. Al dar clic
sobre el nombre de alguno de ellos, las pestaas de Datos personales, Historial y Medicin,
se cargan con la informacin que se tenga almacenada, de este usuario, en el documento
Historial.docx, como se muestra en el Diagrama 4.3.
Diagrama 4.3 Funcionamiento del evento Seleccionar_usuario()
4.5 Visualizacin de datos personales del usuario
seleccionado
En la primera pestaa de la ventana principal, se visualizan los datos personales del usuario
activo, en los cuales se encuentran: Nmero de usuario, nombres, apellido materno, apellido
Visualizacin de datos del usuario seleccionado Captulo 4.- Diseo del software
50
materno, sexo, grupo sanguneo, telfono, direccin y la edad que es calculada con base a
la fecha de nacimiento, como se muestran la Ilustracin 4.5.
Ilustracin 4.5 Pestaa Datos personales despus de seleccionar a un usuario
4.6 Visualizacin del historial del usuario activo
En la pestaa de Historial, aparece en dos tablas diferentes, la informacin de todas las
mediciones realizadas, de la presin arterial y temperatura corporal, con la fecha de su
registro. Adems, a lado de cada tabla se presentan graficados estos resultados (Ilustracin
4.6). Cada una de las grficas tiene colores diferentes, los cuales corresponden al estado de
los signos vitales, y estn acompaadas de ttulos, como:Hipertensin 1, Norma alta,
Normal, Normal baja, Baja o su correspondiente en temperatura, para que sea ms sencillo
para el usuario interpretar sus resultados, y ver la comparacin entre las mediciones
anteriores y las ms recientes El historial tiene un botn de Imprimir, el cual manda a
imprimir el documento Historial.docx.
Visualizacin del historial del usuario activo Captulo 4.- Diseo del software
51
Ilustracin 4.6 Pestaa Historial
Cada grfica tiene un botn de Ampliar, el cual al ser presionado, abre una ventana en laque
se muestra cada grfica, pero con mayor tamao. En las grficas se muestran las ltimas 31
mediciones realizadas (Ilustracin 4.7).
Ilustracin 4.7 Grfica de Temperatura corporal
Visualizacin de resultados Captulo 4.- Diseo del software
52
4.7 Visualizacin de la medicin ms reciente y
control remoto del instrumento
La pestaa de medicin se encuentra dividida en dos partes, la primera corresponde a la
temperatura corporal y la segunda a la presin arterial, cada una de ellas, cuenta con tres
cajas de fecha para que el usuario indique la hora en la que desea que se realicen las
mediciones automticamente (Diagrama 4.4). Adems, cuentan con un botn de Tomar
medicin para que se le mande instantneamente al instrumento la orden de tomar una
medicin.
Diagrama 4.4 Control remoto del instrumento
La comunicacin entre el instrumento y la aplicacin slo puede ser posible despus de
habilitar el puerto en el que est conectado el mdulo bluetooth. Para habilitar el puerto, el
programa cuenta con un botn en la parte superior, el cual despliega la lista de los puertos
para habilitar uno de ellos.
Visualizacin de resultados Captulo 4.- Diseo del software
53
Asimismo, puede recibir informacin de mediciones, cuando el usuario seleccione la opcin
desde el propio instrumento.
Despus de recibir la informacin, se despliega en la caja de texto correspondiente, colorea el
crculo que se encuentra a su lado, de acuerdo al valor registrado y determina un pre
diagnstico. Finalmente, almacena la informacin obtenida en la tabla del usuario activo.
A continuacin, en laIlustracin 4.8 se muestra la pestaa Medicin en uso.
Ilustracin 4.8 Pestaa Medicin
Pruebas y resultados del individuo 1 Captulo 5.- Pruebas y resultados
54
Captulo 5 .- Pruebas y resultados
Se realizaron diez pruebas a seis individuos, tomando como referencia dos instrumentos
comerciales. Para la presin arterial, se utiliz un tensimetro marca BRAUN modelo Bp
2550, y para la temperatura corporal, se us un termmetro marca CITIZEN modelo CT461C.
Pruebas y resultados del individuo 1
El individuo 1, es un hombre de 22 aos, sin ningn padecimiento cardiovascular.
Tabla 5.1 Resultados de la presin arterial del individuo 1
Individuo 1
Prototipo(mmHg)
Baumanmetro
Error absoluto(mmHg) Error relativo(%) BRAUN(mmHg)
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 105 73 105 70 0 3 0.0 4.3
Medicin 2 102 77 109 74 7 3 6.4 4.1
Medicin 3 97 73 100 68 3 5 3.0 7.4
Medicin 4 105 73 111 73 6 0 5.4 0.0
Medicin 5 102 71 109 73 7 2 6.4 2.7
Medicin 6 105 71 109 74 4 3 3.7 4.1
Medicin 7 102 71 108 76 6 5 5.6 6.6
Medicin 8 102 73 109 76 7 3 6.4 3.9
Medicin 9 102 73 108 75 6 2 5.6 2.7
Medicin 10 102 68 108 74 6 6 5.6 8.1
Promedio 102.4 72.3 107.6 73.3 5.2 3.2 4.81 4.39
Tabla 5.2 Resultados de la temperatura corporal del individuo 1
Individuo 1
Prototipo Termmetro Error Abs. Error Rel.
(C) CITIZEN (C) (C) (%)
Temperatura
Medicin 1 36.35 36.6 0.25 0.68306011
Medicin 2 36.2 36.5 0.3 0.82191781
Medicin 3 36.4 36.6 0.2 0.54644809
Medicin 4 36.25 36.5 0.25 0.68493151
Pruebas y resultados del individuo 1 Captulo 5.- Pruebas y resultados
55
Medicin 5 36.25 36.3 0.05 0.13774105
Medicin 6 36.4 36.7 0.3 0.81743869
Medicin 7 36.1 36.4 0.3 0.82417582
Medicin 8 36.3 36.5 0.2 0.54794521
Medicin 9 36.1 36.3 0.2 0.55096419
Medicin 10 36.2 36.5 0.3 0.82191781
Promedio 36.255 36.49 0.235 0.6436
Grfica 5.1 Presin sistlica en el individuo 1
80
85
90
95
100
105
110
115
120
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 1
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 1 Captulo 5.- Pruebas y resultados
56
Grfica 5.2 Presin diastlica en el individuo 1
Grfica 5.3 Temperatura corporal en el individuo 1
60
65
70
75
80
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 1
Prototipo
Baumanmetro BRAUN
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
36.6
36.7
36.8
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 1
Prototipo
Termmetro CITIZEN
Pruebas y resultados del individuo 2 Captulo 5.- Pruebas y resultados
57
Pruebas y resultados del individuo 2
El individuo 2, es una mujer de 22 aos, con arritmia leve.
Tabla 5.3 Resultados de la presin arterial del individuo 2
Individuo 2
Prototipo(mmHg)
Baumanmetro
Error absoluto(mmHg) Error relativo(%) BRAUN(mmHg)
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 122 79 112 68 10 11 8.9 16.2
Medicin 2 118 77 109 71 9 6 8.3 8.5
Medicin 3 122 77 110 76 12 1 10.9 1.3
Medicin 4 122 77 113 71 9 6 8.0 8.5
Medicin 5 118 73 107 68 11 5 10.3 7.4
Medicin 6 118 77 106 71 12 6 11.3 8.5
Medicin 7 113 68 104 70 9 2 8.7 2.9
Medicin 8 113 73 110 71 3 2 2.7 2.8
Medicin 9 113 74 112 70 1 4 0.9 5.7
Medicin 10 113 75 107 68 6 7 5.6 10.3
Promedio 117.2 75 109 70.4 8.2 5 7.56 7.21
Tabla 5.4 Resultados de la temperatura corporal del individuo 2
Individuo 2
Prototipo Termmetro Error Abs. Error Rel.
(C) CITIZEN (C) (C) (%)
Temperatura
Medicin 1 35.9 36.3 0.4 1.10192837
Medicin 2 35.9 35.9 0 0
Medicin 3 35.8 36.2 0.4 1.10497238
Medicin 4 36.1 35.9 0.2 0.55710306
Medicin 5 35.8 36.2 0.4 1.10497238
Medicin 6 35.9 36.2 0.3 0.82872928
Medicin 7 36.1 36.2 0.1 0.27624309
Medicin 8 35.9 36.2 0.3 0.82872928
Medicin 9 36.15 36.3 0.15 0.41322314
Medicin 10 36.1 36.2 0.1 0.27624309
Promedio 35.96 36.16 0.235 0.6492
Pruebas y resultados del individuo 2 Captulo 5.- Pruebas y resultados
58
Grfica 5.4 Presin sistlica en el individuo 2
Grfica 5.5 Presin diastlica en el individuo 2
80
90
100
110
120
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 2
Prototipo
Baumanmetro BRAUN
60
65
70
75
80
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 2
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 2 Captulo 5.- Pruebas y resultados
59
Grfica 5.6 Temperatura corporal en el individuo 2
Pruebas y resultados del individuo 3
El individuo 3, es un hombre de 17 aos, sin ningn padecimiento cardiovascular.
Tabla 5.5 Resultados de la presin arterial del individuo 3
Individuo 3
Prototipo(mmHg)
Baumanmetro
Error absoluto(mmHg) Error relativo(%) BRAUN(mmHg)
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 118 81 124 75 6 6 4.8 8.0
Medicin 2 118 77 121 80 3 3 2.5 3.8
Medicin 3 110 76 119 75 9 1 7.6 1.3
Medicin 4 113 77 119 74 6 3 5.0 4.1
Medicin 5 118 77 121 74 3 3 2.5 4.1
Medicin 6 118 73 121 76 3 3 2.5 3.9
Medicin 7 113 68 119 75 6 7 5.0 9.3
Medicin 8 118 74 124 80 6 6 4.8 7.5
Medicin 9 118 74 113 75 5 1 4.4 1.3
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
36.6
36.7
36.8
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 2
Prototipo
Termmetro CITIZEN
Pruebas y resultados del individuo 3 Captulo 5.- Pruebas y resultados
60
Medicin 10 113 73 115 77 2 4 1.7 5.2
Promedio 115.7 75 119.6 76.1 4.9 3.7 4.08 4.85
Tabla 5.6 Resultados de la temperatura corporal del individuo 3
Individuo 3
Prototipo Termmetro Error Abs. Error Rel.
(C) CITIZEN (C) (C) (%)
Temperatura
Medicin 1 36.1 36.35 0.25
0.69
Medicin 2 35.9 36.1 0.2
0.55
Medicin 3 35.95 36.2 0.25
0.69
Medicin 4 36.2 36.3 0.1
0.28
Medicin 5 36.1 35.9 0.2
0.56
Medicin 6 36.15 36.1 0.05
0.14
Medicin 7 35.9 35.9 0
0.00
Medicin 8 35.9 36.2 0.3
0.83
Medicin 9 36.1 36.2 0.1
0.28
Medicin 10 36.1 36.25 0.15
0.41
Promedio 36.04 36.15 0.16
0.443
Pruebas y resultados del individuo 3 Captulo 5.- Pruebas y resultados
61
Grfica 5.7 Presin sistlica en individuo 3
Grfica 5.8 Presin diastlica en individuo 3
80
85
90
95
100
105
110
115
120
125
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 3
Prototipo
Baumanmetro BRAUN
60
65
70
75
80
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 3
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 3 Captulo 5.- Pruebas y resultados
62
Grfica 5.9 Temperatura en individuo 3
Pruebas y resultados del individuo 4
El individuo 4, es un hombre de 25 aos, sin ningn padecimiento cardiovascular
Tabla 5.7 Resultados de la presin arterial del individuo 4
Individuo 4
Prototipo Baumanmetro Error absoluto Error relativo
(mmHg) BRAUN (mmHg) (mmHg) %
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 128 85 126 81 2 4 0.02 0.05
Medicin 2 124 85 122 83 2 2 0.02 0.02
Medicin 3 126 84 124 81 2 3 0.02 0.04
Medicin 4 124 83 124 79 0 4 0 0.05
Medicin 5 124 86 125 84 1 2 0.01 0.02
Medicin 6 125 85 126 83 1 2 0.01 0.02
Medicin 7 126 85 125 78 1 7 0.01 0.09
Medicin 8 127 84 125 83 2 1 0.02 0.01
Medicin 9 128 86 125 81 3 5 0.02 0.06
Medicin 10 127 84 124 82 3 2 0.02 0.02
Promedio 125.90 84.70 124.60 81.50 1.70 3.20 0.02 0.04
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
36.6
36.7
36.8
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 3
Prototipo
Termmetro CITIZEN
Pruebas y resultados del individuo 4 Captulo 5.- Pruebas y resultados
63
Tabla 5.8 Resultados de la temperatura corporal del individuo 4
Individuo 4
Prototipo Termmetro Error abs.
Error
rel.
(C) CITIZEN (C) (C) %
Temperatura
Medicin 1 36.1 36.2 0.10 0.28
Medicin 2 35.95 36.1 0.15 0.42
Medicin 3 36.12 36.3 0.18 0.50
Medicin 4 36.1 36.3 0.20 0.55
Medicin 5 35.9 36.35 0.45 1.24
Medicin 6 36.3 36.2 0.10 0.28
Medicin 7 36.1 36.4 0.30 0.82
Medicin 8 36.25 36.35 0.10 0.28
Medicin 9 36.2 36.1 0.10 0.28
Medicin 10 36.2 36.2 0.00 0.00
Promedio 36.12 36.25 0.17 0.46
Grfica 5.10 Presin sistlica en el individuo 4
100
105
110
115
120
125
130
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 4
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 4 Captulo 5.- Pruebas y resultados
64
Grfica 5.11 Presin diastlica en el individuo 4
Grfica 5.12 Temperatura corporal en el individuo 4
70
75
80
85
90
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 4
Prototipo
Baumanmetro BRAUN
35.6
35.7
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 4
Prototipo
Termmetro CITIZEN
Pruebas y resultados del individuo 5 Captulo 5.- Pruebas y resultados
65
Pruebas y resultados del individuo 5
El individuo 5, es un hombre de 61 aos, sin ningn padecimiento cardiovascular.
Tabla 5.9 Resultados de la presin arterial del individuo 5
Individuo 5
Prototipo Baumanmetro Error absoluto Error relativo
(mmHg) BRAUN (mmHg) (mmHg) %
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 127 84 125 86 2 2 1.6 2.3
Medicin 2 126 85 129 88 3 3 2.3 3.4
Medicin 3 127 83 128 88 1 5 0.8 5.7
Medicin 4 127 85 129 87 2 2 1.6 2.3
Medicin 5 128 84 127 87 1 3 0.8 3.4
Medicin 6 129 85 126 86 3 1 2.4 1.2
Medicin 7 130 85 128 85 2 0 1.6 0.0
Medicin 8 127 84 128 86 1 2 0.8 2.3
Medicin 9 125 86 129 87 4 1 3.1 1.1
Medicin 10 126 86 124 86 2 0 1.6 0.0
Promedio 127.20 84.70 127.30 86.60 2.10 1.90 1.66 2.17
Tabla 5.10 Resultados de la temperatura corporal del individuo 5
Individuo 5
Prototipo Termmetro Error abs. Error rel.
(C) CITIZEN (C) (C) %
Temperatura
Medicin 1 36.1 36.6 0.5 1.366
Medicin 2 36.1 36.4 0.3 0.824
Medicin 3 36.25 36.5 0.25 0.685
Medicin 4 36.2 36.3 0.1 0.275
Medicin 5 35.9 36.3 0.4 1.102
Medicin 6 36.3 36.7 0.4 1.090
Medicin 7 36.1 36.4 0.3 0.824
Medicin 8 36.25 36.5 0.25 0.685
Medicin 9 36.2 36.3 0.1 0.275
Medicin 10 36.2 36.5 0.3 0.822
Promedio 36.16 36.45 0.29 0.79
Pruebas y resultados del individuo 5 Captulo 5.- Pruebas y resultados
66
Grfica 5.13 Presin sistlica en el individuo 5
Grfica 5.14 Presin diastlica en el individuo 5
100
105
110
115
120
125
130
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 5
Prototipo
Baumanmetro BRAUN
70
75
80
85
90
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 5
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 5 Captulo 5.- Pruebas y resultados
67
Grfica 5.15 Temperatura corporal en el individuo 5
Pruebas y resultados del individuo 6
El individuo 6, es una mujer de 19 aos, sin ningn padecimiento cardiovascular
Tabla 5.11 Resultados de la presin arterial del individuo 6
Individuo 6
Prototipo(mmHg)
Baumanmetro
Error absoluto(mmHg) Error relativo(%) BRAUN(mmHg)
Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica Sistlica Diastlica
Medicin 1 96 68 101 70 5 2 5.0 2.9
Medicin 2 93 71 99 70 6 1 6.1 1.4
Medicin 3 95 69 99 71 4 2 4.0 2.8
Medicin 4 93 68 98 70 5 2 5.1 2.9
Medicin 5 93 69 97 69 4 0 4.1 0.0
Medicin 6 94 72 97 70 3 2 3.1 2.9
Medicin 7 94 71 98 69 4 2 4.1 2.9
Medicin 8 93 69 96 70 3 1 3.1 1.4
Medicin 9 95 68 99 68 4 0 4.0 0.0
Medicin 10 89 73 98 69 9 4 9.2 5.8
Promedio 93.50 69.80 98.20 69.60 4.70 1.60 4.78 2.30
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
36.6
36.7
36.8
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 5
Prototipo
Termmetro CITIZEN
Pruebas y resultados del individuo 6 Captulo 5.- Pruebas y resultados
68
Tabla 5.12 Resultados de la temperatura corporal del individuo 6
Individuo 6
Prototipo Termmetro Error Abs. Error Rel.
(C) CITIZEN (C) (C) (%)
Temperatura
Medicin 1 36.35 36.1 0.25 0.69
Medicin 2 36.1 35.9 0.2 0.56
Medicin 3 36.2 36.1 0.1 0.28
Medicin 4 36.1 36.1 0 0.00
Medicin 5 36.2 36.15 0.05 0.14
Medicin 6 36.3 36.2 0.1 0.28
Medicin 7 35.9 36.1 0.2 0.55
Medicin 8 36.2 36.1 0.1 0.28
Medicin 9 36.2 36.15 0.05 0.14
Medicin 10 36.25 36.2 0.05 0.14
Promedio 36.18 36.11 0.11 0.31
Grfica 5.16 Presin sistlica en el individuo 6
80
85
90
95
100
105
110
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin sistlica en individuo 6
Prototipo
Baumanmetro BRAUN
Pruebas y resultados del individuo 6 Captulo 5.- Pruebas y resultados
69
Grfica 5.17 Presin diastlica en el individuo 6
Grfica 5.18 Temperatura corporal en el individuo 6
60
65
70
75
80
1 2 3 4 5 6 7 8 9 10
m
m
H
g
Presin diastlica en individuo 6
Prototipo
Baumanmetro BRAUN
35.8
35.9
36
36.1
36.2
36.3
36.4
36.5
36.6
36.7
36.8
1 2 3 4 5 6 7 8 9 10
C
Temperatura en individuo 6
Prototipo
Termmetro CITIZEN
Observaciones Captulo 5.- Pruebas y resultados
70
Observaciones
Al analizar los resultados de la temperatura corporal, se observa que en promedio, los valores
obtenidos por el prototipo, se encuentran 0.2C por debajo de los valores del termmetro
comercial. Sin embargo, en la mayora de los casos, los resultados son ms consistentes en
el prototipo.
Para el caso de la presin arterial, el prototipo presenta algunas inconsistencias en personas
con presin sistlica superior a 120 mm Hg. Mientras que, para la presin diastlica, el
prototipo muestra variaciones en la medicin de personas con presiones menores a 68 mm
Hg.
Tabla 5.13 Promedio total de errores de presin arterial
Error absoluto Error relativo
(mmHg) %
Sistlica Diastlica Sistlica Diastlica
Promedio1 5.2 3.2 4.81 4.39
Promedio2 8.2 5 7.56 7.21
Promedio3 4.9 3.7 4.08 4.85
Promedio4 1.7 3.2 0.02 0.04
Promedio5 2.1 1.9 1.66 2.17
Promedio6 4.7 1.6 4.78 2.3
PromedioTotal 4.47 3.10 3.82 3.49
Tabla 5.14 Promedio total de errores de temperatura corporal
Error abs. Error rel.
(C) %
Temperatura
Promedio1 0.235 0.6436
Promedio2 0.235 0.6492
Promedio3 0.16 0.443
Promedio4 0.17 0.46
Promedio5 0.29 0.79
Promedio6 0.11 0.31
PromedioTotal 0.20 0.55
Captulo 6: Conclusiones
71
Captulo 6 Conclusiones
El prototipo construido para medir la presin arterial y temperatura corporal demostr con
base a las pruebas realizadas, ser un instrumento funcional debido a que los resultados
difieren muy poco de los instrumentos de referencia con los cuales se compar. Un factor a
considerar en la diferencia de resultados obtenidos, es que, cuando se mide la presin arterial
de forma oscilomtrica, los resultados pueden variar debido a las condiciones en las que se
efecte la medicin. Es por ello que se recomienda que al momento de tomar la presin de un
paciente, ste se encuentre sentado y sin ejercer alguna fuerza en el brazo izquierdo.
Los datos registrados de temperatura corporal muestran una ligera variacin de los resultados
obtenidos en el termmetro digital utilizado como referencia, esta variacin no es muy
significativa al momento de hacer un diagnstico, debido a que este tipo de variaciones no
representan un factor significativo.
Por otra parte, la comunicacin entre el instrumento y la PC, demostr ser eficiente, debido a
la practicidad en el muestreo o seguimiento del usuario. Los datos recibidos se despliegan de
una forma accesible y fcil de interpretar, para ello, la aplicacin se auxilia de grficos con los
diferentes niveles tanto de presin como de temperatura.
El tipo de visualizacin y diagnstico previo utilizado en este instrumento, puede ser llevado a
otros instrumentos mdicos, o, inclusive, es posible adicionar otras variables a medir para
lograr un diagnstico ms preciso, tales como el nivel de azcar en la sangre, el ritmo
cardiaco, etc. De esta forma se podra lograr un monitoreo completo del usuario ya sea para
uso particular o en hospitales.
Glosario
72
Glosario
Arritmia cardaca: Es la variacin del ritmo regular de los latidos cardacos.
Arteriola: Una arteriola es un vaso sanguneo de pequea dimensin, que resulta de
ramificaciones de las arterias.
Baumanmetro: Es un instrumento mdico empleado para la medicin indirecta de la presin
arterial
Diastlica: La presin diastlica es la presin mnima de la sangre, que se registra cuando el
corazn se relaja despus de la contraccin, y devuelve la sangre a sus cavidades.
Esfigmomanmetro:Es un instrumento que proporciona una medida indirecta de la presin
arterial.Se compone de un sistema de brazalete hinchable, ms un manmetro,
tradicionalmente una columna de mercurio, en la cual se refleja la presin. La palabra
proviene etimolgicamente del griegosphygms que significa pulso y de las palabras,
ligero y , medida.
Estetoscopio: Es un aparato acstico usado en medicina, fisioterapia, enfermera,
kinesiologa, fonoaudiologa y veterinaria, para la auscultacin o para or los sonidos internos
del cuerpo humano o animal. Generalmente se usa en la auscultacin de los ruidos cardacos
o los ruidos respiratorios, aunque algunas veces tambin se usa para objetivar ruidos
intestinales o soplos por flujos anmalos sanguneos en arterias y venas.
Manmetro: Es un instrumento de medicin que sirve para medir la presin de fluidos
contenidos en recipientes cerrados.
Sistlica: La presin sistlica es la presin sangunea mxima. Representa la presin que
sufren las arterias, cuando el corazn se contrae y bombea sangre por ellas.
Referencias
73
Referencias
[1] La medicina desde la antigedad hasta los tiempos modernos
http://lamedicinacmc.blogspot.mx/2012/06/medicina-prehistorica.html
[2] a)Laennec auscultando un paciente con el estetoscopio de su invencin
http://www.cucaiba.gba.gov.ar/historia.htm b) Primer estetoscopio
http://enroquedeciencia.blogspot.mx/2012/10/a-proposito-del-fonendo-2.html
[3] Baumanometro con conexin a PC http://www.librerialeo.com.mx/baumanometro-digital-automatico-
con-conexion-pc-p-774.html?currency=EUR
[4] Clasificacin de la presin arterial (OMS) http://scielo.isciii.es/scielo.php?pid=S1695-
61412009000100012&script=sci_arttext
[5] Mtodo auscultorio http://default.qa.adam.com/content.aspx?productId=39&pid=5&gid=003398&print=1
[6] Baumanmetro digital http://www.pacienteplus.com/tienda/product_info.php?products_id=1679
[7]Canalizacin vascular http://www.sepeap.org/archivos/revisiones/urgencias/venas.htm
[8] a) Esfigmomanmetro de mercurio http://www.leches-dietas-yotros.es/esfigmomanometro-mercurio-
mide-tension-arterial/3-210-160-210.htm, b) Baumanmetro analgico
http://micasamexico.orgshowthread.php/?sid=30668, c) Baumanmetro digital
http://distritofederal.quebarato.com.mx/gustavo-a-madero/baumanometro-digital__434718.html.
[9] Tensimetro de dedo http://www.hospitecnia.com/Compra-Venta-Pulsioximetros/Valencia/Pulsioximetro-
dedo/id-Lbhcbiafedaicbc.xsql
[10] Tabla de temperaturas http://www.une.edu.ve/salud/notas/clases/ClaseIntroductoriaSalud/sld013.htm
[11] a) Termmetro de mercuriohttp://www.bebesymas.com/noticias/la-muerte-anunciada-del-termometro-
de-mercurio, b)Termmetro digital http://gustavoamadero.olx.com.mx/termometro-digital-rigido-iid-
123746100
[12] Medicin oral http://html.rincondelvago.com/fiebre_2.html
[13] Medicin rectal , Medicin axilar http://www.infermeravirtual.com/es-es/problemas-de-salud/signos-
sintomas/fiebre/informacion-relacionada.html
[14] Medicin por el odo http://www.drugs.com/cg_esp/c%C3%B3mo-tomar-la-temperatura-en-el-
o%C3%ADdo.html
[15] Termmetro cutneo http://inventos.teoriza.net/thermofocus-para-medir-la-temperatura-termometro-
infrarojos-para-ninos-no-invasivo
Referencias
74
[16] Integrated Silicon Pressure Sensro On-Chip Signal Conditioned, Temperature Compesated and
Calibratedhttp://www.datasheetcatalog.org/datasheet/motorola/MPX5050GVS.pdf
[17] LM35 LM35 Precision Centigrade Temperature Sensorshttp://www.ti.com/lit/ds/symlink/ lm35.pdf
[18] LCD http://mikropic.delphiaccess.com/forum/index.php%3Ftopic%3D18.0&docid=
QU5e32lBo33UrM&imgurl
[19]Matriz LCD http://server-die.alc.upv.es/asignaturas/lsed/2002-03/Pantallas_LCD/2lcd.htm
[20] MC9S08SH8 Family Data Sheethttp://www.freescale.com/files/microcontrollers/doc/
data_sheet/MC9S08SH8.pdf
Bibliografa
75
Bibliografa
- Microsoft 2012 . C# Programming Guide.
Enlace:http://msdn.microsoft.com
- MC9S08SH8 Family Data Sheet
Enlace: http://www.freescale.com/files/microcontrollers/doc/ data_sheet/MC9S08SH8.pdf
- LM35 Precision Centigrade Temperature Sensors
Enlace: http://www.ti.com/lit/ds/symlink/ lm35.pdf
- Integrated Silicon Pressure Sensro On-Chip Signal Conditioned, Temperature Compesated and
Calibrated
Enlace: http://www.datasheetcatalog.org/datasheet/motorola/MPX5050GVS.pdf
- MedLine Plus Enciclopedia mdica
Enlace: http://www.nlm.nih.gov/medlineplus/spanish/ ency/article/002341.html
- Del Examen Fsico General PRESIN ARTERIAL
Enlace: http://escuela.med.puc.cl/Publ/ ManualSemiologia /210PresionArterial.htm
- Organizacin Mundial de la Salud
Enlace: http://www.who.int/es/
- MEDICAL RENTAL Como Usar el Baumanmetro para Medir la Presin Arterial
Enlace: http://medicalrental.com.mx/blog/como-usar-el-baumanometro-para-medir-la-presion-arterial-
2/
- Diccionario mdico
Enlace: www.esacademic.com/dic.nsf/es_mediclopedia/52192/temperatura
- Signos vitales
Enlace: http://med.unne.edu.ar/catedras/medicinai/semioclas/sig_vit.pdf
Autores: Dr. Jorge Alberto Costa y Dra. Silvia Rodrguez Cuimbra
- Historia del tensimetro y la tensin arterial
Enlace:http://www.tensiometrovirtual.com/upload/81-001_a.pdf
- Historia de la hipertensin
Enlace: http://files.sld.cu/hta/files/2010/07/historia-de-la-hipertension-arterial.pdfAutor: David Garca
Barreto
- La medicina interna, su historia y sus textos
Enlace: http://www.nietoeditores.com.mx/download/med%20interna/noviembre-
diciembre2009/MI%206-12%20MEDICINA.pdf
Autor: Guillermo Murillo-Godnez
Bibliografa
76
- Pantalla de cristal lquido
Enlace: http://es.wikipedia.org/wiki/Pantalla_de_cristal_l%C3%ADquido
- Bluetooth
Enlace: http://es.wikipedia.org/wiki/Bluetooth
- Amplificadores Operacionales Y Circuitos Integrados Lineales
Escrito por Robert Francis Coughlin,Frederick F. Driscoll
Pag. 311-313
- Sensores y acondicionadores de seal: prcticas
Escrito por Ramn Palls Areny
Pag. 3-7,Terminologa
Anexo A
77
Anexo A
Cdigo del microcontrolador
Bibliotecas utilizadas
#include "Cpu.h"
#include "Events.h"
#include "Bits1.h"
#include "Bits2.h"
#include "TI1.h"
#include "AD1.h"
#include "KB1.h"
#include "EInt1.h"
#include "Bit1.h"
#include "Bit2.h"
#include "AS1.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#define DDRAM_L1 0x80
#define DDRAM_L2 0xC0
Funcines
void BCD_ASCIIP2(void);
void BCD_ASCIIP1(void);
void BCD_ASCIIT(void);
void medirpt(void);
void medirp(void);
void medirt(void);
void midiendo(void);
void Comando_LCD2(char);
void espera(void);
void esperapt(void);
Anexo A
78
Declaracin de variables
int w=15;
char s='S',d='D',t='T';
byte c,d;
word presion=0,pulso=0,dato=0,x=15;
word sistolica=0,diastolica=0;
intz=0,menu=0,seleccion=1,tiempo=0,
program=15,medicion=0,mediciont=0,ban=0,primeravez=0,comu=0;
char inicio=0,ok=0,presion1=0,presion2=0,temperatura=0, orden=0;
Mensajes de la LCD
char TITULO[] = " PRESION & TEMP.",
NOMBRES[] = "CAMACHO&DIOSDADO",
PRESION1[]= "S:000 D:000 MMHG",
PRESION2[]= "DIAS:000000 MMHG",
TEMPERA[]= "000000 C ",
VACIO[]= " ",
TIEMPO[] = "PROGRAMACION: ",
TIEMPO2[] = " 000 MIN",
MEDIR1[] = "1 CHEQUEO ",
MEDIR2[] = "2 TEMPERATURA ",
MEDIR3[] = "3 TOMAR PRESION ",
SALIR[] = "5 SALIR ",
MENU[] = " MENU: ",
PROGRAMAR[] = "4 CONECTAR A PC ",
MIDIENDO2[] = " MIDIENDO ",
ACTIV[] = " ACTIVADA ",
DESACTIV[] = " DESACTIVADA";
Programa principal
void main(void)
{
char *Puntero;
PE_low_level_init();
c=TI1_Disable();
Inicializa_LCD();
while(1)
{
if(inicio==0)
{
Puntero = &TITULO[0]; // Puntero a mensaje1 "IPN"
Anexo A
79
Comando_LCD2(DDRAM_L1); // Cursor en linea No. 1
Mensaje(Puntero); // Mensaje No. 1, IPN
Puntero = &NOMBRES[0]; // Puntero a mensaje2 "Escuela"
Comando_LCD2(DDRAM_L2); // Cursor en linea No. 2
Mensaje(Puntero);
}
while(menu==1)
{
inicio=1;
if(seleccion==1 && ok==0)
{
Puntero = &MENU[0]; // Puntero a mensaje1 "IPN"
Comando_LCD2(DDRAM_L1); // Cursor en linea No. 1
Mensaje(Puntero); // Mensaje No. 1, IPN
Puntero = &MEDIR1[0]; // Puntero a mensaje2 "Escuela"
Comando_LCD2(DDRAM_L2); // Cursor en linea No. 2
Mensaje(Puntero);
}
if(seleccion==2 && ok==0)
{
Puntero = &MENU[0]; // Puntero a mensaje1 "IPN"
Comando_LCD2(0x80); // Cursor en linea No. 1
Mensaje(Puntero); // Mensaje No. 1, IPN
Puntero = &MEDIR2[0]; // Puntero a mensaje2 "Escuela"
Comando_LCD2(0xC0); // Cursor en linea No. 2
Mensaje(Puntero);
}
if(seleccion==3 && ok==0)
{
Puntero = &MENU[0]; // Puntero a mensaje1 "IPN"
Comando_LCD2(0x80); // Cursor en linea No. 1
Mensaje(Puntero); // Mensaje No. 1, IPN
Puntero = &MEDIR3[0]; // Puntero a mensaje2 "Escuela"
Comando_LCD2(0xC0); // Cursor en linea No. 2
Mensaje(Puntero);
}
if(seleccion==4 && ok==0)
{
Puntero = &MENU[0]; // Puntero a mensaje1 "IPN"
Comando_LCD2(0x80); // Cursor en linea No. 1
Mensaje(Puntero); // Mensaje No. 1, IPN
Puntero = &PROGRAMAR[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
if(seleccion==5 && ok==0)
{
Puntero = &MENU[0];
Comando_LCD2(0x80);
Anexo A
80
Mensaje(Puntero);
Puntero = &SALIR[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
if(seleccion==1 && ok==1)
{
sistolica=0;diastolica=0;dato=0;
esperapt();
medirpt();
if (comu==0)
{
while(ok!=2){
medicion=0;
EInt1_Disable();
//midiendo();
//while(!medicion);
BCD_ASCIIP1();
Puntero = &PRESION1[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
Puntero = &TEMPERA[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}}
if(comu==1)
{
while(!medicion);
medicion=0;
EInt1_Disable();
//midiendo();
//while(!medicion);
BCD_ASCIIP1();
Puntero = &PRESION1[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
Puntero = &TEMPERA[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
AS1_SendChar(PRESION1[2]);AS1_SendChar(PRESION1[3]);AS1_SendChar(PRESION1[4]);
AS1_SendChar(83);//S
AS1_SendChar(PRESION1[8]);AS1_SendChar(PRESION1[9]);AS1_SendChar(PRESION1[10]);
AS1_SendChar(68);//D
AS1_SendChar(TEMPERA[3]);AS1_SendChar(TEMPERA[4]);AS1_SendChar(46);//.
AS1_SendChar(TEMPERA[6]);AS1_SendChar(TEMPERA[7]);AS1_SendChar(84);//T
Anexo A
81
}
EInt1_Enable();
medicion=0;
inicio=0;
menu=0;
tiempo=0;
seleccion=1;
ok=0;
}
if(seleccion==2 && ok==1)
{
EInt1_Disable();
medicion=1;
medirt();
midiendo();
espera();
AD1_Disable();
TEMPERA[0]=' ';TEMPERA[1]=' ';TEMPERA[2]='T';TEMPERA[3]='E';
TEMPERA[4]='M';TEMPERA[5]='P';TEMPERA[6]='E';TEMPERA[7]='R';
TEMPERA[8]='A';TEMPERA[9]='T';TEMPERA[10]='U';TEMPERA[11]='R';
TEMPERA[12]='A';TEMPERA[13]=':';TEMPERA[14]=' ';TEMPERA[15]=' ';
Puntero = &TEMPERA[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
BCD_ASCIIT();
Puntero = &TEMPERA[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
if(comu==1)
{ int c=0;
for(c=0;c==4;c++)
{
AS1_SendChar(TEMPERA[5]);AS1_SendChar(TEMPERA[6]);AS1_SendChar(46);//.
AS1_SendChar(TEMPERA[8]);AS1_SendChar(TEMPERA[9]);AS1_SendChar(84);//T
}
}
if(comu==0)
while(ok!=2);
medicion=0;
inicio=0;
menu=0;
tiempo=0;
seleccion=1;
ok=0;
EInt1_Enable();
}
Anexo A
82
if(seleccion==3 && ok==1)
{
sistolica=0;diastolica=0;dato=0;
medirpt();
if(comu==0)
while(ok!=2){
medicion=0;
EInt1_Disable();
//midiendo();
//while(!medicion);
BCD_ASCIIP2();
Puntero = &PRESION1[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
Puntero = &PRESION2[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
if(comu==1)
{ int c=0;
medicion=0;
EInt1_Disable();
for(c=0; c<=5;c++)
{
AS1_SendChar(PRESION1[6]);AS1_SendChar(PRESION1[7]);AS1_SendChar(PRESION1[8]);
AS1_SendChar('S');
AS1_SendChar(PRESION1[7]);AS1_SendChar(PRESION1[8]);AS1_SendChar(PRESION1[9]);
AS1_SendChar('D');
}
}
EInt1_Enable();
medicion=0;
inicio=0;
menu=0;
tiempo=0;
seleccion=1;
ok=0;
}
if(seleccion==4 && ok==1)
{
if (comu==0)
{
AS1_Enable(); comu=1;
Puntero = &ACTIV[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
Puntero = &VACIO[0];
Anexo A
83
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
else if (comu==1)
{
AS1_Disable(); comu=0;
Puntero = &DESACTIV[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
Puntero = &VACIO[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
while(ok!=2);
EInt1_Enable();
medicion=0;
inicio=0;
menu=0;
tiempo=0;
seleccion=1;
ok=0;
}
if(seleccion==5 && ok==1)
{
medicion=0;
inicio=0;
menu=0;
tiempo=0;
seleccion=1;
ok=0;
}
}
}
}
Funcin de espera para las mediciones
void espera(void)
{
long time,t,s;char *Puntero;
int b=0;
int time2;
for(b=0;b<=15;b++){VACIO[b]=' ';}
for(s=0;s<=15;s++){
VACIO[s]=219;
Puntero = &VACIO[0];
Anexo A
84
Comando_LCD2(0xC0);
Mensaje(Puntero);
for(t=0;t<=11;t++)
{
for(time=0;time<=6000; time++)
{
time2=1;
}
}}
for(b=0;b<=15;b++){VACIO[b]=' ';}
Puntero = &VACIO[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
}
Funcin de espera para el desplegado en LCD
void esperapt(void)
{
long time,t,s;char *Puntero;
int b=0;
int time2;
MIDIENDO2[0] =' ';MIDIENDO2[1] =' ';MIDIENDO2[2] =' ';
MIDIENDO2[3] ='P';MIDIENDO2[4] ='R';MIDIENDO2[5] ='E';MIDIENDO2[6] ='P';
MIDIENDO2[7] ='A';MIDIENDO2[8] ='R';MIDIENDO2[9] ='A';MIDIENDO2[10] ='N';
MIDIENDO2[11] ='D';MIDIENDO2[12] ='O';MIDIENDO2[13] =' ';MIDIENDO2[14] =' ';
Puntero = &MIDIENDO2[0];
Comando_LCD2(0x80);
Mensaje(Puntero);
for(b=0;b<=15;b++){VACIO[b]=' ';}
for(s=0;s<=8;s++){
VACIO[s]=219;
Puntero = &VACIO[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
for(t=0;t<=10;t++)
{
for(time=0;time<=6000; time++)
{
time2=1;
}
}}
for(b=0;b<=15;b++){VACIO[b]=' ';}
Puntero = &VACIO[0];
Comando_LCD2(0xC0);
Mensaje(Puntero);
MIDIENDO2[0] =' ';MIDIENDO2[1] =' ';MIDIENDO2[2] =' ';MIDIENDO2[3] =' ';
MIDIENDO2[4] ='M';MIDIENDO2[5] ='I';MIDIENDO2[6] ='D';MIDIENDO2[7] ='I';
Anexo A
85
MIDIENDO2[8] ='E';MIDIENDO2[9] ='N';MIDIENDO2[10] ='D';MIDIENDO2[11]
='0';
MIDIENDO2[12] =' ';MIDIENDO2[13] =' ';MIDIENDO2[14] =' ';MIDIENDO2[15]
=' ';
}
Conversin de dato de presin y temperatura a ASCII
void BCD_ASCIIP1(void)
{
word valor;
int j;
valor = (dato*5);
for(j=7; j>=3; j--)
{
if(j==5)j--;TEMPERA[j] = valor % 10 + 0x30;
TEMPERA[5]='.';
TEMPERA[0]='T';TEMPERA[1]=':';TEMPERA[2]=' ';TEMPERA[9]='C';TEMPERA[8]=223;
TEMPERA[11]=' ';TEMPERA[12]=' '; TEMPERA[13]=' '; TEMPERA[14]='
';TEMPERA[15]=' ';
valor /= 10; // Divide entre 10
}
valor = (((((sistolica/10)*48)/10)*85)/100);
for(j=4; j>=2; j--)
{
PRESION1[j] = valor % 10 + 0x30;
PRESION1[0]='S';PRESION1[1]=':';PRESION1[5]=' ';
valor /= 10; // Divide entre 10
}
valor = (((((diastolica/10)*48)/10)*85)/100); // Recorre el
punto flotante
for(j=10; j>=8; j--)
{
PRESION1[j] = valor % 10 + 0x30;
PRESION1[6]='D';PRESION1[7]=':';PRESION1[12]='M';PRESION1[13]='M';
PRESION1[14]='H';PRESION1[15]='G';PRESION1[11]=' ';
valor /= 10; // Divide entre 10
}
}
Conversin de dato de presin a ASCII
Anexo A
86
void BCD_ASCIIP2(void)
{
word valor;
int j;
valor = (((((sistolica/10)*48)/10)*85)/100);
for(j=8; j>=6; j--)
{
PRESION1[j] = valor % 10 + 0x30;
PRESION1[0]=' ';PRESION1[1]='S';PRESION1[2]='I';
PRESION1[3]='S';PRESION1[4]=':';PRESION1[5]=' ';
PRESION1[9]=' ';PRESION1[10]='M';PRESION1[11]='M';
PRESION1[12]='H';PRESION1[13]='G';PRESION1[14]=' ';PRESION1[15]=' ';
valor /= 10; // Divide entre 10
}
valor = (((((diastolica/10)*48)/10)*85)/100); // Recorre el
punto flotante
for(j=9; j>=7; j--)
{
PRESION2[j] = valor % 10 + 0x30;
PRESION2[0]=' ';PRESION2[1]='D';PRESION2[2]='I';
PRESION2[3]='A';PRESION2[4]='S';PRESION2[5]=':';PRESION2[6]=' ';
PRESION2[10]=' ';PRESION2[11]='M';PRESION2[12]='M';
PRESION2[13]='H';PRESION2[14]='G';PRESION2[15]=' ';
valor /= 10; // Divide entre 10
}
}
Conversin de dato de temperatura a ASCII
void BCD_ASCIIT(void)
{
word valor;
int j;
valor = (dato*5)+65;
for(j=9; j>=5; j--)
{
if(j==7)j--;TEMPERA[j] = valor % 10 + 0x30;
TEMPERA[7]='.';
TEMPERA[0]=' ';TEMPERA[1]=' ';TEMPERA[2]=' ';TEMPERA[3]=' ';TEMPERA[4]='
';
TEMPERA[10]=' ';TEMPERA[11]=223; TEMPERA[12]='C';TEMPERA[13]=' ';
valor /= 10; // Divide entre 10
}
}
Habilitar medicin de presin y temperatura
Anexo A
87
void medirpt(void)
{
Bit2_SetVal();
Bit1_SetVal();
AD1_Enable();
AD1_Start();
}
Habilitar medicin de temperatura
void medirt(void)
{Bit1_ClrVal();Bit2_ClrVal();
AD1_Enable();
AD1_Start();
}
Funcin para el envo de comandos en la LCD
void Comando_LCD2(char dato)
{
char temp;
temp = dato; // Respalda dato en temp
dato = dato >> 4; // Corrimiento de cuatro lugares a la derecha
Bits1_PutVal(dato);//PTBD = dato; // Nible alto en Puerto
Bits2_PutBit(1,0);//Byte1_PutBit(6,0);//PTB_PTB5 = 0; //
Escribir en LCD
Bits2_PutBit(0,0);//Byte1_PutBit(4,0);//PTB_PTB4 = 0;
// Indica comando para LCD
Bits2_PutBit(2,1);//Byte1_PutBit(5,1);//PTB_PTB6 = 1;
// Activa Pulso de reloj
d=TI1_Enable();
while(ban<1){}// Retardo de 15 mseg.
d=TI1_Disable();
ban=0;
Bits2_PutBit(2,0);//PTB_PTB6 = 0; // Desactiva Pulso
de reloj
temp = temp & 0b00001111;
Bits1_PutVal(temp);//PTBD = temp; // Nible bajo en Puerto
Bits2_PutBit(1,0);//PTB_PTB5 = 0; // Escribir en LCD
Bits2_PutBit(0,0);//PTB_PTB4 = 0; // Indica comando
para LCD
Bits2_PutBit(2,1);//PTB_PTB6 = 1; // Activa Pulso de
reloj
d= TI1_Enable();
while(ban<1){}// Retardo de 15 mseg.
Anexo A
88
d= TI1_Disable();
ban=0;
Bits2_PutBit(2,0);//PTB_PTB6 = 0; // Desactiva Pulso
de reloj
}
Anexo B
89
Anexo B
Cdigo del formulario 1
Bibliotecas utilizadas
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools.Word;
using System.Drawing.Text;
using System.IO;
Descripcin de la clase
namespace Historial
{
public partial class Form1 : Form
{
string datos, texto="";
double sis1=75, sis2=90, sis3=100, sis4=125, sis5=135, sis6=150, sis7=160, dias1=50, dias2=60,
dias3=65, dias4=77.5, dias5=82.5, dias6=90, dias7=95, te1=33.5, te2=34.5, te3=36, te4=37.5,
te5=39,te6=40;
public Form1()
{
InitializeComponent();
serialPort1.DataReceived += new
System.IO.Ports.SerialDataReceivedEventHandler(Recibe);
}
Recepcion de datos del puerto serial
private void Recibe(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
datos = serialPort1.ReadExisting();
this.Invoke(new EventHandler(Actualiza));
}
Anexo B
90
Prediagnstico para presin diastlica
private void Actualiza(object sender, EventArgs e)
{
if (datos == "D")
{
labeldiast.Text = texto;
texto = "";
if (Double.Parse(labeldiast.Text) >= dias1 && Double.Parse(labeldiast.Text) < dias2)
{ ovaldias.FillColor = Color.DeepSkyBlue; rdias.Text = "Baja"; }
if (Double.Parse(labeldiast.Text) >= dias2 && Double.Parse(labeldiast.Text) < dias3)
{ ovaldias.FillColor = Color.MediumAquamarine; rdias.Text = "Normal baja"; }
if (Double.Parse(labeldiast.Text) >= dias3 && Double.Parse(labeldiast.Text) <
dias4)
{ ovaldias.FillColor = Color.LimeGreen; rdias.Text = "Normal"; }
if (Double.Parse(labeldiast.Text) >= dias4 && Double.Parse(labeldiast.Text) < dias5)
{ ovaldias.FillColor = Color.Lime; rdias.Text = "ptima"; }
if (Double.Parse(labeldiast.Text) >= dias5 && Double.Parse(labeldiast.Text) <
dias6)
{ ovaldias.FillColor = Color.Red; rdias.Text = "Normal alta"; }
if (Double.Parse(labeldiast.Text) >= dias6 && Double.Parse(labeldiast.Text) <
dias7)
{ ovaldias.FillColor = Color.Firebrick; rdias.Text = "Hipertensin 1"; }
if (Double.Parse(labeldiast.Text) > dias7)
{ ovaldias.FillColor = Color.Maroon; rdias.Text = "Hipertensin 2"; }
}
Prediagnstico para presin sistlica
else if (datos == "S")
{
labelsist.Text = texto;
texto = "";
if (Double.Parse(labelsist.Text) >= sis1 && Double.Parse(labelsist.Text) < sis2)
{ ovalsis.FillColor = Color.DeepSkyBlue; rsis.Text = "Baja"; }
if (Double.Parse(labelsist.Text) >= sis2 && Double.Parse(labelsist.Text) < sis3)
{ ovalsis.FillColor = Color.MediumAquamarine; rsis.Text = "Normal baja"; }
if (Double.Parse(labelsist.Text) >= sis3 && Double.Parse(labelsist.Text) < sis4)
{ ovalsis.FillColor = Color.LimeGreen; rsis.Text = "Normal"; }
if (Double.Parse(labelsist.Text) >= sis4 && Double.Parse(labelsist.Text) < sis5)
{ ovalsis.FillColor = Color.Lime; rsis.Text = "ptima"; }
if (Double.Parse(labelsist.Text) >= sis5 && Double.Parse(labelsist.Text) < sis6)
{ ovalsis.FillColor = Color.Red; rsis.Text = "Normal alta"; }
if (Double.Parse(labelsist.Text) >= sis6 && Double.Parse(labelsist.Text) < sis7)
{ ovalsis.FillColor = Color.Firebrick; rsis.Text = "Hipertensin 1"; }
if (Double.Parse(labelsist.Text) > sis7)
{ ovalsis.FillColor = Color.Maroon; rsis.Text = "Hipertensin 2"; }
}
Prediagnstico para la temperatura
Anexo B
91
else if (datos == "T")
{
labeltemp.Text = texto;
texto = "";
if (Double.Parse(labelsist.Text) >= te1 && Double.Parse(labelsist.Text) < te2)
{ ovalsis.FillColor = Color.DeepSkyBlue; rsis.Text = "Hipotermia"; }
if (Double.Parse(labelsist.Text) >= te2 && Double.Parse(labelsist.Text) < te3)
{ ovalsis.FillColor = Color.MediumAquamarine; rsis.Text = "Hipotermia"; }
if (Double.Parse(labelsist.Text) >= te3 && Double.Parse(labelsist.Text) < te4)
{ ovalsis.FillColor = Color.Lime; rsis.Text = "Normal"; }
if (Double.Parse(labelsist.Text) >= te4 && Double.Parse(labelsist.Text) < te5)
{ ovalsis.FillColor = Color.Red; rsis.Text = "Fiebre"; }
if (Double.Parse(labelsist.Text) >= te5 && Double.Parse(labelsist.Text) < te6)
{ ovalsis.FillColor = Color.Firebrick; rsis.Text = "Fiebre"; }
}
texto += datos;
}
Carga de datos en el expediente
private void Form1_Activated(object sender, EventArgs e)
{
if (Datos.matricula >= 1) button2.Enabled = true;
labnom.Text = Datos.NOM;
labapp.Text = Datos.APP;
labapm.Text = Datos.APM;
labgpo.Text = Datos.GPO;
labedd.Text = Datos.EDD.ToString();
labtel.Text = Datos.TEL;
labdrc.Text = Datos.DIR;
labsx.Text = Datos.SX;
labmat.Text = Datos.matricula.ToString();
ldia.Text = Datos.dia.ToString();
lmes.Text = Datos.mes.ToString();
lan.Text = Datos.anio.ToString();
if (Datos.nuevo2 == true)
{
listBox1.Items.Add(Datos.APP + " " + Datos.APM + " " + Datos.NOM);
listBox1.SelectedIndex = Datos.matricula - 1;Datos.nuevo2=false; Datos.nuevo1=false;
}
else if (Datos.edit2 == true)
{
listBox1.Items.Insert(Datos.matricula - 1, (Datos.APP + " " + Datos.APM + " " + Datos.NOM));
listBox1.Items.RemoveAt(Datos.matricula );
listBox1.SelectedIndex = Datos.matricula - 1;Datos.edit2 = false; Datos.edit1 =
false;
}
listBox1.SelectedIndex = 0;
}
Botn Nuevo
private void button1_Click_1(object sender, EventArgs e)
Anexo B
92
{
if (Datos.edit1 == false && Datos.nuevo1 == false)
{
Datos.nuevo1 = true;
Datos.edit1 = false;
Form2 ventana2 = new Form2();
ventana2.Show();
}
}
Botn Editar
private void button2_Click(object sender, EventArgs e)
{
if (Datos.edit1 == false && Datos.nuevo1 == false)
{
Datos.edit1 = true;
Datos.nuevo1 = false;
Datos.NOM = labnom.Text;
Datos.APP = labapp.Text;
Datos.APM = labapm.Text;
Datos.GPO = labgpo.Text;
Datos.EDD = Int32.Parse(labedd.Text);
Datos.TEL = labtel.Text;
Datos.DIR = labdrc.Text;
Datos.SX = labsx.Text;
Datos.matricula = Int32.Parse(labmat.Text);
Datos.dia = Int32.Parse(ldia.Text);
Datos.mes = Int32.Parse(lmes.Text);
Datos.anio = Int32.Parse(lan.Text);
Form2 ventana2 = new Form2();
ventana2.Show();
}
}
Comunicacin de la PC al Microcontrolador
private void timer1_Tick(object sender, EventArgs e)
{
toolStripStatusLabel4.Text = DateTime.Now.ToString();
if (date1.Value == DateTime.Now && checkBox1.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("TTT"); }
if (date2.Value == DateTime.Now && checkBox2.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("TTT"); }
if (date3.Value == DateTime.Now && checkBox3.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("TTT"); }
if (dateTimePicker4.Value == DateTime.Now && checkBox4.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("PPP"); }
if (dateTimePicker5.Value == DateTime.Now && checkBox5.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("PPP"); }
if (dateTimePicker6.Value == DateTime.Now && checkBox6.Checked && serialPort1.IsOpen) {
serialPort1.WriteLine("PPP"); }
}
Almacenamiento de datos en el archivo de Word
Anexo B
93
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application word = new
Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\HistorialC.docx";
object readOnly = false;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref
miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
miss, ref miss, ref miss, ref miss, ref miss, ref miss);
Datos.matricula = listBox1.SelectedIndex + 1;
Word.Table tabla = docs.Tables[Datos.matricula];
//Datos.matricula++;
Datos.NOM = tabla.Cell(2, 1).Range.Text.Substring(0, tabla.Cell(2,
1).Range.Text.Length - 1);
Datos.APP = tabla.Cell(2, 2).Range.Text.Substring(0, tabla.Cell(2,
2).Range.Text.Length - 1);
Datos.APM = tabla.Cell(2, 3).Range.Text.Substring(0, tabla.Cell(2,
3).Range.Text.Length - 1);
Datos.SX = tabla.Cell(2, 4).Range.Text.Substring(0, tabla.Cell(2,
4).Range.Text.Length - 1);
Datos.GPO = tabla.Cell(2, 6).Range.Text.Substring(0, tabla.Cell(2,
6).Range.Text.Length - 1);
Datos.TEL = tabla.Cell(2, 7).Range.Text.Substring(0, tabla.Cell(2,
7).Range.Text.Length - 1);
Datos.DIR = tabla.Cell(3, 2).Range.Text.Substring(0, tabla.Cell(3,
2).Range.Text.Length - 1);
Datos.ddmmaa = DateTime.Parse(tabla.Cell(2, 5).Range.Text.Substring(0, tabla.Cell(2,
5).Range.Text.Length - 1));
Datos.dia = Datos.ddmmaa.Day;
Datos.mes = Datos.ddmmaa.Month;
Datos.anio = Datos.ddmmaa.Year;
int dia = DateTime.Now.Day - Datos.dia;
int mes = DateTime.Now.Month - Datos.mes;
int anio = DateTime.Now.Year - Datos.anio;
Datos.EDD = anio;
if (mes < 0) Datos.EDD = anio - 1;
if (mes == 0 && dia < 0) Datos.EDD = anio - 1;
labnom.Text = Datos.NOM;
labapp.Text = Datos.APP;
labapm.Text = Datos.APM;
labgpo.Text = Datos.GPO;
labedd.Text = Datos.EDD.ToString();
labtel.Text = Datos.TEL;
labdrc.Text = Datos.DIR;
labsx.Text = Datos.SX;
labmat.Text = Datos.matricula.ToString();
ldia.Text = Datos.dia.ToString();
lmes.Text = Datos.mes.ToString();
lan.Text = Datos.anio.ToString();
string fecha1;
string di;
string si;
string tep;
int ft = 0, fp = 0;
fp = data1.RowCount;
ft = data2.RowCount;
Anexo B
94
for (int h = fp - 2; h >= 0; h--) { data1.Rows.RemoveAt(h); data1[0, 0].Value = ""; data1[1,
0].Value = ""; data1[2, 0].Value = ""; }
for (int h = ft - 2; h >= 0; h--) { data2.Rows.RemoveAt(h); data2[0, 0].Value = ""; data2[1,
0].Value = ""; }
for (int f = 5; f <= 8; f++)
{
fecha1 = tabla.Cell(f, 1).Range.Text.Substring(0, tabla.Cell(f,
1).Range.Text.Length - 1);
di = tabla.Cell(f, 2).Range.Text.Substring(0, tabla.Cell(f, 2).Range.Text.Length - 1);
si = tabla.Cell(f, 3).Range.Text.Substring(0, tabla.Cell(f, 3).Range.Text.Length - 1);
tep = tabla.Cell(f, 4).Range.Text.Substring(0, tabla.Cell(f, 4).Range.Text.Length - 1);
if (fecha1 == di || fecha1 == si || fecha1 == tep) f = 23;
if (fecha1 != di || di != si || si != tep)
{
if (tep != fecha1)
{
if (f == 5)
{
data2[0, 0].Value = fecha1; data2[1, 0].Value = tep;
}
else
{
data2.Rows.Add();
ft = data2.RowCount;
data2[0, ft - 2].Value = fecha1; data2[1, ft - 2].Value = tep;
}
}
if (si != di)
{
if (f == 5)
{
data1[0, 0].Value = fecha1;
data1[1, 0].Value = si;
data1[2, 0].Value = di;
}
else
{
data1.Rows.Add();
fp = data1.RowCount;
data1[0, ft - 2].Value = fecha1;
data1[1, ft - 2].Value = si;
data1[2, ft - 2].Value = di;
}
}
data1.Sort(data1.Columns[0], ListSortDirection.Descending);
data2.Sort(data2.Columns[0], ListSortDirection.Descending);
}
}
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
}
Anexo B
95
Carga de datos del archivo de Word
private void Form1_Load(object sender, EventArgs e)
{
if (System.IO.File.Exists("Historial1.docx"))
ReadMsWord();
else
{
MessageBox.Show("No se ha encontrado el archivo Historial.docx. Espere mientras se crea");
creardocumentoword();
}
}
public void creardocumentoword()
{
Word.Application objWordApplication;
Word.Document objWordDocument;
Object oMissing = System.Reflection.Missing.Value;
objWordApplication = new Word.Application();
objWordDocument = objWordApplication.Documents.Add(ref oMissing,
ref oMissing,
ref oMissing,ref oMissing );
object fileName =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\Historial1.docx";
objWordDocument.SaveAs(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
private void ReadMsWord()
{
Microsoft.Office.Interop.Word.Application word = new
Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\HistorialC.docx";
object readOnly = false;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref
miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
miss, ref miss, ref miss, ref miss, ref miss, ref miss);
int ntablas = 0;
ntablas = docs.Tables.Count; Datos.matultimo = ntablas;
for (int g = 1; g <= ntablas; g++)
{
Word.Table tabla = docs.Tables[g];
string ap, am, nm;
nm = tabla.Cell(2, 1).Range.Text.Substring(0,tabla.Cell(2, 1).Range.Text.Length - 1);
ap = tabla.Cell(2, 2).Range.Text.Substring(0, tabla.Cell(2, 2).Range.Text.Length - 1);
am = tabla.Cell(2, 3).Range.Text.Substring(0, tabla.Cell(2, 3).Range.Text.Length - 1);
listBox1.Items.Add(ap + " " + am + " " + nm);
}
if (ntablas > 0)
{
Datos.matricula = 1; Word.Table tabla = docs.Tables[1];
Datos.NOM = tabla.Cell(2, 1).Range.Text.Substring(0, tabla.Cell(2, 1).Range.Text.Length - 1);
Datos.APP = tabla.Cell(2, 2).Range.Text.Substring(0, tabla.Cell(2,
2).Range.Text.Length - 1);
Anexo B
96
Datos.APM = tabla.Cell(2, 3).Range.Text.Substring(0, tabla.Cell(2,
3).Range.Text.Length - 1);
Datos.SX = tabla.Cell(2, 4).Range.Text.Substring(0, tabla.Cell(2,
4).Range.Text.Length - 1);
Datos.GPO = tabla.Cell(2, 6).Range.Text.Substring(0, tabla.Cell(2,
6).Range.Text.Length - 1);
Datos.TEL = tabla.Cell(2, 7).Range.Text.Substring(0, tabla.Cell(2,
7).Range.Text.Length - 1);
Datos.DIR = tabla.Cell(3, 2).Range.Text.Substring(0, tabla.Cell(3,
2).Range.Text.Length - 1);
Datos.ddmmaa = DateTime.Parse(tabla.Cell(2, 5).Range.Text.Substring(0,
tabla.Cell(2, 5).Range.Text.Length - 1));
Datos.dia = Datos.ddmmaa.Day;
Datos.mes = Datos.ddmmaa.Month;
Datos.anio = Datos.ddmmaa.Year;
int dia = DateTime.Now.Day - Datos.dia;
int mes = DateTime.Now.Month - Datos.mes;
int anio = DateTime.Now.Year - Datos.anio;
Datos.EDD = anio;
if (mes < 0) Datos.EDD = anio - 1;
if (mes == 0 && dia < 0) Datos.EDD = anio - 1;
labnom.Text = Datos.NOM;
labapp.Text = Datos.APP;
labapm.Text = Datos.APM;
labgpo.Text = Datos.GPO;
labedd.Text = Datos.EDD.ToString();
labtel.Text = Datos.TEL;
labdrc.Text = Datos.DIR;
labsx.Text = Datos.SX;
labmat.Text = Datos.matricula.ToString();
ldia.Text = Datos.dia.ToString();
lmes.Text = Datos.mes.ToString();
lan.Text = Datos.anio.ToString();
string fecha1;
string di;
string si;
string tep;
int ft = 0, fp = 0;
fp = data1.RowCount;
ft = data2.RowCount;
for (int h = fp - 1; h > 2; h--) data1.Rows.RemoveAt(h);
for (int h = ft - 1; h > 2; h--) data2.Rows.RemoveAt(h);
for (int f = 5; f <= 22; f++)
{
fecha1 = tabla.Cell(f, 1).Range.Text.Substring(0, tabla.Cell(f,
1).Range.Text.Length - 1);
di = tabla.Cell(f, 2).Range.Text.Substring(0, tabla.Cell(f, 2).Range.Text.Length - 1);
si = tabla.Cell(f, 3).Range.Text.Substring(0, tabla.Cell(f, 3).Range.Text.Length - 1);
tep = tabla.Cell(f, 4).Range.Text.Substring(0, tabla.Cell(f, 4).Range.Text.Length - 1);
if (fecha1 == di || fecha1 == si || fecha1 == tep) f = 23;
if (fecha1 != di || di != si || si != tep)
{
if (tep != fecha1)
{
if (f == 5)
{
data2[0, 0].Value = fecha1; data2[1, 0].Value = tep;
}
else
{
Anexo B
97
data2.Rows.Add();
ft = data2.RowCount;
data2[0, ft - 2].Value = fecha1; data2[1, ft - 2].Value = tep;
}
}
if (si != di)
{
if (f == 5)
{
data1[0, 0].Value = fecha1;
data1[1, 0].Value = si;
data1[2, 0].Value = di;
}
else
{
data1.Rows.Add();
fp = data1.RowCount;
data1[0, ft - 2].Value = fecha1;
data1[1, ft - 2].Value = si;
data1[2, ft - 2].Value = di;
}
}
data1.Sort(data1.Columns[0], ListSortDirection.Descending);
data2.Sort(data2.Columns[0], ListSortDirection.Descending);
}
}
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
listBox1.SelectedIndex = 0;
}
else
{
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
}
}
Opcin de imprimir
private void button3_Click(object sender, EventArgs e)
{
object missing= System.Reflection.Missing.Value;
object copies = "1";
object pages = Datos.matricula;
object range = Word.WdPrintOutRange.wdPrintFromTo;
object items = Word.WdPrintOutItem.wdPrintDocumentContent;
object pageType = Word.WdPrintOutPages.wdPrintAllPages;
object oTrue = true;
object oFalse = false;
object start= Datos.matricula;
object end= Datos.matricula+1;
Anexo B
98
PrintOut(ref oTrue, ref oFalse, ref range, ref missing,
ref start, ref end, ref items, ref copies, ref pages, ref pageType, ref oFalse,
ref oTrue, ref missing, ref oFalse, ref missing, ref missing, ref missing,
ref missing);
}
private void PrintOut(ref object oTrue, ref object oFalse, ref object range, ref object
missing, ref object start, ref object end, ref object items, ref object copies, ref object
pages, ref object pageType, ref object oFalse_2, ref object oTrue_2, ref object missing_2, ref
object oFalse_3, ref object missing_3, ref object missing_4, ref object missing_5, ref object
missing_6)
{
throw new NotImplementedException();
}
Seleccin de puerto serial
private void menuItem1_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen) serialPort1.Close();
serialPort1.PortName = menuItem1.Text;
menuItem3.Text = "Iniciada en COM1";
if (serialPort1.IsOpen == false) serialPort1.Open();
}
Medicin de temperatura
private void button7_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen) serialPort1.WriteLine("TTT");
else { MessageBox.Show("No se ha establecido la comunicacin con el instrumento"); }
}
Medicin de presin
private void button8_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen) serialPort1.WriteLine("PPP");
else { MessageBox.Show("No se ha establecido la comunicacin con el instrumento"); }
}
Graficar presin
private void button4_Click(object sender, EventArgs e)
{
Datos.graf = 1;
int filast = data2.RowCount, contt = 0;
int filas = data1.RowCount, cont = 0;
for (int j = 0; j < 32; j++)
{
Anexo B
99
Datos.sistol[j] = 600;
}
for (int j = 0; j < 32; j++)
{
Datos.diastol[j] = 600;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.diastol[cont] = Condias(Double.Parse(data1[2, j].Value.ToString()));
cont++;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.sistol[cont] = Consis(Double.Parse(data1[1, j].Value.ToString()));
cont++;
}
for (int j = 0; j < 32; j++)
{
Datos.temper[j] = 600;
}
contt = 0;
for (int j = filast - 1; j >= 0; j--)
{
Datos.temper[contt] = Contemp(Double.Parse(data2[1, j].Value.ToString()));
contt++;
}
Graficas ob = new Graficas();
ob.Show();
}
private void button9_Click(object sender, EventArgs e)
{
Datos.graf = 2;
int filast = data2.RowCount, contt = 0;
int filas = data1.RowCount, cont = 0;
for (int j = 0; j < 32; j++)
{
Datos.sistol[j] = 600;
}
for (int j = 0; j < 32; j++)
{
Datos.diastol[j] = 600;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.diastol[cont] = Condias(Double.Parse(data1[2, j].Value.ToString()));
cont++;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.sistol[cont] = Consis(Double.Parse(data1[1, j].Value.ToString()));
cont++;
}
Anexo B
100
for (int j = 0; j < 32; j++)
{
Datos.temper[j] = 600;
}
contt = 0;
for (int j = filast - 1; j >= 0; j--)
{
Datos.temper[contt] = Contemp(Double.Parse(data2[1, j].Value.ToString()));
contt++;
}
Graficas ob = new Graficas();
ob.Show();
}
Grfica de temperatura
private void button5_Click(object sender, EventArgs e)
{
Datos.graf = 3;
int filast = data2.RowCount, contt = 0;
int filas = data1.RowCount, cont = 0;
for (int j = 0; j < 32; j++)
{
Datos.sistol[j] = 600;
}
for (int j = 0; j < 32; j++)
{
Datos.diastol[j] = 600;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.diastol[cont] = Condias(Double.Parse(data1[2, j].Value.ToString()));
cont++;
}
cont = 0;
for (int j = filas - 1; j >= 0; j--)
{
Datos.sistol[cont] = Consis(Double.Parse(data1[1, j].Value.ToString()));
cont++;
}
for (int j = 0; j < 32; j++)
{
Datos.temper[j] = 600;
}
contt = 0;
for (int j = filast - 1; j >= 0; j--)
{
Datos.temper[contt] = Contemp(Double.Parse(data2[1, j].Value.ToString()));
contt++;
}
Graficas ob = new Graficas();
ob.Show();
Anexo B
101
}
Interpretacin de datos recibidos por el microcontrolador
private int Condias(double valor)
{
int valord=0;
valord = (int)((160 - valor) * ((465 - 35) / (160 - 75)) + 35);
return valord;
}
private int Consis(double valor)
{
int valors = 35;
valors= (int)((95-valor)*((465-35)/(95-52.5))+35);
return valors;
}
private int Contemp(double valor)
{
int valort = 0;
valort = (int)((40 - valor) * ((466 - 36) / (40 - 33.5)) + 36);
return valort;
}
}
}
Cdigo del formulario 2
Bibliotecas utilizadas
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools.Word;
using System.Windows.Forms;
using System.IO;
Inicializacin del formulario
namespace Historial
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
Anexo B
102
}
Carga de datos
public void Editar(int indice)
{
Microsoft.Office.Interop.Word.Application word = new
Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\HistorialC.docx";
object readOnly = false;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref
miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
miss, ref miss, ref miss, ref miss, ref miss, ref miss);
object True = true;
Word.Table tabla = docs.Tables[indice];
Word.Cell celda1 = tabla.Cell(2, 1); Word.Cell celda2 = tabla.Cell(2, 2);
Word.Cell celda3 = tabla.Cell(2, 3); Word.Cell celda4 = tabla.Cell(2, 4);
Word.Cell celda5 = tabla.Cell(2, 5); Word.Cell celda6 = tabla.Cell(2, 6);
Word.Cell celda7 = tabla.Cell(2, 7); Word.Cell celda8 = tabla.Cell(2, 8);
celda1.Range.Text = Datos.NOM;
celda2.Range.Text = Datos.APP;
celda3.Range.Text = Datos.APM;
celda4.Range.Text = Datos.SX;
celda5.Range.Text = (Datos.dia.ToString() + "/" + Datos.mes.ToString() + "/" +
Datos.anio.ToString());
celda6.Range.Text = Datos.GPO;
celda7.Range.Text = Datos.TEL;
celda8.Range.Text = Datos.matultimo.ToString();
celda2 = tabla.Cell(3, 2);
celda2.Range.Text = Datos.DIR;
docs.Save();
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
}
Registro nuevo
public void Nuevo()
{
Microsoft.Office.Interop.Word.Application word = new
Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\HistorialC.docx";
object readOnly = false;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref
miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
miss, ref miss, ref miss, ref miss, ref miss, ref miss);
object start = "\\endofdoc";
Anexo B
103
object end = "\\endofdoc";
object True = true;
Microsoft.Office.Interop.Word.Range ubicacion = docs.Bookmarks.get_Item(ref
start).Range;
Word.Paragraph para = docs.Content.Paragraphs.Add(ubicacion);
para.Range.Text = Environment.NewLine + "Usuario " + Datos.matultimo.ToString() +
Environment.NewLine;
start = "\\endofdoc";
ubicacion = docs.Bookmarks.get_Item(ref start).Range;
docs.Tables.Add(ubicacion, 21, 8, ref miss, ref True);
Word.Table tabla = docs.Tables[Datos.matultimo];
tabla.Borders.Enable = 1;
Word.Cell celda1 = tabla.Cell(1, 1); Word.Cell celda2 = tabla.Cell(1, 2);
Word.Cell celda3 = tabla.Cell(1, 3); Word.Cell celda4 = tabla.Cell(1, 4);
Word.Cell celda5 = tabla.Cell(1, 5); Word.Cell celda6 = tabla.Cell(1, 6);
Word.Cell celda7 = tabla.Cell(1, 7); Word.Cell celda8 = tabla.Cell(1, 8);
celda1.Range.Text = "Nombres:";
celda2.Range.Text = "Apellido paterno:";
celda3.Range.Text = "Apellido materno:";
celda4.Range.Text = "Sexo:";
celda5.Range.Text = "Fecha de nacimiento:";
celda6.Range.Text = "Grupo sanguneo:";
celda7.Range.Text = "Telfono:";
celda8.Range.Text = "No. de usuario:";
celda1 = tabla.Cell(2, 1); celda2 = tabla.Cell(2, 2);
celda3 = tabla.Cell(2, 3); celda4 = tabla.Cell(2, 4);
celda5 = tabla.Cell(2, 5); celda6 = tabla.Cell(2, 6);
celda7 = tabla.Cell(2, 7); celda8 = tabla.Cell(2, 8);
tabla.Columns[1].SetWidth((float)97, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[2].SetWidth((float)67, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[3].SetWidth((float)68.6, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[4].SetWidth((float)69.5, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[5].SetWidth((float)104, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[6].SetWidth((float)55.9, Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[7].SetWidth((float)51.33,
Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Columns[8].SetWidth((float)51.33,
Microsoft.Office.Interop.Word.WdRulerStyle.wdAdjustNone);
tabla.Rows.SetHeight((float)28.36,
Microsoft.Office.Interop.Word.WdRowHeightRule.wdRowHeightExactly);
//
celda1.Range.Text = Datos.NOM;
celda2.Range.Text = Datos.APP;
celda3.Range.Text = Datos.APM;
celda4.Range.Text = Datos.SX;
celda5.Range.Text = (Datos.dia.ToString() + "/" + Datos.mes.ToString() + "/" +
Datos.anio.ToString());
celda6.Range.Text = Datos.GPO;
celda7.Range.Text = Datos.TEL;
celda8.Range.Text = Datos.matultimo.ToString();
celda1 = tabla.Cell(3, 1); celda5 = tabla.Cell(3, 5);
celda2 = tabla.Cell(3, 2); celda6 = tabla.Cell(3, 6);
celda3 = tabla.Cell(3, 3); celda7 = tabla.Cell(3, 7);
celda4 = tabla.Cell(3, 4); celda8 = tabla.Cell(3, 8);
celda7.Merge(celda8); celda6.Merge(celda7);
celda5.Merge(celda6); celda4.Merge(celda5);
celda3.Merge(celda4); celda2.Merge(celda3);
celda1 = tabla.Cell(3, 1); celda2 = tabla.Cell(3, 2);
celda1.Range.Text = "Direccin:";
celda2.Range.Text = Datos.DIR;
Anexo B
104
celda1 = tabla.Cell(4, 1); celda5 = tabla.Cell(4, 5);
celda2 = tabla.Cell(4, 2); celda6 = tabla.Cell(4, 6);
celda3 = tabla.Cell(4, 3); celda7 = tabla.Cell(4, 7);
celda4 = tabla.Cell(4, 4); celda8 = tabla.Cell(4, 8);
celda1.Range.Text = "Horarios:";
celda2.Range.Text = "Diastlica";
celda3.Range.Text = "Sistlica";
celda4.Range.Text = "Temp.";
celda5.Range.Text = "Fecha";
celda6.Range.Text = "Diastlica";
celda7.Range.Text = "Sistlica";
celda8.Range.Text = "Temp.";
tabla.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;
docs.Save();
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
}
Botn Ok
private void button1_Click(object sender, EventArgs e)
{
bool bien = true;
bien = Verificar();
if (bien == true)
{
int dia = DateTime.Now.Day - date1.Value.Day;
int mes= DateTime.Now.Month - date1.Value.Month;
int anio = DateTime.Now.Year - date1.Value.Year;
Datos.NOM = txtnom.Text.Trim();
Datos.APP = txtapp.Text.Trim();
Datos.APM = txtam.Text.Trim();
Datos.TEL = txttel.Text.Trim();
Datos.DIR = txtdir.Text.Trim();
Datos.dia = date1.Value.Day;
Datos.mes = date1.Value.Month;
Datos.anio = date1.Value.Year;
Datos.GPO = txtgpo.SelectedItem.ToString();
Datos.EDD = anio;
if(mes < 0 ) Datos.EDD= anio-1;
if(mes==0 && dia<0) Datos.EDD= anio - 1;
if (radioButton1.Checked) Datos.SX = "Femenino";
else Datos.SX = "Masculino";
}
if (Datos.edit1 == true && bien == true)
{
Microsoft.Office.Interop.Word.Application word = new
Microsoft.Office.Interop.Word.Application();
object miss = System.Reflection.Missing.Value;
object path =
"C:\\Users\\Oscar\\Dropbox\\Tesis\\Historial\\Historial\\bin\\Debug\\HistorialC.docx";
object readOnly = false;
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref
miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref
miss, ref miss, ref miss, ref miss, ref miss, ref miss);
object True = true;
Anexo B
105
Word.Table tabla = docs.Tables[Datos.matricula];
Word.Cell celda1 = tabla.Cell(2, 1); Word.Cell celda2 = tabla.Cell(2, 2);
Word.Cell celda3 = tabla.Cell(2, 3); Word.Cell celda4 = tabla.Cell(2, 4);
Word.Cell celda5 = tabla.Cell(2, 5); Word.Cell celda6 = tabla.Cell(2, 6);
Word.Cell celda7 = tabla.Cell(2, 7); Word.Cell celda8 = tabla.Cell(2, 8);
celda1.Range.Text = Datos.NOM;
celda2.Range.Text = Datos.APP;
celda3.Range.Text = Datos.APM;
celda4.Range.Text = Datos.SX;
celda5.Range.Text = (Datos.dia.ToString() + "/" + Datos.mes.ToString() + "/" +
Datos.anio.ToString());
celda6.Range.Text = Datos.GPO;
celda7.Range.Text = Datos.TEL;
celda8.Range.Text = Datos.matricula.ToString();
celda2 = tabla.Cell(3, 2);
celda2.Range.Text = Datos.DIR;
docs.Save();
docs.Close(ref miss, ref miss, ref miss);
docs = null;
word.Quit(ref miss, ref miss, ref miss);
word = null;
for(double tiempo=0; tiempo<1000;tiempo++)
{
}
//docs = null;
// word.Quit(ref miss, ref miss, ref miss);
Datos.edit1 = false;
Datos.edit2 = true;
}
else if (Datos.nuevo1==true && bien == true)
{
Datos.matultimo++;
Datos.nuevo1 = false;
Datos.nuevo2 = true;
Nuevo();
}
if(bien == true)
Close();
}
Botn Cancelar
private void button2_Click(object sender, EventArgs e)
{
Datos.edit1 = false;
Datos.nuevo1 = false;
Datos.edit2= false;
Datos.nuevo2 = false;
Close();
}
private void Form2_Load(object sender, EventArgs e)
{
txtgpo.SelectedIndex = 0;
}
public bool Verificar()
{
Anexo B
106
bool bien = true;
if (txtnom.Text == null || txtnom.Text == "")
{ label2.Text = "* Nombre(s):"; label2.ForeColor = Color.Red; bien = false; }
else { label2.Text = "Nombre(s):"; label2.ForeColor = Color.Black; }
if (txtapp.Text == null || txtapp.Text == "")
{ label5.Text = "* Apellido paterno:"; label5.ForeColor = Color.Red; bien = false; }
else { label5.Text = "Apellido paterno:"; label5.ForeColor = Color.Black; }
if (txtam.Text == null || txtam.Text == "")
{ label7.Text = "* Apellido materno"; label7.ForeColor = Color.Red; bien = false; }
else { label7.Text = "Apellido materno:"; label7.ForeColor = Color.Black; }
if (txttel.Text == null || txttel.Text == "")
{ label15.Text = "* Telfono:"; label15.ForeColor = Color.Red; bien = false; }
else { label15.Text = "Telfono"; label15.ForeColor = Color.Black; }
if (txtdir.Text == null || txtdir.Text == "")
{ label17.Text = "* Direccin:"; label17.ForeColor = Color.Red; bien = false; }
else { label17.Text = "Direccin:"; label17.ForeColor = Color.Black; }
return (bien);
}
Actualizar datos
private void Form2_Activated(object sender, EventArgs e)
{
if (Datos.edit1 == true)
{
txtnom.Text = Datos.NOM ;
txtapp.Text =Datos.APP ;
txtam.Text =Datos.APM ;
txttel.Text = Datos.TEL;
txtdir.Text = Datos.DIR;
if (Datos.SX == "Femenino") radioButton1.Checked=true;
else radioButton2.Checked = true;
txtgpo.SelectedItem = Datos.GPO;
date1.Value = DateTime.Parse(Datos.dia.ToString()+"/"+
Datos.mes.ToString()+"/"+Datos.anio.ToString());
//Datos.edit1 = false;
}
}
}
}
Cdigo de la clase Graficas
Bibliotecas utilizadas
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
Anexo B
107
Inicializacin del formulario
namespace Historial
{
public partial class Graficas : Form
{
Pen Pluma = new Pen(Color.Black, 3);
public Graficas()
{
InitializeComponent();
}
Desplegado de grficas
private void menuItem1_Click(object sender, EventArgs e)
{
if (pictureBox1.ImageLocation != "Presion1.png")
{
Graphics g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
pictureBox1.ImageLocation = "Presion1.png";
}
}
private void menuItem2_Click(object sender, EventArgs e)
{
if (pictureBox1.ImageLocation != "Presion2.png")
{
Graphics g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
pictureBox1.ImageLocation = "Presion2.png";
}
}
private void menuItem3_Click(object sender, EventArgs e)
{
if (pictureBox1.ImageLocation != "Temperatura.png")
{
Graphics g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
pictureBox1.ImageLocation = "Temperatura.png";
}
}
private void Graficas_Activated(object sender, EventArgs e)
{
if (Datos.graf == 1) pictureBox1.ImageLocation = "Presion1.png";
else if (Datos.graf == 2) pictureBox1.ImageLocation = "Presion2.png";
else if (Datos.graf == 3) pictureBox1.ImageLocation = "Temperatura.png";
}
Anexo B
108
Graficacin de puntos
private void timer1_Tick(object sender, EventArgs e)
{
int ajusteh = 85;
Graphics g = pictureBox1.CreateGraphics();
if (pictureBox1.ImageLocation == "Presion1.png")
{
for (int i = 0; i < 32; i++)
{
g.DrawEllipse(Pluma, ajusteh + (i * 20), Datos.sistol[i], 3, 3);
}
}
else if (pictureBox1.ImageLocation == "Presion2.png")
{
for (int j = 0; j < 32; j++)
{
g.DrawEllipse(Pluma, ajusteh + (j * 20), Datos.diastol[j], 3, 3);
}
}
else if (pictureBox1.ImageLocation == "Temperatura.png")
{
for (int j = 0; j < 32; j++)
{
g.DrawEllipse(Pluma, ajusteh + (j * 20),Datos.temper[j], 3, 3);
}
}
}
}
}
Anexo C
109
Anexo C: Costo del prototipo
DISEO DEL CIRCUITO DEL INSTRUMENTO
Materiales Cantidad Precio unitario Total
Microcontrolador M9S08SH8 1 $ 60.00 $ 60.00
Sensor MPX5050DP 1 $ 246.00 $ 246.00
Sensor LM35 1 $ 17.00 $ 17.00
Resistor 1/4 W 15 $ 0.30 $ 4.50
Capacitor cermico 4 $ 4.00 $ 16.00
Capacitor electroltico 2 $ 5.00 $ 10.00
Amplificador operacional LF411 3 $ 15.60 $ 46.80
Amplificador operacional LM741 1 $ 4.30 $ 4.30
LCD de 2 lneas 1 $ 160.00 $ 160.00
Modulo bluetooth 1 $ 150.00 $ 150.00
Base para integrados de 20 pines 1 $ 4.00 $ 4.00
Base para integrados de 8 pines 4 $ 3.00 $ 12.00
Botn de presin 2 $ 9.00 $ 18.00
Interruptor 2 polos 1 $ 29.00 $ 29.00
Placa fenolica 10 x10 cm doble cara 1 $ 18.00 $ 18.00
Transistor 2N3904 2 $ 1.70 $ 3.40
Bomba de aire 1 $ 80.00 $ 80.00
Electrovlvula 1 $ 70.00 $ 70.00
Jack de audio estereo 1 $ 4.00 $ 4.00
Plug de audio estereo 1 $ 8.00 $ 8.00
Anexo C
110
Header hembra 1 $ 7.00 $ 7.00
Metro de alambre de cobre 2 $ 5.00 $ 10.00
Licencia de la aplicacin PCB Wizard 1 Libre $ -
Subtotal 49 $ 900.90 $ 978.00
DISEO DEL CIRCUITO DE LA FUENTE
Materiales Cantidad Precio unitario Total
Transformador 24V 2A 1 $ 198.00 $ 198.00
Puente rectificador 2A 1 $ 9.00 $ 9.00
Regulador LM317 1 $ 25.00 $ 25.00
Regulador LM337 1 $ 11.30 $ 11.30
Capacitor electroltico 6 $ 19.00 $ 114.00
Resistor 1/4 W 4 $ 0.30 $ 1.20
Fusible 2A europeo 1 $ 5.00 $ 5.00
Base para fusible 1 $ 8.00 $ 8.00
Disipador 2 $ 9.00 $ 18.00
Placa fenolica 5x10 cm 1 $ 9.00 $ 9.00
Subtotal 19 $ 293.60 $ 398.50
HERRAMIENTAS PARA LA ELABORACIN DE LOS CIRCUITOS
Herramienta Cantidad Precio unitario Total
Cautn de lpiz de 25 W 1 $ 260.00 $ 260.00
Metros de soldadura 3 $ 8.00 $ 24.00
Litros de cloruro frrico 0.5 $ 26.00 $ 13.00
Taladro 1 $ 460.00 $ 460.00
Anexo C
111
Broca de 0.5 mm 2 $ 16.00 $ 32.00
Broca de 0.7 mm 2 $ 23.00 $ 46.00
Pinzas de punta 1 $ 120.00 $ 120.00
Pinzas de corte 1 $ 120.00 $ 120.00
Botella de Flux lquido 1 $ 76.00 $ 76.00
Cinta de aislar 1 $ 14.00 $ 14.00
Malla para desoldar 1 $ 19.00 $ 19.00
Tijeras 1 $ 16.00 $ 16.00
Envase plstico 1 $ 3.00 $ 3.00
Hoja de papel couche 2 $ 2.00 $ 4.00
Cutter 1 $ 18.00 $ 18.00
Barra de silicon 1 $ 6.50 $ 6.50
Subtotal 20.5 $ 1,187.50 $ 1,231.50
OTROS ELEMENTOS
Elemento Cantidad Precio unitario Total
DEMOM9S08SH8 1 $ 800.00 $ 800.00
Cable USB 1 $ 52.00 $ 52.00
Caja de plstico de 16x 9x7 cm 1 $ 67.00 $ 67.00
Caja de madera 12x12x8 cm 1 $ 25.00 $ 25.00
Brazalete inflable 1 $ 140.00 $ 140.00
Tornillos 6 $ 0.20 $ 1.20
Pegamento para plsticos 1 $ 40.00 $ 40.00
Pegamento multiusos 1 $ 19.00 $ 19.00
Metro de termofit 11 $ 11.00 $ 121.00
Anexo C
112
Metro de manguera 1 $ 15.00 $ 15.00
Metro de alambre galvanizado 3 $ 5.00 $ 15.00
Clavija 1 $ 6.00 $ 6.00
Bote de pintura 100ml 1 $ 25.00 $ 25.00
Subtotal 30 $ 1,205.20 $ 1,326.20
COSTO DE LICENCIAS
Licencia Cantidad Precio unitario Total
Microsoft Office Office 2010
Hogar/Estudiantes
1 $1,799.00 $1,799.00
Microsoft Visual Studio 2010 1 $ 4, 999.00 $4,999.00
Code Warrior 10.2 1 Libre $ -
Microsoft Windows 7 Ultimate 1 $3,499.00 $3,499.00
Subtotal 4 $10,297.00 $10,297.00
COSTO DEL PERSONAL CALIFICADO
Personal calificado Das Sueldo por da Total
Ingeniero de diseo 30 $1,100.00 $33,000.00
Tcnico 40 $226.00 $9,040.00
Subtotal 70
$1,326.00
$42,040.00
TOTAL $59,863.50
Indiscutiblemente, tanto el uso de paquetera como el gasto que implica emplear personal
especializado, son lo que representan la mayor parte del costo del proyecto.
Sin embargo, si ste se produjera en masa, el costo individual representara la dcima parte
del total presentado.
Anexo D
113
Anexo D: Diagrama de clases de la interfaz grfica