ESCUELA POLITÉCNICA NACIONAL FACULTAD DE INGENIERÍA ELÉCTRICA Y ELECTRÓNICA DISEÑO Y CONSTRUCCIÓN DE UN GENERADOR DE SEÑALES DEL CORAZÓN PROYECTO PREVIO A LA OBTENCIÓN DEL TÍTULO DE INGENIERO EN ELECTRÓNICA Y CONTROL JUAN FERNANDO BASTIDAS ACUÑA juferbas@yahoo.com DIRECTOR: Dr. LUIS CORRALES lcorrales@epn.edu.ec Quito, septiembre de 2008 DECLARACIÓN Yo Bastidas Acuña Juan Fernando, declaro bajo juramento que el trabajo aquí descrito es de mi autoría; que no ha sido previamente presentada para ningún grado o calificación profesional; y, que he consultado las referencias bibliográficas que se incluyen en este documento. A través de la presente declaración cedo mis derechos de propiedad intelectual correspondientes a este trabajo, a la Escuela Politécnica Nacional, según lo establecido por la Ley de Propiedad Intelectual, por su Reglamento y por la normatividad institucional vigente. ____________________________ Bastidas Acuña Juan Fernando CERTIFICACIÓN Certifico que el presente trabajo fue desarrollado por Juan Bastidas, bajo mi supervisión. ________________________ Dr. Luis Corrales DIRECTOR DEL PROYECTO AGRADECIMIENTOS A todas aquellas personas que colaboraron en la realización del presente Proyecto de Titulación y en forma especial agradecer la guía y contribución brindada por mi director de tesis el Dr. Luis Corrales. DEDICATORIA Dedico este trabajo a mis padres, quienes con la confianza y ejemplo que me han dado a lo largo de la vida han hecho de mí una persona de bien y me han permitido culminar con éxito esta etapa de mi vida. A mi familia, que siempre me han ofrecido su respeto y compañía y han sido el motivo para salir adelante. A Andrea Gabriel por su amor, comprensión y ayuda incondicional en los últimos años CONTENIDO CAPITULO 1 INTRODUCCIÓN…………………………………………………………………………1 1.1 1.2 1.3 1.4 1.5 Análisis de las principales causas de muerte……………………………..1 1.1.1 Análisis según tipo de sexo………………………………………….2 1.1.2 Hipertensión arterial…………………………………………………..5 1.1.2.1 Causas…………………………………………………………6 1.1.2.1.1 Herencia……………………………………………..6 1.1.2.1.2 Sexo………………………………………………….6 1.1.2.1.3 Edad y raza………………………………………….7 1.1.2.1.4 Sobrepeso…………………………………………...7 1.1.2.2 Síntomas……………………………………………………….7 1.1.2.3 Tratamientos…………………………………………………...8 Anatomía del corazón…………………………………………………………9 1.2.1 Sistema de conducción auriculoventricular del corazón ……………………………………………………10 Fisiología cardiaca……………………………………………………………12 Electrocardiograma…………………………………………………………...14 1.4.1 Frecuencia cardiaca………………………………………………….17 1.4.2 Derivaciones electrocardiográficas…………………………………18 1.4.2.1Derivaciones del plano frontal………………………………18 1.4.2.2 Derivaciones aumentadas………………………………….19 1.4.2.3 Derivaciones del plano horizontal…………………..20 1.4.2.4 Eje eléctrico del corazón……………………………...21 Electrocardiografía……………………………………………………………23 CAPITULO 2 2.1 2.2 2.3 2.4 2.4 2.5 2.6 2.7 2.8 Diagrama de bloques del equipo…………………………………………...25 Diseño del módulo de generación………………………………………….26 2.2.1 Requerimientos del sistema…………………………………………26 Generador de señales………………………………………………………..26 Sistema de visualización…………………………………………………….29 Acondicionador de señales………………………………………………….31 Diseño y construcción del generador………………………………………35 2.5.1 Manejo de entradas…………………………………………………...35 2.5.2 Generación de señales……………………………………………….39 Diseño y construcción del visualizador……………………………………..40 2.6.1 Interfaz de visualización………………………………………………40 Diseño y construcción del acondicionador…………………………………41 2.7.1 Conversión d/a…………………………………………………………41 2.7.2 Filtros activos……………………………………………………………43 2.7.3 Ganancia del sistema………………………………………………….47 2.7.3.1 Acondicionamiento de señal………………………….48 Diagrama de generación y acondicionamiento de una señal....…………52 2.9 2.10 Diseño de fuentes……………………………………………………………..52 2.9.1 Fuente regulada de 5vdc………………………………………………52 2.9.2 Fuente regulada de ±12vdc……………………………………………55 Diseño de circuitos impresos………………………………………………….55 2.10.1 Etapa digital, visualización, conversión d/a y fuente de 5vdc..........57 2.10.2 Etapa análoga……………………………………………………………57 2.10.3 Etapa de acondicionamiento y filtrado final………………………….58 2.10.4 Fuente regulada de ±12vdc…………………………………………….59 CAPITULO 3 3.1 3.2 3.3 3.4 Desarrollo del software del módulo generador de señales del corazón…60 Desarrollo del software del generador………………………………………..61 3.2.1 Inicializar PIC16F877A…………………………………………………62 3.2.2 Lectura de tablas………………………………………………………...62 3.2.3 Interrupción externa…………………………………………………….63 3.2.4 Enviar datos al visualizador……………………………………………65 3.2.5 Generar señales……………………...…………………………………66 3.2.6 Seleccionar frecuencia cardiaca………………………………………67 3.2.7 Seleccionar ECG normal o anormal…………………………………..67 3.2.8 Cálculo de frecuencia cardiaca……………………………………….68 Desarrollo del software para el pic16f628a…………………………………..70 3.3.1 Inicializar pic16f628a…………………………………………………...72 3.3.2 Inicializar lcd……………………………………………………………..72 3.3.3 Escribir en lcd……………………………………………………………73 Digitalización de señales de voltajes precordiales………………………….73 CAPITULO 4 4.1 4.2 4.3 4.4 Equipo utilizado para las pruebas…………………………………………….80 Realización de la prueba………………………………………………………83 Resultados obtenidos…………………………………………………………..84 Cálculo de errores………………………………………………………………87 4.4.1 Error de frecuencia a 60bmp…………………………………………..87 4.4.2 Error de frecuencia a 80bmp…………………………………………..87 4.4.3 Análisis de v1 a 60bmp de un corazón sano………………………..87 4.4.4 Análisis de v2 a 60bmp de un corazón sano………………………..88 4.4.5 Análisis de v3 a 60bmp de un corazón sano………………………..89 4.4.6 Análisis de v4 a 60bmp de un corazón sano………………………..90 4.4.7 Análisis de v5 a 60bmp de un corazón sano………………………..91 4.4.8 Análisis de v6 a 60bmp de un corazón sano………………………..92 4.4.9 Análisis de v1 a 60bmp de un corazón enfermo……………………92 4.4.10 Análisis de v2 a 60bmp de un corazón enfermo……………………93 4.4.11 Análisis de v3 a 60bmp de un corazón enfermo……………………94 4.4.12 Análisis de v4 a 60bmp de un corazón enfermo……………………95 4.4.13 Análisis de v5 a 60bmp de un corazón enfermo……………………96 4.4.14 Análisis de v6 a 60bmp de un corazón enfermo……………………96 4.4.15 Análisis de v1 a 80bmp de un corazón sano………………………..97 4.4.16 Análisis de v2 a 80bmp de un corazón sano………………………..98 4.5 4.4.17 Análisis de v3 a 80bmp de un corazón sano………………………99 4.4.18 Análisis de v4 a 80bmp de un corazón sano……………………..100 4.4.19 Análisis de v5 a 80bmp de un corazón sano……………………..100 4.4.20 Análisis de v6 a 80bmp de un corazón sano……………………..101 4.4.21 Análisis de v1 a 80bmp de un corazón enfermo…………………102 4.4.22 Análisis de v2 a 80bmp de un corazón enfermo…………………103 4.4.23 Análisis de v3 a 80bmp de un corazón enfermo…………………104 4.4.24 Análisis de v4 a 80bmp de un corazón enfermo…………………104 4.4.25 Análisis de v5 a 80bmp de un corazón enfermo…………………105 4.4.26 Análisis de v6 a 80bmp de un corazón enfermo…………………106 Análisis y cálculo del promedio del porcentaje de error………….107 CAPITULO 5 5.1 5.2 Conclusiones…………………………………………………………………109 Recomendaciones…………………………………………………………...112 RESUMEN En este proyecto se diseña y construye un generador de las señales que produce el corazón humano en las seis derivaciones precordiales. Las señales producidas por este generador son para probar que un electrocardiógrafo está funcionando o ha sido reparado correctamente. Con este objetivo, primero se analizó el funcionamiento del corazón para determinar las formas de onda de las derivaciones y el plano eléctrico en el que se encuentra. Luego se diseñó y construyó un sistema micro procesado que genera las señales usando la técnica PWM para poder ser convertidas a análogas y así acondicionarlas a los voltajes requeridos por los electrocardiógrafos comerciales. El generador produce las señales generadas por un corazón sano y aquellos afectados con la patología más recurrente en el país que es la hipertensión arterial, cuyo efecto más común en las personas es el infarto al miocardio. Luego de realizadas pruebas al equipo empleando un electrocardiógrafo comercial, se obtuvo señales que en promedio tenían un error aproximadamente ±7.11%, error valorado por especialistas como aceptable. de PRESENTACIÓN El presente Proyecto de Titulación está dirigido al diseño e implementación de un sistema de generación de señales del corazón y está organizado en cinco capítulos, a continuación se da una breve descripción del contenido de cada uno de ellos. En el Capítulo 1 se realiza un análisis del comportamiento fisiológico del corazón, iniciando con la generación del impulso eléctrico que activa el ciclo cardiaco, se estudian las señales tomadas desde la derivaciones del triangulo de Eithoven y luego sus derivaciones en el plano horizontal que es el plano en el que se trabajará, es decir con las terminales precordiales. También se realiza un estudio de la principal causa de muerte en el país, que en base a la publicación del INEC en el 2006 muestra que es el infarto al miocardio. En el Capítulo 2 se hace referencia al diseño e implementación del hardware. Para esto se realiza una breve descripción del sistema y se definen los componentes que serán parte del mismo como los microcontroladores, amplificadores operacionales y reguladores de voltaje. Son descritas las principales características de operación y especificaciones técnicas de éstos elementos. Posteriormente se detalla el diseño de la generación de señales, comunicación con el visualizador, conversión D/A, amplificadores y filtrado activo y pasivo; y se describen los circuitos de la tarjeta electrónica que se encarga de la generación de las señales, su acondicionamiento y la alimentación. En el Capítulo 3 se definen las funciones del software para el microcontrolador generador de señales y del visualizador; en la primera parte se exponen las rutinas de programación del microcontrolador generador que tiene como funciones: el manejo de entradas y salidas, la comunicación con el visualizador y el manejo de las tablas de datos. La segunda parte explica las funciones del visualizador que son: la lectura del puerto de salida del generador e interpretar el código enviado para ser escrito en una pantalla LCD En el Capítulo 4 se detallan las pruebas y resultados realizados para comprobar el funcionamiento del sistema. Estas pruebas consisten básicamente en verificar la generación de las señales en un electrocardiógrafo comercial y verificar su amplitud y su frecuencia de generación, esta prueba fue realizada en el departamento de cardiopulmonar del Hospital Vozandes Quito. En este capítulo también se muestra las formas de onda obtenidas para un corazón sano y uno presentando un infarto al miocardio en las primeras horas de producido. Finalmente se calcula el error existente entre las señales generadas y las tomadas como estándar obteniendo un error que evaluado por especialistas está dentro de un rango aceptable. Para finalizar en el capítulo 5 se presentan las conclusiones recomendaciones obtenidas en el desarrollo del proyecto de titulación. y 1 CAPITULO 1 MARCO TEÓRICO 1 INTRODUCCIÓN La ciencia médica cuenta con aparatos de diagnostico, indispensables para poder diagnosticar de mejor manera a la gente que lo requiera. Este tipo de aparatos (llámese electrocardiógrafos, electroencefalógrafos, rayos x, etc.) son muy útiles para el médico. El electrocardiógrafo es un equipo que ayuda a visualizar las señales generadas por el corazón y mediante el electrocardiograma, que es el resultado que entrega este equipo, se puede hacer un análisis del estado del corazón. Estos equipos se ven afectados en su funcionamiento por fallas producidas por su uso o su manipulación constante y deben ser reparados. Pero, luego de realizada la reparación, como se puede afirmar de que el equipo esté funcionando correctamente. Si se piensa detenidamente, esta tarea se la podría realizar si se cuenta primeramente con un voluntario; luego, uno que genere una onda previamente conocida, lo cual no es fácil o práctico de lograrlo. Por esta razón, se ha visto la necesidad de contar con un generador de señales que simule el funcionamiento del corazón y genere señales que permitan comprobar si el equipo está o no reparado correctamente. Para dar una visión sobre la posible demanda que podría tener este equipo conviene revisar algunas estadísticas al respecto. 1.1 ANÁLISIS DE LAS PRINCIPALES CAUSAS DE MUERTE Las tablas siguientes tienen como fuente al Instituto Nacional de Estadísticas y Censos (INEC) publicadas en el artículo de causas de Mortandad en el 2006. 2 1.1.1 ANÁLISIS SEGÚN TIPO DE SEXO: En la Tabla 1.1 se muestra las principales causas de mortandad masculina, en la que, según realizado el censo, se ubica en tercer lugar la muerte por enfermedades cerebrovasculares con un porcentaje de 4.9%, seguida por las enfermedades isquémicas del corazón con un porcentaje igual de 4.9% y en quinto lugar las enfermedades hipertensivas con un 4.3%. Estos porcentajes se basan en una población estimada del 2006 de 6’523.631 y un total de defunciones de 32.775. PRINCIPALES CAUSAS DE MORTALIDAD MASCULINA LISTA CORTA DE AGRUPAMIENTO DE CAUSAS DE MUERTE (L.C. CIE-10) - 2006 POBLACIÓN ESTIMADA 2006 TOTAL DE DEFUNCIONES 32.775 TASA DE MORTALIDAD GENERAL (x 10.000 hab.) Nº Orden CODIGO L.C. CÓD. CIE-10 DETALLADA 1 64 X85-Y09 2 57 V00-V89 3 42 4 6.523.631 50,2 Número % Tasa AGRESIONES (HOMICIDIOS) 2.138 6,5 32,8 ACCIDENTES DE TRANSPORTE TERRESTRE 1.974 6,0 30,3 I60-I69 ENFERMEDADES CEREBROVASCULARES 1.622 4,9 24,9 35 I20-I25 ENFERMEDADES ISQUÉMICAS DEL CORAZÓN 1.606 4,9 24,6 5 46 J10-J18 INFLUENZA Y NEUMONÍIA 1.581 4,8 24,2 6 34 I10-I15 ENFERMEDADES HIPERTENSIVAS 1.395 4,3 21,4 7 26 E10-E14 DIABETES MELLITUS 1.277 3,9 19,6 INSUFICIENCIA CARDIACA, COMPLICACIONES Y ENFERMEDADES MAL DEFINIDAS 1.275 3,9 19,5 8 41 I50-I51 CAUSAS DE MUERTE 9 51 K70-K76 CIRROSIS Y OTRAS ENFERMEDADES DEL HÍGADO 1.224 3,7 18,8 10 55 P00-P96 CIERTAS AFECCIONES ORIGINADAS EN EL PERÍODO PERINATAL 1.000 3,1 15,3 11 09 C16 NEOPLASIA MALIGNA DEL ESTÓMAGO 868 2,6 13,3 12 53 N00-N39 ENFERMEDADES DEL SISTEMA URINARIO 854 2,6 13,1 13 20 C61 NEOPLASIA MALIGNA DE LA PRÓSTATA 707 2,2 10,8 14 47 J40-J47 ENFERMEDADES CRÓNICAS DE LAS VÍAS RESPIR. INFERIORES 637 1,9 9,8 15 63 X60-X84 LESIONES AUTOINFLINGIDAS INTENCIONALMENTE (SUICIDIO 602 1,8 9,2 16 07 B20-B24 ENFERMEDAD POR VIRUS DE LA INMUNODEFICIENCIA (VIH) 557 1,7 8,5 17 02 A15-A19 TUBERCULOSIS 498 1,5 7,6 18 24 C81-C96 NEOPLASIA MALIGNA DEL TEJIDO LINFÁTICO,HEMAT.Y AFÍN 432 1,3 6,6 19 60 W65-W74 AHOGAMIENTO Y SUMERSIÓN ACCIDENTALES 425 1,3 6,5 27 D50-D53, E40E64 5,8 20 88 99 R00-R99 DESNUTRICIÓN Y ANEMIAS NUTRICIONALES 380 1,2 RESTO DE CAUSAS 6.719 20,5 - CAUSAS MAL DEFINIDAS 3.331 10,2 51,1 Tabla 1.1: Censo de mortalidad masculina 3 En la Tabla 1.2 se muestra las principales causas de mortandad femenina, en la cual se destacan las enfermedades hipertensivas en el cuarto lugar con un porcentaje de 5.4%, seguida por insuficiencia cardiaca con un 5.1% y las enfermedades isquémicas del corazón en sexto lugar con un 4.1%. Estos porcentajes se basan en una población estimada del 2006 de 6’684.639 y un total de defunciones de 25.165. PRINCIPALES CAUSAS DE MORTALIDAD FEMENINA LISTA CORTA DE AGRUPAMIENTO DE CAUSAS DE MUERTE (L.C. CIE-10) - 2006 POBLACIÓN ESTIMADA 2006 TOTAL DE DEFUNCIONES 25.165 TASA DE MORTALIDAD GENERAL (x 10.000 hab.) Nº Orden CODIGO L.C. CÓD. CIE-10 DETALLADA 1 26 E10-E14 2 42 I60-I69 3 46 J10-J18 4 34 5 41 6.684.639 CAUSAS DE MUERTE 37,6 Número % Tasa DIABETES MELLITUS 1.697 6,7 25,4 ENFERMEDADES CEREBROVASCULARES 1.545 6,1 23,1 INFLUENZA Y NEUMONÍIA 1.507 6,0 22,5 I10-I15 ENFERMEDADES HIPERTENSIVAS 1.371 5,4 20,5 I50-I51 INSUFICIENCIA CARDIACA, COMPLICACIONES Y ENFERMEDADES MAL DEFINIDAS 1.274 5,1 19,1 ENFERMEDADES ISQUÉMICAS DEL CORAZÓN 6 35 I20-I25 1.024 4,1 15,3 7 55 P00-P96 CIERTAS AFECCIONES ORIGINADAS EN EL PERÍODO PERINATAL 802 3,2 12,0 8 53 N00-N39 ENFERMEDADES DEL SISTEMA URINARIO 792 3,1 11,8 9 09 C16 NEOPLASIA MALIGNA DEL ESTÓMAGO 728 2,9 10,9 10 18 C53-C55 NEOPLASIA MALIGNA DEL ÚTERO 724 2,9 10,8 11 51 K70-K76 CIRROSIS Y OTRAS ENFERMEDADES DEL HÍGADO 610 2,4 9,1 12 57 V00-V89 ACCIDENTES DE TRANSPORTE TERRESTRE 546 2,2 8,2 13 47 J40-J47 ENFERMEDADES CRÓNICAS DE LAS VÍAS RESPIR. INFERIORES 430 1,7 6,4 14 17 C50 NEOPLASIA MALIGNA DE LA MAMA 405 1,6 6,1 15 11 C22 NEOPLASIA MALIGNA DEL HÍGADO Y DE LAS VÍAS BILIARES 369 1,5 5,5 16 24 C81-C96 NEOPLASIA MALIGNA DEL TEJIDO LINFÁTICO,HEMAT.Y AFÍN 364 1,4 5,4 17 27 D50-D53, E40E64 DESNUTRICIÓN Y ANEMIAS NUTRICIONALES 358 1,4 5,4 18 06 A40-A41 SEPTICEMIA 308 1,2 4,6 302 1,2 4,5 298 1,2 4,5 RESTO 5.444 21,6 - CAUSAS MAL DEFINIDAS 3.001 11,9 44,9 19 56 Q00-Q99 MALFORMACIONES CONGENITAS,DEFORMID.Y ANOMALÍAS CROMOSÓMICAS 20 63 X60-X84 LESIONES AUTOINFLINGIDAS INTENCIONALMENTE (SUICIDIO 88 99 R00-R99 Tabla 1.2: Censo de mortalidad femenina 4 Los datos mostrados en las siguientes tablas tienen como fuente al Instituto Nacional de Estadísticas y Censos (INEC) en el artículo publicado en el 2006. En la Tabla 1.3 se muestra la causa de mortalidad general, siendo las enfermedades cerebrovasculares las que presentan un mayor porcentaje, con el 5.5% de un total de 57940 defunciones, y en el orden quinto se presentan las enfermedades hipertensivas (Hipertensión Arterial), con un porcentaje total de 4.8%, seguida de las enfermedades isquémicas del corazón con el 4.5%, tomado en relación a 57.940 defunciones del año 2006. PRINCIPALES CAUSAS DE MORTALIDAD GENERAL LISTA CORTA DE AGRUPAMIENTO DE CAUSAS DE MUERTE (L.C. CIE-10) 2006 TOTAL DE DEFUNCIONES 57.940 TASA DE MORTALIDAD GENERAL (x 10.000 hab.) Nº Orden CODIGO L.C. CÓD. CIE-10 DETALLADA CAUSAS DE MUERTE 43,2 Número % Tasa 1 42 I60-I69 ENFERMEDADES CEREBROVASCULARES 3.167 5,5 23,6 2 46 J10-J18 INFLUENZA Y NEUMONÍIA 3.088 5,3 23,0 3 26 E10-E14 DIABETES MELLITUS 2.974 5,1 22,2 4 34 I10-I15 ENFERMEDADES HIPERTENSIVAS 2.766 4,8 20,6 5 35 I20-I25 ENFERMEDADES ISQUÉMICAS DEL CORAZÓN 2.630 4,5 19,6 I50-I51 INSUFICIENCIA CARDIACA, COMPLICACIONES Y ENFERMEDADES MAL DEFINIDAS 2.549 4,4 19,0 6 41 7 57 V00-V89 ACCIDENTES DE TRANSPORTE TERRESTRE 2.520 4,3 18,8 8 64 X85-Y09 AGRESIONES (HOMICIDIOS) 2.357 4,1 17,6 9 51 K70-K76 CIRROSIS Y OTRAS ENFERMEDADES DEL HÍGADO 1.834 3,2 13,7 10 55 P00-P96 CIERTAS AFECCIONES ORIGINADAS EN EL PERÍODO PERINATAL 1.802 3,1 13,4 11 53 N00-N39 ENFERMEDADES DEL SISTEMA URINARIO 1.646 2,8 12,3 12 09 C16 NEOPLASIA MALIGNA DEL ESTÓMAGO 1.596 2,8 11,9 13 47 J40-J47 ENFERMEDADES CRÓNICAS DE LAS VÍAS RESPIR. INFERIORES 1.067 1,8 8,0 14 63 X60-X84 LESIONES AUTOINFLINGIDAS INTENCIONALMENTE (SUICIDIO 900 1,6 6,7 15 24 C81-C96 NEOPLASIA MALIGNA DEL TEJIDO LINFÁTICO,HEMAT.Y AFÍN 796 1,4 5,9 16 02 A15-A19 TUBERCULOSIS 774 1,3 5,8 17 27 D50-D53, E40-E64 DESNUTRICIÓN Y ANEMIAS NUTRICIONALES 738 1,3 5,5 18 18 C53-C55 NEOPLASIA MALIGNA DEL ÚTERO 724 1,2 5,4 19 20 C61 NEOPLASIA MALIGNA DE LA PRÓSTATA 707 1,2 5,3 20 07 B20-B24 ENFERMEDAD POR VIRUS DE LA INMUNODEFICIENCIA (VIH) 699 1,2 5,2 RESTO DE CAUSAS 13.206 22,8 - CAUSAS MAL DEFINIDAS 6.332 10,9 47,2 88 99 R00-R99 Tabla 1.3: Censo de mortalidad general 5 De las enfermedades descritas, se considera pertinente estudiar aparte las que se relacionan con el corazón. 1.1.2 HIPERTENSIÓN ARTERIAL La hipertensión arterial es el aumento de la presión arterial de forma crónica. Es una enfermedad que no da síntomas durante mucho tiempo y, si no se trata, puede desencadenar complicaciones severas como un infarto de miocardio, una hemorragia o trombosis cerebral, lo que se puede evitar si se controla adecuadamente. Las primeras consecuencias de la hipertensión las sufren las arterias, que se endurecen a medida que soportan la presión arterial alta de forma continua, se hacen más gruesas y puede verse dificultado el paso de la sangre. Los límites de presión normal sistólica [1] como diastólica [2] se muestran en la Tabla 1.4 y no se manifiesta en cambios electro fisiológico. CATEGORÍA SISTÓLICA (mmHg) DIASTÓLICA (mmHG) Optima Normal <120 <130 130-139 <80 <85 85-89 Normal Alta 140-159 Grado 1 Hipertensión ("leve) 140-149 Subgrupo: Limítrofe 160-179 Grado 2 Hipertensión ("moderada") 180t Grado 3 Hipertensión ("severa") 140t Hipertensión Sistólica Aislada 140-149 Subgrupo: Limítrofe 90-99 90-94 100-109 110t <90 <90 Tabla 1.4: Valores de presión arterial [1] SISTÓLICA: Significa que la cavidad ya sea aurícula o ventrículo se están contrayendo, también conocida como despolarización. [2] DIASTÓLICA: Significa que las cavidades se están relajando, también conocida como repolarización. 6 1.1.2.1 Causas Se desconoce el mecanismo de la hipertensión arterial más frecuente, denominada "hipertensión esencial", "primaria". En la hipertensión esencial no se han descubierto todavía las causas específicas, aunque se ha relacionado con una serie de factores que suelen estar presentes en la mayoría de las personas que la sufren. Conviene separar aquellos relacionados con la herencia, el sexo, la edad y la raza y por tanto poco modificables, de aquellos otros que se podrían cambiar al variar los hábitos, ambiente, y las costumbres de las personas, como: la obesidad, la sensibilidad al sodio, el consumo excesivo de alcohol, el uso de anticonceptivos orales y un estilo de vida muy sedentario. 1.1.2.1.1 Herencia: Cuando se transmite de padres a hijos se hereda una tendencia o predisposición a desarrollar cifras elevadas de tensión arterial. Se desconoce su mecanismo exacto, pero la experiencia acumulada demuestra que cuando una persona tiene un progenitor (o ambos) hipertensos, las posibilidades de desarrollar hipertensión son el doble que las de otras personas con ambos padres sin problemas de hipertensión. 1.1.2.1.2 Sexo: Los hombres tienen más predisposición a desarrollar hipertensión arterial que las mujeres hasta que éstas llegan a la edad de la menopausia. A partir de esta etapa la frecuencia en ambos sexos se iguala. Esto es así porque la naturaleza ha dotado a la mujer con unas hormonas protectoras mientras se encuentra en edad fértil, los estrógenos, y por ello tienen menos riesgo de padecer enfermedades cardiovasculares. Sin embargo, en las mujeres más jóvenes existe un riesgo especial cuando toman píldoras anticonceptivas. 7 1.1.2.1.3 Edad y raza: La edad es otro factor, por desgracia no modificable, que va a influir sobre las cifras de presión arterial, de manera que tanto la presión arterial sistólica o máxima como la diastólica o mínima aumentan con los años y lógicamente se encuentra un mayor número de hipertensos a medida que aumenta la edad. En cuanto a la raza, los individuos de raza negra tienen el doble de posibilidades de desarrollar hipertensión que los de raza blanca, además de tener un peor pronóstico. 1.1.2.1.4 Sobrepeso: Los individuos con sobrepeso están más expuestos a tener más alta la presión arterial que un individuo con peso normal. A medida que se aumenta de peso se eleva la tensión arterial y esto es mucho más evidente en los menores de 40 años y en las mujeres. La frecuencia de la hipertensión arterial entre los obesos, independientemente de la edad, es entre dos y tres veces superior a la de los individuos con un peso normal. No se sabe con claridad si es la obesidad por sí misma la causa de la hipertensión, o si hay un factor asociado que aumente la presión en personas con sobrepeso, aunque las últimas investigaciones apuntan a que a la obesidad se asocian otra serie de alteraciones que serían en parte responsables del aumento de presión arterial. También es cierto que la reducción de peso hace que desaparezcan estas alteraciones. 1.1.2.2 Síntomas La presión arterial elevada rara vez presenta síntomas. Estar nervioso o tenso, por ejemplo, no es sinónimo de tener la presión arterial elevada. La única manera de detectar la hipertensión en sus inicios es con revisiones periódicas. Mucha gente tiene la presión arterial elevada durante años sin saberlo. El 8 diagnóstico se puede realizar a través de los antecedentes familiares y personales, una exploración física y otras pruebas complementarias. 1.1.2.3 Tratamientos La hipertensión no puede curarse en la mayoría de los casos, pero puede controlarse. En general debe seguirse un tratamiento regular de por vida para bajar la presión y mantenerla estable. Las pastillas son sólo parte del tratamiento de la hipertensión, ya que el médico también suele recomendar una dieta para perder peso y medidas como no abusar del consumo de sal, hacer ejercicio con regularidad. Consejos para el paciente con hipertensión: x Reducir el peso corporal si se tiene sobrepeso. x Reducir el consumo de sal a 4-6 gramos al día; consumir menos productos preparados y en conserva. No obstante, existen pacientes que no responden a la restricción salina. x Reducir la ingesta de alcohol, que en las mujeres debe ser inferior a 140 gramos a la semana y en los hombres inferior a 210 gramos. x Realizar ejercicio físico, preferentemente pasear, correr moderadamente, nadar o ir en bicicleta, de 30 a 45 minutos, un mínimo de 3 veces por semana. x Reducir el consumo de café y no consumir más de 2-3 cafés al día. x Consumir alimentos ricos en potasio, como legumbres, frutas y verduras. x Abandonar el hábito de fumar. 9 Seguir una dieta rica en ácidos grasos poli saturados y pobre en grasas saturadas. Además de las medidas recomendadas, el hipertenso dispone de una amplia variedad de fármacos que le permiten controlar la enfermedad. El tratamiento debe ser siempre individualizado. Para la elección del fármaco, hay que considerar factores como la edad y el sexo del paciente, el grado de hipertensión, la presencia de otros trastornos (como diabetes o valores elevados de colesterol), los efectos secundarios y el coste de los fármacos y las pruebas necesarias para controlar su seguridad. Habitualmente los pacientes toleran bien los fármacos, pero cualquier fármaco anti hipertensivo puede provocar efectos secundarios, de modo que si éstos aparecen, se debería informar de ello al médico para que ajuste la dosis o cambie el tratamiento. El infarto al miocardio se produce al interrumpirse el flujo sanguíneo al corazón al verse afectadas las arterias, este tema será tratado a fondo en las arritmias. Los datos recopilados explican el porqué todo centro médico cuenta con un electrocardiógrafo. En la medicina existen muchos electrocardiógrafos, por lo cual se puede concluir que el equipo tendría demanda. 1.2 ANATOMÍA DEL CORAZÓN El corazón es el órgano principal del sistema circulatorio de la sangre, localizado en el tórax levemente a la izquierda del esternón. Se divide principalmente en dos partes que son el corazón izquierdo y el derecho, a esta división se la conoce como Septum cada uno conformado por una aurícula y un ventrículo. La circulación de la sangre se controla mediante cuatro válvulas: Tricúspide, Mitral, Pulmonar y Aórtica, las cuales, se encargan de permitir el paso de la sangre entre las cavidades al interior y al 10 exterior del corazón. El tamaño es aproximadamente el de un puño y las salidas y entradas de la sangre son las arterias y las venas respectivamente. En la Figura 1.1 se muestra las partes más relevantes que conforman al corazón. Figura 1.1: Anatomía del corazón 1.2.1 SISTEMA DE CONDUCCIÓN AURICULOVENTRICULAR DEL CORAZÓN Un latido cardíaco es una acción de bombeo que toma aproximadamente un segundo. A medida que se va acumulando sangre en las aurículas se produce una contracción en las mismas que impulsa la sangre a través de las válvulas Tricúspide y Mitral hacia las cavidades inferiores que se encuentran en reposo (ventrículos derecho e izquierdo). Esta contracción se origina a partir de un impulso eléctrico generado en el nodo Sinusal (SA) (denominado también el marcapasos). Las señales eléctricas enviadas por el nódulo SA se propagan por una vía de conducción eléctrica hasta el nodo auriculoventricular (AV), el cual, retrasa el impulso cardiaco hasta que los ventrículos estén llenos de sangre; después de cerrarse firmemente las válvulas tricúspide y mitral para impedir que la sangre retorne, el impulso eléctrico pasa del nodo AV al haz de His y el sistema de Purkinje (Figura 11 1.2), los cuales estimulan la contracción de los ventrículos y abren las válvulas pulmonar y aórtica, al mismo tiempo. Así el ventrículo derecho impulsa la sangre hacia los pulmones para oxigenarla y retorne hacia la aurícula izquierda para que luego fluya la sangre oxigenada desde el ventrículo izquierdo a otras partes del cuerpo. Cuando la sangre pasa a la arteria pulmonar y aorta, los ventrículos se relajan y las válvulas pulmonar y aórtica se cierran. Al reducirse la presión en los ventrículos se abren las válvulas tricúspide y mitral y el ciclo comienza de nuevo. Figura 1.2: Fisiología del corazón Un esquema de cómo se desplaza la sangre en un diagrama de bloques se ilustran en la Figura 1.3. 1- aurícula derecha 2- aurícula izquierda 3- ventrículo derecho 4- ventrículo izquierdo 5- pulmones 6- circulación 7- vena cava 8- vena pulmonar 9- arteria pulmonar 10- aorta 11- válvula tricúspide 12 12- válvula mitral 13- válvula pulmonar 14- válvula aórtica Figura 1.3: Diagrama de bloques de funcionamiento del corazón 1.3 FISIOLOGÍA CARDIACA Los movimientos de los diferentes órganos del cuerpo, incluyendo el de las extremidades son producidos por la excitación eléctrica de los músculos asociados a esas estructuras. Si no hay excitación eléctrica el musculo permanece relajado. La excitación de los músculos que forman el corazón es provocada por el sistema autónomo con el que cuenta este órgano, el cual se encarga de dar un pulso periódico para que inicie el ciclo de bombeo de la sangre. Estos potenciales se presentan debido a que en las células se generan corrientes eléctricas de muy baja intensidad como consecuencia de desplazamientos iónicos de Potasio (K+), Sodio (Na+), Cloro (Cl-) y Calcio (Ca++) que continuamente se están produciendo en un flujo continuo bidireccional a través de la membrana celular. La membrana celular se encuentra en estado de reposo (polarización Figura 1.4) si en el interior de la célula predominan los iones K+ mientras que en el exterior prevalecen los iones Na+, generando así una superioridad de cargas negativas en el interior (aproximadamente -90mV) y de positivas en el exterior. Figura 1.4: Estado de reposo celular 13 El impulso de excitación generado por la inestabilidad del potencial de reposo en células automáticas (nodo SA) o a partir de un estímulo externo sobre células no automáticas, hace disminuir el potencial de la membrana celular a un nivel de disparo de -70mV, la membrana deja pasar iones de Sodio (Na+) y cambia la polaridad interna hasta llegar a un nivel de +30mV. En este punto se genera la salida de iones Potasio (Ka+) y la entrada de iones cloro (Cl-) haciendo regresar el potencial a 0mV que se aprecia de mejor manera en la Figura 1.5, lo cual permite la entrada de iones calcio (Ca-) y la salida posterior de iones de potasio (Ka+) llevando a la célula a su repolarización [2] (aprox. -90mV). Figura 1.5: Despolarización media y completa de las células. Este impulso producido logra la contracción muscular y va desplazándose a través del corazón como se muestra en la Figura 1.6. Figura 1.6: Circulación del impulso eléctrico por el corazón El corazón está conformado por dos tipos de células: 14 x Células automáticas o de respuesta lenta (nodo SA) x Células no automáticas o de respuesta rápida (masa muscular) La diferencia fundamental entre estas células se basa en que las primeras poseen un potencial de reposo inestable que de forma automática va a despolarizarse [1] y que al alcanzar un potencial de umbral, generan un potencial de acción que va a transmitirse a las células vecinas. Por el contrario, las células no automáticas poseen un potencial de reposo estable y necesitan de un estímulo externo que lo sitúe en el potencial de umbral para posteriormente generar un potencial de acción (Figura 1.7). Figura 1.7: Tipos de células cardiacas 1.4 ELECTROCARDIOGRAMA El electrocardiograma es la gráfica resultante de la actividad eléctrica cardiaca, la cual es adquirida a través del electrocardiógrafo. Las deflexiones obtenidas son interpretadas de acuerdo a su amplitud y duración tomando como referencia la cuadricula del papel en el cual se imprime el electrocardiograma. Este papel esta milimetrado de manera que el tiempo se mida sobre el eje de abscisas y la amplitud 15 sobre el de ordenadas; cada cinco milímetros (5 cuadros pequeños), aparece una línea más gruesa conformando cuadros de 5mm de lado (Figura 1.8). La velocidad del papel es de 25 mm/seg y por tanto cada milímetro en el eje de abscisas supone 0,04 seg y cada 5mm representa 0,2 segundos. Cada milivoltio (mV) registrado se traduce en un desplazamiento de la aguja de 10 mm en el eje de ordenadas. Figura 1.8: Papel milimetrado para impresión de electrocardiogramas Las ondas del corazón están formadas por deflexiones positivas o negativas. Una onda puede ser positiva o negativa con relación a la línea isoeléctrica (cero voltios). En la Figura 1.9 se muestra el trazado de un electrocardiograma que es considerado como estándar. En el corazón hay una parte donde no hay actividad eléctrica, entonces en el trazado del papel se interpreta que está en línea isoeléctrica. Cuando la deflexión está por encima de la línea isoeléctrica (ondas P, R y T) entonces esa onda es positiva; por el contrario si la línea está por debajo (ondas Q y S) la onda es negativa. 16 Figura 1.9: Forma de onda estándar del electrocardiograma x Onda P: Es la deflexión producida por la despolarización auricular. Es una onda redondeada con una amplitud normal no mayor de 0.25mV y una duración entre 60ms y 100ms. El eje de una onda P en el plano frontal bajo condiciones normales está entre 30 y 60º. x Intervalo PR (PQ): Se denomina así al intervalo desde el inicio de la onda P al comienzo del complejo QRS cualquiera que sea su primera deflexión, suele ser isoeléctrico. En los adultos su valor normal va entre 120 y 200 ms. Es reflejo del tiempo de conducción auriculoventricular (AV) que incluye el retardo fisiológico a través del nodo AV. Su duración disminuye con el aumento de la frecuencia cardiaca. Este intervalo es producido por la despolarización del ventrículo derecho x Complejo QRS: Corresponde a la contracción ventricular. En adultos su intervalo normal va entre 60 y 100 ms. x Segmento ST: Comprende desde el fin del complejo QRS (punto J) hasta el inicio de la onda T. Se debe tener en cuenta su relación con la línea de base. 17 Tiene valor patológico si hay desniveles mayores a 1 mm. Debido a que no hay mayor cambio de potencial durante esta fase, el segmento ST suele ser isoeléctrico en los electrocardiogramas normales. x Onda T: Corresponde con la repolarización (relajación) ventricular y aparece al final del segmento ST. La forma de la onda T es redondeada pero asimétrica, por lo general la rama ascendente de la T suele ser de inscripción lenta mientras que la descendente busca la isoeléctrica de forma rápida. La amplitud de la onda T es bastante variable de unas a otras derivaciones, aunque nunca debe exceder de 0.6mV. x Intervalo QT: El intervalo QT se mide desde el comienzo del complejo QRS hasta el final de la onda T. Se relaciona, dentro de ciertos límites con la duración de la despolarización y de la repolarización de las aurículas y los ventrículos. El intervalo QT a veces no indica con precisión el tiempo de recuperación de los ventrículos, su duración habitualmente es de 0.38 segundos a 0.44 segundos. Sin embargo, varía de acuerdo a la frecuencia cardiaca. Bazett propuso una fórmula que permite calcular el intervalo QT corregido en cuanto a la frecuencia cardíaca: QTc= QT/RR donde QTc es el intervalo QT corregido, QT es el intervalo QT y RR es el intervalo medido entre dos picos R de dos ondas ECG consecutivas. 1.4.1 FRECUENCIA CARDIACA El tiempo que existe entre dos ondas R sucesivas sirve para calcular la frecuencia cardiaca, parámetro que define la rapidez con la que se expande el impulso eléctrico del corazón. La frecuencia es considerada normal si está entre 60 y 100 latidos por minuto. 18 Recordando que un segundo equivale a 5 cuadros de 5mm (cuadros grandes), luego en un minuto habrá 300 cuadros grandes y 1500 cuadros de 1mm (cuadros pequeños), existen varios métodos para medir este parámetro como son: x Método estándar: consiste en dividir 300 entre el número de cuadros de 5mm que hay entre dos ondas R. x Método de los 1500: consiste en dividir 1500 entre el número de cuadros de 1mm que existen entre dos ondas R. x Método del muestreo: se divide 60000 (un minuto tiene 60000 milisegundos) entre la longitud en milisegundos que hay entre dos ondas R consecutivas. 1.4.2 DERIVACIONES ELECTROCARDIOGRÁFICAS La disposición de los electrodos sobre el cuerpo del paciente durante el registro de ECG es denominada derivación, un electrocardiograma completo está compuesto por 12 derivaciones que pueden ser clasificadas dependiendo de su posición en el cuerpo y del tipo de polaridad utilizada. 1.4.2.1 Derivaciones del plano frontal Las derivaciones bipolares son tres, cada una de ellas corresponde a dos electrodos aproximadamente equidistantes al corazón. Fueron desarrolladas por Willem Einthoven (Figura 1.10). x Derivación I (DI): diferencia de potencial entre el brazo derecho (polo negativo) y el izquierdo (polo positivo). El eje de la derivación es 0º. 19 x Derivación II (DII): diferencia de potencial entre el brazo derecho (polo negativo) y la pierna izquierda (polo positivo). El eje de la derivación es +60º. x Derivación III (DIII): diferencia de potencial entre el brazo izquierdo (polo negativo) y la pierna izquierda (polo positivo). El eje de la derivación es +120º o -60 º. Figura 1.10: Derivaciones del electrocardiograma 1.4.2.2 Derivaciones aumentadas: En este grupo, dos de las extremidades se conectan mediante resistencias eléctricas al polo negativo del amplificador, mientras el polo positivo se conecta con otra resistencia a la tercera extremidad (Figura 1.11). Fueron desarrolladas por Wilson y Goldberger. x aVR: polo positivo en el brazo derecho. El eje de la derivación es 210º (–150º). x aVL: polo positivo en el brazo izquierdo. El eje de la derivación es -30º. x aVF: polo positivo en la pierna izquierda. El eje de la derivación es +90º. 20 Figura 1.11: Derivaciones aumentadas del electrocardiograma 1.4.2.3 Derivaciones del plano horizontal Las derivaciones precordiales son positivas y usan el centro del campo eléctrico del corazón como punto negativo. El electrodo se coloca en la superficie anterior del tórax, encima del corazón, como polo positivo (Figura 1.12), mientras el polo negativo, se conecta mediante resistencias eléctricas provenientes de los electrodos en las extremidades. Estas derivaciones son: x V1: cuarto espacio intercostal. Borde derecho del esternón. x V2: cuarto espacio intercostal. Borde izquierdo del esternón. x V3: quinto espacio intercostal. Línea media clavicular. x V4: entre V3 y V5 x V5: quinto espacio intercostal. Línea axilar anterior. x V6: quinto espacio intercostal. Línea media axilar. 21 Figura 1.12: Derivaciones en el plano horizontal 1.4.3 EJE ELÉCTRICO DEL CORAZÓN El eje eléctrico puede definirse como el vector resultante del conjunto de la actividad eléctrica de cada ciclo cardiaco y representa la resultante eléctrica determinada por la despolarización de ambos ventrículos. Es de gran utilidad clínica, ya que orienta en el diagnostico electrocardiográfico. Su colocación entre 0o y 90o se considera normal (ver la Figura 1.13); aunque existen electrocardiogramas patológicos con eje eléctrico normal, su desviación es indicación de alguna patología. Se determina mediante la valoración de las seis derivaciones del plano frontal, permitiéndose su cálculo con una variación de ± 15o sin existir ningún sistema que permita mayor precisión en su determinación. Figura 1.13: Eje eléctrico del corazón 22 Después de la inspección de las seis derivaciones del plano frontal, se decide en que derivación la suma algebraica de sus deflexiones se aproxima a cero. En la Figura 1.14a se observa que la derivación en la que la suma algebraica de sus deflexiones, teniendo en cuenta que a las ondas Q y S se les asigna un valor negativo y a la onda R positivo, es +3, mientras que en la Figura 1.14b el resultado del cálculo sería igual a cero. Una vez identificada la derivación con deflexiones que sumen cero o cerca de cero, también llamada derivación isodifásica [3], se sabe que el eje eléctrico se localiza a 90o de dicha derivación Figura 1.14a: Eje eléctrico con resultado +3 Figura 1.14b: Eje eléctrico con resultado 0 En la Figura 1.14a se observa que la derivación DII (con electrodo explorador a +60o) es isodifásica; por lo tanto el eje eléctrico se localizará a 90o de ella, en una u otra dirección y se encontrará en aVL (-30o) o a +150o. La inspección de aVL dará la clave definitiva: si es predominantemente positiva, el eje eléctrico se localizará a -30o; y si es predominantemente negativa se localizara a 150o. En los casos en los que la suma algebraica no sea cero o sea que no haya una derivación isodifásica, se identificará el que más se aproxime a cero, el eje se localizará aproximadamente a 90o de una de ellas. Una vez identificada se procede a corregir su localización definitiva: si la derivación original era más positiva que [3] ISODIFÁSICA: El eje tomado como referencia, se ubica a 90º de dicho eje. 23 negativa, el eje se localizará 15o más cerca, mientras que si fuese más negativa que positiva, el eje se localizará 15omás lejos. Para calcular el eje eléctrico se toma en cuenta al complejo QRS en el cual se toma en cuenta la suma algebraica del valor en milímetros de los puntos Q, R y S de las siguientes señales: x Derivación bipolar I x Derivación monopolar aVF Un ejemplo de cálculo de eje eléctrico se muestra en la Figura1.15 siguiente: Figura 1.15: Cálculo de eje eléctrico. 1.5 ELECTROCARDIOGRAFÍA La electrocardiografía es el estudio de la actividad eléctrica del corazón que representa los cambios en el potencial de acción ocurridos durante el ciclo cardiaco; 24 estos cambios son descritos como una serie de vectores que indican la dirección de la despolarización celular en cada una de las cavidades cardiacas; por ello, el análisis de la secuencia de propagación del impulso hace factible la deducción del comportamiento electro fisiológico de las estructuras del corazón y de posibles anormalidades. El registro de dicha actividad se ve representado por el desplazamiento del impulso eléctrico que muestra una serie de deflexiones en la medida en la que el impulso cardiaco se propaga y es obtenida a través de aparatos llamados electrocardiógrafos, los cuales, son conectados al paciente mediante cables unidos a electrodos de superficie ubicados sobre el cuerpo, según normas establecidas, llamadas derivaciones. La señal electrocardiográfica puede interpretarse de acuerdo a la derivación con la que es captada, ya que cada una de estas, representa la lectura de la magnitud y dirección de los vectores del potencial de acción desde distintos lugares de referencia. Tomando todo lo antes mencionado se realizará un sistema que genere una señal tomada como estándar en el plano horizontal del corazón y además una señal producida por un corazón presentando un infarto en las primeras horas de producido el mismo. 25 CAPITULO 2 DISEÑO Y CONSTRUCCIÓN DEL HARDWARE El objetivo del presente capítulo es describir el diseño del hardware construido, así como las características del equipo utilizado y la función de cada uno de ellos. 2.1 DIAGRAMA DE BLOQUES DEL EQUIPO El proyecto a diseñarse es un generador de señales del corazón que produce los voltajes de las terminales precordiales en el plano horizontal. El hardware del módulo se lo puede resumir mediante el siguiente diagrama de bloques (Figura 2.1): Figura 2.1: Diagrama de bloques del módulo 26 2.2 DISEÑO DEL MÓDULO DE GENERACIÓN El módulo a diseñar debe cumplir con las funciones de generar las señales producidas por el corazón. Las señales a su salida deben tener valores que van en el orden de las unidades de milivoltios. Para el diseño del módulo se deben considerar elementos para acondicionar las señales que tengan un coeficiente bajo de admisión de ruido. Para la generación se necesita un microprocesador que tenga la capacidad de trabajar con señales de frecuencias altas y posea puertos de entrada salida suficientes para soportar los requerimientos del sistema. 2.2.1 REQUERIMIENTOS DEL SISTEMA Entrada de pulsantes para seleccionar la operación que se desea realizar. Salida de señales PWM, un puerto para cada una frecuencia cardiaca, seis señales para cada ritmo cardiaco. Un visualizador que muestre al exterior la función que se encuentra realizando el módulo. Acondicionador de señales para que las salidas estén en el orden antes mencionados. 2.3 GENERADOR DE SEÑALES Esta etapa necesita de entradas que se activen cuando se seleccione la opción, por lo tanto las entradas seleccionadas serán pulsantes. Se necesita de un microcontrolador para manejar dichas entradas y tenga dos puertos más para la 27 generación de las señales PWM. Además que tenga un puerto para enviar datos a un sistema de visualización. Análisis de requerimientos: x Se necesitan seis entradas de pulsantes que realicen las siguientes funciones: o Encendido o Apagado o Selección de generar un corazón sano o Selección de generar un corazón enfermo o Selección de frecuencia a 60BMP o Selección de frecuencia a 80BMP Para que sea identificado se necesitaría que cada uno genere una interrupción para que puedan ser leídos, por lo tanto se implementa un sistema digital que ayude a que, cada vez que se presione un pulsante, se genere una interrupción en común. x El microprocesador debe contar por lo menos con cuatro puertos empleados para: o Lectura de pulsantes o Generación de señales PWM para una frecuencia cardiaca de 60BMP o Generación de señales PWM para una frecuencia cardiaca de 80BMP o Enviar datos al sistema de visualización Se necesita que trabaje con una frecuencia de oscilación de 20MHz para realizar las operaciones en un tiempo pequeño que no afecte a la generación 28 de las señales. Además de una memoria que pueda abarcar a todo el software con el que funcionará el sistema. Los requisitos identificados apuntaron a un microprocesador de la familia de 16F de los que cumplen con un mínimo de cuatro puertos de entrada/salida, una alta capacidad de memoria. De los microprocesadores analizados y por su facilidad de conseguir en el país se ha seleccionado al microcontrolador PIC16F877A, las principales características de este elemento son: o Voltaje de alimentación de corriente continua de 5Vdc con una variación de 3 a 5.5Vdc, o Temperatura de operación que va de -55 a +125ºC o Potencia máxima de disipación de 1W o Máxima corriente de 250mA. o Puede trabajar hasta una frecuencia con un cristal interno que va desde 4MHz hasta 48kHz. o Memoria flash de 8KB, memoria de datos de 368KB y una memoria EEPROM de 256KB o Interrupciones: 15 o Puertos de entrada salida cinco o Timmers: 3 El datasheet del microcontrolador PIC16F877A se muestra en el Anexo 1. Tiene un empaquetamiento tipo SOIC de 40 pines, los cuales se muestran en la Figura 2.2. 29 Figura 2.2: Microcontrolador PIC16F877A 2.4 SISTEMA DE VISUALIZACIÓN Este sistema se encargará de realizar una interfaz visual que muestre al usuario la función que se encuentra realizando el generador. También debe contar con una pantalla y un microprocesador que se encargue de traducir el código enviado desde el generador para mostrarlo en la pantalla. Análisis de requerimientos: o Pantalla tipo LCD que tenga al menos dos líneas para mostrar el tipo de corazón que se está simulando (normal o con anomalía) y la frecuencia cardiaca. o Microprocesador para lectura de código del generador y manejo del LCD. Para la lectura del puerto se necesita de un puerto y para el manejo de LCD se necesita de otro puerto, por lo tanto se requiere de un microprocesador que posea 2 puertos. 30 x LCD. De las pantallas comerciales la que se ajusta a los requerimientos del sistema son: una de dos líneas con dieciséis caracteres cada una. Por tanto se escoge el LCD LM016L cuyo esquema se muestra en la Figura 2.3. Figura 2.3: LCD LM016L x El microprocesador perteneciente a la familia 16F que cumple con estos otros requerimientos del sistema es el PIC16F628A, seleccionado estar comercialmente disponible y sus características de memoria y funcionamiento con o sin cristal de oscilación lo que facilita el diseño del hardware. La características del microprocesador se muestran a continuación: o Voltaje de alimentación de corriente continua de 5Vdc con una variación de 3 a 5.5Vdc, o Temperatura de operación que va de -40 a +125ºC o Potencia máxima de disipación de 0.8W o Máxima corriente de 250mA. o Puede trabajar hasta una frecuencia que va desde DC hasta 20MHz. o Memoria flash de 2KB, memoria de datos de 224KB y una memoria EEPROM de 128KB o Interrupciones: 10 o Puertos de entrada salida: 2 o Timmers: 3 x El datasheet del microcontrolador PIC16F628A se muestra en el Anexo 2. 31 Tiene un empaquetamiento tipo SOIC de 18 pines, los cuales se muestran en la Figura 2.3. Figura 2.3: Microcontrolador PIC16F628A 2.4 ACONDICIONADOR DE SEÑALES Para realizar esta fase se debe primeramente convertir la señal a análoga, luego filtrarla, para luego amplificarla al nivel de salida deseada, como se muestra en la Figura 2.4 siguiente. Figura 2.4: Diagrama de acondicionamiento de señales Esta etapa está dividida en las siguientes fases: o Conversión D/A o Filtros activos o Amplificadores diferenciales o Filtros pasivos o Amplificadores inversores 32 x Conversión D/A, para convertir las señales digitales PWM a análogas se utiliza un convertidor del tipo RC formado como su nombre lo indica por una resistencia y un capacitor. Esta conversión se basa en tomar el valor promedio en DC del tiempo de duración en alto de la señal PWM, obteniéndose un valor promedio a la salida, calculado mediante la siguiente ecuación: Vdc CU * 5V Ecuación 2.1: Ecuación de conversor D/A Donde CU es el porcentaje del valor en alto con respecto al periodo que tiene la señal PWM. x Filtro Activo. Al tratarse de señales que tienen un valor pequeño en amplitud y frecuencia, se necesita de un filtro que permita el paso de una determinada banda de frecuencias. Las frecuencias cardiacas generadas son de 1 Hz y de 1.33Hz, pero poseen componentes que llegan a valores aproximados de 70Hz, calculados a partir de las formas de onda de los voltajes generados por el corazón en el plano horizontal, como se muestra en la Figura 2.5, y de debe permitir el paso de todas las componentes para formar la señal final. Por lo tanto se emplearan filtros pasa-bajos. Figura 2.5: Voltaje de la terminal precordial V1 33 Un filtro adecuado para eliminar el ruido de estas señales es el filtro Butterworth que puede ser de primero, segundo o tercer orden. De los mencionados se seleccionó un filtro activo Butterworth de segundo orden para tener una atenuación de -40dB de las señales superiores a la de corte. x Amplificador diferencial. Este tipo de amplificador se utiliza en modo de rechazo en modo común (CMMR) que es una de las ventajas que poseen los amplificadores operacionales y además de que se le puede dar una ganancia menor a uno que es lo que se desea para tener la amplitud de las señales a los valores deseados. La desventaja que tienen los amplificadores operacionales es la ganancia máxima recomendada por el fabricante que es de 50 veces. Debido a la conversión D/A de una señal Positiva y al necesitar que a la salida esta señal tenga un valor tanto positivo como negativo por la despolarización y repolarización de las células, como se vio anteriormente, es necesario sumar un valor negativo a la señal generada. x Filtros pasivos. Este tipo de filtro se lo emplea para tener una segunda etapa de filtrado debido al uso de potenciómetros, estos generan ruido que contaminará a la señal generada. El tipo de filtro empleado al igual que en la fase anterior será un pasa-bajos con una frecuencia igual a la anterior, calculada de la misma forma. x Amplificador inversor. Utilizado para dar la ganancia final al sistema. No se puede implementar un amplificador no inversor debido a que no trabaja con ganancias menores a 1, por esta razón la señal generada debe ser invertida para obtener a la salida la forma de onda deseada. 34 Debido a la ganancia de los amplificadores se ve la necesidad de aumentar una etapa de amplificación, de tal modo que el diagrama final de acondicionamiento quedará de la siguiente forma: Figura 2.5: Diagrama final de acondicionamiento de señales Para la implementación de los filtros se necesita de un amplificador operacional, el cual será seleccionado de acuerdo a los requerimientos del acondicionador y los niveles de voltaje a la salida, tomando en cuenta admisión de ruido y el coeficiente CMMR. Un amplificador que cumple con los requisitos es el TL084 el cual presenta las siguientes características eléctricas: x Tipo de entradas: JFET. x Impedancia de entrada/salida: Alta. x Admisión de ruido: Bajo. x Niveles de voltaje de alimentación de ±5Vdc a ±15Vdc. El datasheet del amplificador operacional TL084 se muestra en el Anexo 3. Tiene un empaquetamiento DIP tipo SOIC de 14 pines en el cual están implementados 4 amplificadores operacionales. La distribución de pines y la función se muestran en la Figura 2.6: 35 Figura 2.6: Amplificador operacional TL084 En la Tabla 2.1 se muestran las características especiales del amplificador operacional TL084, el dato más importante por el que fue seleccionado es el ruido equivalente de entrada de voltaje que es de 4 nV/¥Hz para una resistencia de carga de 20 a una frecuencia de 10Hz a 10KHz. Tabla 2.1: Características especiales del TL084 2.5 DISEÑO Y CONSTRUCCIÓN DEL GENERADOR Como se vio anteriormente las etapas que conforman el generador es el manejo de entradas y la generación de señales, estas dos etapas se detallan a continuación. 2.5.1 MANEJO DE ENTRADAS Como se mencionó, se necesita de un sistema digital que produzca un pulso positivo para activar la interrupción cada vez que se presione un pulsante. Este sistema se 36 basa en compuertas digitales NAND y OR, cuyas tablas de verdad se muestran a continuación: A 0 0 1 1 NAND B 0 1 0 1 C 1 1 1 0 A 0 0 1 1 OR B 0 1 0 1 C 0 1 1 1 Tabla 2.2: Tablas de verdad de compuertas utilizadas. Al existir solo una interrupción externa en el microcontrolador a través del bit”0” del puerto B (RB0) y seis entradas que sensar, se emplea un arreglo de compuertas lógicas para provocar la interrupción formada por: compuertas OR (74LS32) y compuertas NAND (74LS00). La respuesta de un pulsante es discreta (ON – OFF) y se deben colocar resistencias limitadoras de corriente entre la alimentación y el pulsante normalmente abierto para obtener una respuesta en reposo de 1L y activado de 0L. Por ser un elemento mecánico que produce ruido se deben colocar elementos atenuadores de ruido, en este caso capacitores recomendados para el microcontrolador con un valor de 0.1uf. El circuito para manejar las entradas se basa en comparar los pulsantes de dos en dos mediante una compuerta NAND, para luego ser sumadas con una compuerta OR como se muestra en la Figura 2.7: 37 R2 R3 R4 R5 R6 R7 10k 10k 10k 10k 10k 10k RB1 RB2 RB3 RB4 RB5 RB6 C4 C5 C6 C7 C8 C9 100n 100n 100n 100n 100n 100n U2:A RB1 RB2 U2:C 1 2 U3:A U2:B RB4 8 9 RB6 7400 RB3 10 RB5 3 U3:B 7400 4 1 6 4 3 6 5 RB0 2 5 7432 7432 7400 Figura 2.7: Manejo de entradas Con este arreglo se tiene a la salida un valor de 0L cuando ningún pulsante se encuentra presionado y un valor de 1L cuando se presiona algún pulsante. De esta manera se tiene la entrada deseada para la interrupción externa del microcontrolador. A continuación se muestra la comprobación del funcionamiento descrito mediante la tabla de verdad. 38 A 0 0 0 0 0 0 0 0 0 0 0 0 B 0 0 0 0 0 0 0 0 0 0 0 0 C 0 0 0 0 0 0 0 0 1 1 1 1 D 0 0 0 0 1 1 1 1 0 0 0 0 E 0 0 1 1 0 0 1 1 0 0 1 1 F 0 1 0 1 0 1 0 1 0 1 0 1 A*B 1 1 1 1 1 1 1 1 1 1 1 1 C*D 1 1 1 1 1 1 1 1 1 1 1 1 E*F 1 1 1 0 1 1 1 0 1 1 1 0 (A+B)(+B)(A+B) A B C D E F A*B C*D E*F (A+B)(+B)(A+B) 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 0 1 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 Tabla 2.3: Tabla de verdad de circuito digital 39 2.5.2 GENERACIÓN DE SEÑALES La generación de señales la realiza el microcontrolador PIC16F877A, que opera con un cristal de oscilación de 20MHz. Esta frecuencia se escogió por ser la más alta a la que puede trabajar el microcontrolador y es lo que se necesita para no perder resolución del sistema durante la generación como se verá más adelante. Las señales del corazón generadas se reproducen por dos puertos del microcontrolador, tal como se muestra en la Figura 2.8, los cuales son: x Puerto D para la generación a 60BMP x Puerto C para la generación a 80BMP La generación a 60BMP presenta la siguiente configuración: RD0 para V1, RD1 para V2, RD2 para V3, RD3 para V4, RD4 para V5, RD5 para V6; de igual manera para 80BMP se tiene: RC0 para V1, RC1 para V2, RC2 para V3, RC3 para V4, RC4 para V5, RC5 para V6. C2 15p C1 U1 X1 13 14 1 20MHz RA0 RA1 RA2 RA3 15p R1 RA5 10k C3 100n 2 3 4 5 6 7 8 9 10 OSC1/CLKIN OSC2/CLKOUT MCLR/Vpp/THV RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RE0/AN5/RD RC2/CCP1 RE1/AN6/WR RC3/SCK/SCL RE2/AN7/CS RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A Figura 2.8: Generación de señales 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30 INTER ENCENDER APAGAR CORAZON SANO CORAZON ENFERMO 60BMP 80BMP V1 (80BMP) V2 (80BMP) V3 (80BMP) V4 (80BMP) V5 (80BMP) V6 (80BMP) V1 (60BMP) V2 (60BMP) V3 (60BMP) V4 (60BMP) V5 (60BMP) V6 (60BMP) 40 2.6 DISEÑO Y CONSTRUCCIÓN DEL VISUALIZADOR Esta etapa como se vio anteriormente consta de una pantalla LCD y de un microcontrolador el cual fue seleccionado en el análisis, siendo este el PIC16F628A. El diseño de las fases se muestra a continuación: 2.6.1 INTERFAZ DE VISUALIZACIÓN Para el modo de operación del PIC16F877A (generador de señales del corazón) se utiliza un microcontrolador PIC16F628A el cual se encarga de leer el dato enviado desde el puerto A del microcontrolador PIC16F877A acopladas con resistencias de 330 para disminuir la corriente. Este dato es mostrado en un LCD. La configuración utilizada para este sistema se muestra en la Figura 2.9 siguiente: LCD1 LM016L RB0/INT RB1/RX/DT RB2/TX/CK RB3/CCP1 RB4 RB5 RB6/T1OSO/T1CKI RB7/T1OSI 6 7 8 9 10 11 12 13 D0 D1 D2 D3 D4 D5 D6 D7 RA0 RA1 RA2 RA3 RA5 RS RW E 330 330 330 330 330 4 5 6 17 18 1 2 3 7 8 9 10 11 12 13 14 RA5/MCLR RA0/AN0 RA1/AN1 RA2/AN2/VREF RA3/AN3/CMP1 RA4/T0CKI/CMP2 1 2 3 4 RA7/OSC1/CLKIN RA6/OSC2/CLKOUT VSS VDD VEE DEL PUERTO A DEL PIC16F877A U1 16 15 RV1 10k PIC16F628A VDD=VSS VSS=VDD Figura 2.9: Esquema de visualización Se utiliza al LCD en el modo de 4bits empleando los pines del 4 al 8 del puerto B del microcontrolador, la línea de RW del LCD de control es conectada a la referencia debido a que solo se realiza la función de escritura y por las líneas restantes del pórtico B del microcontrolador 16F628A se controlan los pines de habilitación y la 41 línea de código de instrucción. Por el pórtico A se leen los pines del microcontrolador 16F877A. El contraste es controlado mediante un potenciómetro de 10K con el cual se controla el voltaje aplicado al pin VEE del LCD. 2.7 DISEÑO Y CONSTRUCCIÓN DEL ACONDICIONADOR Las distintas fases de esta etapa se muestran a continuación: 2.7.1 CONVERSIÓN D/A Cada salida cuenta con conversores D/A basados en un filtro RC pasa bajos de distintos valores de frecuencia de corte de acuerdo a la forma de onda de cada señal de voltaje. A pesar de que son iguales en período, porque son generadas simultáneamente, están formadas por un conjunto de señales de una frecuencia mayor a la deseada. La configuración del filtro pasivo pasa bajos se muestra en la Figura 2.10, un ejemplo de cálculo para la frecuencia de 70Hz correspondiente al voltaje de la terminal precordial 1 (V1) a una frecuencia cardiaca de 60BMP (latidos por minuto) de un corazón sano, se muestra a continuación: R ENTRADA DIGITAL SALIDA ANALOGA C Figura 2.10: Conversor digital-análogo 42 1 RC 1 f 2SRC Asumimir C 0.68uf 1 1 R 2SfC 2 * S * 70 * 0.68e 6 R 3343.67: Wc La forma de determinar la frecuencia de corte correspondiente a la componente de mayor frecuencia se obtiene de relacionar el período de la señal con una componente. Para esto se recurre a la Figura 2.5 en la cual se detalla la señal del voltaje de la terminal V1 a 60BMP de un corazón sano. Como se puede observar en la Figura 2.5 la componente que tiene el mayor valor de frecuencia es la de 2.57, que con una regla de 3 se obtiene que la frecuencia equivale a 70Hz. El mismo proceso se realizó con las terminales faltantes. Los cálculos realizados para la selección de los filtros se muestran a continuación en las siguientes tablas: TERMINAL PRECORDIAL FILTROS PARA 60BPM FRECUENCIA CAPACITOR MÁXIMA DE PASO UTILIZADO (Hz) (uf) RESISTENCIA () V1 70 0,68 3343,672826 V2 70 0,68 3343,672826 V3 60 0,68 3900,95163 V4 40 0,68 5851,427445 V5 40 0,68 5851,427445 V6 70 0,68 3343,672826 Tabla 2.4a: Filtros para una frecuencia de 60BMP 43 TERMINAL PRECORDIAL FILTROS PARA 80BPM FRECUENCIA CAPACITOR MÁXIMA DE PASO UTILIZADO (Hz) (uf) RESISTENCIA () V1 60 0,68 3900,95163 V2 40 0,68 5851,427445 V3 50 0,68 4681,141956 V4 60 0,68 3900,95163 V5 40 0,68 5851,427445 V6 60 0,68 3900,95163 Tabla 2.4b: Filtros para una frecuencia de 80BMP La razón por la cual las salidas tienen un filtro pasivo antes del activo es conseguir una señal análoga con un nivel de ruido pequeño para que este sea eliminado por el filtro activo, ya que presenta problemas de picos en la señal de salida. Para este tipo de filtro se deben utilizar potenciómetros de precisión para no tener que aproximar a valores estándar y variar la frecuencia de corte. 2.7.2 FILTROS ACTIVOS Esta etapa se encarga de eliminar completamente el ruido se las señales generadas para posteriormente ser acondicionadas. El módulo tiene implementado filtros activos Butterworth de segundo orden pasa bajos. Los filtros Butterworth presentan una atenuación que depende del grado del filtro y que puede ser calculado con la Ecuación 1. Esta atenuación está relacionada directamente con la frecuencia de corte del filtro. 44 Atenuación § w 20 * n * log¨¨ © wc · ¸¸ ¹ n 1,2,3......... Ecuación 2.2: Relación de atenuación con la frecuencia de corte El tipo de filtro implementado es uno de segundo orden siendo un filtro de -40db, con una atenuación de 0.707 (3db) en amplitud de la señal, cuyas características se observan en la Figura 2.11, en la que se detalla la respuesta del filtro ideal y la del filtro real. Figura 2.11: Atenuación para un filtro Butterworth de segundo orden La configuración del filtro pasa bajos de segundo orden basado en el amplificador operacional TL084 se muestra en la Figura 2.12, detallándose a continuación el diseño del mismo: 45 C2 R3 4 +VCC R2 3 1 SALIDA 8 + R1 ENTRADA U1A - 2 TL084 C1 -VCC Figura 2.12: Filtro Butterworth pasa bajos de segundo orden C2 R1 Rf R 2 * C1 R2 R 2* R 0.707 2 * S * fc * C Para un funcionamiento óptimo del filtro se recomienda utilizar capacitores en un rango que va de 100pf a 0.1uf. De igual manera que los filtros pasivos anteriormente mencionados se deben implementar filtros activos de distintos valores de frecuencia de corte. En este caso son los mismos valores de frecuencia que poseen los filtros pasivos. Los cálculos de los elementos de los filtros se los muestra en las Tablas 2.2 El cálculo para una frecuencia de corte de 60hz se muestra a continuación: Sea C=0.022uf 46 R 0.707 2 * S * 60 * 0.022e 6 82246.4321: Aproximando R 82000: C 2 2 * 0.022uf 0.044uf Aproximando C 2 0.047uf Racalculando la frecuencia se obtiene que : f 0.707 2 * S * 82000 * 0.022e 6 62.375Hz El cálculo para los distintos filtros a las frecuencias correspondientes se muestra en las Tablas 2.5 FILTROS PARA GENERACIÓN A 60BPM FRECUENCIA TERMINAL C1 (uf) C2 (uf) R () R1 (K) MÁXIMA DE PRECORDIAL PASO (Hz) Rf (K) FRECUENCIA FINAL DE CORTE (Hz) V1 60 0,022 0,047 85246,4321 82 160 62,3754381 V2 40 0,022 0,047 127869,648 120 220 42,62321604 V3 50 0,022 0,047 102295,718 100 200 51,14785924 V4 60 0,022 0,047 85246,4321 82 160 62,3754381 V5 40 0,022 0,047 127869,648 120 220 42,62321604 V6 60 0,022 0,047 85246,4321 82 160 62,3754381 Tabla 2.5a: Cálculo de filtros activos para 60BMP 47 TERMINAL PRECORDIAL FILTROS PARA GENERACIÓN A 80BPM FRECUENCIA C1 (uf) C2 (uf) R () R1 (K) Rf (K) MÁXIMA DE PASO (Hz) FRECUENCIA FINAL DE CORTE (Hz) V1 70 0,022 0,047 73068,3703 75 150 68,19714566 V2 70 0,022 0,047 73068,3703 75 150 68,19714566 V3 60 0,022 0,047 85246,4321 82 160 62,3754381 V4 40 0,022 0,047 127869,648 120 220 42,62321604 V5 40 0,022 0,047 127869,648 120 220 42,62321604 V6 70 0,022 0,047 73068,3703 75 150 68,19714566 Tabla 2.5b: Cálculo de filtros activos para 80BMP 2.7.3 GANANCIA DEL SISTEMA Se generan señales de 2mV (pico-pico), ya que es una entrada aceptable para el electrocardiógrafo. Cabe destacar que no todas las señales tienen la misma amplitud, y por esta razón se toma a la señal más pequeña, que es V1, con una amplitud de 1mVpp y como la digitalización de las señales se la realizo con señales a escala se tomará la misma ganancia para todas las señales restantes. Según la digitalización se tiene que el valor máximo en digital es de 70 y el menor de 11 hay una diferencia de 59. El valor de la señal a la salida de conversor D/A es de 300mVdc, con lo que para obtener a la salida un voltaje de 1mV es necesario reducirla en 300veces: Con una ganancia de 0.1 en el amplificador diferencial una reducción final de 0.33 en el amplificador inversor, se tiene una ganancia de 0.033 que es lo que se requiere para el sistema. 48 2.7.3.1 ACONDICIONAMIENTO DE SEÑAL Este proceso se implementa mediante amplificadores operacionales en la configuración de diferencial, con una ganancia menor a uno para reducir la amplitud de la señal. Dicha configuración se muestra en la Figura 2.13 R4 4 +VCC R1 3 ENTRADA (+) 1 SALIDA + ENTRADA (-) U3A - 2 8 R2 TL084 R3 -VCC Figura 2.13: Amplificador diferencial Una ventaja que presenta este modo de operación es el de eliminación de ruido ya que si ingresan dos señales en modo común estas se eliminan entre sí. La señal será no solo amplificada sino además nivelada a un valor en el cual la señal sea simétrica con respecto al nivel de 0V. Como las señales se generan independientemente, todas las señales deben pasar por esta etapa. Para hacer más fácil el análisis del funcionamiento y los cálculos de resistencias se asumen las siguientes consideraciones: R1 R 2 R R3 R 4 Rf Rf G R 49 Entonces el circuito modificado para el análisis se muestra a continuación en la Figura 2.14: Rf 4 +VCC R 8 R 1 SALIDA + 3 ENTRADA (+) U3A - 2 ENTRADA (-) TL084 Rf -VCC Figura 2.14: Modificación del amplificador diferencial Los cálculos para el diseño del diferencial, se muestran a continuación: G 0.1 Vo G *Vi Vi 100mV Vo 0.1*100mV 10mV Se asume R1 10Kȍ Rf Rf R Rf 1K: G 0.1* R El circuito implementado en el módulo para cada una de las señales se muestra en la Figura 2.12. La entrada positiva corresponde a la salida del filtro pasivo, mientras que la entrada negativa al potenciómetro de nivelación de cero con un voltaje positivo ya que al entrar por la entrada negativa este invierte su polaridad. No se pueden colocar resistencias fijas debido a que el nivel de cada señal debe ser exacto para que el sistema funcione correctamente. 50 Antes de pasar a la segunda atapa de amplificación se hace pasar a las señales por un filtro pasivo para reducir los niveles de ruido inducidos por la utilización de potenciómetros en la nivelación de las señales. Estos filtros tienen la configuración básica con resistencias y capacitores fijos, cumpliendo con la frecuencia de corte de los filtros anteriores pero con un poco de variación en el ancho de la banda pasante para descartar cortes de las señales. En este caso se utilizaron capacitores de 0.47uf, siguiendo el mismo procedimiento de cálculo se determinaron y escogieron los valores de resistencia ilustrado en las Tablas 2.6. TERMINAL PRECORDIAL FRECUENCIA DE 60BPM FRECUENCIA CAPACITOR RESISTENCIA MÁXIMA DE PASO UTILIZADO () (Hz) (uf) RESISTENCIA ESTÁNDAR () V1 60 0,47 5643,930018 5600 V2 40 0,47 8465,895027 8200 V3 50 0,47 6772,716021 6800 V4 60 0,47 5643,930018 5600 V5 40 0,47 8465,895027 8200 V6 60 0,47 5643,930018 5600 Tabla 2.6a TERMINAL PRECORDIAL FRECUENCIA DE 80BPM FRECUENCIA CAPACITOR RESISTENCIA MÁXIMA DE PASO UTILIZADO () (Hz) (uf) RESISTENCIA ESTÁNDAR () V1 70 0,47 4837,654301 4700 V2 70 0,47 4837,654301 4700 V3 60 0,47 5643,930018 5600 V4 40 0,47 8465,895027 8200 V5 40 0,47 8465,895027 8200 V6 70 0,47 4837,654301 4700 Tabla 2.6b 51 Por último, la señal pasa por otra etapa de amplificación para disminuir el voltaje a la salida, en este caso implementado con amplificadores inversores debido a que el amplificador no inversor no permite tener ganancias menores que 1. Por este motivo, las señales deben ser generadas en forma inversa para que a la salida se obtengan las señales de la forma requerida. La Figura 2.15 muestra la configuración de un amplificador no inversor implementado con el mismo amplificador operacional utilizado en las otras etapas. Rf 4 +VCC R 7 8 5 U3B SALIDA + 6 - ENTRADA (-) TL084 -VCC Figura 2.15: Filtro Butterworth de segundo orden G Vo Vi Rf R El valor de la amplificación de esta etapa es de 1/30, de esta manera se obtendrán señales del valor de 2mVpico-pico, que es un valor aceptable para la entrada de un electrocardiógrafo comercial. El diseño para este amplificador se lo realiza de la siguiente manera: 1 Rf 30 R R 30 Rf Sea Rf 1Kȍ R 30 K: G 52 2.8 DIAGRAMA DE GENERACIÓN Y ACONDICIONAMIENTO DE UNA SEÑAL El diagrama de la Figura 2.16, muestra el acondicionamiento completo de una señal generada desde uno de los puertos C y D del microcontrolador PIC16F877A. Cada elemento de los circuitos posee un valor de acuerdo a lo calculado anteriormente. C2 RV2 1k R4 R3 13 R1 R1 ENTRADA 82k 14 12 10k 1 R3 3 4 C C1 0.022u 0.022u 30k R5 5.6k R6 1k 10k R4 1k U5:B 6 7 5 4 TL084 50K U5:A 2 82k RV1 R7 1k U4:D 11 11 160k 11 R2 TL084 C10 0.47u SALIDA 4 0.047u TL084 Figura 2.16: Acondicionamiento completo de una señal 2.9 DISEÑO DE FUENTES La alimentación requerida para el funcionamiento tomando en cuenta la etapa digital tanto como la análoga es: x Fuente regulada de 5Vdc x Fuente regulada de ±12Vdc 2.9.1 FUENTE REGULADA DE 5Vdc Consta de un transformador el cual se encarga de reducir el voltaje de alimentación que es de 120Vac, a una salida de 12Vac, un rectificador tipo puente para rectificar la onda de voltaje y de esta manera obtener un voltaje continuo. Para obtener una 53 señal continua mejor se coloca un filtro para eliminar el rizado. El filtro usado es un capacitor que posee una alta capacitancia y este voltaje resultante es regulado con un C.I. 7805, que es un regulador de voltaje integrado, a cuya salida entrega un voltaje estable de 5Vdc a una corriente de 500mA. Esta corriente es suficiente para el funcionamiento del circuito debido a que cada microcontrolador tiene un consumo a temperatura ambiente (25ºC) de 780uA para el PIC16F628A según la Figura 2.17y de 5mA para el PIC16F877A según la Figura 2.18. Teniendo además el consumo del LCD, que es de 100mA, se tiene un total de 105.78mA. A la salida se colocan filtros de capacitores con capacitancias bajas para mejorar su rendimiento. Para la protección de la fuente y del circuito al cual va a alimentar se coloca un fusible a la entrada de la fuente el cual tiene un valor igual al máximo que puede entregar el regulador (500mA). El esquema de la fuente se muestra en la Figura 2.19 Figura 2.17: Característica de corriente vs. Voltaje respecto al oscilador, PIC16F628A 54 Figura 2.18: Característica de corriente vs. Voltaje respecto al oscilador, PIC16F877A U1 7805 1 VO C1 2 TR1 VI GND BR1 3 5Vdc R1 100k 1000u 110Vac 2W005G C2 C3 47u 47u D1 LED TRAN-2P2S Figura 2.19: Fuente regulada de 5Vdc Los valores de capacitancia asumidos en el diseño fueron escogidos debido a las siguientes características: Capacitor de entrada. Debe tener un valor alto para eliminar el rizado del rectificador y el regulador tenga un buen funcionamiento. Capacitores de salida. Se colocan dos para obtener una disminución de la caída de potencial en el regulador debido a que el sistema genera señales PWM y va a requerir picos de corriente, los cuales asumen los capacitores. El datasheet del regulador de voltaje 7805 se muestra en el Anexo 4. 55 2.6.2 FUENTE REGULADA DE ±12Vdc Formado por un transformador con tab central el cual se encarga de reducir el voltaje de alimentación, que es de 120Vac, a una salida de 24Vac, con un voltaje entre el tab y los terminales del secundario del transformador de 12Vac. Un rectificador tipo puente para rectificar la onda de voltaje y de esta manera obtener un voltaje continuo tomado desde los extremos del transformador y la referencia desde el tab central del transformador. Para obtener una señal continua mejor se coloca un filtro para eliminar el rizado. El filtro usado es un capacitor que posea una alta capacitancia (1000uf) y este voltaje resultante es regulado con un C.I. 7812 que es un regulador de voltaje integrado a cuya salida entrega un voltaje estable de +12Vdc y un C.I. 7912 que es un regulador de voltaje integrado a cuya salida entrega un voltaje estable de -12Vdc con una corriente de 500mA máxima. El Análisis de consumo de corriente de los amplificadores operacionales que van a ser alimentados por esta fuente se la realiza en base al consumo de uno de ellos el cual se detalla en la Figura 2.20 de la cual obtenemos que el consumo a ±12Vdc de alimentación es de 1.4mA, por tanto se tiene un consumo total para los 9 amplificadores de 12.6mA. A la salida se colocan filtros de capacitores con capacitancias bajas para mejorar su rendimiento como se analizó en la fuente anterior. Para la protección de la fuente y del circuito al cual va a alimentar, se coloca un fusible a la entrada de la fuente el cual tiene un valor igual al máximo que puede entregar el regulador (500mA), el esquema de la fuente se muestra en la Figura 2.21 El datasheet del regulador de voltaje 7812 y 7912 se muestra en el Anexo 5. 56 Figura 2.20: Fuente regulada doble de ±12Vdc U2 7812 1 VI TR2 VO 3 GND BR2 100k 2 C4 +12Vdc R2 1000u 110Vac C5 C6 47u 47u C7 C8 47u 47u D2 2W005G LED TRAN-2P3S D3 LED 1 R3 2 GND 100k VI VO 3 -12Vdc U3 7912 Figura 2.21: Fuente regulada doble de ±12Vdc 2.7 DISEÑO DE CIRCUITOS IMPRESOS El diseño de los circuitos impresos fue realizado en el paquete computacional PROTEL DXP el cual permite un ambiente interactivo y dinámico en el diseño, teniendo como características el ancho de conexiones y eliminación de capacitancia 57 parasita para un correcto funcionamiento del sistema y un apropiado plano de referencia y en una baquelita de 2 lados para facilitar el ruteado debido a la cantidad de conexiones requeridas. 2.7.1 ETAPA DIGITAL, VISUALIZACIÓN, CONVERSIÓN D/A Y FUENTE DE 5Vdc Montado el microcontrolador PIC16F877A con sus respectivas entradas de pulsantes y los capacitores para eliminación de rebotes en las entradas, así como la etapa de conversión D/A mediante filtros pasivos. También el microcontrolador PIC16F628A con el conector de salida para la conexión del LCD. Por último la fuente de 5Vdc, La Figura 2.19 muestra una imagen en 3D de la tarjeta diseñada. Figura 2.19: Tarjeta digital, conversión D/A y fuente de 5Vdc 2.7.2 ETAPA ANÁLOGA La primera parte está formada por los filtros Butterworth de segundo orden, seguido de la etapa de acondicionamiento formada por los amplificadores diferenciales de 58 ganancia 0.1 y los potenciómetros para nivelación de señal. La Figura 2.20 muestra una imagen en 3D de la tarjeta. Figura 2.20: Filtros activos y amplificadores diferenciales 2.7.3 ETAPA DE ACONDICIONAMIENTO Y FILTRADO FINAL En esta tarjeta se montó la etapa de filtros pasivos y la etapa de amplificación con amplificadores operacionales y ganancia 0.33. La Figura 2.21 muestra una imagen en 3Dde la tarjeta. 59 Figura 2.21: Filtros pasivos y amplificador inversor 2.7.3 FUENTE REGULADA DE ±12Vdc Se muestra el diseño realizado en un solo lado debido a que no necesita de muchas conexiones. La Figura 2.22 muestra la imagen en 3D de la tarjeta. Figura 2.22: Fuente doble de ±12Vdc Todo esto está construido en forma modular debido a la ventaja que tiene de que puede ser reparada o sustituida la tarjeta que presente mal funcionamiento o se deteriore por el tiempo. 60 CAPITULO 3 DESARROLLO DEL SOFTWARE El objetivo del presente capitulo es dar a conocer la estructura del software con el cual funciona el módulo de generación de señales del corazón, así como la obtención de tablas para generar dichas señales. 3.1 DESARROLLO DEL SOFTWARE DEL MÓDULO GENERADOR DE SEÑALES DEL CORAZÓN. El generador de señales diseñado en este proyecto requiere el desarrollo del software para: x El microcontrolador PIC16F877A x El microcontrolador PIC16F628A El programa del generador se encarga de reproducir seis señales del tipo PWM correspondientes a las terminales precordiales para cada frecuencia cardiaca; es decir, genera 12 señales independientes de seis en seis. El modo de generar estas señales es utilizar la modulación por ancho de pulso mediante la cual se obtiene un valor medio de voltaje que se puede controlar para reproducir las señales. El programa del visualizador se encarga de leer el puerto A de salida del generador de señales para mostrarlo en el LCD. El algoritmo para manejar el LCD se podía haber implementado en el software del generador de señales, pero el generador debe tener la mayor precisión posible para evitar que una de las salidas presente un pico indeseable de voltaje. 61 3.2 DESARROLLO DEL SOFTWARE DEL GENERADOR El programa en el generador de señales está realizado en un lenguaje de programación de bajo nivel, es decir, en lenguaje assembler. Para la compilación y construcción del archivo ejecutable se utilizó el paquete computacional MPLAB. Las funciones que debe llevar a cabo el microcontrolador se muestran en el diagrama de bloques de la Figura 3.1 siguiente: INICIALIZAR PIC16F877A INTERRUPCIONES ENVIAR DATOS AL VISUALIZADOR GENERAR SEÑALES ACTIVA INTERRUPCIÓN EXTERNA SI PULSANTES NO SI SI FRECUENCIA CARDIACA=60BMP LECTURA DE PULSANTES NO SI FRECUENCIA CARDIACA=80BMP ACTIVA INTERRUPCIÓN INTERNA SI TABLAS DE DATOS GENERAR A 60BMP SI GENERAR A 80BMP SI GENERAR ECG NORMAL SI GENERAR ECG ANORMAL NO NO SI ECG NORMAL LECTURA DE TABLAS NO SI ECG ANORMAL NO REGRESAR AL PROGRAMA PRINCIPAL Figura 3.1: Diagrama general del software del microcontrolador PIC16F877A 62 3.2.1 Inicializar PIC16F877A: Configurar puertos Configurar puerto A como digital Configurar puerto A como salida Configurar puerto B como entrada Configurar puerto C como salida Configurar puerto D como salida Configurar pre escalador de timmer 2 para cumplir con frecuencia de 1Hz y 1.33Hz. Asignar nombres a registros para almacenar datos de tablas: UNO para datos de voltaje precordial 1 (0X20) DOS para datos de voltaje precordial 2 (0X21) TRES para datos de voltaje precordial 3 (0X22) CUATRO para datos de voltaje precordial 4 (0X23) CINCO para datos de voltaje precordial 5 (0X24) SEIS para datos de voltaje precordial 6 (0X25) Configurar interrupciones: Configurar interrupción externa Configurar interrupción de timmer 2 Habilitar interrupciones Fin de inicialización. 3.2.2 Lectura de tablas: Si bandera de interrupción interna se activa Si se ha seleccionado generar a 60BMP Si se no debe cambiar de dato Poner puerto D en alto Si se debe cambiar de dato Poner puerto D en alto Leer siguiente dato de tabla de cada voltaje precordial Limpiar bandera Salir interrupción Si se ha seleccionado generar a 80BMP 63 Si se no debe cambiar de dato Poner puerto D en alto Si se debe cambiar de dato Poner puerto D en alto Leer siguiente dato de tabla de cada voltaje precordial Limpiar bandera Salir interrupción Limpiar bandera Salir de interrupción. 3.2.3 Interrupción externa: Si bandera de interrupción externa se activa Leer puerto de entrada B Si bit1=0 Encender sistema Encender timmer 2, Leer primer dato de cada tabla Habilitar generar señales Limpiar banderas Salir de interrupción Si bit2=0 Apagar sistema Apagar timmer 2 Deshabilitar la generación de señales Limpiar banderas Salir de interrupción Si bit3=0 ECG normal Leer tablas de datos de ECG normal Limpiar banderas Salir de interrupción Si bit4=0 ECG anormal 64 Leer tablas de datos de ECG anormal Limpiar banderas Salir de interrupción Si bit5=0 Frecuencia cardiaca de 60BMP Generar por el puerto D de salida Limpiar banderas Salir de interrupción Si bit6=0 Frecuencia cardiaca de 80BMP Generar por el puerto C de salida Limpiar banderas Salir de interrupción Limpiar banderas Salir de interrupción Para una mejor comprensión de lo explicado aquí se detalla en la Figura 3.2 65 INTERRUPCIÓN EXTERNA SI PRESIONA EL PULSANTE 1 SI ENCENDER SISTEMA NO SI PRESIONA EL PULSANTE 2 SI APAGAR SISTEMA NO SI PRESIONA EL PULSANTE 3 NO NO SI PRESIONA EL PULSANTE 4 SI SI GENERAR ECG NORMAL NO SI PRESIONA EL PULSANTE 5 GENERAR ECG ANORMAL SI FRECUENCIA DE 60BMP LIMPIAR BANDERAS REGRESAR AL PROGRAMA PRINCIPAL Figura 3.2: Diagrama de bloques de lectura de pulsantes 3.2.4 Enviar datos al visualizador: Enviar datos por puerto A Si bit0=0: Mostrar: SISTEMA APAGADO Si bit0=1: Mostrar: SISTEMA ENCENDIDO Si bit1=0: Sin función Si bit1=1: Mostrar: CORAZÓN SANO Si bit2=0: Sin función Si bit2=1: Mostrar: CORAZÓN ENFERMO Si bit3=0: Sin función SI PRESIONA EL PULSANTE 6 SI FRECUENCIA DE 80BMP NO 66 Si bit3=1: Mostrar: FRECUENCIA = 60BMP Si bit4=0: Sin función Si bit4=1: Sin función Si bit5=0: Sin función Si bit5=1: Mostrar: FRECUENCIA = 80BMP 3.2.5 Generar señales: Si se habilita generar señales: Si se ha seleccionado generar a frecuencia cardiaca de 60BMP Generar por puerto D de salida del generador Comparar registros TMR2 y UNO: Comparar registros TMR2 y DOS: Comparar registros TMR2 y TRES: Comparar registros TMR2 y CUATRO: Comparar registros TMR2 y CINCO: Comparar registros TMR2 y SEIS: Si se ha seleccionado generar a frecuencia cardiaca de 80BMP Generar por puerto C de salida del generador Comparar registros TMR2 y UNO: Comparar registros TMR2 y DOS: Comparar registros TMR2 y TRES: Comparar registros TMR2 y CUATRO: Comparar registros TMR2 y CINCO: Comparar registros TMR2 y SEIS: Regresar a inicio de programa Si deshabilitar generar señales Regresar a inicio de programa La generación de las señales se las detalla en el siguiente diagrama 67 UNO MAYOR QUE TMR2 SI BAJAR A CERO BIT DE PUERTO SELECCIONADO NO DOS MAYOR QUE TMR2 SI BAJAR A CERO BIT DE PUERTO SELECCIONADO NO TRES MAYOR QUE TMR2 SI BAJAR A CERO BIT DE PUERTO SELECCIONADO SI BAJAR A CERO BIT DE PUERTO SELECCIONADO SI BAJAR A CERO BIT DE PUERTO SELECCIONADO SI BAJAR A CERO BIT DE PUERTO SELECCIONADO NO GENERACIÓN CUATRO MAYOR QUE TMR2 NO CINCO MAYOR QUE TMR2 NO SEIS NO Figura 3.3: Generación de señales 3.2.6 Seleccionar frecuencia cardiaca: Si se ha seleccionado generar a 60BMP Sacar señal por puerto D Salir de subrutina Si se ha seleccionado generar a 80BMP Sacar señal por puerto C Salir de subrutina 3.2.7 Seleccionar ECG normal o anormal: Seleccionar ECG normal Seleccionar tablas: Tabla 1: voltaje precordial 1 68 Tabla 2: voltaje precordial 2 Tabla 3: voltaje precordial 3 Tabla 4: voltaje precordial 4 Tabla 5: voltaje precordial 5 Tabla 6: voltaje precordial 6 Seleccionar ECG anormal Seleccionar tablas: Tabla 7: voltaje precordial 1 Tabla 8: voltaje precordial 2 Tabla 9: voltaje precordial 3 Tabla 10: voltaje precordial 4 Tabla 11: voltaje precordial 5 Tabla 12: voltaje precordial 6 Fin de selección 3.2.8 CÁLCULO DE FRECUENCIA CARDIACA. Por medio del registro llamado AFREC (auxiliar de frecuencia), se mantiene registrada la frecuencia cardiaca en el generador de señales. La frecuencia cardiaca considerada como normal va desde 60BMP hasta 100BMP, el módulo de generación reproduce señales de 60BMP y 80BMP, equivalentes a 1Hz y 1.33Hz, respectivamente. Para obtener la frecuencia deseada se utiliza el timmer 2 del microcontrolador con un pre escalador de 4, lo que significa que pasan 4 ciclos de máquina para que haya un incremento en el registro TMR2. Funcionando con un cristal de 20MHz se tiene un ciclo de máquina de: cm 4 f osc 4 20MHz 0.2Pseg 69 Por tanto el timmer se desbordará para producir una interrupción cada: T 0 IF 256 * 4 * 0.2Pseg 204.8Pseg 60 BMP 1Hz t 1 f 1 1Hz 80 BMP 1.33Hz 1seg. t 1 f 1 1.33Hz 0.75seg. Con estos datos se calcula el número de interrupciones que deben transcurrir antes de realizar un cambio de dato. Periodo x Numero de datos * x * Tiempo entre interrupciones Periodo Numero de datos * Tiempo entre interrupciones Para 60BMP 1seg x 180 * 204.8Pseg x 27,12 x 27 Para 80BMP 0,75seg x 180 * 204.8Pseg x 20,34 x 20 Para una frecuencia de 60BMP se requiere: Que hayan sucedido 20 interrupciones antes de leer al siguiente dato de la tabla y, Para una frecuencia de 80BMP se requiere: Que hayan sucedido 27 interrupciones antes de leer al siguiente dato de la tabla. 70 3.3 DESARROLLO DEL SOFTWARE PARA EL PIC16F628A El programa del PIC16F628A está realizado en un lenguaje de programación de alto nivel, en este caso, en lenguaje BASIC. Para la compilación y construcción del archivo ejecutable se utilizó el paquete computacional MICROCODE ESTUDIO. Las funciones que debe llevar a cabo el microcontrolador se muestran en el diagrama de bloques de la Figura 3.4 siguiente: Figura 3.4: Diagrama de bloques del software del visualizador Inicializar PIC16F628A Configurar puertos Configurar puerto A como digital 71 Configurar puerto A como entrada Configurar puerto B como salida Bit 2 habilitación de escritura del LCD Bit 3 habilitación del LCD Bit 4-7 envío de datos Inicializar LCD Configurar para escritura de datos en modo multiplexado (4bits) Línea de lectura a cero voltios (solo se escribirá) Leer puerto A Lee el puerto A mediante el cual recibe la instrucción del generador de señales. Codificar dato leído Codificar: Si puerto A=0 escribir: SISTEMA APAGADO Si puerto A=1 escribir: SISTEMA ENCENDIDO Si puerto A=3 escribir: CORAZÓN SANO Si puerto A=5 escribir: CORAZÓN ENFERMO Si puerto A=9 escribir: FRECUENCIA=60BMP Si puerto A=11 escribir: FRECUENCIA=80BM Si puerto A=13 escribir: CORAZÓN SANO FRECUENCIA=60BMP Si puerto A=17 escribir: CORAZÓN SANO FRECUENCIA=80BM Si puerto A=19 escribir: CORAZÓN ENFERMO 72 FRECUENCIA=60BMP Si puerto A=21 escribir: CORAZÓN ENFERMO FRECUENCIA=80BM Escribir en LCD Retardo de 500mseg entre cada instrucción Enviar código de ubicación de cursor y línea mediante instrucción LCDOUT: Primera línea y cursor a la izquierda: lcdout $fe, 1 Segunda línea y cursor a la izquierda: lcdout $fe, $c0 Enviar frases mediante instrucción: lcdout Regresar a leer puerto 3.3.1 INICIALIZAR PIC16F628A. La configuración del microcontrolador se la realiza de acuerdo a los requerimientos del hardware, siendo estos: Puertos A entrada Puerto B salida Puerto C no se utiliza para este módulo. 3.3.2 INICIALIZAR LCD. Enviar código de configuración de funcionamiento en modo multiplexado, ubicar cursor y seleccionar línea de escritura 73 3.3.3 ESCRIBIR EN LCD. Para realizar la escritura se debe cumplir: Habilitar escritura Habilitar LCD Ubicar cursor desde donde se escribirá Ubicar línea para escribir Enviar dato 3.4 DIGITALIZACIÓN DE SEÑALES DE VOLTAJES PRECORDIALES. Debido a que no se cuenta con una ecuación que represente a una señal cardiaca para realizar las proyecciones de las mismas y a que el cuerpo humano no es un medio homogéneo para que las proyecciones tengan el valor deseado en cada punto, como se mencionó anteriormente, el software del generador tiene integradas 12 tablas en su programa, las cuales tienen su origen del siguiente análisis: Las señales obtenidas del Atlas de cardiología, electrocardiogramas y rayos-x se tienen las siguientes imágenes de las mismas: 74 Figura 3.5: Corazón normal en el plano horizontal Figura 3.6: Corazón con in infarto agudo inferior del miocardio en las primeras horas 75 Las Figuras 3.5 y 3.6 tienen como fuente el libro “AN ATLAS OF CARDIOLOGY AND CHEST X-RAYS” Con estas ondas se procedió a utilizar el paquete computacional Autocad2006 mediante el cual se reprodujeron las imágenes para luego estas ser escaladas y colocadas en una cuadricula milimetrada que posee una escala horizontal de 180mm y de alto 255mm, con lo cual se obtiene valores a ser cargados al generador y poder reproducir dichas ondas. El resultado de este proceso se muestra en el Anexo1 y las graficas de lo obtenido por medio del paquete EXCEL se muestran a continuación: 80 70 60 50 40 Series1 30 20 10 0 0 50 100 150 200 Figura 3.7: Voltaje precordial 1 de un corazón sano 160 140 120 100 80 Series1 60 40 20 0 0 50 100 150 200 Figura 3.8: Voltaje precordial 2 de un corazón sano 76 160 140 120 100 80 Series1 60 40 20 0 0 50 100 150 200 Figura 3.9: Voltaje precordial 3 de un corazón sano 140 120 100 80 60 Series1 40 20 0 Ͳ20 0 50 100 150 200 Figura 3.10: Voltaje precordial 4 de un corazón sano 120 100 80 60 Series1 40 20 0 0 50 100 150 200 Ͳ20 Figura 3.11: Voltaje precordial 5 de un corazón sano 77 90 80 70 60 50 40 Series1 30 20 10 0 0 50 100 150 200 Figura 3.12: Voltaje precordial 6 de un corazón sano 160 140 120 100 80 Series1 60 40 20 0 0 50 100 150 200 Figura 3.13: Voltaje precordial 1 de un corazón enfermo 250 200 150 Series1 100 50 0 0 50 100 150 200 Figura 3.14: Voltaje precordial 2 de un corazón enfermo 78 160 140 120 100 80 Series1 60 40 20 0 0 50 100 150 200 Figura 3.15: Voltaje precordial 3 de un corazón enfermo 200 150 100 Series1 50 0 0 50 100 150 200 Ͳ50 Figura 3.16: Voltaje precordial 4 de un corazón enfermo 250 200 150 Series1 100 50 0 0 50 100 150 200 Ͳ50 Figura 3.17: Voltaje precordial 5 de un corazón enfermo 79 250 200 150 Series1 100 50 0 0 50 100 150 200 Figura 3.18: Voltaje precordial 6 de un corazón enfermo Haciendo una comparación entre las graficas normalizadas y las digitalizadas manualmente no se observa un cambio significativo, por tanto se trabaja con las tablas obtenidas de esta manera. 80 CAPITULO 4 PRUEBAS Y RESULTADOS Este capítulo tiene como objetivo la describir las pruebas que se realizaron para determinar la calidad del módulo de generación de señales del corazón. 4.1 EQUIPO UTILIZADO PARA LAS PRUEBAS El equipo usado para realizar las pruebas de funcionamiento del módulo es el CARDIOVIT AT-1, el cual posee entradas para las terminales precordiales. El equipo se muestra en la Figura 4.1 en la que se puede apreciar sus controles y la impresora incorporada. Este equipo necesita que todos los electrodos estén conectados y no flotando (no conectados) ya que se dispara la alarma de electrodo suelto y no realiza el análisis. Figura 4.1: Electrocardiógrafo SCHILLER modelo CARDIOVIT AT-1 Marca: SCHILLER Modelo: CARDIOVIT AT-1 Formato de impresión de 3 canales Rango de voltajes de entrada: ±100mV 81 Perteneciente a: HOSPITAL VOZANDES QUITO (Villalengua Oe 2.37 y 10 de Agosto) Dimensiones: 290 x 210 x 69 mm/11.4 x 8.3 x 2.7 pulgadas. (l/w/h) Peso: Ca. 2.9 kg / aproximadamente 6.7 libras Necesidades de fuente de alimentación: 220 - 240 (nominal) en forma de V, 50/60 Hz o 110--115 v (nominal), 50/60 operación independiente Hz con recargar incorporado batería, indicador de LED para parte principal y batería, la unidad de cargador incorporada Tiempo de carga de batería: 15 hrs. de una batería completamente descargado. Capacidad de batería: 2 hrs del uso normal Sistema de circuitos de entrada paciente: Enteramente flotante y aíslado, protección de desfibrilación (sólo con el cable de paciente original SCHILLER) Rango de frecuencia de la grabadora digital: 0 Hz para > 150 Hz (IEC/AHA) amplificador de ECG: - El registro simultáneo, sincrónico de todo 9 avisos de electrodo activo (= 12 direcciones estándar) - Probar frecuencia: 1000 Hz - Detección de corredor que marca el paso: ± 2 mV/ ± 0.1 ms Representación gráfica de los fenómenos musculares (tremor de músculo) con ayuda de un filtro programable: 25 Hz (40 dB/dec) y 35 Hz (20 dB/dec), programable. Filtro de frecuencia de línea: Supresión de interferencias sinusoidal mediante un filtro digital adaptable Panel de control: Teclas de block e indicadores tipo LED: - Grupo principal -- bandeja de papel vacío o atascado. - Operación de batería - electrodo suelto (destellos de indicador) Estándares de seguridad: IEC / ENE 60601-1; UL 60601 - 1; No. C22.2 601.1-M90; IEC/EN 60601-2-25; IEC / EN 60601 - 1 - 2 (EMC) 82 Clase de protección: Según IEC/EN 60601-1 (con la fuente de alimentación interna) Parte aplicada: CF acordando IEC/EN 60601-1 Conformidad: acuerdo directivo 93/42/EEC (dispositivos médicos) Clasificación: según acuerdo IIa de la norma 93/92/EEC Condiciones ambientales: - La temperatura de operación: 10°C a 40°C. - Temperatura, almacenamiento: -10° a 50 ° C/14 ° a 122 ° F - Humedad relativa: 25 al 95% (sin condensación) Velocidad de papel: 5/25/50 mm/s (directo) Sensibilidad: 5/10/20 mm/mV, ajuste de forma automática o manual Papel de gráfico: Termo sensible Impresión térmica de alta resolución: -8 puntos por mm/200 puntos por in (pulgadas de amplitud) -40 puntos por mm/1000 puntos por in (pulgadas de tiempo, a 25 mm/s) Pistas de grabación: 3 canales. Cable de paciente de 10 derivaciones 1 conjunto de electrodos, consiste de 4 electrodos de extremidad de acero inoxidable, 6 electrodos precordiales o electrodos disponibles Gel de electrodo Cable de fuerza Función manual Transporte (opcional) Medida automática y programa de interpretación de resultados no confiable al 100%. 83 4.2 REALIZACIÓN DE LA PRUEBA La realización de las pruebas se la realizaron en el Hospital Vozandes Quito, en el departamento de CARDIOPULMONAR ubicado en el segundo piso del hospital. Figura 4.2: Hospital Vozandes Quito A continuación se muestran las fotografías del equipo utilizado y del módulo generador de señales del corazón conectado al mismo. Figura 4.3: Electrocardiógrafo CARDIOVIT AT-1 84 Figura 4.4: Módulo generador de señales del corazón 4.3 RESULTADOS OBTENIDOS Los resultados obtenidos se muestran a continuación como imágenes para cada frecuencia cardiaca y estado (normal, anormal). 85 Figura 4.5: Señales tomadas de un corazón sano a una frecuencia cardiaca de 60BMP Figura 4.5: Señales tomadas de un corazón enfermo a una frecuencia cardiaca de 60BMP 86 Figura 4.5: Señales tomadas de un corazón sano a una frecuencia cardiaca de 80BMP Figura 4.5: Señales tomadas de un corazón enfermo a una frecuencia cardiaca de 80BMP 87 4.4 CÁLCULO DE ERRORES. 4.4.1 ERROR DE FRECUENCIA A 60BMP La frecuencia medida por el electrocardiógrafo es de 58bmp, y la real es de 60bmp por lo tanto se tiene que: Error Error Error 4.4.2 Valor Real Valor Medido Valor Real 60 58 0.03333 60 3.33% ERROR DE FRECUENCIA A 80BMP La frecuencia medida por el electrocardiógrafo es de 58bmp, y la real es de 80bmp por lo tanto se tiene que: Error Error Error 4.4.3 Valor Real Valor Medido Valor Real 80 78 0.025 80 2.5% ANÁLISIS DE V1 A 60BMP DE UN CORAZÓN SANO En la Figura 4.1 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 88 Figura 4.1: Voltaje precordial 1 de un corazón sano a 60BMP AMPLITUD De las figuras se obtienen los datos siguientes: SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 7.5 8 6.25 Tabla 4.1: Error de amplitud del voltaje precordial 1 de un corazón sano a 60BMP La Tabla 4.1 presenta un error de 6.25%, pero muestra todas las deflexiones que forman la señal de la derivación y se puede apreciar tanto la onda P como el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.4 ANÁLISIS DE V2 A 60BMP DE UN CORAZÓN SANO En la Figura 4.2 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 89 AMPLITUD Figura 4.2: Voltaje precordial 2 de un corazón sano a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 19 20 5 Tabla 4.2: Error de amplitud del voltaje precordial 2 de un corazón sano a 60BMP La Tabla 4.2 presenta un error de 5%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.5 ANÁLISIS DE V3 A 60BMP DE UN CORAZÓN SANO En la Figura 4.3 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays Figura 4.3: Voltaje precordial 3 de un corazón sano a 60BMP AMPLITUD 90 SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 24 21 -14.28 Tabla 4.3: Error de amplitud del voltaje precordial 3 de un corazón sano a 60BMP La Tabla 4.3 presenta un error de -14.28% que es un error considerable, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.6 ANÁLISIS DE V4 A 60BMP DE UN CORAZÓN SANO En la Figura 4.4 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.4: Voltaje precordial 4 de un corazón sano a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 20 19 5.26 Tabla 4.4: Error de amplitud del voltaje precordial 4 de un corazón sano a 60BMP 91 La Tabla 4.4 presenta un error de 5.26%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.7 ANÁLISIS DE V5 A 60BMP DE UN CORAZÓN SANO En la Figura 4.5 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.5: Voltaje precordial 5 de un corazón sano a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 15 15 0 Tabla 4.5: Error de amplitud del voltaje precordial 5 de un corazón sano a 60BMP La Tabla 4.5 presenta un error de 0%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS a pesar de que no se produce el pico negativo se encuentra dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 92 4.4.8 ANÁLISIS DE V6 A 60BMP DE UN CORAZÓN SANO En la Figura 4.6 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.6: Voltaje precordial 6 de un corazón sano a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 13 12 -8.33 Tabla 4.6: Error de amplitud del voltaje precordial 6 de un corazón sano a 60BMP La Tabla 4.6 presenta un error de -8.33%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.9 ANÁLISIS DE V1 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.7 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 93 AMPLITUD Figura 4.7: Voltaje precordial 1 de un corazón enfermo a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 15 16 6.25 Tabla 4.7: Error de amplitud del voltaje precordial 1 de un corazón enfermo a 60BMP La Tabla 4.7 presenta un error de 6.25%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar tanto la onda P como el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.10 ANÁLISIS DE V2 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.8 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays Figura 4.8: Voltaje precordial 2 de un corazón enfermo a 60BMP AMPLITUD 94 SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 24 25 4 Tabla 4.8: Error de amplitud del voltaje precordial 2 de un corazón enfermo a 60BMP La Tabla 4.8 presenta un error de 4%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.11 ANÁLISIS DE V3 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.9 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.9: Voltaje precordial 3 de un corazón enfermo a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 14 15 6.66 Tabla 4.9: error de amplitud del voltaje precordial 3 de un corazón enfermo a 60BMP 95 La Tabla 4.9 presenta un error de 6.66%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.12 ANÁLISIS DE V4 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.10 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.10: Voltaje precordial 4 de un corazón enfermo a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 26 24 -8.33 Tabla 4.10: Error de amplitud del voltaje precordial 4 de un corazón enfermo a 60BMP La Tabla 4.10 presenta un error de -8.88%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 96 4.4.13 ANÁLISIS DE V5 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.11 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.11: Voltaje precordial 5 de un corazón enfermo a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 25 26 3.84 Tabla 4.11: Error de amplitud del voltaje precordial 5 de un corazón enfermo a 60BMP La Tabla 4.11 presenta un error de 3.84%, pero muestra todas las deflexiones que forman la señal de la derivación y un pulso que se lo puede despreciar, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.14 ANÁLISIS DE V6 A 60BMP DE UN CORAZÓN ENFERMO En la Figura 4.12 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 97 AMPLITUD Figura 4.12: Voltaje precordial 6 de un corazón enfermo a 60BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 27 25 -8 Tabla 4.12: Error de amplitud del voltaje precordial 6 de un corazón enfermo a 60BMP La Tabla 4.12 presenta un error de -8%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.15 ANÁLISIS DE V1 A 80BMP DE UN CORAZÓN SANO En la Figura 4.13 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays Figura 4.13: Voltaje precordial 1 de un corazón sano a 80BMP AMPLITUD 98 SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 9 8 -12.5 Tabla 4.13: Error de amplitud del voltaje precordial 1 de un corazón sano a 80BMP La Tabla 4.13 presenta un error de -12.5% que es un error apreciable, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar tanto la onda P como el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.16 ANÁLISIS DE V2 A 80BMP DE UN CORAZÓN SANO En la Figura 4.14 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.14: Voltaje precordial 2 de un corazón sano a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 18 20 10 Tabla 4.14: Error de amplitud del voltaje precordial 2 de un corazón sano a 80BMP 99 La Tabla 4.14 presenta un error de -10%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.17 ANÁLISIS DE V3 A 80BMP DE UN CORAZÓN SANO En la Figura 4.15 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.15: Voltaje precordial 3 de un corazón sano a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 23 21 -9.52 Tabla 4.15: Error de amplitud del voltaje precordial 3 de un corazón sano a 80BMP La Tabla 4.15 presenta un error de -9.52%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 100 4.4.18 ANÁLISIS DE V4 A 80BMP DE UN CORAZÓN SANO En la Figura 4.16 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.16: Voltaje precordial 4 de un corazón sano a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 21 19 -10.52 Tabla 4.16: Error de amplitud del voltaje precordial 4 de un corazón sano a 80BMP La Tabla 4.16 presenta un error de -10.52%que es un erro apreciable, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.19 ANÁLISIS DE V5 A 80BMP DE UN CORAZÓN SANO En la Figura 4.17 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 101 AMPLITUD Figura 4.17: Voltaje precordial 5 de un corazón sano a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 15 15 0 Tabla 4.17: Error de amplitud del voltaje precordial 5 de un corazón sano a 80BMP La Tabla 4.17 presenta un error de 0%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS aunque no muestra el pico del punto s la señal se encuentra dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.20 ANÁLISIS DE V6 A 80BMP DE UN CORAZÓN SANO En la Figura 4.18 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays Figura 4.18: Voltaje precordial 6 de un corazón sano a 80BMP AMPLITUD 102 SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 13 12 -8 Tabla 4.18: Error de amplitud del voltaje precordial 6 de un corazón sano a 80BMP La Tabla 4.18 presenta un error de -8%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS dentro de los límites normales, por lo que se considera una onda normal producida por un corazón sin ninguna anomalía. 4.4.21 ANÁLISIS DE V1 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.19 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.19: Voltaje precordial 1 de un corazón enfermo a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 13 15 13.33 Tabla 4.19: Error de amplitud del voltaje precordial 1 de un corazón enfermo a 80BMP 103 La Tabla 4.19 presenta un error de 13.33% que es apreciable, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar tanto la onda P como el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.22 ANÁLISIS DE V2 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.20 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.20: Voltaje precordial 2 de un corazón enfermo a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 25 25 0 Tabla 4.20: Error de amplitud del voltaje precordial 2 de un corazón enfermo a 80BMP La Tabla 4.20 presenta un error de 0%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 104 4.4.23 ANÁLISIS DE V3 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.21 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.21: Voltaje precordial 3 de un corazón enfermo a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 16 15 -6.66 Tabla 4.21: Error de amplitud del voltaje precordial 3 de un corazón enfermo a 80BMP La Tabla 4.21 presenta un error de -6.66%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.24 ANÁLISIS DE V4 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.22 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays 105 AMPLITUD Figura 4.22: Voltaje precordial 4 de un corazón enfermo a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 27 25 -8 Tabla 4.22: Error de amplitud del voltaje precordial 4 de un corazón enfermo a 80BMP La Tabla 4.22 presenta un error de -8%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.25 ANÁLISIS DE V5 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.23 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays Figura 4.23: Voltaje precordial 5 de un corazón enfermo a 80BMP AMPLITUD 106 SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 25 26 3.84 Tabla 4.23: Error de amplitud del voltaje precordial 5 de un corazón enfermo a 80BMP La Tabla 4.23 presenta un error de -3.84%, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. 4.4.26 ANÁLISIS DE V6 A 80BMP DE UN CORAZÓN ENFERMO En la Figura 4.24 se muestra a la izquierda la señal obtenida con el generador mediante un electrocardiógrafo comercial y a la derecha la señal considerada como estándar obtenidas del libro An athas of cardiology and chest x-rays AMPLITUD Figura 4.24: Voltaje precordial 6 de un corazón enfermo a 80BMP SEÑAL GENERADA (mm) SEÑAL ESTÁNDAR (mm) PORCENTAJE DE ERROR 28 25 -12 Tabla 4.24: Error de amplitud del voltaje precordial 6 de un corazón enfermo a 80BMP 107 La Tabla 4.24 presenta un error de -12% que es apreciable, pero muestra todas las deflexiones que forman la señal de la derivación, se puede apreciar el complejo QRS anormal reflejándose como un infarto al miocardio, por lo que se considera una onda normal producida por un corazón con un infarto al corazón. ANÁLISIS Y CÁLCULO DEL PROMEDIO DEL PORCENTAJE DE ERROR ECGNORMAL ECGANORMAL 4.5 V1a60BMP V2a60BMP V3a60BMP V4a60BMP V5a60BMP V6a60BMP V1a60BMP V2a60BMP V3a60BMP V4a60BMP V5a60BMP V6a60BMP V1a80BMP V2a80BMP V3a80BMP V4a80BMP V5a80BMP V6a80BMP V1a80BMP V2a80BMP V3a80BMP V4a80BMP V5a680BMP VALOR ABSOLUTO %ERROR 6,25 6,25 5 5 -14,28 14,28 5,26 5,26 0 0 -8,33 8,33 6,25 6,25 4 4 6,66 6,66 -8,33 8,33 3,84 3,84 -8 8 -12,5 12,5 10 10 -9,52 9,52 -10,52 10,52 0 0 -8 8 13,33 13,33 0 0 -6,66 6,66 -8 8 3,84 3,84 -12 12 V6a80BMP TOTAL PROMEDIO 7,11 DESVIACIÓN 0,080930523 170,57 Tabla 4.3: Promedio de error y desviación estándar 108 Del análisis realizado se tiene un error global de 7.11% con lo que se puede concluir que el equipo tiene un correcto funcionamiento tomando en cuenta que el cuerpo humano no es un medio homogéneo y no se obtendrán las señales exactamente iguales para cada persona debido a su constitución física, sexo y edad. De lo que se ha podido apreciar en los resultados de distintos pacientes en el hospital, la señal varia en amplitud por las razones antes mencionadas, por lo que los médicos se basan en la forma de onda, y especialmente a las principales deflexiones como son: la onda P y el complejo QRS que presenta cada señal y la onda U que casi nunca aparece. 109 CAPITULO 5 CONCLUSIONES Y RECOMENDACIONES Luego de realizado el proyecto y probado su funcionamiento, de los resultados obtenidos es posible extraer las conclusiones que se indican a continuación. Por otro lado, la experiencia acumulada durante este trabajo permite la emisión de ciertas recomendaciones respecto a este proyecto o posteriores. 5.1 CONCLUSIONES x La teoría revisada y los resultados que se obtuvieron con el electrocardiógrafo comercial permiten comprobar que la señal generada por un corazón varía según el sexo y edad de la persona, así como también de su constitución física. Es por esto que el modelo del EGC que se tomó como patrón no necesariamente corresponde al de un corazón real sino que es un modelo fabricado sobre la base de miles criterios y experiencias de muchos médicos. x En todas las derivaciones se puede apreciar el complejo QRS, que es el más usado para determinar anomalías en el corazón, incluso el eje eléctrico se calcula con dicho complejo. Es por esto que en el presente proyecto se trató de reproducir este complejo con el menor error posible. x Para el voltaje V1 correspondiente a la derivación precordial 1 de un corazón sano generado a una frecuencia cardiaca de 60BMP, se tiene un error del 6.25%, equivalente a una diferencia de amplitudes de 0.5mm. Medicos y libros consultados respecto a estas diferencias, la consideran insignificante, tomando en cuenta que en pacientes reales se presentan diferencias similares. De lo indicado se puede concluir que se genera una señal buena para esta terminal precordial. 110 Para cada una de las señales se muestra el error en la siguiente tabla. ECGANORMAL ECGNORMAL V1a60BMP V2a60BMP V3a60BMP V4a60BMP V5a60BMP V6a60BMP V1a60BMP V2a60BMP V3a60BMP V4a60BMP V5a60BMP V6a60BMP V1a80BMP V2a80BMP V3a80BMP V4a80BMP V5a80BMP V6a80BMP V1a80BMP V2a80BMP V3a80BMP V4a80BMP V5a680BMP 6,25 6,25 5 5 -14,28 14,28 5,26 5,26 0 0 -8,33 8,33 6,25 6,25 4 4 6,66 6,66 -8,33 8,33 3,84 3,84 -8 8 -12,5 12,5 10 10 -9,52 9,52 -10,52 10,52 0 0 -8 8 13,33 13,33 0 0 -6,66 6,66 -8 8 3,84 3,84 -12 12 V6a80BMP x VALOR ABSOLUTO %ERROR TOTAL PROMEDIO 7,11 DESVIACIÓN 0,080930523 170,57 Del análisis realizado al error porcentual del sistema se tiene un valor de 7.11% con una desviación estándar de 0.0809 con lo que se puede afirmar que el sistema tiene un correcto funcionamiento, debido a que las señales no son iguales para cada persona. 111 5.2 RECOMENDACIONES x Para tener una medida correcta con el sistema se recomienda chequear que todos los electrodos estén conectados firmemente, igualmente la referencia a tierra. Conexiones flojas produjeron desperfectos durante la prueba. Adicionalmente, algunos electrocardiógrafos no operan si detectan un electrodo suelto. x Los electrocardiógrafos cuentan con entradas para las terminales precordiales y para las extremidades (triangulo de EITHOVEN). El módulo cuenta con seis salidas para cada frecuencia con una referencia. Se recomienda conectar los terminales sobrantes del electrocardiógrafo a la referencia del módulo para no tener problemas de ruido o tener una mala medición. x Antes de conectar el sistema a un electrocardiógrafo se deben ver las especificaciones del equipo para evitar posibles daños. x No se recomienda tomar el diagnostico del electrocardiógrafo como algo indiscutible, ya que el resultado debe ser analizado por un cardiólogo. x Se recomienda que la conexión del modulo sea a un toma con tierra porque la estructura del módulo actúa como una barrera contra el ruido externo que puede afectar al correcto funcionamiento del sistema. x Se recomienda la creación de otras soluciones electro-medicas. Ya que este trabajo demuestra que no es necesario importar todo. BIBLIOGRAFÍA 1. NEVILLE, Conway; Escuela Politécnica Nacional, An Atlas Of Cardiology Electrocardiograms And Chestx-Rays. Primera edición. Wolfe medical publications LTD. México. 2. BOYLESTAD, Roberth; Escuela Politécnica Nacional. ELECTRONICA Teoría De Circuitos. Sexta edición. Pearson Educación. México. 2003. 3. SERALD, Greme; Escuela Politécnica Nacional. Applications Of Operational Amplifiers. Primera Edición. BURR-BROWN editorial. 4. DUBIN, Darle; Anónimo. Electrocardiografía Práctica. Tercera edición. McGraw Hill. Interamericana México. 2002 5. DE LA SERNA, Fernando; Anónimo. Insuficiencia Cardiaca Crónica. Tercera Actualización. Editorial FAC. México. 1998 6. TORRES, M.; MANUAL DE PRÓTEL. España. RA-MA editorial 2006. www.protel.com/manuales 7. MICROCHIP; Datasheet PIC16F87X. www.microchip.com 8. MICROCHIP; Datasheet PIC16F62X. www.microchip.com 9. NATIONAL SEMICONDUCTOR; Datasheet TL084. www.dataseets.com ANEXO 1 PIC16F87X Data Sheet 28/40-Pin 8-Bit CMOS FLASH Microcontrollers 2001 Microchip Technology Inc. DS30292C PIC16F87X 28/40-Pin 8-Bit CMOS FLASH Microcontrollers • PIC16F873 • PIC16F874 • PIC16F876 • PIC16F877 Microcontroller Core Features: • High performance RISC CPU • Only 35 single word instructions to learn • All single cycle instructions except for program branches which are two cycle • Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle • Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memory (RAM) Up to 256 x 8 bytes of EEPROM Data Memory • Pinout compatible to the PIC16C73B/74B/76/77 • Interrupt capability (up to 14 sources) • Eight level deep hardware stack • Direct, indirect and relative addressing modes • Power-on Reset (POR) • Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) • Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation • Programmable code protection • Power saving SLEEP mode • Selectable oscillator options • Low power, high speed CMOS FLASH/EEPROM technology • Fully static design • In-Circuit Serial Programming (ICSP) via two pins • Single 5V In-Circuit Serial Programming capability • In-Circuit Debugging via two pins • Processor read/write access to program memory • Wide operating voltage range: 2.0V to 5.5V • High Sink/Source Current: 25 mA • Commercial, Industrial and Extended temperature ranges • Low-power consumption: - < 0.6 mA typical @ 3V, 4 MHz - 20 µA typical @ 3V, 32 kHz - < 1 µA typical standby current 2001 Microchip Technology Inc. Pin Diagram PDIP MCLR/VPP RA0/AN0 1 2 40 39 RB7/PGD RB6/PGC RA1/AN1 RA2/AN2/VREF- 3 38 RB5 4 37 RA3/AN3/VREF+ 36 35 RB4 RB3/PGM RA4/T0CKI 5 6 RA5/AN4/SS 7 34 RB1 RE0/RD/AN5 8 33 RB0/INT RE1/WR/AN6 9 10 32 31 VDD 30 RD7/PSP7 29 28 RD6/PSP6 RD5/PSP5 RE2/CS/AN7 VDD 11 VSS 12 OSC1/CLKIN 13 PIC16F877/874 Devices Included in this Data Sheet: RB2 VSS OSC2/CLKOUT 14 27 RD4/PSP4 RC0/T1OSO/T1CKI 15 26 RC7/RX/DT RC1/T1OSI/CCP2 16 25 RC6/TX/CK RC2/CCP1 17 24 RC5/SDO RC3/SCK/SCL RD0/PSP0 18 23 19 20 22 21 RC4/SDI/SDA RD3/PSP3 RD1/PSP1 RD2/PSP2 Peripheral Features: • Timer0: 8-bit timer/counter with 8-bit prescaler • Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external crystal/clock • Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler • Two Capture, Compare, PWM modules - Capture is 16-bit, max. resolution is 12.5 ns - Compare is 16-bit, max. resolution is 200 ns - PWM max. resolution is 10-bit • 10-bit multi-channel Analog-to-Digital converter • Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave) • Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection • Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls (40/44-pin only) • Brown-out detection circuitry for Brown-out Reset (BOR) DS30292C-page 1 PIC16F87X Pin Diagrams PLCC PIC16F877 PIC16F874 39 38 37 36 35 34 33 32 31 30 9 RB3/PGM RB2 RB1 RB0/INT VDD VSS RD7/PSP7 RD6/PSP6 RD5/PSP5 RD4/PSP4 RC7/RX/DT 44 43 42 41 40 39 38 37 36 35 34 QFP 7 8 9 10 11 12 13 14 15 16 17 RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RC4/SDI/SDA RC5/SDO RC6/TX/CK NC RC6/TX/CK RC5/SDO RC4/SDI/SDA RD3/PSP3 RD2/PSP2 RD1/PSP1 RD0/PSP0 RC3/SCK/SCL RC2/CCP1 RC1/T1OSI/CCP2 NC RA4/T0CKI RA5/AN4/SS RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 VDD VSS OSC1/CLKIN OSC2/CLKOUT RC0/T1OSO/T1CK1 NC RA3/AN3/VREF+ RA2/AN2/VREFRA1/AN1 RA0/AN0 MCLR/VPP NC RB7/PGD RB6/PGC RB5 RB4 NC RB7/PGD RB6/PGC RB5 RB4 RB3/PGM RB2 RB1 RB0/INT VDD VSS RC7/RX/DT RC6/TX/CK RC5/SDO RC4/SDI/SDA 6 5 4 3 2 1 44 43 42 41 40 28 27 26 25 24 23 22 21 20 19 18 17 16 15 18 19 20 21 22 23 24 25 26 27 282 1 2 3 4 5 6 7 8 9 10 11 12 13 14 MCLR/VPP RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS VSS OSC1/CLKIN OSC2/CLKOUT RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL PIC16F876/873 PDIP, SOIC PIC16F877 PIC16F874 33 32 31 30 29 28 27 26 25 24 23 12 13 14 15 16 17 18 19 20 21 22 1 2 3 4 5 6 7 8 9 10 11 NC RC0/T1OSO/T1CKI OSC2/CLKOUT OSC1/CLKIN VSS VDD RE2/AN7/CS RE1/AN6/WR RE0/AN5/RD RA5/AN4/SS RA4/T0CKI NC NC RB4 RB5 RB6/PGC RB7/PGD MCLR/VPP RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RC7/RX/DT RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 VSS VDD RB0/INT RB1 RB2 RB3/PGM DS30292C-page 2 2001 Microchip Technology Inc. PIC16F87X Key Features PICmicro™ Mid-Range Reference Manual (DS33023) PIC16F873 PIC16F874 PIC16F876 PIC16F877 Operating Frequency DC - 20 MHz DC - 20 MHz DC - 20 MHz DC - 20 MHz RESETS (and Delays) POR, BOR (PWRT, OST) POR, BOR (PWRT, OST) POR, BOR (PWRT, OST) POR, BOR (PWRT, OST) FLASH Program Memory (14-bit words) 4K 4K 8K 8K Data Memory (bytes) 192 192 368 368 EEPROM Data Memory 128 128 256 256 Interrupts 13 14 13 14 I/O Ports Ports A,B,C Ports A,B,C,D,E Ports A,B,C Ports A,B,C,D,E Timers 3 3 3 3 Capture/Compare/PWM Modules 2 2 2 2 MSSP, USART Serial Communications MSSP, USART MSSP, USART MSSP, USART Parallel Communications — PSP — PSP 10-bit Analog-to-Digital Module 5 input channels 8 input channels 5 input channels 8 input channels Instruction Set 35 instructions 35 instructions 35 instructions 35 instructions 2001 Microchip Technology Inc. DS30292C-page 3 PIC16F87X Table of Contents 1.0 Device Overview ................................................................................................................................................... 5 2.0 Memory Organization.......................................................................................................................................... 11 3.0 I/O Ports .............................................................................................................................................................. 29 4.0 Data EEPROM and FLASH Program Memory.................................................................................................... 41 5.0 Timer0 Module .................................................................................................................................................... 47 6.0 Timer1 Module .................................................................................................................................................... 51 7.0 Timer2 Module .................................................................................................................................................... 55 8.0 Capture/Compare/PWM Modules ....................................................................................................................... 57 9.0 Master Synchronous Serial Port (MSSP) Module ............................................................................................... 65 10.0 Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART) ........................................ 95 11.0 Analog-to-Digital Converter (A/D) Module......................................................................................................... 111 12.0 Special Features of the CPU............................................................................................................................. 119 13.0 Instruction Set Summary................................................................................................................................... 135 14.0 Development Support ....................................................................................................................................... 143 15.0 Electrical Characteristics................................................................................................................................... 149 16.0 DC and AC Characteristics Graphs and Tables................................................................................................ 177 17.0 Packaging Information ...................................................................................................................................... 189 Appendix A: Revision History .................................................................................................................................... 197 Appendix B: Device Differences ................................................................................................................................ 197 Appendix C: Conversion Considerations ................................................................................................................... 198 Index .......................................................................................................................................................................... 199 On-Line Support ......................................................................................................................................................... 207 Reader Response ...................................................................................................................................................... 208 PIC16F87X Product Identification System ................................................................................................................. 209 TO OUR VALUED CUSTOMERS It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and enhanced as new volumes and updates are introduced. If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via E-mail at docerrors@mail.microchip.com or fax the Reader Response Form in the back of this data sheet to (480) 792-4150. We welcome your feedback. Most Current Data Sheet To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at: http://www.microchip.com You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page. The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000). Errata An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision of silicon and revision of document to which it applies. To determine if an errata sheet exists for a particular device, please check with one of the following: • Microchip’s Worldwide Web site; http://www.microchip.com • Your local Microchip sales office (see last page) • The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277 When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include literature number) you are using. Customer Notification System Register on our web site at www.microchip.com/cn to receive the most current information on all of our products. DS30292C-page 4 2001 Microchip Technology Inc. PIC16F87X 1.0 DEVICE OVERVIEW There are four devices (PIC16F873, PIC16F874, PIC16F876 and PIC16F877) covered by this data sheet. The PIC16F876/873 devices come in 28-pin packages and the PIC16F877/874 devices come in 40-pin packages. The Parallel Slave Port is not implemented on the 28-pin devices. This document contains device specific information. Additional information may be found in the PICmicro™ Mid-Range Reference Manual (DS33023), which may be obtained from your local Microchip Sales Representative or downloaded from the Microchip website. The Reference Manual should be considered a complementary document to this data sheet, and is highly recommended reading for a better understanding of the device architecture and operation of the peripheral modules. FIGURE 1-1: The following device block diagrams are sorted by pin number; 28-pin for Figure 1-1 and 40-pin for Figure 1-2. The 28-pin and 40-pin pinouts are listed in Table 1-1 and Table 1-2, respectively. PIC16F873 AND PIC16F876 BLOCK DIAGRAM Device Program FLASH Data Memory Data EEPROM PIC16F873 4K 192 Bytes 128 Bytes PIC16F876 8K 368 Bytes 256 Bytes 13 FLASH Program Memory Program Bus PORTA RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS RAM File Registers 8 Level Stack (13-bit) 14 8 Data Bus Program Counter RAM Addr(1) PORTB 9 RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD Addr MUX Instruction reg Direct Addr 7 8 Indirect Addr FSR reg STATUS reg 8 PORTC 3 Power-up Timer Instruction Decode & Control Oscillator Start-up Timer Timing Generation Watchdog Timer Brown-out Reset In-Circuit Debugger OSC1/CLKIN OSC2/CLKOUT Power-on Reset MUX ALU 8 RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT W reg Low Voltage Programming MCLR VDD, VSS Timer0 Timer1 Timer2 10-bit A/D Data EEPROM CCP1,2 Synchronous Serial Port USART Note 1: Higher order bits are from the STATUS register. 2001 Microchip Technology Inc. DS30292C-page 5 PIC16F87X FIGURE 1-2: PIC16F874 AND PIC16F877 BLOCK DIAGRAM Device Program FLASH Data Memory Data EEPROM PIC16F874 4K 192 Bytes 128 Bytes PIC16F877 8K 368 Bytes 256 Bytes 13 Program Memory 14 PORTA RA0/AN0 RA1/AN1 RA2/AN2/VREFRA3/AN3/VREF+ RA4/T0CKI RA5/AN4/SS RAM File Registers 8 Level Stack (13-bit) Program Bus 8 Data Bus Program Counter FLASH RAM Addr(1) PORTB 9 RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD Addr MUX Instruction reg Direct Addr 7 8 Indirect Addr FSR reg STATUS reg 8 PORTC 3 Power-up Timer Instruction Decode & Control Oscillator Start-up Timer Timing Generation Watchdog Timer Brown-out Reset OSC1/CLKIN OSC2/CLKOUT Power-on Reset RC0/T1OSO/T1CKI RC1/T1OSI/CCP2 RC2/CCP1 RC3/SCK/SCL RC4/SDI/SDA RC5/SDO RC6/TX/CK RC7/RX/DT MUX ALU 8 W reg PORTD RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 In-Circuit Debugger Low-Voltage Programming Parallel Slave Port PORTE MCLR RE0/AN5/RD VDD, VSS RE1/AN6/WR RE2/AN7/CS Timer0 Timer1 Timer2 10-bit A/D Data EEPROM CCP1,2 Synchronous Serial Port USART Note 1: Higher order bits are from the STATUS register. DS30292C-page 6 2001 Microchip Technology Inc. PIC16F87X 2.2.2.1 STATUS Register The STATUS register contains the arithmetic status of the ALU, the RESET status and the bank select bits for data memory. The STATUS register can be the destination for any instruction, as with any other register. If the STATUS register is the destination for an instruction that affects the Z, DC or C bits, then the write to these three bits is disabled. These bits are set or cleared according to the device logic. Furthermore, the TO and PD bits are not writable, therefore, the result of an instruction with the STATUS register as destination may be different than intended. REGISTER 2-1: For example, CLRF STATUS will clear the upper three bits and set the Z bit. This leaves the STATUS register as 000u u1uu (where u = unchanged). It is recommended, therefore, that only BCF, BSF, SWAPF and MOVWF instructions are used to alter the STATUS register, because these instructions do not affect the Z, C or DC bits from the STATUS register. For other instructions not affecting any status bits, see the “Instruction Set Summary." Note: The C and DC bits operate as a borrow and digit borrow bit, respectively, in subtraction. See the SUBLW and SUBWF instructions for examples. STATUS REGISTER (ADDRESS 03h, 83h, 103h, 183h) R/W-0 R/W-0 R/W-0 R-1 R-1 R/W-x R/W-x R/W-x IRP RP1 RP0 TO PD Z DC C bit 7 bit 0 bit 7 IRP: Register Bank Select bit (used for indirect addressing) 1 = Bank 2, 3 (100h - 1FFh) 0 = Bank 0, 1 (00h - FFh) bit 6-5 RP1:RP0: Register Bank Select bits (used for direct addressing) 11 = Bank 3 (180h - 1FFh) 10 = Bank 2 (100h - 17Fh) 01 = Bank 1 (80h - FFh) 00 = Bank 0 (00h - 7Fh) Each bank is 128 bytes bit 4 TO: Time-out bit 1 = After power-up, CLRWDT instruction, or SLEEP instruction 0 = A WDT time-out occurred bit 3 PD: Power-down bit 1 = After power-up or by the CLRWDT instruction 0 = By execution of the SLEEP instruction bit 2 Z: Zero bit 1 = The result of an arithmetic or logic operation is zero 0 = The result of an arithmetic or logic operation is not zero bit 1 DC: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow, the polarity is reversed) 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result bit 0 C: Carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) 1 = A carry-out from the Most Significant bit of the result occurred 0 = No carry-out from the Most Significant bit of the result occurred Note: For borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high, or low order bit of the source register. Legend: DS30292C-page 18 R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown 2001 Microchip Technology Inc. PIC16F87X 2.2.2.2 OPTION_REG Register Note: The OPTION_REG Register is a readable and writable register, which contains various control bits to configure the TMR0 prescaler/WDT postscaler (single assignable register known also as the prescaler), the External INT Interrupt, TMR0 and the weak pull-ups on PORTB. REGISTER 2-2: To achieve a 1:1 prescaler assignment for the TMR0 register, assign the prescaler to the Watchdog Timer. OPTION_REG REGISTER (ADDRESS 81h, 181h) R/W-1 R/W-1 R/W-1 R/W-1 R/W-1 R/W-1 R/W-1 R/W-1 RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 bit 7 bit 0 bit 7 RBPU: PORTB Pull-up Enable bit 1 = PORTB pull-ups are disabled 0 = PORTB pull-ups are enabled by individual port latch values bit 6 INTEDG: Interrupt Edge Select bit 1 = Interrupt on rising edge of RB0/INT pin 0 = Interrupt on falling edge of RB0/INT pin bit 5 T0CS: TMR0 Clock Source Select bit 1 = Transition on RA4/T0CKI pin 0 = Internal instruction cycle clock (CLKOUT) bit 4 T0SE: TMR0 Source Edge Select bit 1 = Increment on high-to-low transition on RA4/T0CKI pin 0 = Increment on low-to-high transition on RA4/T0CKI pin bit 3 PSA: Prescaler Assignment bit 1 = Prescaler is assigned to the WDT 0 = Prescaler is assigned to the Timer0 module bit 2-0 PS2:PS0: Prescaler Rate Select bits Bit Value 000 001 010 011 100 101 110 111 TMR0 Rate WDT Rate 1:2 1:4 1:8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 1:1 1:2 1:4 1:8 1 : 16 1 : 32 1 : 64 1 : 128 Legend: Note: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown When using low voltage ICSP programming (LVP) and the pull-ups on PORTB are enabled, bit 3 in the TRISB register must be cleared to disable the pull-up on RB3 and ensure the proper operation of the device 2001 Microchip Technology Inc. DS30292C-page 19 PIC16F87X 2.2.2.3 INTCON Register Note: The INTCON Register is a readable and writable register, which contains various enable and flag bits for the TMR0 register overflow, RB Port change and External RB0/INT pin interrupts. REGISTER 2-3: Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, GIE (INTCON<7>). User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. INTCON REGISTER (ADDRESS 0Bh, 8Bh, 10Bh, 18Bh) R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-x GIE PEIE T0IE INTE RBIE T0IF INTF RBIF bit 7 bit 0 bit 7 GIE: Global Interrupt Enable bit 1 = Enables all unmasked interrupts 0 = Disables all interrupts bit 6 PEIE: Peripheral Interrupt Enable bit 1 = Enables all unmasked peripheral interrupts 0 = Disables all peripheral interrupts bit 5 T0IE: TMR0 Overflow Interrupt Enable bit 1 = Enables the TMR0 interrupt 0 = Disables the TMR0 interrupt bit 4 INTE: RB0/INT External Interrupt Enable bit 1 = Enables the RB0/INT external interrupt 0 = Disables the RB0/INT external interrupt bit 3 RBIE: RB Port Change Interrupt Enable bit 1 = Enables the RB port change interrupt 0 = Disables the RB port change interrupt bit 2 T0IF: TMR0 Overflow Interrupt Flag bit 1 = TMR0 register has overflowed (must be cleared in software) 0 = TMR0 register did not overflow bit 1 INTF: RB0/INT External Interrupt Flag bit 1 = The RB0/INT external interrupt occurred (must be cleared in software) 0 = The RB0/INT external interrupt did not occur bit 0 RBIF: RB Port Change Interrupt Flag bit 1 = At least one of the RB7:RB4 pins changed state; a mismatch condition will continue to set the bit. Reading PORTB will end the mismatch condition and allow the bit to be cleared (must be cleared in software). 0 = None of the RB7:RB4 pins have changed state Legend: DS30292C-page 20 R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown 2001 Microchip Technology Inc. PIC16F87X 2.2.2.4 PIE1 Register The PIE1 register contains the individual enable bits for the peripheral interrupts. REGISTER 2-4: Note: Bit PEIE (INTCON<6>) must be set to enable any peripheral interrupt. PIE1 REGISTER (ADDRESS 8Ch) R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE bit 7 bit 0 bit 7 PSPIE(1): Parallel Slave Port Read/Write Interrupt Enable bit 1 = Enables the PSP read/write interrupt 0 = Disables the PSP read/write interrupt bit 6 ADIE: A/D Converter Interrupt Enable bit 1 = Enables the A/D converter interrupt 0 = Disables the A/D converter interrupt bit 5 RCIE: USART Receive Interrupt Enable bit 1 = Enables the USART receive interrupt 0 = Disables the USART receive interrupt bit 4 TXIE: USART Transmit Interrupt Enable bit 1 = Enables the USART transmit interrupt 0 = Disables the USART transmit interrupt bit 3 SSPIE: Synchronous Serial Port Interrupt Enable bit 1 = Enables the SSP interrupt 0 = Disables the SSP interrupt bit 2 CCP1IE: CCP1 Interrupt Enable bit 1 = Enables the CCP1 interrupt 0 = Disables the CCP1 interrupt bit 1 TMR2IE: TMR2 to PR2 Match Interrupt Enable bit 1 = Enables the TMR2 to PR2 match interrupt 0 = Disables the TMR2 to PR2 match interrupt bit 0 TMR1IE: TMR1 Overflow Interrupt Enable bit 1 = Enables the TMR1 overflow interrupt 0 = Disables the TMR1 overflow interrupt Note 1: PSPIE is reserved on PIC16F873/876 devices; always maintain this bit clear. Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 21 PIC16F87X 2.2.2.5 PIR1 Register Note: The PIR1 register contains the individual flag bits for the peripheral interrupts. REGISTER 2-5: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 PIR1 REGISTER (ADDRESS 0Ch) R/W-0 R/W-0 R-0 R-0 R/W-0 R/W-0 R/W-0 R/W-0 PSPIF(1) bit 7 ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF bit 0 PSPIF(1): Parallel Slave Port Read/Write Interrupt Flag bit 1 = A read or a write operation has taken place (must be cleared in software) 0 = No read or write has occurred ADIF: A/D Converter Interrupt Flag bit 1 = An A/D conversion completed 0 = The A/D conversion is not complete RCIF: USART Receive Interrupt Flag bit 1 = The USART receive buffer is full 0 = The USART receive buffer is empty TXIF: USART Transmit Interrupt Flag bit 1 = The USART transmit buffer is empty 0 = The USART transmit buffer is full SSPIF: Synchronous Serial Port (SSP) Interrupt Flag 1 = The SSP interrupt condition has occurred, and must be cleared in software before returning from the Interrupt Service Routine. The conditions that will set this bit are: • SPI - A transmission/reception has taken place. • I2C Slave - A transmission/reception has taken place. • I2C Master - A transmission/reception has taken place. - The initiated START condition was completed by the SSP module. - The initiated STOP condition was completed by the SSP module. - The initiated Restart condition was completed by the SSP module. - The initiated Acknowledge condition was completed by the SSP module. - A START condition occurred while the SSP module was idle (Multi-Master system). - A STOP condition occurred while the SSP module was idle (Multi-Master system). 0 = No SSP interrupt condition has occurred. CCP1IF: CCP1 Interrupt Flag bit Capture mode: 1 = A TMR1 register capture occurred (must be cleared in software) 0 = No TMR1 register capture occurred Compare mode: 1 = A TMR1 register compare match occurred (must be cleared in software) 0 = No TMR1 register compare match occurred PWM mode: Unused in this mode TMR2IF: TMR2 to PR2 Match Interrupt Flag bit 1 = TMR2 to PR2 match occurred (must be cleared in software) 0 = No TMR2 to PR2 match occurred TMR1IF: TMR1 Overflow Interrupt Flag bit 1 = TMR1 register overflowed (must be cleared in software) 0 = TMR1 register did not overflow Note 1: PSPIF is reserved on PIC16F873/876 devices; always maintain this bit clear. Legend: R = Readable bit - n = Value at POR DS30292C-page 22 Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, GIE (INTCON<7>). User software should ensure the appropriate interrupt bits are clear prior to enabling an interrupt. W = Writable bit ’1’ = Bit is set U = Unimplemented bit, read as ‘0’ ’0’ = Bit is cleared x = Bit is unknown 2001 Microchip Technology Inc. PIC16F87X 2.2.2.6 PIE2 Register The PIE2 register contains the individual enable bits for the CCP2 peripheral interrupt, the SSP bus collision interrupt, and the EEPROM write operation interrupt. REGISTER 2-6: PIE2 REGISTER (ADDRESS 8Dh) U-0 R/W-0 U-0 R/W-0 R/W-0 U-0 U-0 R/W-0 — Reserved — EEIE BCLIE — — CCP2IE bit 7 bit 0 bit 7 Unimplemented: Read as '0' bit 6 Reserved: Always maintain this bit clear bit 5 Unimplemented: Read as '0' bit 4 EEIE: EEPROM Write Operation Interrupt Enable 1 = Enable EE Write Interrupt 0 = Disable EE Write Interrupt bit 3 BCLIE: Bus Collision Interrupt Enable 1 = Enable Bus Collision Interrupt 0 = Disable Bus Collision Interrupt bit 2-1 Unimplemented: Read as '0' bit 0 CCP2IE: CCP2 Interrupt Enable bit 1 = Enables the CCP2 interrupt 0 = Disables the CCP2 interrupt Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 23 PIC16F87X 2.2.2.7 PIR2 Register . Note: The PIR2 register contains the flag bits for the CCP2 interrupt, the SSP bus collision interrupt and the EEPROM write operation interrupt. REGISTER 2-7: Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, GIE (INTCON<7>). User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. PIR2 REGISTER (ADDRESS 0Dh) U-0 R/W-0 U-0 R/W-0 R/W-0 U-0 U-0 R/W-0 — Reserved — EEIF BCLIF — — CCP2IF bit 7 bit 0 bit 7 Unimplemented: Read as '0' bit 6 Reserved: Always maintain this bit clear bit 5 Unimplemented: Read as '0' bit 4 EEIF: EEPROM Write Operation Interrupt Flag bit 1 = The write operation completed (must be cleared in software) 0 = The write operation is not complete or has not been started bit 3 BCLIF: Bus Collision Interrupt Flag bit 1 = A bus collision has occurred in the SSP, when configured for I2C Master mode 0 = No bus collision has occurred bit 2-1 Unimplemented: Read as '0' bit 0 CCP2IF: CCP2 Interrupt Flag bit Capture mode: 1 = A TMR1 register capture occurred (must be cleared in software) 0 = No TMR1 register capture occurred Compare mode: 1 = A TMR1 register compare match occurred (must be cleared in software) 0 = No TMR1 register compare match occurred PWM mode: Unused Legend: DS30292C-page 24 R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown 2001 Microchip Technology Inc. PIC16F87X 2.2.2.8 PCON Register Note: The Power Control (PCON) Register contains flag bits to allow differentiation between a Power-on Reset (POR), a Brown-out Reset (BOR), a Watchdog Reset (WDT), and an external MCLR Reset. REGISTER 2-8: BOR is unknown on POR. It must be set by the user and checked on subsequent RESETS to see if BOR is clear, indicating a brown-out has occurred. The BOR status bit is a “don’t care” and is not predictable if the brown-out circuit is disabled (by clearing the BODEN bit in the configuration word). PCON REGISTER (ADDRESS 8Eh) U-0 U-0 U-0 U-0 U-0 U-0 R/W-0 R/W-1 — — — — — — POR BOR bit 7 bit 0 bit 7-2 Unimplemented: Read as '0' bit 1 POR: Power-on Reset Status bit 1 = No Power-on Reset occurred 0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs) bit 0 BOR: Brown-out Reset Status bit 1 = No Brown-out Reset occurred 0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs) Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 25 PIC16F87X 2.3 PCL and PCLATH The program counter (PC) is 13-bits wide. The low byte comes from the PCL register, which is a readable and writable register. The upper bits (PC<12:8>) are not readable, but are indirectly writable through the PCLATH register. On any RESET, the upper bits of the PC will be cleared. Figure 2-5 shows the two situations for the loading of the PC. The upper example in the figure shows how the PC is loaded on a write to PCL (PCLATH<4:0> → PCH). The lower example in the figure shows how the PC is loaded during a CALL or GOTO instruction (PCLATH<4:3> → PCH). FIGURE 2-5: LOADING OF PC IN DIFFERENT SITUATIONS PCH PCL 12 8 7 0 PC 8 PCLATH<4:0> 5 Instruction with PCL as Destination ALU PCLATH PCH 12 11 10 PCL 8 Note 1: There are no status bits to indicate stack overflow or stack underflow conditions. 2: There are no instructions/mnemonics called PUSH or POP. These are actions that occur from the execution of the CALL, RETURN, RETLW and RETFIE instructions, or the vectoring to an interrupt address. 2.4 Program Memory Paging All PIC16F87X devices are capable of addressing a continuous 8K word block of program memory. The CALL and GOTO instructions provide only 11 bits of address to allow branching within any 2K program memory page. When doing a CALL or GOTO instruction, the upper 2 bits of the address are provided by PCLATH<4:3>. When doing a CALL or GOTO instruction, the user must ensure that the page select bits are programmed so that the desired program memory page is addressed. If a return from a CALL instruction (or interrupt) is executed, the entire 13-bit PC is popped off the stack. Therefore, manipulation of the PCLATH<4:3> bits is not required for the return instructions (which POPs the address from the stack). Note: 0 7 PC GOTO,CALL 2 PCLATH<4:3> 11 Opcode <10:0> PCLATH 2.3.1 COMPUTED GOTO A computed GOTO is accomplished by adding an offset to the program counter (ADDWF PCL). When doing a table read using a computed GOTO method, care should be exercised if the table location crosses a PCL memory boundary (each 256 byte block). Refer to the application note, “Implementing a Table Read" (AN556). 2.3.2 Example 2-1 shows the calling of a subroutine in page 1 of the program memory. This example assumes that PCLATH is saved and restored by the Interrupt Service Routine (if interrupts are used). EXAMPLE 2-1: CALL OF A SUBROUTINE IN PAGE 1 FROM PAGE 0 ORG 0x500 BCF PCLATH,4 BSF PCLATH,3 CALL SUB1_P1 : : ORG 0x900 STACK The PIC16F87X family has an 8-level deep x 13-bit wide hardware stack. The stack space is not part of either program or data space and the stack pointer is not readable or writable. The PC is PUSHed onto the stack when a CALL instruction is executed, or an interrupt causes a branch. The stack is POPed in the event of a RETURN,RETLW or a RETFIE instruction execution. PCLATH is not affected by a PUSH or POP operation. The contents of the PCLATH register are unchanged after a RETURN or RETFIE instruction is executed. The user must rewrite the contents of the PCLATH register for any subsequent subroutine calls or GOTO instructions. ;Select page 1 ;(800h-FFFh) ;Call subroutine in ;page 1 (800h-FFFh) ;page 1 (800h-FFFh) SUB1_P1 : : RETURN ;called subroutine ;page 1 (800h-FFFh) ;return to ;Call subroutine ;in page 0 ;(000h-7FFh) The stack operates as a circular buffer. This means that after the stack has been PUSHed eight times, the ninth push overwrites the value that was stored from the first push. The tenth push overwrites the second push (and so on). DS30292C-page 26 2001 Microchip Technology Inc. PIC16F87X 2.5 Indirect Addressing, INDF and FSR Registers A simple program to clear RAM locations 20h-2Fh using indirect addressing is shown in Example 2-2. The INDF register is not a physical register. Addressing the INDF register will cause indirect addressing. EXAMPLE 2-2: Indirect addressing is possible by using the INDF register. Any instruction using the INDF register actually accesses the register pointed to by the File Select Register, FSR. Reading the INDF register itself, indirectly (FSR = ’0’) will read 00h. Writing to the INDF register indirectly results in a no operation (although status bits may be affected). An effective 9-bit address is obtained by concatenating the 8-bit FSR register and the IRP bit (STATUS<7>), as shown in Figure 2-6. FIGURE 2-6: MOVLW MOVWF CLRF INCF BTFSS GOTO NEXT Bank Select ;initialize pointer ;to RAM ;clear INDF register ;inc pointer ;all done? ;no clear next CONTINUE : ;yes continue DIRECT/INDIRECT ADDRESSING Direct Addressing RP1:RP0 INDIRECT ADDRESSING 0x20 FSR INDF FSR,F FSR,4 NEXT 6 Indirect Addressing From Opcode 0 IRP 7 Bank Select Location Select 00 01 10 FSR register 0 Location Select 11 00h 80h 100h 180h 7Fh FFh 17Fh 1FFh Data Memory(1) Bank 0 Bank 1 Bank 2 Bank 3 Note 1: For register file map detail, see Figure 2-3. 2001 Microchip Technology Inc. DS30292C-page 27 PIC16F87X NOTES: DS30292C-page 28 2001 Microchip Technology Inc. PIC16F87X 3.0 I/O PORTS FIGURE 3-1: Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. Additional information on I/O ports may be found in the PICmicro™ Mid-Range Reference Manual, (DS33023). 3.1 Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read, the value is modified and then written to the port data latch. Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open drain output. All other PORTA pins have TTL input levels and full CMOS output drivers. Other PORTA pins are multiplexed with analog inputs and analog VREF input. The operation of each pin is selected by clearing/setting the control bits in the ADCON1 register (A/D Control Register1). On a Power-on Reset, these pins are configured as analog inputs and read as '0'. The TRISA register controls the direction of the RA pins, even when they are being used as analog inputs. The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs. EXAMPLE 3-1: BCF BCF CLRF BSF MOVLW MOVWF MOVLW MOVWF WR Port INITIALIZING PORTA STATUS, RP0 STATUS, RP1 PORTA STATUS, RP0 0x06 ADCON1 0xCF TRISA ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Bank0 Initialize PORTA by clearing output data latches Select Bank 1 Configure all pins as digital inputs Value used to initialize data direction Set RA<3:0> as inputs RA<5:4> as outputs TRISA<7:6>are always read as ’0’. Data Latch D Q VDD Q CK P I/O pin(1) TRIS Latch PORTA and the TRISA Register PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin). Note: Data Bus BLOCK DIAGRAM OF RA3:RA0 AND RA5 PINS D WR TRIS N Q VSS Analog Input Mode Q CK RD TRIS TTL Input Buffer Q D EN RD Port To A/D Converter Note 1: I/O pins have protection diodes to VDD and VSS. FIGURE 3-2: Data Bus WR Port BLOCK DIAGRAM OF RA4/T0CKI PIN Data Latch D Q CK Q N I/O pin(1) TRIS Latch WR TRIS D Q CK Q VSS Schmitt Trigger Input Buffer RD TRIS Q D ENEN RD Port TMR0 Clock Input Note 1: I/O pin has protection diodes to VSS only. 2001 Microchip Technology Inc. DS30292C-page 29 PIC16F87X TABLE 3-1: PORTA FUNCTIONS Name Bit# Buffer Function RA0/AN0 bit0 TTL Input/output or analog input. RA1/AN1 bit1 TTL Input/output or analog input. RA2/AN2 bit2 TTL Input/output or analog input. RA3/AN3/VREF bit3 TTL Input/output or analog input or VREF. RA4/T0CKI bit4 ST Input/output or external clock input for Timer0. Output is open drain type. RA5/SS/AN4 bit5 TTL Input/output or slave select input for synchronous serial port or analog input. Legend: TTL = TTL input, ST = Schmitt Trigger input TABLE 3-2: Address SUMMARY OF REGISTERS ASSOCIATED WITH PORTA Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on: Value on all POR, other BOR RESETS RA5 RA4 RA3 RA2 RA1 RA0 --0x 0000 --0u 0000 --11 1111 --11 1111 PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000 05h PORTA — — 85h TRISA — — 9Fh ADCON1 ADFM — PORTA Data Direction Register — — Legend: x = unknown, u = unchanged, - = unimplemented locations read as '0'. Shaded cells are not used by PORTA. Note: When using the SSP module in SPI Slave mode and SS enabled, the A/D converter must be set to one of the following modes, where PCFG3:PCFG0 = 0100,0101, 011x, 1101, 1110, 1111. DS30292C-page 30 2001 Microchip Technology Inc. PIC16F87X 3.2 PORTB and the TRISB Register PORTB is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin). Three pins of PORTB are multiplexed with the Low Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD. The alternate functions of these pins are described in the Special Features Section. Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset. FIGURE 3-3: BLOCK DIAGRAM OF RB3:RB0 PINS VDD RBPU(2) Data Bus WR Port Weak P Pull-up a) b) Any read or write of PORTB. This will end the mismatch condition. Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF. Reading PORTB will end the mismatch condition and allow flag bit RBIF to be cleared. The interrupt-on-change feature is recommended for wake-up on key depression operation and operations where PORTB is only used for the interrupt-on-change feature. Polling of PORTB is not recommended while using the interrupt-on-change feature. This interrupt-on-mismatch feature, together with software configureable pull-ups on these four pins, allow easy interface to a keypad and make it possible for wake-up on key depression. Refer to the Embedded Control Handbook, “Implementing Wake-up on Key Strokes” (AN552). RB0/INT is an external interrupt input pin and is configured using the INTEDG bit (OPTION_REG<6>). RB0/INT is discussed in detail in Section 12.10.1. Data Latch D FIGURE 3-4: Q CK D BLOCK DIAGRAM OF RB7:RB4 PINS I/O pin(1) VDD TRIS Latch WR TRIS This interrupt can wake the device from SLEEP. The user, in the Interrupt Service Routine, can clear the interrupt in the following manner: RBPU(2) Q TTL Input Buffer CK Data Bus Weak P Pull-up Data Latch D Q WR Port I/O pin(1) CK RD TRIS Q TRIS Latch D Q D RD Port WR TRIS EN RB0/INT RB3/PGM TTL Input Buffer CK RD TRIS Schmitt Trigger Buffer RD Port Note 1: I/O pins have diode protection to VDD and VSS. 2: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit (OPTION_REG<7>). Four of the PORTB pins, RB7:RB4, have an interrupton-change feature. Only pins configured as inputs can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the interrupton-change comparison). The input pins (of RB7:RB4) are compared with the old value latched on the last read of PORTB. The “mismatch” outputs of RB7:RB4 are OR’ed together to generate the RB Port Change Interrupt with flag bit RBIF (INTCON<0>). 2001 Microchip Technology Inc. ST Buffer Latch Q D RD Port EN Q1 Set RBIF Q From other RB7:RB4 pins D RD Port EN Q3 RB7:RB6 In Serial Programming Mode Note 1: I/O pins have diode protection to VDD and VSS. 2: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit (OPTION_REG<7>). DS30292C-page 31 PIC16F87X TABLE 3-3: Name PORTB FUNCTIONS Bit# Buffer RB0/INT bit0 TTL/ST(1) RB1 bit1 TTL Input/output pin. Internal software programmable weak pull-up. RB2 bit2 TTL Input/output pin. Internal software programmable weak pull-up. bit3 TTL Input/output pin or programming pin in LVP mode. Internal software programmable weak pull-up. RB4 bit4 TTL Input/output pin (with interrupt-on-change). Internal software programmable weak pull-up. RB5 bit5 TTL Input/output pin (with interrupt-on-change). Internal software programmable weak pull-up. RB6/PGC bit6 TTL/ST(2) Input/output pin (with interrupt-on-change) or In-Circuit Debugger pin. Internal software programmable weak pull-up. Serial programming clock. RB7/PGD bit7 TTL/ST(2) Input/output pin (with interrupt-on-change) or In-Circuit Debugger pin. Internal software programmable weak pull-up. Serial programming data. RB3/PGM Legend: Note 1: 2: 3: (3) Function Input/output pin or external interrupt input. Internal software programmable weak pull-up. TTL = TTL input, ST = Schmitt Trigger input This buffer is a Schmitt Trigger input when configured as the external interrupt. This buffer is a Schmitt Trigger input when used in Serial Programming mode. Low Voltage ICSP Programming (LVP) is enabled by default, which disables the RB3 I/O function. LVP must be disabled to enable RB3 as an I/O pin and allow maximum compatibility to the other 28-pin and 40-pin mid-range devices. TABLE 3-4: Address SUMMARY OF REGISTERS ASSOCIATED WITH PORTB Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 RB7 RB6 RB5 RB4 RB3 06h, 106h PORTB 86h, 186h TRISB 81h, 181h OPTION_REG RBPU RB2 RB1 T0CS T0SE Value on all other RESETS RB0 xxxx xxxx uuuu uuuu PORTB Data Direction Register INTEDG Value on: POR, BOR 1111 1111 1111 1111 PSA PS2 PS1 PS0 1111 1111 1111 1111 Legend: x = unknown, u = unchanged. Shaded cells are not used by PORTB. DS30292C-page 32 2001 Microchip Technology Inc. PIC16F87X 3.3 PORTC and the TRISC Register PORTC is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISC bit (= 0) will make the corresponding PORTC pin an output (i.e., put the contents of the output latch on the selected pin). PORTC is multiplexed with several peripheral functions (Table 3-5). PORTC pins have Schmitt Trigger input buffers. FIGURE 3-6: Port/Peripheral Select(2) Peripheral Data Out Data Bus WR Port WR TRIS When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modifywrite instructions (BSF, BCF, XORWF) with TRISC as destination, should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings. RD TRIS PORTC BLOCK DIAGRAM (PERIPHERAL OUTPUT OVERRIDE) RC<2:0>, RC<7:5> Port/Peripheral Select(2) Peripheral Data Out Data Bus WR Port D CK CK VDD Q Q P 1 I/O pin(1) D CK Q Q N TRIS Latch Peripheral OE(3) RD Port Vss Schmitt Trigger Q D EN 0 Schmitt Trigger with SMBus levels SSPl Input 1 CKE SSPSTAT<6> Note 1: I/O pins have diode protection to VDD and VSS. 2: Port/Peripheral select signal selects between port data and peripheral output. 3: Peripheral OE (output enable) is only activated if peripheral select is active. VDD 0 Q Q D 0 Data Latch When the I2C module is enabled, the PORTC<4:3> pins can be configured with normal I2C levels, or with SMBus levels by using the CKE bit (SSPSTAT<6>). FIGURE 3-5: PORTC BLOCK DIAGRAM (PERIPHERAL OUTPUT OVERRIDE) RC<4:3> P 1 I/O pin(1) Data Latch D WR TRIS CK Q Q N TRIS Latch VSS RD TRIS Schmitt Trigger Peripheral OE(3) Q D EN RD Port Peripheral Input Note 1: I/O pins have diode protection to VDD and VSS. 2: Port/Peripheral select signal selects between port data and peripheral output. 3: Peripheral OE (output enable) is only activated if peripheral select is active. 2001 Microchip Technology Inc. DS30292C-page 33 PIC16F87X TABLE 3-5: PORTC FUNCTIONS Name Bit# Buffer Type Function RC0/T1OSO/T1CKI bit0 ST Input/output port pin or Timer1 oscillator output/Timer1 clock input. RC1/T1OSI/CCP2 bit1 ST Input/output port pin or Timer1 oscillator input or Capture2 input/ Compare2 output/PWM2 output. RC2/CCP1 bit2 ST Input/output port pin or Capture1 input/Compare1 output/ PWM1 output. RC3/SCK/SCL bit3 ST RC3 can also be the synchronous serial clock for both SPI and I2C modes. RC4/SDI/SDA bit4 ST RC4 can also be the SPI Data In (SPI mode) or data I/O (I2C mode). RC5/SDO bit5 ST Input/output port pin or Synchronous Serial Port data output. RC6/TX/CK bit6 ST Input/output port pin or USART Asynchronous Transmit or Synchronous Clock. RC7/RX/DT bit7 ST Input/output port pin or USART Asynchronous Receive or Synchronous Data. Legend: ST = Schmitt Trigger input TABLE 3-6: Address SUMMARY OF REGISTERS ASSOCIATED WITH PORTC Name 07h PORTC 87h TRISC Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on: POR, BOR Value on all other RESETS RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx uuuu uuuu 1111 1111 1111 1111 PORTC Data Direction Register Legend: x = unknown, u = unchanged DS30292C-page 34 2001 Microchip Technology Inc. PIC16F87X 3.4 FIGURE 3-7: PORTD and TRISD Registers PORTD and TRISD are not implemented on the PIC16F873 or PIC16F876. Data Bus PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is individually configureable as an input or output. WR Port PORTD can be configured as an 8-bit wide microprocessor port (parallel slave port) by setting control bit PSPMODE (TRISE<4>). In this mode, the input buffers are TTL. PORTD BLOCK DIAGRAM (IN I/O PORT MODE) I/O pin(1) Data Latch D Q CK TRIS Latch D WR TRIS Q Schmitt Trigger Input Buffer CK RD TRIS Q D ENEN RD Port Note 1: I/O pins have protection diodes to VDD and VSS. TABLE 3-7: Name PORTD FUNCTIONS Bit# RD0/PSP0 Buffer Type bit0 Function ST/TTL (1) Input/output port pin or parallel slave port bit0. (1) Input/output port pin or parallel slave port bit1. RD1/PSP1 bit1 ST/TTL RD2/PSP2 bit2 ST/TTL(1) Input/output port pin or parallel slave port bit2. RD3/PSP3 bit3 ST/TTL(1) Input/output port pin or parallel slave port bit3. RD4/PSP4 bit4 ST/TTL (1) Input/output port pin or parallel slave port bit4. RD5/PSP5 bit5 ST/TTL(1) Input/output port pin or parallel slave port bit5. RD6/PSP6 bit6 ST/TTL(1) Input/output port pin or parallel slave port bit6. bit7 ST/TTL(1) Input/output port pin or parallel slave port bit7. RD7/PSP7 Legend: ST = Schmitt Trigger input, TTL = TTL input Note 1: Input buffers are Schmitt Triggers when in I/O mode and TTL buffers when in Parallel Slave Port mode. TABLE 3-8: SUMMARY OF REGISTERS ASSOCIATED WITH PORTD Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on: POR, BOR Value on all other RESETS 08h PORTD RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx uuuu uuuu 88h TRISD PORTD Data Direction Register 1111 1111 1111 1111 89h TRISE 0000 -111 0000 -111 Address IBF OBF IBOV PSPMODE — PORTE Data Direction Bits Legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by PORTD. 2001 Microchip Technology Inc. DS30292C-page 35 PIC16F87X 3.5 FIGURE 3-8: PORTE and TRISE Register PORTE and TRISE are not implemented on the PIC16F873 or PIC16F876. Data Bus PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6, and RE2/CS/AN7) which are individually configureable as inputs or outputs. These pins have Schmitt Trigger input buffers. PORTE BLOCK DIAGRAM (IN I/O PORT MODE) I/O pin(1) Data Latch D Q WR Port CK TRIS Latch The PORTE pins become the I/O control inputs for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make certain that the TRISE<2:0> bits are set, and that the pins are configured as digital inputs. Also ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL. D WR TRIS Q Schmitt Trigger Input Buffer CK RD TRIS Register 3-1 shows the TRISE register, which also controls the parallel slave port operation. PORTE pins are multiplexed with analog inputs. When selected for analog input, these pins will read as ’0’s. Q TRISE controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs. Note: ENEN RD Port Note 1: I/O pins have protection diodes to VDD and VSS. On a Power-on Reset, these pins are configured as analog inputs, and read as ‘0’. TABLE 3-9: D PORTE FUNCTIONS Name Bit# RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 Buffer Type bit0 bit1 bit2 Function ST/TTL(1) I/O port pin or read control input in Parallel Slave Port mode or analog input: RD 1 = Idle 0 = Read operation. Contents of PORTD register are output to PORTD I/O pins (if chip selected) ST/TTL(1) I/O port pin or write control input in Parallel Slave Port mode or analog input: WR 1 = Idle 0 = Write operation. Value of PORTD I/O pins is latched into PORTD register (if chip selected) ST/TTL(1) I/O port pin or chip select control input in Parallel Slave Port mode or analog input: CS 1 = Device is not selected 0 = Device is selected Legend: ST = Schmitt Trigger input, TTL = TTL input Note 1: Input buffers are Schmitt Triggers when in I/O mode and TTL buffers when in Parallel Slave Port mode. TABLE 3-10: Address SUMMARY OF REGISTERS ASSOCIATED WITH PORTE Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 09h PORTE — — — — — 89h TRISE IBF OBF IBOV PSPMODE — 9Fh ADCON1 ADFM — — — PCFG3 Bit 2 Bit 1 Bit 0 Value on: POR, BOR Value on all other RESETS RE2 RE1 RE0 ---- -xxx ---- -uuu PORTE Data Direction Bits 0000 -111 0000 -111 PCFG2 --0- 0000 --0- 0000 PCFG1 PCFG0 Legend: x = unknown, u = unchanged, - = unimplemented, read as ’0’. Shaded cells are not used by PORTE. DS30292C-page 36 2001 Microchip Technology Inc. PIC16F87X REGISTER 3-1: TRISE REGISTER (ADDRESS 89h) R-0 R-0 R/W-0 R/W-0 U-0 R/W-1 R/W-1 R/W-1 IBF OBF IBOV PSPMODE — Bit2 Bit1 Bit0 bit 7 bit 0 Parallel Slave Port Status/Control Bits: bit 7 IBF: Input Buffer Full Status bit 1 = A word has been received and is waiting to be read by the CPU 0 = No word has been received bit 6 OBF: Output Buffer Full Status bit 1 = The output buffer still holds a previously written word 0 = The output buffer has been read bit 5 IBOV: Input Buffer Overflow Detect bit (in Microprocessor mode) 1 = A write occurred when a previously input word has not been read (must be cleared in software) 0 = No overflow occurred bit 4 PSPMODE: Parallel Slave Port Mode Select bit 1 = PORTD functions in Parallel Slave Port mode 0 = PORTD functions in general purpose I/O mode bit 3 Unimplemented: Read as '0' PORTE Data Direction Bits: bit 2 Bit2: Direction Control bit for pin RE2/CS/AN7 1 = Input 0 = Output bit 1 Bit1: Direction Control bit for pin RE1/WR/AN6 1 = Input 0 = Output bit 0 Bit0: Direction Control bit for pin RE0/RD/AN5 1 = Input 0 = Output Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 37 PIC16F87X 7.0 TIMER2 MODULE Register 7-1 shows the Timer2 control register. Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the PWM time-base for the PWM mode of the CCP module(s). The TMR2 register is readable and writable, and is cleared on any device RESET. Additional information on timer modules is available in the PICmicro™ Mid-Range MCU Family Reference Manual (DS33023). FIGURE 7-1: The input clock (FOSC/4) has a prescale option of 1:1, 1:4, or 1:16, selected by control bits T2CKPS1:T2CKPS0 (T2CON<1:0>). Sets Flag bit TMR2IF TIMER2 BLOCK DIAGRAM TMR2 Output(1) RESET The Timer2 module has an 8-bit period register, PR2. Timer2 increments from 00h until it matches PR2 and then resets to 00h on the next increment cycle. PR2 is a readable and writable register. The PR2 register is initialized to FFh upon RESET. Postscaler 1:1 to 1:16 EQ 4 The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2 interrupt (latched in flag bit TMR2IF, (PIR1<1>)). TMR2 Reg Prescaler 1:1, 1:4, 1:16 2 Comparator PR2 Reg FOSC/4 T2CKPS1: T2CKPS0 T2OUTPS3: T2OUTPS0 Note 1: TMR2 register output can be software selected by the SSP module as a baud clock. Timer2 can be shut-off by clearing control bit TMR2ON (T2CON<2>), to minimize power consumption. REGISTER 7-1: T2CON: TIMER2 CONTROL REGISTER (ADDRESS 12h) U-0 — R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 bit 7 bit 0 bit 7 Unimplemented: Read as '0' bit 6-3 TOUTPS3:TOUTPS0: Timer2 Output Postscale Select bits 0000 = 1:1 Postscale 0001 = 1:2 Postscale 0010 = 1:3 Postscale • • • 1111 = 1:16 Postscale bit 2 TMR2ON: Timer2 On bit 1 = Timer2 is on 0 = Timer2 is off bit 1-0 T2CKPS1:T2CKPS0: Timer2 Clock Prescale Select bits 00 = Prescaler is 1 01 = Prescaler is 4 1x = Prescaler is 16 Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 55 PIC16F87X 7.1 Timer2 Prescaler and Postscaler 7.2 The prescaler and postscaler counters are cleared when any of the following occurs: • a write to the TMR2 register • a write to the T2CON register • any device RESET (POR, MCLR Reset, WDT Reset, or BOR) Output of TMR2 The output of TMR2 (before the postscaler) is fed to the SSP module, which optionally uses it to generate shift clock. TMR2 is not cleared when T2CON is written. TABLE 7-1: Address REGISTERS ASSOCIATED WITH TIMER2 AS A TIMER/COUNTER Value on: POR, BOR Value on all other RESETS Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 0Bh,8Bh, INTCON 10Bh,18Bh GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u 0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000 8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000 11h TMR2 12h T2CON 92h PR2 Timer2 Module’s Register — 0000 0000 0000 0000 TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000 Timer2 Period Register 1111 1111 1111 1111 Legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by the Timer2 module. Note 1: Bits PSPIE and PSPIF are reserved on the PIC16F873/876; always maintain these bits clear. DS30292C-page 56 2001 Microchip Technology Inc. PIC16F87X 8.0 CAPTURE/COMPARE/PWM MODULES Each Capture/Compare/PWM (CCP) module contains a 16-bit register which can operate as a: • 16-bit Capture register • 16-bit Compare register • PWM Master/Slave Duty Cycle register Both the CCP1 and CCP2 modules are identical in operation, with the exception being the operation of the special event trigger. Table 8-1 and Table 8-2 show the resources and interactions of the CCP module(s). In the following sections, the operation of a CCP module is described with respect to CCP1. CCP2 operates the same as CCP1, except where noted. CCP2 Module: Capture/Compare/PWM Register2 (CCPR2) is comprised of two 8-bit registers: CCPR2L (low byte) and CCPR2H (high byte). The CCP2CON register controls the operation of CCP2. The special event trigger is generated by a compare match and will reset Timer1 and start an A/D conversion (if the A/D module is enabled). Additional information on CCP modules is available in the PICmicro™ Mid-Range MCU Family Reference Manual (DS33023) and in application note AN594, “Using the CCP Modules” (DS00594). TABLE 8-1: CCP1 Module: Capture/Compare/PWM Register1 (CCPR1) is comprised of two 8-bit registers: CCPR1L (low byte) and CCPR1H (high byte). The CCP1CON register controls the operation of CCP1. The special event trigger is generated by a compare match and will reset Timer1. TABLE 8-2: CCP Mode Timer Resource Capture Compare PWM Timer1 Timer1 Timer2 INTERACTION OF TWO CCP MODULES CCPx Mode CCPy Mode Capture CCP MODE - TIMER RESOURCES REQUIRED Capture Interaction Same TMR1 time-base Capture Compare The compare should be configured for the special event trigger, which clears TMR1 Compare Compare The compare(s) should be configured for the special event trigger, which clears TMR1 PWM PWM PWM Capture None The PWMs will have the same frequency and update rate (TMR2 interrupt) PWM Compare None 2001 Microchip Technology Inc. DS30292C-page 57 PIC16F87X REGISTER 8-1: CCP1CON REGISTER/CCP2CON REGISTER (ADDRESS: 17h/1Dh) U-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 — — CCPxX CCPxY CCPxM3 CCPxM2 CCPxM1 CCPxM0 bit 7 bit 0 bit 7-6 Unimplemented: Read as '0' bit 5-4 CCPxX:CCPxY: PWM Least Significant bits Capture mode: Unused Compare mode: Unused PWM mode: These bits are the two LSbs of the PWM duty cycle. The eight MSbs are found in CCPRxL. bit 3-0 CCPxM3:CCPxM0: CCPx Mode Select bits 0000 = Capture/Compare/PWM disabled (resets CCPx module) 0100 = Capture mode, every falling edge 0101 = Capture mode, every rising edge 0110 = Capture mode, every 4th rising edge 0111 = Capture mode, every 16th rising edge 1000 = Compare mode, set output on match (CCPxIF bit is set) 1001 = Compare mode, clear output on match (CCPxIF bit is set) 1010 = Compare mode, generate software interrupt on match (CCPxIF bit is set, CCPx pin is unaffected) 1011 = Compare mode, trigger special event (CCPxIF bit is set, CCPx pin is unaffected); CCP1 resets TMR1; CCP2 resets TMR1 and starts an A/D conversion (if A/D module is enabled) 11xx = PWM mode Legend: DS30292C-page 58 R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown 2001 Microchip Technology Inc. PIC16F87X 8.1 8.1.2 Capture Mode TIMER1 MODE SELECTION In Capture mode, CCPR1H:CCPR1L captures the 16-bit value of the TMR1 register when an event occurs on pin RC2/CCP1. An event is defined as one of the following: Timer1 must be running in Timer mode, or Synchronized Counter mode, for the CCP module to use the capture feature. In Asynchronous Counter mode, the capture operation may not work. • • • • 8.1.3 Every falling edge Every rising edge Every 4th rising edge Every 16th rising edge The type of event is configured by control bits CCP1M3:CCP1M0 (CCPxCON<3:0>). When a capture is made, the interrupt request flag bit CCP1IF (PIR1<2>) is set. The interrupt flag must be cleared in software. If another capture occurs before the value in register CCPR1 is read, the old captured value is overwritten by the new value. 8.1.1 CCP PIN CONFIGURATION In Capture mode, the RC2/CCP1 pin should be configured as an input by setting the TRISC<2> bit. Note: If the RC2/CCP1 pin is configured as an output, a write to the port can cause a capture condition. FIGURE 8-1: RC2/CCP1 pin CAPTURE MODE OPERATION BLOCK DIAGRAM Prescaler ÷ 1, 4, 16 Set Flag bit CCP1IF (PIR1<2>) CCPR1H When the Capture mode is changed, a false capture interrupt may be generated. The user should keep bit CCP1IE (PIE1<2>) clear to avoid false interrupts and should clear the flag bit CCP1IF, following any such change in operating mode. 8.1.4 Switching from one capture prescaler to another may generate an interrupt. Also, the prescaler counter will not be cleared, therefore, the first capture may be from a non-zero prescaler. Example 8-1 shows the recommended method for switching between capture prescalers. This example also clears the prescaler counter and will not generate the “false” interrupt. EXAMPLE 8-1: CLRF MOVLW CCPR1L Capture Enable TMR1H CCP PRESCALER There are four prescaler settings, specified by bits CCP1M3:CCP1M0. Whenever the CCP module is turned off, or the CCP module is not in Capture mode, the prescaler counter is cleared. Any RESET will clear the prescaler counter. MOVWF and edge detect SOFTWARE INTERRUPT CHANGING BETWEEN CAPTURE PRESCALERS CCP1CON ; Turn CCP module off NEW_CAPT_PS ; Load the W reg with ; the new prescaler ; move value and CCP ON CCP1CON ; Load CCP1CON with this ; value TMR1L CCP1CON<3:0> Qs 2001 Microchip Technology Inc. DS30292C-page 59 PIC16F87X 8.2 8.2.2 Compare Mode In Compare mode, the 16-bit CCPR1 register value is constantly compared against the TMR1 register pair value. When a match occurs, the RC2/CCP1 pin is: • Driven high • Driven low • Remains unchanged Timer1 must be running in Timer mode, or Synchronized Counter mode, if the CCP module is using the compare feature. In Asynchronous Counter mode, the compare operation may not work. 8.2.3 The action on the pin is based on the value of control bits CCP1M3:CCP1M0 (CCP1CON<3:0>). At the same time, interrupt flag bit CCP1IF is set. COMPARE MODE OPERATION BLOCK DIAGRAM Special event trigger will: reset Timer1, but not set interrupt flag bit TMR1IF (PIR1<0>), and set bit GO/DONE (ADCON0<2>). Special Event Trigger CCPR1H CCPR1L Q S R TRISC<2> Output Enable 8.2.1 Output Logic Match CCP1CON<3:0> Mode Select Comparator TMR1H SPECIAL EVENT TRIGGER In this mode, an internal hardware trigger is generated, which may be used to initiate an action. The special event trigger output of CCP1 resets the TMR1 register pair. This allows the CCPR1 register to effectively be a 16-bit programmable period register for Timer1. The special event trigger output of CCP2 resets the TMR1 register pair and starts an A/D conversion (if the A/D module is enabled). Set Flag bit CCP1IF (PIR1<2>) RC2/CCP1 pin SOFTWARE INTERRUPT MODE When Generate Software Interrupt mode is chosen, the CCP1 pin is not affected. The CCPIF bit is set, causing a CCP interrupt (if enabled). 8.2.4 FIGURE 8-2: TIMER1 MODE SELECTION Note: The special event trigger from the CCP1and CCP2 modules will not set interrupt flag bit TMR1IF (PIR1<0>). TMR1L CCP PIN CONFIGURATION The user must configure the RC2/CCP1 pin as an output by clearing the TRISC<2> bit. Note: Clearing the CCP1CON register will force the RC2/CCP1 compare output latch to the default low level. This is not the PORTC I/O data latch. DS30292C-page 60 2001 Microchip Technology Inc. PIC16F87X 8.3 8.3.1 PWM Mode (PWM) In Pulse Width Modulation mode, the CCPx pin produces up to a 10-bit resolution PWM output. Since the CCP1 pin is multiplexed with the PORTC data latch, the TRISC<2> bit must be cleared to make the CCP1 pin an output. Note: Clearing the CCP1CON register will force the CCP1 PWM output latch to the default low level. This is not the PORTC I/O data latch. Figure 8-3 shows a simplified block diagram of the CCP module in PWM mode. For a step-by-step procedure on how to set up the CCP module for PWM operation, see Section 8.3.3. FIGURE 8-3: SIMPLIFIED PWM BLOCK DIAGRAM Duty Cycle Registers The PWM period is specified by writing to the PR2 register. The PWM period can be calculated using the following formula: PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value) PWM frequency is defined as 1 / [PWM period]. When TMR2 is equal to PR2, the following three events occur on the next increment cycle: • TMR2 is cleared • The CCP1 pin is set (exception: if PWM duty cycle = 0%, the CCP1 pin will not be set) • The PWM duty cycle is latched from CCPR1L into CCPR1H Note: CCP1CON<5:4> CCPR1L 8.3.2 CCPR1H (Slave) RC2/CCP1 R Comparator TMR2 Q (Note 1) S TRISC<2> Comparator Clear Timer, CCP1 pin and latch D.C. PR2 Note 1: The 8-bit timer is concatenated with 2-bit internal Q clock, or 2 bits of the prescaler, to create 10-bit timebase. A PWM output (Figure 8-4) has a time-base (period) and a time that the output stays high (duty cycle). The frequency of the PWM is the inverse of the period (1/period). FIGURE 8-4: PWM OUTPUT PWM PERIOD The Timer2 postscaler (see Section 7.1) is not used in the determination of the PWM frequency. The postscaler could be used to have a servo update rate at a different frequency than the PWM output. PWM DUTY CYCLE The PWM duty cycle is specified by writing to the CCPR1L register and to the CCP1CON<5:4> bits. Up to 10-bit resolution is available. The CCPR1L contains the eight MSbs and the CCP1CON<5:4> contains the two LSbs. This 10-bit value is represented by CCPR1L:CCP1CON<5:4>. The following equation is used to calculate the PWM duty cycle in time: PWM duty cycle =(CCPR1L:CCP1CON<5:4>) • TOSC • (TMR2 prescale value) CCPR1L and CCP1CON<5:4> can be written to at any time, but the duty cycle value is not latched into CCPR1H until after a match between PR2 and TMR2 occurs (i.e., the period is complete). In PWM mode, CCPR1H is a read-only register. The CCPR1H register and a 2-bit internal latch are used to double buffer the PWM duty cycle. This double buffering is essential for glitch-free PWM operation. When the CCPR1H and 2-bit latch match TMR2, concatenated with an internal 2-bit Q clock, or 2 bits of the TMR2 prescaler, the CCP1 pin is cleared. The maximum PWM resolution (bits) for a given PWM frequency is given by the formula: Period Resolution Duty Cycle = FOSC log FPWM ( log(2) ) bits TMR2 = PR2 TMR2 = Duty Cycle TMR2 = PR2 2001 Microchip Technology Inc. Note: If the PWM duty cycle value is longer than the PWM period, the CCP1 pin will not be cleared. DS30292C-page 61 PIC16F87X 8.3.3 SETUP FOR PWM OPERATION 3. The following steps should be taken when configuring the CCP module for PWM operation: 4. 1. 5. 2. Set the PWM period by writing to the PR2 register. Set the PWM duty cycle by writing to the CCPR1L register and CCP1CON<5:4> bits. TABLE 8-3: EXAMPLE PWM FREQUENCIES AND RESOLUTIONS AT 20 MHz PWM Frequency 1.22 kHz Timer Prescaler (1, 4, 16) PR2 Value Maximum Resolution (bits) TABLE 8-4: Address Make the CCP1 pin an output by clearing the TRISC<2> bit. Set the TMR2 prescale value and enable Timer2 by writing to T2CON. Configure the CCP1 module for PWM operation. 4.88 kHz 19.53 kHz 78.12kHz 156.3 kHz 208.3 kHz 16 4 1 1 1 1 0xFFh 0xFFh 0xFFh 0x3Fh 0x1Fh 0x17h 10 10 10 8 7 5.5 REGISTERS ASSOCIATED WITH CAPTURE, COMPARE, AND TIMER1 Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 0Bh,8Bh, INTCON 10Bh, 18Bh GIE PEIE T0IE INTE RBIE T0IF INTF RBIF PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF Value on: POR, BOR Value on all other RESETS 0000 000x 0000 000u 0Ch PIR1 TMR1IF 0000 0000 0000 0000 0Dh PIR2 — — — — — — — CCP2IF ---- ---0 ---- ---0 8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000 — — — — — — — CCP2IE ---- ---0 ---- ---0 8Dh PIE2 87h TRISC PORTC Data Direction Register 1111 1111 1111 1111 0Eh TMR1L Holding Register for the Least Significant Byte of the 16-bit TMR1 Register xxxx xxxx uuuu uuuu 0Fh TMR1H Holding Register for the Most Significant Byte of the 16-bit TMR1 Register xxxx xxxx uuuu uuuu 10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu 15h CCPR1L Capture/Compare/PWM Register1 (LSB) 16h CCPR1H Capture/Compare/PWM Register1 (MSB) 17h CCP1CON 1Bh 1Ch 1Dh CCP2CON — CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000 CCPR2L Capture/Compare/PWM Register2 (LSB) xxxx xxxx uuuu uuuu CCPR2H Capture/Compare/PWM Register2 (MSB) xxxx xxxx uuuu uuuu — CCP1X xxxx xxxx uuuu uuuu CCP1Y — — xxxx xxxx uuuu uuuu CCP2X CCP2Y CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 --00 0000 Legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by Capture and Timer1. Note 1: The PSP is not implemented on the PIC16F873/876; always maintain these bits clear. DS30292C-page 62 2001 Microchip Technology Inc. PIC16F87X TABLE 8-5: Address REGISTERS ASSOCIATED WITH PWM AND TIMER2 Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 0Bh,8Bh, INTCON 10Bh, 18Bh GIE PEIE T0IE INTE RBIE T0IF INTF RBIF PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF Value on: POR, BOR Value on all other RESETS 0000 000x 0000 000u 0Ch PIR1 0Dh PIR2 — — — — — — — CCP2IF ---- ---0 ---- ---0 8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000 8Dh PIE2 — — — — — — — CCP2IE ---- ---0 ---- ---0 87h TRISC PORTC Data Direction Register 1111 1111 1111 1111 11h TMR2 Timer2 Module’s Register 0000 0000 0000 0000 92h PR2 Timer2 Module’s Period Register 1111 1111 1111 1111 12h T2CON 15h CCPR1L Capture/Compare/PWM Register1 (LSB) 16h CCPR1H Capture/Compare/PWM Register1 (MSB) 17h CCP1CON — — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000 — CCP1X CCP1Y 1Bh CCPR2L Capture/Compare/PWM Register2 (LSB) 1Ch CCPR2H Capture/Compare/PWM Register2 (MSB) 1Dh CCP2CON — TMR1IF 0000 0000 0000 0000 — CCP2X CCP2Y xxxx xxxx uuuu uuuu xxxx xxxx uuuu uuuu CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000 xxxx xxxx uuuu uuuu xxxx xxxx uuuu uuuu CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 --00 0000 Legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by PWM and Timer2. Note 1: Bits PSPIE and PSPIF are reserved on the PIC16F873/876; always maintain these bits clear. 2001 Microchip Technology Inc. DS30292C-page 63 PIC16F87X 11.0 ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE The A/D module has four registers. These registers are: • • • • The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices and eight for the other devices. The analog input charges a sample and hold capacitor. The output of the sample and hold capacitor is the input into the converter. The converter then generates a digital result of this analog level via successive approximation. The A/D conversion of the analog input signal results in a corresponding 10-bit digital number. The A/D module has high and low voltage reference input that is software selectable to some combination of VDD, VSS, RA2, or RA3. The ADCON0 register, shown in Register 11-1, controls the operation of the A/D module. The ADCON1 register, shown in Register 11-2, configures the functions of the port pins. The port pins can be configured as analog inputs (RA3 can also be the voltage reference), or as digital I/O. Additional information on using the A/D module can be found in the PICmicro™ Mid-Range MCU Family Reference Manual (DS33023). The A/D converter has a unique feature of being able to operate while the device is in SLEEP mode. To operate in SLEEP, the A/D clock must be derived from the A/D’s internal RC oscillator. REGISTER 11-1: A/D Result High Register (ADRESH) A/D Result Low Register (ADRESL) A/D Control Register0 (ADCON0) A/D Control Register1 (ADCON1) ADCON0 REGISTER (ADDRESS: 1Fh) R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 U-0 R/W-0 ADCS1 ADCS0 CHS2 CHS1 CHS0 GO/DONE — ADON bit 7 bit 0 bit 7-6 ADCS1:ADCS0: A/D Conversion Clock Select bits 00 = FOSC/2 01 = FOSC/8 10 = FOSC/32 11 = FRC (clock derived from the internal A/D module RC oscillator) bit 5-3 CHS2:CHS0: Analog Channel Select bits 000 = channel 0, (RA0/AN0) 001 = channel 1, (RA1/AN1) 010 = channel 2, (RA2/AN2) 011 = channel 3, (RA3/AN3) 100 = channel 4, (RA5/AN4) 101 = channel 5, (RE0/AN5)(1) 110 = channel 6, (RE1/AN6)(1) 111 = channel 7, (RE2/AN7)(1) bit 2 GO/DONE: A/D Conversion Status bit If ADON = 1: 1 = A/D conversion in progress (setting this bit starts the A/D conversion) 0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D conversion is complete) bit 1 Unimplemented: Read as '0' bit 0 ADON: A/D On bit 1 = A/D converter module is operating 0 = A/D converter module is shut-off and consumes no operating current Note 1: These channels are not available on PIC16F873/876 devices. Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared 2001 Microchip Technology Inc. x = Bit is unknown DS30292C-page 111 PIC16F87X REGISTER 11-2: ADCON1 REGISTER (ADDRESS 9Fh) U-0 U-0 R/W-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 bit 7 bit 0 bit 7 ADFM: A/D Result Format Select bit 1 = Right justified. 6 Most Significant bits of ADRESH are read as ‘0’. 0 = Left justified. 6 Least Significant bits of ADRESL are read as ‘0’. bit 6-4 Unimplemented: Read as '0' bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits: PCFG3: AN7(1) AN6(1) AN5(1) RE2 RE1 RE0 PCFG0 AN4 RA5 AN3 RA3 AN2 RA2 AN1 RA1 AN0 RA0 VREF+ VREF- CHAN/ Refs(2) 0000 A A A A A A A A VDD VSS 8/0 0001 A A A A VREF+ A A A RA3 VSS 7/1 0010 D D D A A A A A VDD VSS 5/0 0011 D D D A VREF+ A A A RA3 VSS 4/1 0100 D D D D A D A A VDD VSS 3/0 0101 D D D D VREF+ D A A RA3 VSS 2/1 011x D D D D D D D D VDD VSS 0/0 1000 A A A A VREF+ VREF- A A RA3 RA2 6/2 1001 D D A A A A A A VDD VSS 6/0 1010 D D A A VREF+ A A A RA3 VSS 5/1 1011 D D A A VREF+ VREF- A A RA3 RA2 4/2 1100 D D D A VREF+ VREF- A A RA3 RA2 3/2 1101 D D D D VREF+ VREF- A A RA3 RA2 2/2 1110 D D D D D D D A VDD VSS 1/0 1111 D D D D VREF+ VREF- D A RA3 RA2 1/2 A = Analog input D = Digital I/O Note 1: These channels are not available on PIC16F873/876 devices. 2: This column indicates the number of analog channels available as A/D inputs and the number of analog channels used as voltage reference inputs. Legend: R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared The ADRESH:ADRESL registers contain the 10-bit result of the A/D conversion. When the A/D conversion is complete, the result is loaded into this A/D result register pair, the GO/DONE bit (ADCON0<2>) is cleared and the A/D interrupt flag bit ADIF is set. The block diagram of the A/D module is shown in Figure 11-1. x = Bit is unknown To determine sample time, see Section 11.1. After this acquisition time has elapsed, the A/D conversion can be started. After the A/D module has been configured as desired, the selected channel must be acquired before the conversion is started. The analog input channels must have their corresponding TRIS bits selected as inputs. DS30292C-page 112 2001 Microchip Technology Inc. PIC16F87X 3. 4. These steps should be followed for doing an A/D Conversion: 1. 2. Configure the A/D module: • Configure analog pins/voltage reference and digital I/O (ADCON1) • Select A/D input channel (ADCON0) • Select A/D conversion clock (ADCON0) • Turn on A/D module (ADCON0) Configure A/D interrupt (if desired): • Clear ADIF bit • Set ADIE bit • Set PEIE bit • Set GIE bit FIGURE 11-1: 5. 6. 7. Wait the required acquisition time. Start conversion: • Set GO/DONE bit (ADCON0) Wait for A/D conversion to complete, by either: • Polling for the GO/DONE bit to be cleared (with interrupts enabled); OR • Waiting for the A/D interrupt Read A/D result register pair (ADRESH:ADRESL), clear bit ADIF if required. For the next conversion, go to step 1 or step 2, as required. The A/D conversion time per bit is defined as TAD. A minimum wait of 2TAD is required before the next acquisition starts. A/D BLOCK DIAGRAM CHS2:CHS0 111 110 101 100 VAIN 011 (Input Voltage) 010 A/D Converter 001 VDD 000 RE2/AN7(1) RE1/AN6(1) RE0/AN5(1) RA5/AN4 RA3/AN3/VREF+ RA2/AN2/VREFRA1/AN1 RA0/AN0 VREF+ (Reference Voltage) PCFG3:PCFG0 VREF(Reference Voltage) VSS PCFG3:PCFG0 Note 1: Not available on PIC16F873/876 devices. 2001 Microchip Technology Inc. DS30292C-page 113 PIC16F87X 11.1 A/D Acquisition Requirements For the A/D converter to meet its specified accuracy, the charge holding capacitor (CHOLD) must be allowed to fully charge to the input channel voltage level. The analog input model is shown in Figure 11-2. The source impedance (RS) and the internal sampling switch (RSS) impedance directly affect the time required to charge the capacitor CHOLD. The sampling switch (RSS) impedance varies over the device voltage (VDD), see Figure 11-2. The maximum recommended impedance for analog sources is 10 kΩ. As the impedance is decreased, the acquisition time may be decreased. EQUATION 11-1: TACQ TC TACQ After the analog input channel is selected (changed), this acquisition must be done before the conversion can be started. To calculate the minimum acquisition time, Equation 11-1 may be used. This equation assumes that 1/2 LSb error is used (1024 steps for the A/D). The 1/2 LSb error is the maximum error allowed for the A/D to meet its specified resolution. To calculate the minimum acquisition time, TACQ, see the PICmicro™ Mid-Range Reference Manual (DS33023). ACQUISITION TIME = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient = = = = = = = TAMP + TC + TCOFF 2µs + TC + [(Temperature -25°C)(0.05µs/°C)] CHOLD (RIC + RSS + RS) In(1/2047) - 120pF (1kΩ + 7kΩ + 10kΩ) In(0.0004885) 16.47µs 2µs + 16.47µs + [(50°C -25°C)(0.05µs/°C) 19.72µs Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out. 2: The charge holding capacitor (CHOLD) is not discharged after each conversion. 3: The maximum recommended impedance for analog sources is 10 kΩ. This is required to meet the pin leakage specification. 4: After a conversion has completed, a 2.0TAD delay must complete before acquisition can begin again. During this time, the holding capacitor is not connected to the selected A/D input channel. FIGURE 11-2: ANALOG INPUT MODEL VDD RS VA ANx CPIN 5 pF VT = 0.6V VT = 0.6V RIC ≤ 1k Sampling Switch SS RSS CHOLD = DAC capacitance = 120 pF I LEAKAGE ± 500 nA VSS Legend CPIN = input capacitance = threshold voltage VT I LEAKAGE = leakage current at the pin due to various junctions = interconnect resistance RIC = sampling switch SS = sample/hold capacitance (from DAC) CHOLD DS30292C-page 114 6V 5V VDD 4V 3V 2V 5 6 7 8 9 10 11 Sampling Switch (kΩ) 2001 Microchip Technology Inc. PIC16F87X 11.2 Selecting the A/D Conversion Clock For correct A/D conversions, the A/D conversion clock (TAD) must be selected to ensure a minimum TAD time of 1.6 µs. The A/D conversion time per bit is defined as TAD. The A/D conversion requires a minimum 12TAD per 10-bit conversion. The source of the A/D conversion clock is software selected. The four possible options for TAD are: • • • • Table 11-1 shows the resultant TAD times derived from the device operating frequencies and the A/D clock source selected. 2TOSC 8TOSC 32TOSC Internal A/D module RC oscillator (2-6 µs) TABLE 11-1: TAD vs. MAXIMUM DEVICE OPERATING FREQUENCIES (STANDARD DEVICES (C)) AD Clock Source (TAD) Maximum Device Frequency Operation ADCS1:ADCS0 Max. 2TOSC 00 1.25 MHz 8TOSC 01 5 MHz 32TOSC 10 20 MHz RC(1, 2, 3) 11 (Note 1) Note 1: The RC source has a typical TAD time of 4 µs, but can vary between 2-6 µs. 2: When the device frequencies are greater than 1 MHz, the RC A/D conversion clock source is only recommended for SLEEP operation. 3: For extended voltage devices (LC), please refer to the Electrical Characteristics (Sections 15.1 and 15.2). 11.3 Configuring Analog Port Pins The ADCON1 and TRIS registers control the operation of the A/D port pins. The port pins that are desired as analog inputs must have their corresponding TRIS bits set (input). If the TRIS bit is cleared (output), the digital output level (VOH or VOL) will be converted. The A/D operation is independent of the state of the CHS2:CHS0 bits and the TRIS bits. Note 1: When reading the port register, any pin configured as an analog input channel will read as cleared (a low level). Pins configured as digital inputs will convert an analog input. Analog levels on a digitally configured input will not affect the conversion accuracy. 2: Analog levels on any pin that is defined as a digital input (including the AN7:AN0 pins), may cause the input buffer to consume current that is out of the device specifications. 2001 Microchip Technology Inc. DS30292C-page 115 PIC16F87X 11.4 A/D Conversions acquisition is started. After this 2TAD wait, acquisition on the selected channel is automatically started. The GO/DONE bit can then be set to start the conversion. Clearing the GO/DONE bit during a conversion will abort the current conversion. The A/D result register pair will NOT be updated with the partially completed A/D conversion sample. That is, the ADRESH:ADRESL registers will continue to contain the value of the last completed conversion (or the last value written to the ADRESH:ADRESL registers). After the A/D conversion is aborted, a 2TAD wait is required before the next FIGURE 11-3: In Figure 11-3, after the GO bit is set, the first time segment has a minimum of TCY and a maximum of TAD. Note: The GO/DONE bit should NOT be set in the same instruction that turns on the A/D. A/D CONVERSION TAD CYCLES TCY to TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 b9 b8 b7 b6 b5 b4 b3 TAD9 TAD10 TAD11 b2 b1 b0 Conversion starts Holding capacitor is disconnected from analog input (typically 100 ns) Set GO bit 11.4.1 ADRES is loaded GO bit is cleared ADIF bit is set Holding capacitor is connected to analog input A/D RESULT REGISTERS The ADRESH:ADRESL register pair is the location where the 10-bit A/D result is loaded at the completion of the A/D conversion. This register pair is 16-bits wide. The A/D module gives the flexibility to left or right justify the 10-bit result in the 16-bit result register. The A/D FIGURE 11-4: Format Select bit (ADFM) controls this justification. Figure 11-4 shows the operation of the A/D result justification. The extra bits are loaded with ’0’s’. When an A/D result will not overwrite these locations (A/D disable), these registers may be used as two general purpose 8-bit registers. A/D RESULT JUSTIFICATION 10-bit Result ADFM = 0 ADFM = 1 7 0 2107 7 0765 0000 00 0000 00 ADRESH ADRESL 10-bit Result Right Justified DS30292C-page 116 0 ADRESH ADRESL 10-bit Result Left Justified 2001 Microchip Technology Inc. PIC16F87X 11.5 A/D Operation During SLEEP Turning off the A/D places the A/D module in its lowest current consumption state. The A/D module can operate during SLEEP mode. This requires that the A/D clock source be set to RC (ADCS1:ADCS0 = 11). When the RC clock source is selected, the A/D module waits one instruction cycle before starting the conversion. This allows the SLEEP instruction to be executed, which eliminates all digital switching noise from the conversion. When the conversion is completed, the GO/DONE bit will be cleared and the result loaded into the ADRES register. If the A/D interrupt is enabled, the device will wake-up from SLEEP. If the A/D interrupt is not enabled, the A/D module will then be turned off, although the ADON bit will remain set. Note: 11.6 Address Effects of a RESET A device RESET forces all registers to their RESET state. This forces the A/D module to be turned off, and any conversion is aborted. All A/D input pins are configured as analog inputs. When the A/D clock source is another clock option (not RC), a SLEEP instruction will cause the present conversion to be aborted and the A/D module to be turned off, though the ADON bit will remain set. TABLE 11-2: For the A/D module to operate in SLEEP, the A/D clock source must be set to RC (ADCS1:ADCS0 = 11). To allow the conversion to occur during SLEEP, ensure the SLEEP instruction immediately follows the instruction that sets the GO/DONE bit. The value that is in the ADRESH:ADRESL registers is not modified for a Power-on Reset. The ADRESH:ADRESL registers will contain unknown data after a Power-on Reset. REGISTERS/BITS ASSOCIATED WITH A/D Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 0Bh,8Bh, INTCON 10Bh,18Bh GIE PEIE T0IE INTE RBIE T0IF INTF RBIF Value on POR, BOR Value on MCLR, WDT 0000 000x 0000 000u 0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000 8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000 1Eh ADRESH A/D Result Register High Byte 9Eh ADRESL A/D Result Register Low Byte 1Fh ADCON0 ADCS1 9Fh ADCON1 ADFM — 85h TRISA — — PORTA Data Direction Register 05h PORTA — — PORTA Data Latch when written: PORTA pins when read 89h(1) TRISE IBF OBF IBOV PSPMODE — 09h(1) PORTE — — — — — ADCS0 CHS2 — xxxx xxxx uuuu uuuu xxxx xxxx uuuu uuuu CHS1 CHS0 GO/DONE — ADON 0000 00-0 0000 00-0 — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000 --11 1111 --11 1111 --0x 0000 --0u 0000 PORTE Data Direction bits RE2 RE1 RE0 0000 -111 0000 -111 ---- -xxx ---- -uuu Legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used for A/D conversion. Note 1: These registers/bits are not available on the 28-pin devices. 2001 Microchip Technology Inc. DS30292C-page 117 PIC16F87X 12.2 FIGURE 12-2: Oscillator Configurations 12.2.1 OSCILLATOR TYPES The PIC16F87X can be operated in four different oscillator modes. The user can program two configuration bits (FOSC1 and FOSC0) to select one of these four modes: • • • • LP XT HS RC EXTERNAL CLOCK INPUT OPERATION (HS, XT OR LP OSC CONFIGURATION) Low Power Crystal Crystal/Resonator High Speed Crystal/Resonator Resistor/Capacitor 12.2.2 OSC1 Clock from Ext. System PIC16F87X OSC2 Open CRYSTAL OSCILLATOR/CERAMIC RESONATORS In XT, LP or HS modes, a crystal or ceramic resonator is connected to the OSC1/CLKIN and OSC2/CLKOUT pins to establish oscillation (Figure 12-1). The PIC16F87X oscillator design requires the use of a parallel cut crystal. Use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. When in XT, LP or HS modes, the device can have an external clock source to drive the OSC1/ CLKIN pin (Figure 12-2). FIGURE 12-1: C1(1) CRYSTAL/CERAMIC RESONATOR OPERATION (HS, XT OR LP OSC CONFIGURATION) OSC1 XTAL RF(3) OSC2 C2(1) To Internal Logic Rs(2) SLEEP PIC16F87X TABLE 12-1: CERAMIC RESONATORS Ranges Tested: Mode Freq. OSC1 OSC2 XT 455 kHz 2.0 MHz 4.0 MHz 68 - 100 pF 15 - 68 pF 15 - 68 pF 68 - 100 pF 15 - 68 pF 15 - 68 pF HS 8.0 MHz 16.0 MHz 10 - 68 pF 10 - 22 pF 10 - 68 pF 10 - 22 pF These values are for design guidance only. See notes following Table 12-2. Resonators Used: 455 kHz Panasonic EFO-A455K04B ± 0.3% 2.0 MHz Murata Erie CSA2.00MG ± 0.5% 4.0 MHz Murata Erie CSA4.00MG ± 0.5% 8.0 MHz Murata Erie CSA8.00MT ± 0.5% 16.0 MHz Murata Erie CSA16.00MX ± 0.5% All resonators used did not have built-in capacitors. Note 1: See Table 12-1 and Table 12-2 for recommended values of C1 and C2. 2: A series resistor (Rs) may be required for AT strip cut crystals. 3: RF varies with the crystal chosen. 2001 Microchip Technology Inc. DS30292C-page 121 PIC16F87X TABLE 12-2: Osc Type LP XT HS CAPACITOR SELECTION FOR CRYSTAL OSCILLATOR Crystal Freq. Cap. Range C1 Cap. Range C2 32 kHz 33 pF 33 pF 200 kHz 15 pF 15 pF 200 kHz 47-68 pF 47-68 pF 1 MHz 15 pF 15 pF 4 MHz 15 pF 15 pF 4 MHz 15 pF 15 pF 8 MHz 15-33 pF 15-33 pF 20 MHz 15-33 pF 15-33 pF These values are for design guidance only. See notes following this table. 12.2.3 RC OSCILLATOR For timing insensitive applications, the “RC” device option offers additional cost savings. The RC oscillator frequency is a function of the supply voltage, the resistor (REXT) and capacitor (CEXT) values, and the operating temperature. In addition to this, the oscillator frequency will vary from unit to unit due to normal process parameter variation. Furthermore, the difference in lead frame capacitance between package types will also affect the oscillation frequency, especially for low CEXT values. The user also needs to take into account variation due to tolerance of external R and C components used. Figure 12-3 shows how the R/C combination is connected to the PIC16F87X. FIGURE 12-3: RC OSCILLATOR MODE VDD Crystals Used 32 kHz Epson C-001R32.768K-A ± 20 PPM 200 kHz STD XTL 200.000KHz ± 20 PPM 1 MHz ECS ECS-10-13-1 ± 50 PPM 4 MHz ECS ECS-40-20-1 ± 50 PPM 8 MHz EPSON CA-301 8.000M-C ± 30 PPM 20 MHz EPSON CA-301 20.000MC ± 30 PPM REXT OSC1 CEXT Internal Clock PIC16F87X VSS FOSC/4 Recommended values: OSC2/CLKOUT 3 kΩ ≤ REXT ≤ 100 kΩ CEXT > 20pF Note 1: Higher capacitance increases the stability of oscillator, but also increases the startup time. 2: Since each resonator/crystal has its own characteristics, the user should consult the resonator/crystal manufacturer for appropriate values of external components. 3: Rs may be required in HS mode, as well as XT mode, to avoid overdriving crystals with low drive level specification. 4: When migrating from other PICmicro devices, oscillator performance should be verified. DS30292C-page 122 2001 Microchip Technology Inc. PIC16F87X TABLE 13-2: PIC16F87X INSTRUCTION SET Mnemonic, Operands 14-Bit Opcode Description Cycles MSb LSb Status Affected Notes BYTE-ORIENTED FILE REGISTER OPERATIONS ADDWF ANDWF CLRF CLRW COMF DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF f, d f, d f f, d f, d f, d f, d f, d f, d f, d f f, d f, d f, d f, d f, d Add W and f AND W with f Clear f Clear W Complement f Decrement f Decrement f, Skip if 0 Increment f Increment f, Skip if 0 Inclusive OR W with f Move f Move W to f No Operation Rotate Left f through Carry Rotate Right f through Carry Subtract W from f Swap nibbles in f Exclusive OR W with f 1 1 1 1 1 1 1(2) 1 1(2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0xxx dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff xxxx ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk C,DC,Z Z Z Z Z Z Z Z Z C C C,DC,Z Z 1,2 1,2 2 1,2 1,2 1,2,3 1,2 1,2,3 1,2 1,2 1,2 1,2 1,2 1,2 1,2 BIT-ORIENTED FILE REGISTER OPERATIONS BCF BSF BTFSC BTFSS f, b f, b f, b f, b Bit Clear f Bit Set f Bit Test f, Skip if Clear Bit Test f, Skip if Set 1 1 1 (2) 1 (2) 01 01 01 01 1,2 1,2 3 3 LITERAL AND CONTROL OPERATIONS ADDLW ANDLW CALL CLRWDT GOTO IORLW MOVLW RETFIE RETLW RETURN SLEEP SUBLW XORLW k k k k k k k k k Add literal and W AND literal with W Call subroutine Clear Watchdog Timer Go to address Inclusive OR literal with W Move literal to W Return from interrupt Return with literal in W Return from Subroutine Go into standby mode Subtract W from literal Exclusive OR literal with W 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 C,DC,Z Z TO,PD Z TO,PD C,DC,Z Z Note 1: When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, 1), the value used will be that value present on the pins themselves. For example, if the data latch is ’1’ for a pin configured as input and is driven low by an external device, the data will be written back with a ’0’. 2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared if assigned to the Timer0 module. 3: If Program Counter (PC) is modified, or a conditional test is true, the instruction requires two cycles. The second cycle is executed as a NOP. Note: Additional information on the mid-range instruction set is available in the PICmicro™ Mid-Range MCU Family Reference Manual (DS33023). DS30292C-page 136 2001 Microchip Technology Inc. PIC16F87X 13.1 Instruction Descriptions ADDLW Add Literal and W BCF Bit Clear f Syntax: [label] ADDLW Syntax: [label] BCF Operands: 0 ≤ k ≤ 255 Operands: Operation: (W) + k → (W) 0 ≤ f ≤ 127 0≤b≤7 Status Affected: C, DC, Z Operation: 0 → (f<b>) Description: The contents of the W register are added to the eight bit literal ’k’ and the result is placed in the W register. Status Affected: None Description: Bit 'b' in register 'f' is cleared. ADDWF Add W and f BSF Bit Set f Syntax: [label] ADDWF Syntax: [label] BSF Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 0≤b≤7 Operation: (W) + (f) → (destination) Operation: 1 → (f<b>) Status Affected: C, DC, Z Status Affected: None Description: Add the contents of the W register with register ’f’. If ’d’ is 0, the result is stored in the W register. If ’d’ is 1, the result is stored back in register ’f’. Description: Bit 'b' in register 'f' is set. ANDLW AND Literal with W BTFSS Syntax: [label] ANDLW k f,d k Operands: 0 ≤ k ≤ 255 Operation: (W) .AND. (k) → (W) Status Affected: Z Description: The contents of W register are AND’ed with the eight bit literal 'k'. The result is placed in the W register. f,b f,b Bit Test f, Skip if Set Syntax: [label] BTFSS f,b Operands: 0 ≤ f ≤ 127 0≤b<7 Operation: skip if (f<b>) = 1 Status Affected: None Description: If bit 'b' in register 'f' is '0', the next instruction is executed. If bit 'b' is '1', then the next instruction is discarded and a NOP is executed instead, making this a 2TCY instruction. BTFSC Bit Test, Skip if Clear Syntax: [label] BTFSC f,b 0 ≤ f ≤ 127 0≤b≤7 ANDWF AND W with f Syntax: [label] ANDWF Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: Operation: (W) .AND. (f) → (destination) Operation: skip if (f<b>) = 0 Status Affected: Z Status Affected: None Description: AND the W register with register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is 1, the result is stored back in register 'f'. Description: If bit 'b' in register 'f' is '1', the next instruction is executed. If bit 'b', in register 'f', is '0', the next instruction is discarded, and a NOP is executed instead, making this a 2TCY instruction. 2001 Microchip Technology Inc. f,d DS30292C-page 137 PIC16F87X CALL Call Subroutine CLRWDT Clear Watchdog Timer Syntax: [ label ] CALL k Syntax: [ label ] CLRWDT Operands: 0 ≤ k ≤ 2047 Operands: None Operation: (PC)+ 1→ TOS, k → PC<10:0>, (PCLATH<4:3>) → PC<12:11> Operation: 00h → WDT 0 → WDT prescaler, 1 → TO 1 → PD Status Affected: None Description: Call Subroutine. First, return address (PC+1) is pushed onto the stack. The eleven-bit immediate address is loaded into PC bits <10:0>. The upper bits of the PC are loaded from PCLATH. CALL is a two-cycle instruction. Status Affected: TO, PD Description: CLRWDT instruction resets the Watchdog Timer. It also resets the prescaler of the WDT. Status bits TO and PD are set. CLRF Clear f COMF Complement f Syntax: [label] CLRF Syntax: [ label ] COMF Operands: 0 ≤ f ≤ 127 Operands: Operation: 00h → (f) 1→Z 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) → (destination) Status Affected: Z Status Affected: Z Description: The contents of register ’f’ are cleared and the Z bit is set. Description: The contents of register ’f’ are complemented. If ’d’ is 0, the result is stored in W. If ’d’ is 1, the result is stored back in register ’f’. CLRW Clear W DECF Decrement f Syntax: [ label ] CLRW Syntax: [label] DECF f,d Operands: None Operands: Operation: 00h → (W) 1→Z 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) - 1 → (destination) Status Affected: Z Status Affected: Z Description: W register is cleared. Zero bit (Z) is set. Description: Decrement register ’f’. If ’d’ is 0, the result is stored in the W register. If ’d’ is 1, the result is stored back in register ’f’. DS30292C-page 138 f f,d 2001 Microchip Technology Inc. PIC16F87X DECFSZ Decrement f, Skip if 0 INCFSZ Increment f, Skip if 0 Syntax: [ label ] DECFSZ f,d Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) - 1 → (destination); skip if result = 0 Operation: (f) + 1 → (destination), skip if result = 0 Status Affected: None Status Affected: None Description: The contents of register ’f’ are decremented. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’. If the result is 1, the next instruction is executed. If the result is 0, then a NOP is executed instead making it a 2TCY instruction. Description: The contents of register ’f’ are incremented. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’. If the result is 1, the next instruction is executed. If the result is 0, a NOP is executed instead, making it a 2TCY instruction. GOTO Unconditional Branch IORLW Inclusive OR Literal with W Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ k ≤ 2047 Operands: 0 ≤ k ≤ 255 Operation: k → PC<10:0> PCLATH<4:3> → PC<12:11> Operation: (W) .OR. k → (W) Status Affected: Z Status Affected: None Description: Description: GOTO is an unconditional branch. The eleven-bit immediate value is loaded into PC bits <10:0>. The upper bits of PC are loaded from PCLATH<4:3>. GOTO is a twocycle instruction. The contents of the W register are OR’ed with the eight bit literal 'k'. The result is placed in the W register. INCF Increment f IORWF Inclusive OR W with f Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) + 1 → (destination) Operation: (W) .OR. (f) → (destination) Status Affected: Z Status Affected: Z Description: The contents of register ’f’ are incremented. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’. Description: Inclusive OR the W register with register 'f'. If 'd' is 0 the result is placed in the W register. If 'd' is 1 the result is placed back in register 'f'. GOTO k INCF f,d 2001 Microchip Technology Inc. INCFSZ f,d IORLW k IORWF f,d DS30292C-page 139 PIC16F87X MOVF Move f NOP No Operation Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: None Operation: No operation Operation: (f) → (destination) Status Affected: None Status Affected: Z Description: No operation. Description: The contents of register f are moved to a destination dependant upon the status of d. If d = 0, destination is W register. If d = 1, the destination is file register f itself. d = 1 is useful to test a file register, since status flag Z is affected. MOVLW Move Literal to W RETFIE Return from Interrupt Syntax: [ label ] Syntax: [ label ] MOVF f,d MOVLW k NOP RETFIE Operands: 0 ≤ k ≤ 255 Operands: None Operation: k → (W) Operation: Status Affected: None TOS → PC, 1 → GIE Description: The eight bit literal ’k’ is loaded into W register. The don’t cares will assemble as 0’s. Status Affected: None MOVWF Move W to f RETLW Return with Literal in W Syntax: [ label ] Syntax: [ label ] MOVWF f RETLW k Operands: 0 ≤ f ≤ 127 Operands: 0 ≤ k ≤ 255 Operation: (W) → (f) Operation: k → (W); TOS → PC Status Affected: None Description: The W register is loaded with the eight bit literal 'k'. The program counter is loaded from the top of the stack (the return address). This is a two-cycle instruction. Status Affected: None Description: Move data from W register to register 'f'. DS30292C-page 140 2001 Microchip Technology Inc. PIC16F87X RLF Rotate Left f through Carry SLEEP Syntax: [ label ] RLF Syntax: [ label ] SLEEP Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: None Operation: Operation: See description below Status Affected: C Description: The contents of register ’f’ are rotated one bit to the left through the Carry Flag. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is stored back in register ’f’. 00h → WDT, 0 → WDT prescaler, 1 → TO, 0 → PD Status Affected: TO, PD Description: The power-down status bit, PD is cleared. Time-out status bit, TO is set. Watchdog Timer and its prescaler are cleared. The processor is put into SLEEP mode with the oscillator stopped. C f,d Register f RETURN Return from Subroutine SUBLW Subtract W from Literal Syntax: [ label ] Syntax: [ label ] SUBLW k RETURN Operands: None Operands: 0 ≤ k ≤ 255 Operation: TOS → PC Operation: k - (W) → (W) Status Affected: None Status Affected: C, DC, Z Description: Return from subroutine. The stack is POPed and the top of the stack (TOS) is loaded into the program counter. This is a two-cycle instruction. Description: The W register is subtracted (2’s complement method) from the eight-bit literal 'k'. The result is placed in the W register. RRF Rotate Right f through Carry SUBWF Subtract W from f Syntax: [ label ] Syntax: [ label ] SUBWF f,d Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: See description below Operation: (f) - (W) → (destination) Status Affected: C The contents of register ’f’ are rotated one bit to the right through the Carry Flag. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed back in register ’f’. Status Affected: C, DC, Z Description: Description: Subtract (2’s complement method) W register from register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is 1, the result is stored back in register 'f'. RRF f,d C 2001 Microchip Technology Inc. Register f DS30292C-page 141 PIC16F87X SWAPF Swap Nibbles in f XORWF Exclusive OR W with f Syntax: [ label ] SWAPF f,d Syntax: [label] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f<3:0>) → (destination<7:4>), (f<7:4>) → (destination<3:0>) Operation: (W) .XOR. (f) → (destination) Status Affected: Z Status Affected: None Description: Description: The upper and lower nibbles of register ’f’ are exchanged. If ’d’ is 0, the result is placed in the W register. If ’d’ is 1, the result is placed in register ’f’. Exclusive OR the contents of the W register with register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is 1, the result is stored back in register 'f'. XORLW f,d Exclusive OR Literal with W Syntax: [label] Operands: 0 ≤ k ≤ 255 Operation: (W) .XOR. k → (W) Status Affected: Z Description: The contents of the W register are XOR’ed with the eight-bit literal 'k'. The result is placed in the W register. DS30292C-page 142 XORWF XORLW k 2001 Microchip Technology Inc. PIC16F87X 16.0 DC AND AC CHARACTERISTICS GRAPHS AND TABLES The graphs and tables provided in this section are for design guidance and are not tested. In some graphs or tables, the data presented is outside specified operating range (i.e., outside specified VDD range). This is for information only and devices are ensured to operate properly only within the specified range. The data presented in this section is a statistical summary of data collected on units from different lots over a period of time and matrix samples. ’Typical’ represents the mean of the distribution at 25°C. ’max’ or ’min’ represents (mean + 3σ) or (mean - 3σ) respectively, where σ is standard deviation, over the whole temperature range. TYPICAL IDD vs. FOSC OVER VDD (HS MODE) FIGURE 16-1: 7 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 6 5 5.5V IDD (mA) 4 5.0V 4.5V 3 4.0V 2 3.5V 3.0V 1 2 .5 V 2 .0 V 0 4 6 8 10 12 14 16 18 20 F O S C (M H z ) MAXIMUM IDD vs. FOSC OVER VDD (HS MODE) FIGURE 16-2: 8 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 7 6 5.5V 5 I DD (mA) 5.0V 4 4.5V 4.0V 3 3.5V 2 3.0V 1 2.5V 2.0V 0 4 6 8 10 12 14 16 18 20 F O S C (M H z ) 2001 Microchip Technology Inc. DS30292C-page 177 PIC16F87X FIGURE 16-3: TYPICAL IDD vs. FOSC OVER VDD (XT MODE) 1.6 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 1.4 5.5V 1.2 5.0V 1.0 I DD (mA) 4.5V 0.8 4.0V 3.5V 0.6 3.0V 0.4 2.5V 2.0V 0.2 0.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 3.5 4.0 F OSC (MHz) MAXIMUM IDD vs. FOSC OVER VDD (LP MODE) FIGURE 16-4: 2.0 1.8 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 1.6 5.5V 1.4 5.0V I DD (mA) 1.2 4.5V 1.0 4.0V 0.8 3.5V 0.6 3.0V 2.5V 0.4 2.0V 0.2 0.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 F OSC (MHz) DS30292C-page 178 © 2001 Microchip Technology Inc. PIC16F87X FIGURE 16-5: TYPICAL IDD vs. FOSC OVER VDD (LP MODE) 90 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 80 5.5V 70 5.0V 60 IDD (uA) 4.5V 50 4.0V 3.5V 40 3.0V 30 2.5V 20 2.0V 10 0 20 30 40 50 60 70 80 90 100 F OS C (kH z ) FIGURE 16-6: MAXIMUM IDD vs. FOSC OVER VDD (XT MODE) 120 110 5.5V Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 100 5.0V 90 80 4.5V IDD (uA) 70 4.0V 60 3.5V 50 3.0V 40 2.5V 30 2.0V 20 10 0 20 30 40 50 60 70 80 90 100 F OSC (kH z ) 2001 Microchip Technology Inc. DS30292C-page 179 PIC16F87X FIGURE 16-7: AVERAGE FOSC vs. VDD FOR VARIOUS VALUES OF R (RC MODE, C = 20 pF, 25°C) 4.0 3.3kΩ 3.5 3.0 5.1kΩ Freq (MHz) 2.5 2.0 10kΩ 1.5 1.0 0.5 100kΩ 0.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) FIGURE 16-8: AVERAGE FOSC vs. VDD FOR VARIOUS VALUES OF R (RC MODE, C = 100 pF, 25°C) 2.0 1.8 1.6 3.3kΩ 1.4 Freq (MHz) 1.2 5.1kΩ 1.0 0.8 0.6 10kΩ 0.4 0.2 100kΩ 0.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) DS30292C-page 180 © 2001 Microchip Technology Inc. PIC16F87X FIGURE 16-9: AVERAGE FOSC vs. VDD FOR VARIOUS VALUES OF R (RC MODE, C = 300 pF, 25°C) 1.0 0.9 0.8 3.3kΩ 0.7 Freq (MHz) 0.6 5.1kΩ 0.5 0.4 0.3 10kΩ 0.2 0.1 100kΩ 0.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 5.0 5.5 V DD (V) FIGURE 16-10: IPD vs. VDD (SLEEP MODE, ALL PERIPHERALS DISABLED) 100.00 Typical: statistical mean @ 25°C Maximum: mean + 3σ (-40°C to 125°C) Minimum: mean – 3σ (-40°C to 125°C) Max (125C) 10.00 I PD (µ A) Max (85C) 1.00 0.10 Typ (25C) 0.01 2.0 2.5 3.0 3.5 4.0 4.5 VDD (V) 2001 Microchip Technology Inc. DS30292C-page 181 PIC16F87X FIGURE 16-11: ∆IBOR vs. VDD OVER TEMPERATURE 1.2 Note: 1.0 Device current in RESET depends on oscillator mode, frequency and circuit. Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) ∆ I BOR (mA) 0.8 Max Reset 0.6 Indeterminate State Typ Reset (25C) 0.4 Device in Sleep Device in Reset 0.2 Max Sleep Typ Sleep (25C) 0.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) FIGURE 16-12: TYPICAL AND MAXIMUM ∆ITMR1 vs. VDD OVER TEMPERATURE (-10°C TO 70°C, TIMER1 WITH OSCILLATOR, XTAL=32 kHZ, C1 AND C2=50 pF) 90 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 80 70 ∆ ITMR1 (uA) 60 50 40 Max 30 Ty p (25C) 20 10 0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V ) DS30292C-page 182 © 2001 Microchip Technology Inc. PIC16F87X FIGURE 16-13: TYPICAL AND MAXIMUM ∆IWDT vs. VDD OVER TEMPERATURE 14 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 12 10 ∆ I WDT (uA) Max (85C) 8 Typ (25C) 6 4 2 0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) FIGURE 16-14: TYPICAL, MINIMUM AND MAXIMUM WDT PERIOD vs. VDD (-40°C TO 125°C) 60 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 50 WDT Period (ms) 40 Max (125C) 30 20 Typ (25C) Min (-40C) 10 0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) 2001 Microchip Technology Inc. DS30292C-page 183 PIC16F87X FIGURE 16-15: AVERAGE WDT PERIOD vs. VDD OVER TEMPERATURE (-40°C TO 125°C) 50 45 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 40 125C 35 WDT Period (ms) 85C 30 25 25C 20 -40C 15 10 5 0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 V DD (V) FIGURE 16-16: TYPICAL, MINIMUM AND MAXIMUM VOH vs. IOH (VDD=5V, -40°C TO 125°C) 5.0 Max (-40C) 4.5 Typ (25C) VOH (V) 4.0 3.5 Min (125C) 3.0 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 2.5 2.0 0 5 10 15 20 25 I OH (-mA) DS30292C-page 184 © 2001 Microchip Technology Inc. PIC16F87X FIGURE 16-17: TYPICAL, MINIMUM AND MAXIMUM VOH vs. IOH (VDD=3V, -40°C TO 125°C) 3.0 Max (-40C) Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 2.5 Typ (25C) VOH (V) 2.0 1.5 Min (125C) 1.0 0.5 0.0 0 5 10 15 20 25 I OH (-mA) FIGURE 16-18: TYPICAL, MINIMUM AND MAXIMUM VOL vs. IOL (VDD=5V, -40°C TO 125°C) 2.0 1.8 Typical: statistical mean @ 25°C Maximum: mean + 3s (-40°C to 125°C) Minimum: mean – 3s (-40°C to 125°C) 1.6 1.4 V OL (V) 1.2 1.0 Max (125C) 0.8 0.6 Typ (25C) 0.4 Min (-40C) 0.2 0.0 0 5 10 15 20 25 I OL (-mA) 2001 Microchip Technology Inc. DS30292C-page 185 PIC16F87X ON-LINE SUPPORT Microchip provides on-line support on the Microchip World Wide Web (WWW) site. The web site is used by Microchip as a means to make files and information easily available to customers. To view the site, the user must have access to the Internet and a web browser, such as Netscape or Microsoft Explorer. Files are also available for FTP download from our FTP site. Connecting to the Microchip Internet Web Site Systems Information and Upgrade Hot Line The Systems Information and Upgrade Line provides system users a listing of the latest versions of all of Microchip's development systems software products. Plus, this line provides information on how customers can receive any currently available upgrade kits.The Hot Line Numbers are: 1-800-755-2345 for U.S. and most of Canada, and 1-480-792-7302 for the rest of the world. 001024 The Microchip web site is available by using your favorite Internet browser to attach to: www.microchip.com The file transfer site is available by using an FTP service to connect to: ftp://ftp.microchip.com The web site and file transfer site provide a variety of services. Users may download files for the latest Development Tools, Data Sheets, Application Notes, User’s Guides, Articles and Sample Programs. A variety of Microchip specific business information is also available, including listings of Microchip sales offices, distributors and factory representatives. Other data available for consideration is: • Latest Microchip Press Releases • Technical Support Section with Frequently Asked Questions • Design Tips • Device Errata • Job Postings • Microchip Consultant Program Member Listing • Links to other useful web sites related to Microchip Products • Conferences for products, Development Systems, technical information and more • Listing of seminars and events 2001 Microchip Technology Inc. DS30292C-page 207 ANEXO 2 PIC16F627A/628A/648A Data Sheet Flash-Based 8-Bit CMOS Microcontrollers with nanoWatt Technology ¤ 2004 Microchip Technology Inc. Preliminary DS40044B PIC16F627A/628A/648A 18-pin Flash-Based 8-Bit CMOS Microcontrollers with nanoWatt Technology High Performance RISC CPU: Low Power Features: • • • • • • Standby Current: - 100 nA @ 2.0V, typical • Operating Current: - 12 µA @ 32 kHz, 2.0V, typical - 120 µA @ 1 MHz, 2.0V, typical • Watchdog Timer Current - 1 µA @ 2.0V, typical • Timer1 oscillator current: - 1.2 µA @ 32 kHz, 2.0V, typical • Dual Speed Internal Oscillator: - Run-time selectable between 4 MHz and 37 kHz - 4 µs wake-up from Sleep, 3.0V, typical Operating speeds from DC - 20 MHz Interrupt capability 8-level deep hardware stack Direct, Indirect and Relative Addressing modes 35 single word instructions - All instructions single cycle except branches Special Microcontroller Features: • Internal and external oscillator options - Precision Internal 4 MHz oscillator factory calibrated to ±1% - Low Power Internal 37 kHz oscillator - External Oscillator support for crystals and resonators. • Power saving Sleep mode • Programmable weak pull-ups on PORTB • Multiplexed Master Clear/Input-pin • Watchdog Timer with independent oscillator for reliable operation • Low voltage programming • In-Circuit Serial Programming™ (via two pins) • Programmable code protection • Brown-out Reset • Power-on Reset • Power-up Timer and Oscillator Start-up Timer • Wide operating voltage range. (2.0 - 5.5V) • Industrial and extended temperature range • High Endurance Flash/EEPROM Cell - 100,000 write Flash endurance - 1,000,000 write EEPROM endurance - 100 year data retention Device Program Memory Peripheral Features: • 16 I/O pins with individual direction control • High current sink/source for direct LED drive • Analog comparator module with: - Two analog comparators - Programmable on-chip voltage reference (VREF) module - Selectable internal or external reference - Comparator outputs are externally accessible • Timer0: 8-bit timer/counter with 8-bit programmable prescaler • Timer1: 16-bit timer/counter with external crystal/ clock capability • Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler • Capture, Compare, PWM module - 16-bit Capture/Compare - 10-bit PWM • Addressable Universal Synchronous/Asynchronous Receiver/Transmitter USART/SCI Data Memory I/O CCP (PWM) USART Comparators Timers 8/16-bit 128 16 1 Y 2 2/1 128 16 1 Y 2 2/1 256 16 1 Y 2 2/1 Flash (words) SRAM (bytes) EEPROM (bytes) PIC16F627A 1024 224 PIC16F628A 2048 224 PIC16F648A 4096 256 ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 1 PIC16F627A/628A/648A Pin Diagrams PDIP, SOIC 1 18 RA1/AN1 RA3/AN3/CMP1 2 17 RA0/AN0 RA4/TOCKI/CMP2 3 16 RA7/OSC1/CLKIN RA5/MCLR/VPP 4 15 RA6/OSC2/CLKOUT VSS 5 14 VDD 13 RB7/T1OSI/PGD 12 RB6/T1OSO/T1CKI/PGC 6 7 RB2/TX/CK 8 11 RB5 RB3/CCP1 9 10 RB4/PGM RA5/MCLR/VPP 8 9 10 NC 11 12 RB4/PGM 13 RB5 NC 14 1 21 NC 2 20 VSS 3 19 NC 4 PIC16F627A/628A 18 NC PIC16F648A VSS 17 5 NC 6 16 RB0/INT 7 15 DS40044B-page 2 RA7/OSC1/CLKIN RA6/OSC2/CLKOUT VDD VDD RB7/T1OSI/PGD RB6/T1OSO/T1CKI/PGC RB1/RX/DT RB2/TX/CK RB3/CCP1 RA2/AN2/VREF RA3/AN3/CMP1 RA4/TOCKI/CMP2 RA5/MCLR/VPP VSS VSS RB0/INT RB1/RX/DT RB2/TX/CK RB3/CCP1 1 2 3 4 5 6 7 8 9 10 PIC16F627A/628A/648A RA1/AN1 RA0/AN0 RA4/T0CKI/CMP2 RA3/AN3/CMP1 RA2/AN2/VREF 28-Pin QFN 20 19 18 17 16 15 14 13 12 11 RA1/AN1 RA0/AN0 RA7/OSC1/CLKIN RA6/OSC2/CLKOUT VDD VDD RB7/T1OSI/PGD RB6/T1OSO/T1CKI/PGC RB5 RB4/PGM RB0/INT RB1/RX/DT 28 27 26 25 NC 24 23 22 NC PIC16F627A/628A/648A PIC16F627A/628A/648A SSOP RA2/AN2/VREF Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A FIGURE 3-1: BLOCK DIAGRAM 13 Program Memory RAM File Registers 8-Level Stack (13-bit) Program Bus 14 8 Data Bus Program Counter Flash RAM Addr (1) PORTA 9 Addr MUX Instruction reg Direct Addr 7 8 RA0/AN0 RA1/AN1 RA2/AN2/VREF RA3/AN3/CMP1 RA4/T0CK1/CMP2 RA5/MCLR/VPP RA6/OSC2/CLKOUT RA7/OSC1/CLKIN Indirect Addr FSR reg Status Reg 8 3 Power-up Timer Instruction Decode & Control Timing Generation OSC1/CLKIN OSC2/CLKOUT Oscillator Start-up Timer MUX RB0/INT RB1/RX/DT RB2/TX/CK RB3/CCP1 RB4/PGM RB5 RB6/T1OSO/T1CKI/PGC RB7/T1OSI/PGD ALU Power-on Reset 8 Watchdog Timer Brown-out Detect PORTB W reg Low-Voltage Programming MCLR Comparator Timer0 VREF CCP1 Note: VDD, VSS Timer1 Timer2 USART Data EEPROM Higher order bits are from the Status Register. DS40044B-page 10 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A TABLE 3-2: PIC16F627A/628A/648A PINOUT DESCRIPTION Name RA0/AN0 Function Input Type Output Type RA0 ST CMOS Description Bidirectional I/O port AN0 AN — RA1/AN1 RA1 ST CMOS AN1 AN — RA2/AN2/VREF RA2 ST CMOS AN2 AN — Analog comparator input VREF output RA3/AN3/CMP1 RA4/T0CKI/CMP2 RA5/MCLR/VPP VREF — AN RA3 ST CMOS RA7/OSC1/CLKIN Bidirectional I/O port Analog comparator input Bidirectional I/O port Bidirectional I/O port AN3 AN — CMP1 — CMOS Comparator 1 output RA4 ST OD Bidirectional I/O port T0CKI ST — Timer0 clock input CMP2 — OD Comparator 2 output RA5 ST — Input port — Master clear. When configured as MCLR, this pin is an active low Reset to the device. Voltage on MCLR/VPP must not exceed VDD during normal device operation. Programming voltage input. MCLR RA6/OSC2/CLKOUT Analog comparator input ST Analog comparator input VPP — — RA6 ST CMOS Bidirectional I/O port OSC2 — XTAL Oscillator crystal output. Connects to crystal or resonator in Crystal Oscillator mode. CLKOUT — CMOS In RC/INTOSC mode, OSC2 pin can output CLKOUT, which has 1/4 the frequency of OSC1 RA7 ST CMOS Bidirectional I/O port OSC1 XTAL — Oscillator crystal input CLKIN ST — External clock source input. RC biasing pin. RB0/INT RB0 TTL CMOS INT ST — RB1/RX/DT RB1 TTL CMOS RX ST — DT ST CMOS Synchronous data I/O. RB2 TTL CMOS Bidirectional I/O port. Can be software programmed for internal weak pull-up. RB2/TX/CK RB3/CCP1 O = Output — = Not used TTL = TTL Input ¤ 2004 Microchip Technology Inc. External interrupt. Bidirectional I/O port. Can be software programmed for internal weak pull-up. USART receive pin TX — CMOS USART transmit pin CK ST CMOS Synchronous clock I/O. RB3 TTL CMOS Bidirectional I/O port. Can be software programmed for internal weak pull-up. ST CMOS Capture/Compare/PWM I/O CCP1 Legend: Bidirectional I/O port. Can be software programmed for internal weak pull-up. CMOS = CMOS Output I = Input OD = Open Drain Output Preliminary P = Power ST = Schmitt Trigger Input AN = Analog DS40044B-page 11 PIC16F627A/628A/648A TABLE 3-2: PIC16F627A/628A/648A PINOUT DESCRIPTION Name RB4/PGM Function Input Type Output Type Description RB4 TTL CMOS PGM ST — RB5 RB5 TTL CMOS Bidirectional I/O port. Interrupt-on-pin change. Can be software programmed for internal weak pull-up. RB6/T1OSO/T1CKI/PGC RB6 TTL CMOS Bidirectional I/O port. Interrupt-on-pin change. Can be software programmed for internal weak pull-up. T1OSO — XTAL Timer1 oscillator output. T1CKI ST — Timer1 clock input. PGC ST — ICSP Programming Clock. RB7 TTL CMOS T1OSI XTAL — RB7/T1OSI/PGD Bidirectional I/O port. Interrupt-on-pin change. Can be software programmed for internal weak pull-up. Low voltage programming input pin. When low voltage programming is enabled, the interrupt-on-pin change and weak pull-up resistor are disabled. Bidirectional I/O port. Interrupt-on-pin change. Can be software programmed for internal weak pull-up. Timer1 oscillator input. PGD ST CMOS VSS VSS Power — Ground reference for logic and I/O pins VDD VDD Power — Positive supply for logic and I/O pins Legend: O = Output — = Not used TTL = TTL Input DS40044B-page 12 ICSP Data I/O CMOS = CMOS Output I = Input OD = Open Drain Output Preliminary P = Power ST = Schmitt Trigger Input AN = Analog ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A TABLE 15-2: PIC16F627A/628A/648A INSTRUCTION SET 14-Bit Opcode Mnemonic, Operands Description Cycles MSb LSb Status Affected Notes BYTE-ORIENTED FILE REGISTER OPERATIONS ADDWF ANDWF CLRF CLRW COMF DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF f, d f, d f — f, d f, d f, d f, d f, d f, d f, d f — f, d f, d f, d f, d f, d Add W and f AND W with f Clear f Clear W Complement f Decrement f Decrement f, Skip if 0 Increment f Increment f, Skip if 0 Inclusive OR W with f Move f Move W to f No Operation Rotate Left f through Carry Rotate Right f through Carry Subtract W from f Swap nibbles in f Exclusive OR W with f 1 1 1 1 1 1 1(2) 1 1(2) 1 1 1 1 1 1 1 1 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0111 0101 0001 0001 1001 0011 1011 1010 1111 0100 1000 0000 0000 1101 1100 0010 1110 0110 dfff dfff lfff 0000 dfff dfff dfff dfff dfff dfff dfff lfff 0xx0 dfff dfff dfff dfff dfff ffff ffff ffff 0011 ffff ffff ffff ffff ffff ffff ffff ffff 0000 ffff ffff ffff ffff ffff 1 1 1(2) 1(2) 01 01 01 01 00bb 01bb 10bb 11bb bfff bfff bfff bfff ffff ffff ffff ffff 1 1 2 1 2 1 1 2 2 2 1 1 1 11 11 10 00 10 11 11 00 11 00 00 11 11 111x 1001 0kkk 0000 1kkk 1000 00xx 0000 01xx 0000 0000 110x 1010 kkkk kkkk kkkk 0110 kkkk kkkk kkkk 0000 kkkk 0000 0110 kkkk kkkk kkkk kkkk kkkk 0100 kkkk kkkk kkkk 1001 kkkk 1000 0011 kkkk kkkk C,DC,Z Z Z Z Z Z Z Z Z C C C,DC,Z Z 1,2 1,2 2 1,2 1,2 1,2,3 1,2 1,2,3 1,2 1,2 1,2 1,2 1,2 1,2 1,2 BIT-ORIENTED FILE REGISTER OPERATIONS f, b f, b f, b f, b BCF BSF BTFSC BTFSS Bit Clear f Bit Set f Bit Test f, Skip if Clear Bit Test f, Skip if Set 1,2 1,2 3 3 LITERAL AND CONTROL OPERATIONS ADDLW ANDLW CALL CLRWDT GOTO IORLW MOVLW RETFIE RETLW RETURN SLEEP SUBLW XORLW Note 1: 2: 3: k k k — k k k — k — — k k Add literal and W AND literal with W Call subroutine Clear Watchdog Timer Go to address Inclusive OR literal with W Move literal to W Return from interrupt Return with literal in W Return from Subroutine Go into Standby mode Subtract W from literal Exclusive OR literal with W C,DC,Z Z TO,PD Z TO,PD C,DC,Z Z When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, 1), the value used will be that value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an external device, the data will be written back with a ‘0’. If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared if assigned to the Timer0 Module. If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is executed as a NOP. DS40044B-page 112 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 15.1 Instruction Descriptions ADDLW Add Literal and W Syntax: [ label ] ADDLW k ANDLW AND Literal with W Syntax: [ label ] ANDLW k Operands: 0 ≤ k ≤ 255 Operands: 0 ≤ k ≤ 255 Operation: (W) + k → (W) Operation: (W) .AND. (k) → (W) Status Affected: C, DC, Z Status Affected: Z Encoding: 11 Description: The contents of the W register are added to the eight bit literal ‘k’ and the result is placed in the W register. Words: 1 Cycles: 1 Example ADDLW Encoding: 11 Description: The contents of W register are AND’ed with the eight bit literal ‘k’. The result is placed in the W register. Words: 1 Cycles: 1 Before Instruction W = 0x10 After Instruction W = 0x25 Example ANDLW ADDWF Add W and f ANDWF AND W with f Syntax: [ label ] ADDWF Syntax: [ label ] ANDWF Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (W) + (f) → (dest) Operation: (W) .AND. (f) → (dest) Status Affected: C, DC, Z Encoding: 00 Description: 111x kkkk kkkk 0x15 1001 kkkk kkkk 0x5F Before Instruction W = 0xA3 After Instruction W = 0x03 f,d f,d Status Affected: Z Encoding: 00 Add the contents of the W register with register ‘f’. If ‘d’ is 0 the result is stored in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. Description: AND the W register with register ‘f’. If ‘d’ is 0 the result is stored in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. Words: 1 Words: 1 Cycles: 1 Cycles: 1 Example ADDWF Example ANDWF 0111 dfff REG1, 0 ffff dfff ffff REG1, 1 Before Instruction W = 0x17 REG1 = 0xC2 After Instruction W = 0x17 REG1 = 0x02 Before Instruction W = 0x17 REG1 = 0xC2 After Instruction W = 0xD9 REG1 = 0xC2 Z = 0 C = 0 DC = 0 ¤ 2004 Microchip Technology Inc. 0101 Preliminary DS40044B-page 113 PIC16F627A/628A/648A BCF Bit Clear f BTFSC Bit Test f, Skip if Clear Syntax: [ label ] BCF Syntax: [ label ] BTFSC f,b Operands: 0 ≤ f ≤ 127 0≤b≤7 Operands: 0 ≤ f ≤ 127 0≤b≤7 Operation: 0 → (f<b>) Operation: skip if (f<b>) = 0 Status Affected: None f,b Status Affected: None Encoding: 01 Description: Bit ‘b’ in register ‘f’ is cleared. Words: 1 Cycles: 1 Example BCF 00bb bfff ffff Encoding: Description: Before Instruction REG1 = 0xC7 After Instruction REG1 = 0x47 Bit Set f Syntax: [ label ] BSF Operands: 0 ≤ f ≤ 127 0≤b≤7 Operation: 1 → (f<b>) Status Affected: None Encoding: 01 Bit ‘b’ in register ‘f’ is set. Words: 1 Cycles: 1 Example BSF 01bb bfff bfff ffff If bit ‘b’ in register ‘f’ is ‘0’ then the next instruction is skipped. Words: 1 Cycles: 1(2) Example HERE FALSE TRUE f,b Description: 10bb If bit ‘b’ is ‘0’ then the next instruction fetched during the current instruction execution is discarded, and a NOP is executed instead, making this a twocycle instruction. REG1, 7 BSF 01 ffff BTFSC GOTO • • • REG1 PROCESS_CODE Before Instruction PC = address HERE After Instruction if REG<1> = 0, PC = address TRUE if REG<1>=1, PC = address FALSE REG1, 7 Before Instruction REG1 = 0x0A After Instruction REG1 = 0x8A DS40044B-page 114 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A BTFSS Bit Test f, Skip if Set CALL Call Subroutine Syntax: [ label ] BTFSS f,b Syntax: [ label ] CALL k Operands: 0 ≤ f ≤ 127 0≤b<7 Operands: 0 ≤ k ≤ 2047 Operation: (PC)+ 1→ TOS, k → PC<10:0>, (PCLATH<4:3>) → PC<12:11> Status Affected: None Encoding: 10 Description: Call Subroutine. First, return address (PC+1) is pushed onto the stack. The eleven bit immediate address is loaded into PC bits <10:0>. The upper bits of the PC are loaded from PCLATH. CALL is a two-cycle instruction. Words: 1 Cycles: 2 Example HERE Operation: skip if (f<b>) = 1 Status Affected: None Encoding: 01 Description: If bit ‘b’ in register ‘f’ is ‘1’ then the next instruction is skipped. If bit ‘b’ is ‘1’, then the next instruction fetched during the current instruction execution, is discarded and a NOP is executed instead, making this a two-cycle instruction. Words: 1 Cycles: 1(2) Example HERE FALSE TRUE 11bb BTFSS GOTO • • • bfff ffff REG1 PROCESS_CODE Before Instruction PC = address HERE After Instruction if FLAG<1> = 0, PC = address FALSE if FLAG<1> = 1, PC = address TRUE 0kkk kkkk CALL kkkk THERE Before Instruction PC = Address HERE After Instruction PC = Address THERE TOS = Address HERE+1 CLRF Syntax: Clear f [ label ] CLRF Operands: 0 ≤ f ≤ 127 Operation: 00h → (f) 1→Z Status Affected: f Z Encoding: 00 Description: The contents of register ‘f’ are cleared and the Z bit is set. Words: 1 Cycles: 1 Example CLRF 0001 1fff ffff REG1 Before Instruction REG1 = 0x5A After Instruction REG1 = 0x00 Z = 1 ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 115 PIC16F627A/628A/648A CLRW Clear W COMF Complement f Syntax: [ label ] CLRW Syntax: [ label ] COMF Operands: None Operands: Operation: 00h → (W) 1→Z 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) → (dest) Status Affected: Z Encoding: 00 Description: The contents of register ‘f’ are complemented. If ‘d’ is 0 the result is stored in W. If ‘d’ is 1 the result is stored back in register ‘f’. Status Affected: Z Encoding: 00 Description: W register is cleared. Zero bit (Z) is set. Words: 1 Cycles: 1 Example CLRW Words: 1 Before Instruction W = 0x5A After Instruction W = 0x00 Z = 1 Cycles: 1 Example COMF CLRWDT Clear Watchdog Timer DECF Syntax: [ label ] CLRWDT Operands: None Operation: 00h → WDT 0 → WDT prescaler, 1 → TO 1 → PD Status Affected: TO, PD Encoding: 00 Description: 0001 0000 0011 1001 f,d dfff ffff REG1, 0 Before Instruction REG1 = 0x13 After Instruction REG1 = 0x13 W = 0xEC Syntax: Decrement f [ label ] DECF f,d Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) - 1 → (dest) Status Affected: Z Encoding: 00 0011 dfff ffff Description: CLRWDT instruction resets the Watchdog Timer. It also resets the prescaler of the WDT. Status bits TO and PD are set. Decrement register ‘f’. If ‘d’ is 0 the result is stored in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. Words: 1 Words: 1 Cycles: 1 Cycles: 1 Example DECF Example 0000 0110 CLRWDT Before Instruction WDT counter = ? After Instruction WDT counter = WDT prescaler = = TO = PD DS40044B-page 116 0100 0x00 0 1 1 Preliminary CNT, 1 Before Instruction CNT = 0x01 Z = 0 After Instruction CNT = 0x00 Z = 1 ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A DECFSZ Decrement f, Skip if 0 GOTO Unconditional Branch Syntax: [ label ] DECFSZ f,d Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ k ≤ 2047 Operation: k → PC<10:0> PCLATH<4:3> → PC<12:11> Status Affected: None Encoding: 10 Description: GOTO is an unconditional branch. The eleven-bit immediate value is loaded into PC bits <10:0>. The upper bits of PC are loaded from PCLATH<4:3>. GOTO is a two-cycle instruction. Words: 1 Cycles: 2 Example GOTO THERE Operation: (f) - 1 → (dest); 0 Status Affected: None Encoding: 00 Description: The contents of register ‘f’ are decremented. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is placed back in register ‘f’. If the result is 0, the next instruction, which is already fetched, is discarded. A NOP is executed instead making it a two-cycle instruction. Words: 1 Cycles: 1(2) Example HERE 1011 DECFSZ GOTO CONTINUE • • • skip if result = dfff ffff GOTO k 1kkk kkkk kkkk After Instruction PC = Address THERE REG1, 1 LOOP Before Instruction PC = address HERE After Instruction REG1 = REG1 - 1 if REG1 = 0, PC = address CONTINUE if REG1 ≠ 0, PC = address HERE+1 ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 117 PIC16F627A/628A/648A INCF Increment f INCFSZ Increment f, Skip if 0 Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) + 1 → (dest) Operation: (f) + 1 → (dest), skip if result = 0 Status Affected: Z Status Affected: None Encoding: 00 Encoding: 00 Description: The contents of register ‘f’ are incremented. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is placed back in register ‘f’. Description: Words: 1 Cycles: 1 Example INCF The contents of register ‘f’ are incremented. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is placed back in register ‘f’. If the result is 0, the next instruction, which is already fetched, is discarded. A NOP is executed instead making it a two-cycle instruction. Words: 1 Cycles: 1(2) Example HERE INCF f,d 1010 dfff ffff REG1, 1 Before Instruction REG1 = 0xFF Z = 0 After Instruction REG1 = 0x00 Z = 1 INCFSZ f,d 1111 dfff INCFSZ GOTO CONTINUE • • • ffff REG1, 1 LOOP Before Instruction PC = address HERE After Instruction REG1 = REG1 + 1 if CNT = 0, PC = address CONTINUE if REG1≠ 0, PC = address HERE +1 DS40044B-page 118 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A IORLW Inclusive OR Literal with W MOVLW Move Literal to W Syntax: [ label ] Syntax: [ label ] IORLW k MOVLW k Operands: 0 ≤ k ≤ 255 Operands: 0 ≤ k ≤ 255 Operation: (W) .OR. k → (W) Operation: k → (W) Status Affected: Z Status Affected: None Encoding: 11 Encoding: 11 Description: The contents of the W register is OR’ed with the eight bit literal ‘k’. The result is placed in the W register. Description: The eight bit literal ‘k’ is loaded into W register. The don’t cares will assemble as 0’s. Words: 1 Words: 1 Cycles: 1 Cycles: 1 Example MOVLW Example IORLW 1000 kkkk kkkk 0x35 Inclusive OR W with f Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] IORWF Operation: Status Affected: kkkk kkkk 0x5A After Instruction W = 0x5A Before Instruction W = 0x9A After Instruction W = 0xBF Z = 0 IORWF 00xx MOVF f,d Move f Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] (W) .OR. (f) → (dest) Operation: (f) → (dest) Z Status Affected: Z Encoding: 00 Description: The contents of register f is moved to a destination dependent upon the status of d. If d = 0, destination is W register. If d = 1, the destination is file register f itself. d = 1 is useful to test a file register since status flag Z is affected. Words: 1 Cycles: 1 Example MOVF Encoding: 00 Description: Inclusive OR the W register with register ‘f’. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is placed back in register ‘f’. Words: 1 Cycles: 1 Example IORWF 0100 dfff REG1, 0 Before Instruction REG1 = 0x13 W = 0x91 After Instruction REG1 = 0x13 W = 0x93 Z = 1 ¤ 2004 Microchip Technology Inc. ffff MOVF f,d 1000 dfff ffff REG1, 0 After Instruction W= value in REG1 register Z = 1 Preliminary DS40044B-page 119 PIC16F627A/628A/648A MOVWF Move W to f OPTION Load Option Register Syntax: [ label ] Syntax: [ label ] 0 ≤ f ≤ 127 Operands: None Operands: Operation: (W) → (f) Operation: (W) → OPTION Status Affected: None Status Affected: None Encoding: 00 Encoding: 00 Description: Move data from W register to register ‘f’. Description: The contents of the W register are loaded in the OPTION register. This instruction is supported for code compatibility with PIC16C5X products. Since OPTION is a readable/writable register, the user can directly address it. Using only register instruction such as MOVWF. Words: 1 Cycles: 1 Words: 1 Cycles: 1 Example MOVWF MOVWF 0000 f 1fff ffff REG1 Before Instruction REG1 = 0xFF W = 0x4F After Instruction REG1 = 0x4F W = 0x4F OPTION 0000 0110 0010 Example To maintain upward compatibility with future PICmicro® products, do not use this instruction. NOP No Operation RETFIE Return from Interrupt Syntax: [ label ] Syntax: [ label ] Operands: None Operands: None Operation: No operation Operation: Status Affected: None TOS → PC, 1 → GIE Encoding: 00 Status Affected: None Description: No operation. Encoding: 00 Words: 1 Description: Cycles: 1 Example NOP Return from Interrupt. Stack is POPed and Top of Stack (TOS) is loaded in the PC. Interrupts are enabled by setting Global Interrupt Enable bit, GIE (INTCON<7>). This is a twocycle instruction. NOP 0000 0xx0 0000 RETFIE 0000 Words: 1 Cycles: 2 Example RETFIE 0000 1001 After Interrupt PC = TOS GIE = 1 DS40044B-page 120 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A RETLW Return with Literal in W RLF Rotate Left f through Carry Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ k ≤ 255 Operands: Operation: k → (W); TOS → PC 0 ≤ f ≤ 127 d ∈ [0,1] Operation: See description below Status Affected: C Encoding: 00 Description: The contents of register ‘f’ are rotated one bit to the left through the Carry Flag. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. RETLW k Status Affected: None Encoding: 11 Description: The W register is loaded with the eight bit literal ‘k’. The program counter is loaded from the top of the stack (the return address). This is a two-cycle instruction. Words: 1 Cycles: 2 Example CALL TABLE;W contains table ;offset value • ;W now has table value • • ADDWF PC;W = offset RETLW k1;Begin table RETLW k2; • • • RETLW kn; End of table TABLE 01xx kkkk kkkk 1 Cycles: 1 Example RLF f,d 1101 C Words: RLF dfff ffff REGISTER F REG1, 0 Before Instruction REG1=1110 0110 C = 0 After Instruction REG1=1110 0110 W = 1100 1100 C = 1 Before Instruction W = 0x07 After Instruction W = value of k8 RETURN Return from Subroutine Syntax: [ label ] Operands: None Operation: TOS → PC Status Affected: None Encoding: 00 Description: Return from subroutine. The stack is POPed and the top of the stack (TOS) is loaded into the program counter. This is a two-cycle instruction. Words: 1 Cycles: 2 Example RETURN RETURN 0000 0000 1000 After Interrupt PC = TOS ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 121 PIC16F627A/628A/648A RRF Rotate Right f through Carry SUBLW Subtract W from Literal Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] RRF f,d Operation: See description below Status Affected: C Encoding: 00 Description: The contents of register ‘f’ are rotated one bit to the right through the Carry Flag. If ‘d’ is 0 the result is placed in the W register. If ‘d’ is 1 the result is placed back in register ‘f’. 1100 C Words: 1 Cycles: 1 Example RRF dfff ffff REGISTER F SUBLW k Operands: 0 ≤ k ≤ 255 Operation: k - (W) → (W) Status Affected: C, DC, Z Encoding: 11 Description: The W register is subtracted (2’s complement method) from the eight bit literal ‘k’. The result is placed in the W register. 110x Words: 1 Cycles: 1 Example 1: SUBLW kkkk kkkk 0x02 Before Instruction W = 1 C = ? REG1, 0 After Instruction Before Instruction REG1 = 1110 0110 C = 0 After Instruction REG1 = 1110 0110 W = 0111 0011 C = 0 W = 1 C = 1; result is positive Example 2: Before Instruction W = 2 C = ? After Instruction W = 0 C = 1; result is zero SLEEP Example 3: Syntax: [ label ] SLEEP Operands: None Operation: 00h → WDT, 0 → WDT prescaler, 1 → TO, 0 → PD W = C = W = C = TO, PD Encoding: 00 Description: The power-down Status bit, PD is cleared. Time out Status bit, TO is set. Watchdog Timer and its prescaler are cleared. The processor is put into Sleep mode with the oscillator stopped. See Section 14.8 "Power-Down Mode (Sleep)" for more details. Words: 1 Cycles: 1 Example: SLEEP DS40044B-page 122 0110 3 ? After Instruction Status Affected: 0000 Before Instruction 0xFF 0; result is negative 0011 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A SUBWF Subtract W from f SWAPF Swap Nibbles in f Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (f) - (W) → (dest) Operation: Status Affected: C, DC, Z (f<3:0>) → (dest<7:4>), (f<7:4>) → (dest<3:0>) Status Affected: None Encoding: 00 Encoding: 00 Description: Subtract (2’s complement method) W register from register ‘f’. If ‘d’ is 0 the result is stored in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. Description: The upper and lower nibbles of register ‘f’ are exchanged. If ‘d’ is 0 the result is placed in W register. If ‘d’ is 1 the result is placed in register ‘f’. Words: 1 Words: 1 Cycles: 1 Cycles: 1 Example 1: SUBWF Example SWAPF SUBWF f,d 0010 dfff ffff REG1, 1 Before Instruction Example 2: 1 2 1; result is positive 1 0 After Instruction Example 3: TRIS REG1 = 1 W = 2 C = ? [ label ] TRIS Operands: 5≤f≤7 Operation: (W) → TRIS register f; Status Affected: None Encoding: 00 Description: The instruction is supported for code compatibility with the PIC16C5X products. Since TRIS registers are readable and writable, the user can directly address them. Words: 1 Cycles: 1 ¤ 2004 Microchip Technology Inc. 0000 f 0110 0fff Example After Instruction = = = = Load TRIS Register Syntax: 0 2 1; result is zero DC = 1 Before Instruction REG1 W C Z REG1, 0 REG1 = 0xA5 W = 0x5A REG1 = 2 W = 2 C = ? = = = = ffff REG1 = 0xA5 Before Instruction REG1 W C Z dfff After Instruction After Instruction = = = = = 1110 Before Instruction REG1 = 3 W = 2 C = ? REG1 W C DC Z SWAPF f,d 0xFF 2 0; result is negative DC = 0 Preliminary To maintain upward compatibility with future PICmicro® products, do not use this instruction. DS40044B-page 123 PIC16F627A/628A/648A XORLW Exclusive OR Literal with W XORWF Exclusive OR W with f Syntax: [ label ] Syntax: [ label ] Operands: 0 ≤ f ≤ 127 d ∈ [0,1] Operation: (W) .XOR. (f) → (dest) Status Affected: Z Encoding: 00 Description: Exclusive OR the contents of the W register with register ‘f’. If ‘d’ is 0 the result is stored in the W register. If ‘d’ is 1 the result is stored back in register ‘f’. Words: 1 Cycles: 1 Example XORWF XORLW k Operands: 0 ≤ k ≤ 255 Operation: (W) .XOR. k → (W) Status Affected: Z Encoding: 11 Description: Words: 1010 kkkk kkkk The contents of the W register are XOR’ed with the eight bit literal ‘k’. The result is placed in the W register. 1 Cycles: 1 Example: XORLW 0xAF Before Instruction W = 0xB5 XORWF 0110 f,d dfff ffff REG1, 1 Before Instruction After Instruction REG1 = 0xAF W = 0xB5 W = 0x1A After Instruction REG1 = 0x1A W = 0xB5 DS40044B-page 124 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A PIC16F627A/628A/648A VOLTAGE-FREQUENCY GRAPH, -40°C ≤ TA ≤ +125°C FIGURE 17-1: 6.0 5.5 5.0 VDD (VOLTS) 4.5 4.0 3.5 3.0 2.5 4 0 10 20 25 FREQUENCY (MHz) Note: The shaded region indicates the permissible combinations of voltage and frequency. PIC16LF627A/628A/648A VOLTAGE-FREQUENCY GRAPH, -40°C ≤ TA ≤ +85°C FIGURE 17-2: 6.0 5.5 5.0 4.5 VDD (VOLTS) 4.0 3.5 3.0 2.5 2.0 0 4 10 20 25 FREQUENCY (MHz) Note: The shaded region indicates the permissible combinations of voltage and frequency. DS40044B-page 132 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 17.1 DC Characteristics: PIC16F627A/628A/648A (Industrial, Extended) PIC16LF627A/628A/648A (Industrial) PIC16LF627A/628A/648A (Industrial) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ Ta ≤ +85°C for industrial PIC16F627A/628A/648A (Industrial, Extended) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ Ta ≤ +85°C for industrial and -40°C ≤ Ta ≤ +125°C for extended Param No. Sym VDD D001 Characteristic/Device Min Typ† Max Units PIC16LF627A/628A/648A 2.0 — 5.5 V PIC16F627A/628A/648A 3.0 — 5.5 V Conditions Supply Voltage D002 VDR RAM Data Retention Voltage(1) — 1.5* — V Device in Sleep mode D003 VPOR VDD Start Voltage to ensure Power-on Reset — VSS — V See Section 14.4 on Power-on Reset for details D004 SVDD VDD Rise Rate to ensure Power-on Reset 0.05* — — V/ms See Section 14.4 on Power-on Reset for details D005 VBOR Brown-out Reset Voltage 3.65 3.65 4.0 4.0 4.35 4.4 V V BOREN configuration bit is set BOREN configuration bit is set, Extended Legend: Rows with standard voltage device data only are shaded for improved readability. * These parameters are characterized but not tested. † Data in “Typ” column is at 5.0 V, 25°C, unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: This is the limit to which VDD can be lowered in Sleep mode without losing RAM data. ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 133 PIC16F627A/628A/648A 17.2 DC Characteristics: PIC16F627A/628A/648A (Industrial) PIC16LF627A/628A/648A (Industrial) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ Ta ≤ +85°C for industrial Param No. LF and F Device Characteristics Min† Typ Max Conditions Units Note VDD Supply Voltage (VDD) D001 LF 2.0 — 5.5 V — LF/F 3.0 — 5.5 V — — 0.1 0.80 µA 2.0 Power-down Base Current (IPD) LF D020 LF/F — 0.1 0.85 µA 3.0 — 0.2 2.7 µA 5.0 — 1 2.0 µA 2.0 — 2 3.4 µA 3.0 — 9 17.0 µA 5.0 WDT, BOR, Comparators, VREF, and T1OSC: disabled Peripheral Module Current (∆IMOD)(1) LF D021 D022 LF/F LF/F LF D023 LF/F LF D024 LF/F LF D025 LF/F — 32 TBD µA 4.5 — 33 TBD µA 5.0 — 15 TBD µA 2.0 — 27 TBD µA 3.0 — 49 TBD µA 5.0 — 34 TBD µA 2.0 — 50 TBD µA 3.0 — 80 TBD µA 5.0 — 1.2 2.0 µA 2.0 — 1.3 2.2 µA 3.0 — 1.8 2.9 µA 5.0 — 12 15 µA 2.0 — 21 25 µA 3.0 WDT Current BOR Current Comparator Current VREF Current T1OSC Current Supply Current (IDD) LF D010 LF/F LF D011 LF/F LF D012 D013 LF/F LF/F — 38 48 µA 5.0 — 130 190 µA 2.0 — 220 340 µA 3.0 — 370 520 µA 5.0 — 270 350 µA 2.0 — 430 600 µA 3.0 — 780 995 µA 5.0 — 2.6 2.9 mA 4.5 — 3 3.3 mA 5.0 FOSC = 32 kHz LP Oscillator Mode FOSC = 1 MHz XT Oscillator Mode FOSC = 4 MHz XT Oscillator Mode FOSC = 20 MHz HS Oscillator Mode Note 1: The “∆” current is the additional current consumed when this peripheral is enabled. This current should be added to the base IDD or IPD measurement. Max values should be used when calculating total current consumption. DS40044B-page 134 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 17.3 DC Characteristics: PIC16F627A/628A/648A (Extended) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ Ta ≤ +125°C for extended Param No. Device Characteristics Min† Typ Max Conditions Units Note VDD Supply Voltage (VDD) D001 — 3.0 — 5.5 V — Power-down Base Current (IPD) D020E — — 0.1 TBD µA 3.0 — 0.2 TBD µA 5.0 WDT, BOR, Comparators, VREF, and T1OSC: disabled — 2 TBD µA 3.0 WDT Current — 9 TBD µA 5.0 — 32 TBD µA 4.5 — 33 TBD µA 5.0 — 27 TBD µA 3.0 — 49 TBD µA 5.0 — 50 TBD µA 3.0 — 83 TBD µA 5.0 Peripheral Module Current (∆IMOD)(1) D021E — D022E — D023E — D024E — D025E — — 1.3 TBD µA 3.0 — 1.8 TBD µA 5.0 — 21 TBD µA 3.0 BOR Current Comparator Current VREF Current T1OSC Current Supply Current (IDD) D010E — D011E — D012E — D013E — — 38 TBD µA 5.0 — 220 TBD µA 3.0 — 370 TBD µA 5.0 — 430 TBD µA 3.0 — 780 TBD µA 5.0 — 2.6 TBD mA 4.5 — 3 TBD mA 5.0 FOSC = 32 kHz LP Oscillator Mode FOSC = 1 MHz XT Oscillator Mode FOSC = 4 MHz XT Oscillator Mode FOSC = 20 MHz HS Oscillator Mode Note 1: The “∆” current is the additional current consumed when this peripheral is enabled. This current should be added to the base IDD or IPD measurement. Max values should be used when calculating total current consumption. ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 135 PIC16F627A/628A/648A 17.4 DC Characteristics: PIC16F627A/628A/648A (Industrial, Extended) PIC16LF627A/628A/648A (Industrial) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ TA ≤ +85°C for industrial and -40°C ≤ TA ≤ +125°C for extended Operating voltage VDD range as described in DC spec Table 17-2 and Table 17-3 DC CHARACTERISTICS Param. No. Sym VIL Characteristic/Device with Schmitt Trigger input(4) MCLR, RA4/T0CKI,OSC1 (in RC mode) OSC1 (in HS) OSC1 (in LP and XT) D031 D032 D033 VIH I/O ports with TTL buffer D041 D042 D043 D043A with Schmitt Trigger input(4) MCLR RA4/T0CKI OSC1 (XT, HS and LP) OSC1 (in RC mode) IPURB IIL PORTB weak pull-up current VOL VOH VSS VSS VSS VSS — — — — 0.8 0.15 VDD 0.2 VDD 0.2 VDD V V V V VSS VSS — — 0.3 VDD 0.8 V V 2.0 V .25 VDD + 0.8 V 0.8 VDD 0.8 VDD 0.7 VDD 0.9 VDD — — — — — — VDD VDD VDD VDD VDD VDD V V V V V V VDD = 4.5V to 5.5V otherwise 50 200 400 µA VDD = 5.0V, VPIN = VSS — — — — — — — — ±1.0 ±0.5 ±1.0 ±5.0 µA µA µA µA VSS ≤ VPIN ≤ VDD, pin at hi-impedance VSS ≤ VPIN ≤ VDD, pin at hi-impedance VSS ≤ VPIN ≤ VDD VSS ≤ VPIN ≤ VDD, XT, HS and LP osc configuration — — — — 0.6 0.6 V V IOL=8.5 mA, VDD=4.5 V, -40° to +85°C IOL=7.0 mA, VDD=4.5 V, +85° to +125°C VDD-0.7 VDD-0.7 — — — — V V IOH=-3.0 mA, VDD=4.5 V, -40° to +85°C IOH=-2.5 mA, VDD=4.5 V, +85° to +125°C — — 8.5* V RA4 pin PIC16F627A/628A/648A, PIC16LF627A/628A/648A In XT, HS and LP modes when external clock used to drive OSC1. VDD = 4.5V to 5.5V otherwise (Note1) (Note1) Output High Voltage(3) I/O ports (Except RA4(4) D090 Conditions Output Low Voltage I/O ports(4) D080 Unit Input Leakage Current(2), (3) I/O ports (Except PORTA) PORTA(4) RA4/T0CKI OSC1, MCLR D060 D061 D063 Max Input High Voltage D040 D070 Typ† Input Low Voltage I/O ports with TTL buffer D030 Min D150 VOD D100* COSC2 OSC2 pin — — 15 pF Cio All I/O pins/OSC2 (in RC mode) — — 50 pF Open-Drain High Voltage Capacitive Loading Specs on Output Pins D101* Note * These parameters are characterized but not tested. † Data in “Typ” column is at 5.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. 1: In RC oscillator configuration, the OSC1 pin is a Schmitt Trigger input. It is not recommended that the PIC16F627A/628A/648A be driven with external clock in RC mode. 2: The leakage current on the MCLR pin is strongly dependent on applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. 3: Negative current is defined as coming out of the pin. 4: Includes OSC1 and OSC2 when configured as I/O pins, CLKIN, or CLKOUT. DS40044B-page 136 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A TABLE 17-1: DC Characteristics: PIC16F627A/628A/648A (Industrial, Extended) PIC16LF627A/628A/648A (Industrial) Standard Operating Conditions (unless otherwise stated) Operating temperature -40°C ≤ TA ≤ +85°C for industrial and -40°C ≤ TA ≤ +125°C for extended Operating voltage VDD range as described in DC spec Table 17-2 and Table 17-3 DC Characteristics Parameter Sym No. Characteristic Min Typ† Max — D120 D120A D121 Data EEPROM Memory ED Endurance ED Endurance VDRW VDD for read/write 100K 10K VMIN 1M 100K — 5.5 D122 D123 TDEW Erase/Write cycle time TRETD Characteristic Retention — 100 4 — 8* — D124 TREF 1M 10M — D130 D130A D131 EP EP VPR 10K 1000 VMIN 100K 10K — — — 5.5 D132 D132A VDD for Block erase VIE VPEW VDD for write 4.5 VMIN — — 5.5 5.5 D133 D133A D134 Block Erase cycle time TIE TPEW Write cycle time TRETP Characteristic Retention — — 100 4 2 — 8* 4* — Number of Total Erase/Write Cycles before Refresh(1) Program Flash Memory Endurance Endurance VDD for read Units Conditions E/W -40°C ≤ TA ≤ 85°C E/W 85°C ≤ TA ≤ 125°C V VMIN = Minimum operating voltage ms Year Provided no other specifications are violated E/W -40°C to +85°C E/W -40°C ≤ TA ≤ 85°C E/W 85°C ≤ TA ≤ 125°C VMIN = Minimum operating V voltage V VMIN = Minimum operating V voltage ms VDD > 4.5V ms year Provided no other specifications are violated * These parameters are characterized but not tested. † Data in “Typ” column is at 5.0 V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: Refer to Section 13.7 "Using the Data EEPROM" for a more detailed discussion on data EEPROM endurance. ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 137 PIC16F627A/628A/648A TABLE 17-2: COMPARATOR SPECIFICATIONS Operating Conditions: 2.0V < VDD <5.5V, -40°C < T A < +125°C, unless otherwise stated. Param No. D300 Characteristics Input Offset Voltage Sym Min Typ Max Units VIOFF — ±5.0 ±10 mV D301 Input Common Mode Voltage VICM 0 — VDD - 1.5* V D302 Common Mode Rejection Ratio CMRR 55* — — db D303 Response Time(1) TRESP — 300 400* ns — 400 600* ns — 400 600* ns — 300 10* µs D304 Comparator Mode Change to Output Valid TMC2OV Comments VDD = 3.0V to 5.5V -40° to +85°C VDD = 3.0V to 5.5V -85° to +125°C VDD = 2.0V to 3.0V -40° to +85°C * These parameters are characterized but not tested. Note 1: Response time measured with one comparator input at (VDD - 1.5)/2 while the other input transitions from VSS to VDD. TABLE 17-3: VOLTAGE REFERENCE SPECIFICATIONS Operating Conditions: 2.0V < VDD < 5.5V, -40°C < TA < +125°C, unless otherwise stated. Spec No. Characteristics Sym Min Typ Max Units Comments D310 Resolution VRES — — VDD/24 VDD/32 LSb LSb Low Range (VRR = 1) High Range (VRR = 0) D311 Absolute Accuracy VRAA — — — — 1/4(2)* 1/2(2)* LSb LSb Low Range (VRR = 1) High Range (VRR = 0) D312 Unit Resistor Value (R) VRUR — 2k* — Ω TSET — — 10* µs D313 Settling Time (1) * These parameters are characterized but not tested. Note 1: Settling time measured while VRR = 1 and VR<3:0> transitions from 0000 to 1111. 2: When VDD is between 2.0V and 3.0V the VREF output voltage levels on RA2 described by the equation:[VDD/2 ± (3-VDD)/2] may cause the Absolute Accuracy (VRAA) of the VREF output signal on RA2 to be greater than the stated max. DS40044B-page 138 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 17.5 Timing Parameter Symbology The timing parameter symbols have been created with one of the following formats: 1. TppS2ppS 2. TppS T F Frequency Lowercase subscripts (pp) and their meanings: pp ck CLKOUT io I/O port mc MCLR Uppercase letters and their meanings: S F Fall H High I Invalid (Hi-impedance) L Low FIGURE 17-3: T Time osc t0 OSC1 T0CKI P R V Z Period Rise Valid Hi-Impedance LOAD CONDITIONS LOAD CONDITION 2 LOAD CONDITION 1 VDD/2 RL CL PIN CL PIN VSS VSS RL = 464Ω CL = 50 pF for all pins except OSC2 15 pF for OSC2 output ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 139 PIC16F627A/628A/648A 19.0 PACKAGING INFORMATION 19.1 Package Marking Information 18-LEAD PDIP (.300") XXXXXXXXXXXXXX XXXXXXXXXXXXXX EXAMPLE PIC16F627A-I/P YYWWNNN 18-LEAD SOIC (.300") XXXXXXXXXXXX XXXXXXXXXXXX XXXXXXXXXXXX YYWWNNN EXAMPLE PIC16F628A -E/SO 0210017 20-LEAD SSOP EXAMPLE XXXXXXXXXXX XXXXXXXXXXX YYWWNNN PIC16F648A -I/SS 0210017 28-LEAD QFN EXAMPLE XXXXXXXX XXXXXXXX YYWWNNN 16F628A -I/ML 0210017 Legend: XX...X YY WW NNN Note: * 0210017 Customer specific information* Year code (last 2 digits of calendar year) Week code (week of January 1 is week ‘01’) Alphanumeric traceability code In the event the full Microchip part number cannot be marked on one line, it will be carried over to the next line thus limiting the number of available characters for customer specific information. Standard PICmicro device marking consists of Microchip part number, year code, week code, and traceability code. For PICmicro device marking beyond this, certain price adders apply. Please check with your Microchip Sales Office. For QTP devices, any special marking adders are included in QTP price. ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 149 PIC16F627A/628A/648A 18-Lead Plastic Dual In-line (P) – 300 mil (PDIP) E1 D 2 n α 1 E A2 A L c A1 B1 β p B eB Units Dimension Limits n p MIN INCHES* NOM 18 .100 .155 .130 MAX MILLIMETERS NOM 18 2.54 3.56 3.94 2.92 3.30 0.38 7.62 7.94 6.10 6.35 22.61 22.80 3.18 3.30 0.20 0.29 1.14 1.46 0.36 0.46 7.87 9.40 5 10 5 10 MIN Number of Pins Pitch Top to Seating Plane A .140 .170 Molded Package Thickness A2 .115 .145 Base to Seating Plane A1 .015 Shoulder to Shoulder Width E .300 .313 .325 Molded Package Width E1 .240 .250 .260 Overall Length D .890 .898 .905 Tip to Seating Plane L .125 .130 .135 c Lead Thickness .008 .012 .015 Upper Lead Width B1 .045 .058 .070 Lower Lead Width B .014 .018 .022 Overall Row Spacing § eB .310 .370 .430 α Mold Draft Angle Top 5 10 15 β Mold Draft Angle Bottom 5 10 15 * Controlling Parameter § Significant Characteristic Notes: Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010” (0.254mm) per side. JEDEC Equivalent: MS-001 Drawing No. C04-007 DS40044B-page 150 Preliminary MAX 4.32 3.68 8.26 6.60 22.99 3.43 0.38 1.78 0.56 10.92 15 15 ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 18-Lead Plastic Small Outline (SO) – Wide, 300 mil (SOIC) E p E1 D 2 B n 1 h α 45° c A2 A φ β L Units Dimension Limits n p Number of Pins Pitch Overall Height Molded Package Thickness Standoff § Overall Width Molded Package Width Overall Length Chamfer Distance Foot Length Foot Angle Lead Thickness Lead Width Mold Draft Angle Top Mold Draft Angle Bottom A A2 A1 E E1 D h L φ c B α β MIN .093 .088 .004 .394 .291 .446 .010 .016 0 .009 .014 0 0 A1 INCHES* NOM 18 .050 .099 .091 .008 .407 .295 .454 .020 .033 4 .011 .017 12 12 MAX .104 .094 .012 .420 .299 .462 .029 .050 8 .012 .020 15 15 MILLIMETERS NOM 18 1.27 2.36 2.50 2.24 2.31 0.10 0.20 10.01 10.34 7.39 7.49 11.33 11.53 0.25 0.50 0.41 0.84 0 4 0.23 0.27 0.36 0.42 0 12 0 12 MIN MAX 2.64 2.39 0.30 10.67 7.59 11.73 0.74 1.27 8 0.30 0.51 15 15 * Controlling Parameter § Significant Characteristic Notes: Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010” (0.254mm) per side. JEDEC Equivalent: MS-013 Drawing No. C04-051 ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 151 PIC16F627A/628A/648A 20-Lead Plastic Shrink Small Outline (SS) – 209 mil, 5.30 mm (SSOP) E E1 p D B 2 1 n α c A2 A φ L A1 β Units Dimension Limits n p Number of Pins Pitch Overall Height Molded Package Thickness Standoff § Overall Width Molded Package Width Overall Length Foot Length Lead Thickness Foot Angle Lead Width Mold Draft Angle Top Mold Draft Angle Bottom A A2 A1 E E1 D L c φ B α β MIN .068 .064 .002 .299 .201 .278 .022 .004 0 .010 0 0 INCHES* NOM 20 .026 .073 .068 .006 .309 .207 .284 .030 .007 4 .013 5 5 MAX .078 .072 .010 .322 .212 .289 .037 .010 8 .015 10 10 MILLIMETERS NOM 20 0.65 1.73 1.85 1.63 1.73 0.05 0.15 7.59 7.85 5.11 5.25 7.06 7.20 0.56 0.75 0.10 0.18 0.00 101.60 0.25 0.32 0 5 0 5 MIN MAX 1.98 1.83 0.25 8.18 5.38 7.34 0.94 0.25 203.20 0.38 10 10 * Controlling Parameter § Significant Characteristic Notes: Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010” (0.254mm) per side. JEDEC Equivalent: MO-150 Drawing No. C04-072 DS40044B-page 152 Preliminary ¤ 2004 Microchip Technology Inc. PIC16F627A/628A/648A 28-Lead Plastic Quad Flat No Lead Package (ML) 6x6 mm Body (QFN) EXPOSED METAL PADS E E1 Q D1 D D2 p 2 1 B n R E2 CH x 45 L TOP VIEW BOTTOM VIEW α A2 A A1 A3 Number of Pins MILLIMETERS* INCHES Units Dimension Limits MIN NOM n MIN MAX MAX NOM 28 28 Pitch p Overall Height A .033 .039 0.85 1.00 Molded Package Thickness A2 .026 .031 0.65 0.80 Standoff A1 .0004 .002 0.01 0.05 Base Thickness A3 .008 REF. 0.20 REF. 6.00 BSC .026 BSC .000 E .236 BSC Molded Package Width E1 .226 BSC Exposed Pad Width E2 Overall Width Overall Length .140 .146 0.65 BSC 0.00 5.75 BSC .152 3.55 .236 BSC D 3.70 3.85 6.00 BSC .226 BSC 5.75 BSC Molded Package Length D1 Exposed Pad Length D2 .140 .146 .152 3.55 3.70 Lead Width B .009 .011 .014 0.23 0.28 0.35 Lead Length L .020 .024 .030 0.50 0.60 0.75 Tie Bar Width R .005 .007 .010 0.13 0.17 0.23 Tie Bar Length Q .012 .016 .026 0.30 0.40 0.65 CH .009 .017 .024 0.24 0.42 0.60 Chamfer Mold Draft Angle Top α 12 3.85 12 *Controlling Parameter Notes: Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010” (0.254mm) per side. JEDEC equivalent: M0-220 Drawing No. C04-114 ¤ 2004 Microchip Technology Inc. Preliminary DS40044B-page 153 ANEXO 3 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 D Low Power Consumption D Wide Common-Mode and Differential D D D D D D D Voltage Ranges Low Input Bias and Offset Currents Output Short-Circuit Protection Low Total Harmonic Distortion . . . 0.003% Typ High Input Impedance . . . JFET-Input Stage Latch-Up-Free Operation High Slew Rate . . . 13 V/µs Typ Common-Mode Input Voltage Range Includes VCC+ description/ordering information The TL08x JFET-input operational amplifier family is designed to offer a wider selection than any previously developed operational amplifier family. Each of these JFET-input operational amplifiers incorporates well-matched, high-voltage JFET and bipolar transistors in a monolithic integrated circuit. The devices feature high slew rates, low input bias and offset currents, and low offset-voltage temperature coefficient. Offset adjustment and external compensation options are available within the TL08x family. The C-suffix devices are characterized for operation from 0°C to 70°C. The I-suffix devices are characterized for operation from −40°C to 85°C. The Q-suffix devices are characterized for operation from −40°C to 125°C. The M-suffix devices are characterized for operation over the full military temperature range of −55°C to 125°C. ORDERING INFORMATION TJ VIOmax AT 255C PDIP (P) PDIP (N) SOIC (D) 0°C to 70°C ORDERABLE PART NUMBER PACKAGE† 15 mV SOP (PS) SOP (NS) TSSOP (PW) TOP-SIDE MARKING Tube of 50 TL081CP TL081CP Tube of 50 TL082CP TL082CP Tube of 25 TL084CN TL084CN Tube of 75 TL081CD Reel of 2500 TL081CDR Tube of 75 TL082CD Reel of 2500 TL082CDR Tube of 50 TL084CD Reel of 2500 TL084CDR Reel of 2000 TL081CPSR T081 Reel of 2000 TL082CPSR T082 Reel of 2000 TL084CNSR TL084 Tube of 150 TL082CPW Reel of 2000 TL082CPWR Tube of 90 TL084CPW Reel of 2000 TL084CPWR TL081C TL082C TL084C T082 T084 † Package drawings, standard packing quantities, thermal data, symbolization, and PCB design guidelines are available at www.ti.com/sc/package. Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of Texas Instruments semiconductor products and disclaimers thereto appears at the end of this data sheet. Copyright 2004, Texas Instruments Incorporated ! " #$%! " &$'(#! )!%* )$#!" # ! "&%##!" &% !+% !%" %," "!$%!" "!)) -!.* )$#! &#%""/ )%" ! %#%""(. #($)% !%"!/ (( &%!%"* &)$#!" #&(! ! 0101 (( &%!%" % !%"!%) $(%"" !+%-"% !%)* (( !+% &)$#!" &)$#! &#%""/ )%" ! %#%""(. #($)% !%"!/ (( &%!%"* POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 1 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 description/ordering information (continued) ORDERING INFORMATION TJ VIOmax AT 255C PACKAGE† TL081ACP TL081ACP Tube of 50 TL082ACP TL082ACP Tube of 25 TL084ACN TL084ACN Tube of 75 TL081ACD Reel of 2500 TL081ACDR Tube of 75 TL082ACD Reel of 2500 TL082ACDR Tube of 50 TL084ACD Reel of 2500 TL084ACDR SOP (PS) Reel of 2000 TL082ACPSR T082A SOP (NS) Reel of 2000 TL084ACNSR TL084A Tube of 50 TL081BCP TL081BCP Tube of 50 TL082BCP TL082BCP Tube of 25 TL084BCN TL084BCN Tube of 75 TL081BCD Reel of 2500 TL081BCDR Tube of 75 TL082BCD Reel of 2500 TL082BCDR Tube of 50 TL084BCD Reel of 2500 TL084BCDR Tube of 50 TL081IP TL081IP Tube of 50 TL082IP TL082IP Tube of 25 TL084IN TL081IN Tube of 75 TL081ID Reel of 2500 TL081IDR Tube of 75 TL082ID Reel of 2500 TL082IDR Tube of 50 TL084ID Reel of 2500 TL084IDR Reel of 2000 TL082IPWR Tube of 50 TL084QD Reel of 2500 TL084QDR CDIP (J) Tube of 25 TL084MJ TL084MJ LCCC (FK) Reel of 55 TL084FK TL084FK CDIP (JG) Tube of 50 TL082MJG TL082MJG LCCC (FK) Tube of 55 TL082MFK PDIP (N) 0°C to 70°C SOIC (D) PDIP (P) PDIP (N) 3 mV SOIC (D) PDIP (P) PDIP (N) −40°C to 85°C 6 mV SOIC (D) TSSOP (PW) −40°C to 125°C 9 mV 9 mV −55°C to 125°C 6 mV TOP-SIDE MARKING Tube of 50 PDIP (P) 6 mV ORDERABLE PART NUMBER SOIC (D) 081AC 082AC TL084AC 081BC 082BC TL084BC TL081I TL082I TL084I Z082 TL084QD TL082MFK † Package drawings, standard packing quantities, thermal data, symbolization, and PCB design guidelines are available at www.ti.com/sc/package. 2 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TL081, TL081A, TL081B D, P, OR PS PACKAGE (TOP VIEW) OFFSET N1 IN − IN + VCC − 1 8 2 7 3 6 4 5 TL084, TL084A, TL084B D, J, N, NS, OR PW PACKAGE (TOP VIEW) TL082, TL082A, TL082B D, JG, P, PS, OR PW PACKAGE (TOP VIEW) NC VCC + OUT OFFSET N2 1OUT 1IN − 1IN + VCC − 1 8 2 7 3 6 4 5 VCC + 2OUT 2IN − 2IN + 1OUT 1IN − 1IN + VCC + 2IN + 2IN − 2OUT NC − No internal connection 14 2 13 3 12 4 11 5 10 6 9 7 8 4OUT 4IN − 4IN + VCC − 3IN + 3IN − 3OUT TL084M . . . FK PACKAGE (TOP VIEW) 1IN − 1OUT NC 4OUT 4IN − NC 1OUT NC VCC+ NC TL082M . . . FK PACKAGE (TOP VIEW) 4 3 2 1 20 19 18 5 17 6 16 7 15 8 14 9 10 11 12 13 NC 2OUT NC 2IN − NC 1IN + NC VCC + NC 2IN + 4 3 2 1 20 19 18 5 17 6 16 7 15 8 14 9 10 11 12 13 4IN + NC VCC − NC 3IN + 2IN − 2OUT NC 3OUT 3IN − NC VCC − NC 2IN + NC NC 1IN − NC 1IN + NC 1 NC − No internal connection NC − No internal connection symbols TL081 TL082 (EACH AMPLIFIER) TL084 (EACH AMPLIFIER) OFFSET N1 IN + + IN − − OUT IN + + IN − − OUT OFFSET N2 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 3 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 schematic (each amplifier) VCC + IN + 64 Ω IN − OUT 128 Ω 64 Ω C1 1080 Ω 1080 Ω VCC − OFFSET N1 OFFSET N2 TL081 Only Component values shown are nominal. 4 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 absolute maximum ratings over operating free-air temperature range (unless otherwise noted)† TL08_C TL08_AC TL08_BC TL08_I TL084Q TL08_M UNIT Supply voltage, VCC + (see Note 1) 18 18 18 18 V Supply voltage VCC − (see Note 1) −18 −18 −18 −18 V Differential input voltage, VID (see Note 2) ± 30 ± 30 ± 30 ± 30 V V Input voltage, VI (see Notes 1 and 3) Duration of output short circuit (see Note 4) ± 15 ± 15 ± 15 ± 15 Unlimited Unlimited Unlimited Unlimited Continuous total power dissipation See Dissipation Rating Table Operating free-air temperature range, TA Package thermal impedance, θJA (see Notes 5 and 6) 0 to 70 − 40 to 85 D package (8-pin) 97 97 D package (14-pin) 86 86 N package (14-pin) 76 76 NS package (14-pin) 80 P package (8-pin) 85 85 PS package (8-pin) 95 95 PW package (8-pin) 149 PW package (14-pin) 113 113 150 150 − 40 to 125 − 55 to 125 °C °C/W 150 °C Case temperature for 60 seconds, TC FK package 260 °C Lead temperature 1,6 mm (1/16 inch) from case for 60 seconds J or JG package 300 °C Operating virtual junction temperature 150 Storage temperature range, Tstg − 65 to 150 − 65 to 150 − 65 to 150 − 65 to 150 °C † Stresses beyond those listed under “absolute maximum ratings” may cause permanent damage to the device. These are stress ratings only, and functional operation of the device at these or any other conditions beyond those indicated under “recommended operating conditions” is not implied. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. NOTES: 1. All voltage values, except differential voltages, are with respect to the midpoint between VCC + and VCC − . 2. Differential voltages are at IN+ with respect to IN −. 3. The magnitude of the input voltage must never exceed the magnitude of the supply voltage or 15 V, whichever is less. 4. The output may be shorted to ground or to either supply. Temperature and/or supply voltages must be limited to ensure that the dissipation rating is not exceeded. 5. Maximum power dissipation is a function of TJ(max), θJA, and TA. The maximum allowable power dissipation at any allowable ambient temperature is PD = (TJ(max) − TA)/θJA. Operating at the absolute maximum TJ of 150°C can affect reliability. 6. The package thermal impedance is calculated in accordance with JESD 51-7. DISSIPATION RATING TABLE PACKAGE TA ≤ 25°C POWER RATING D (14 pin) 680 mW FK J JG DERATING FACTOR DERATE ABOVE TA TA = 70°C POWER RATING TA = 125°C POWER RATING 490 mW 186 mW 7.6 mW/°C 60°C 680 mW 11.0 mW/°C 88°C 680 mW 680 mW 273 mW 680 mW 11.0 mW/° C 88°C 680 mW 680 mW 273 mW 680 mW 8.4 mW/°C 69°C 672 mW 546 mW 210 mW POST OFFICE BOX 655303 604 mW TA = 85°C POWER RATING • DALLAS, TEXAS 75265 5 TEST CONDITIONS TA† MIN 25°C TYP MAX 3 15 VIO Input offset voltage VO = 0 RS = 50 Ω Full range α VIO Temperature coefficient of input offset voltage VO = 0 RS = 50 Ω Full range 18 Input offset current ‡ 25°C 5 IIO VO = 0 Full range IIB Input bias current ‡ VO = 0 Full range POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 VICR Common-mode input voltage range VOM Maximum peak output voltage swing RL ≥ 10 kΩ 30 MAX 3 6 ± 11 25°C ± 12 ± 13.5 MIN 5 3 30 100 5 200 30 ± 11 ± 12 ± 13.5 ± 12 MAX 3 6 9 100 5 200 30 7 ± 11 −12 to 15 ± 11 −12 to 15 ± 12 ± 13.5 ± 12 ± 13.5 ± 12 ± 12 ± 10 ± 12 ± 10 ± 12 200 50 200 50 200 50 200 25 VO = ± 10 V, RL ≥ 2 kΩ Full range 15 pA 10 nA 200 pA 20 nA V V ± 10 25°C 100 ± 12 ± 12 RL ≥ 2 kΩ mV µV/°C 18 ± 10 VO = ± 10 V, UNIT TYP 2 7 −12 to 15 MIN 18 2 400 ± 12 MAX 2 5 18 200 TL081I TL082I TL084I TYP 7.5 10 25°C TLO81BC TL082BC TL084BC TYP 2 −12 to 15 Full range RL ≥ 2 kΩ MIN 20 25°C RL = 10 kΩ TL081AC TL082AC TL084AC AVD Large-signal differential voltage amplification B1 Unity-gain bandwidth 25°C 3 3 3 3 ri Input resistance 25°C 1012 1012 1012 1012 Ω CMRR Common-mode rejection ratio VIC = VICRmin, RS = 50 Ω VO = 0, 25°C 70 86 75 86 75 86 75 86 dB Supply-voltage rejection ratio (∆ VCC± /∆ VIO) Supply current (per amplifier) VCC = ± 15 V to ± 9 V, VO = 0, RS = 50 Ω 25°C 70 86 80 86 80 86 80 86 dB VO = 0, 25°C kSVR ICC No load V/mV 25 1.4 2.8 25 1.4 2.8 25 1.4 2.8 1.4 MHz 2.8 mA VO1/ VO2 Crosstalk attenuation AVD = 100 25°C 120 120 120 120 dB † All characteristics are measured under open-loop conditions with zero common-mode voltage, unless otherwise specified. Full range for TA is 0°C to 70°C for TL08_C, TL08_AC, TL08_BC and − 40°C to 85°C for TL08_I. ‡ Input bias currents of an FET-input operational amplifier are normal junction reverse currents, which are temperature sensitive, as shown in Figure 17. Pulse techniques must be used that maintain the junction temperature as close to the ambient temperature as possible. 22222 2 2 322 PARAMETER TL081C TL082C TL084C SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 6 electrical characteristics, VCC± = ±15 V (unless otherwise noted) SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 electrical characteristics, VCC ± = ± 15 V (unless otherwise noted) PARAMETER TEST CONDITIONS† TA TL081M, TL082M TL084Q, TL084M MIN MIN 25°C TYP MAX 3 6 VIO Input offset voltage VO = 0, RS = 50 Ω Full range αVIO Temperature coefficient of input offset voltage VO = 0 RS = 50 Ω Full range 18 Input offset current‡ 25°C 5 IIO VO = 0 IIB Input bias current‡ VICR Common-mode input voltage range VOM Maximum peak output voltage swing AVD B1 ri Large-signal differential voltage amplification 30 100 RL ≥ 10 kΩ 200 25°C ± 11 25°C ± 12 ± 13.5 Full range 30 50 ± 12 RL ≥ 2 kΩ 5 ± 11 − 12 to 15 ± 12 ± 13.5 ± 10 ± 12 200 25 200 25°C 25 VO = ± 10 V, RL ≥ 2 kΩ Full range 15 100 pA 20 nA 200 pA 50 nA V V ± 12 RL ≥ 2 kΩ mV µV/°C ± 12 ± 10 VO = ± 10 V, UNIT 9 18 125°C − 12 to 15 MAX 15 20 25°C RL = 10 kΩ 3 9 125°C VO = 0 TYP V/mV Unity-gain bandwidth 25°C Input resistance 15 3 12 10 25°C 3 12 10 MHz Ω CMRR Common-mode rejection ratio VIC = VICRmin, VO = 0, RS = 50 Ω 25°C 80 86 80 86 dB kSVR Supply-voltage rejection ratio (∆VCC ± /∆VIO) VCC = ± 15 V to ± 9 V, VO = 0, RS = 50 Ω 25°C 80 86 80 86 dB ICC Supply current (per amplifier) VO = 0, 25°C No load 1.4 2.8 1.4 2.8 mA VO1/ VO2 Crosstalk attenuation AVD = 100 25°C 120 120 dB † All characteristics are measured under open-loop conditions, with zero common-mode input voltage, unless otherwise specified. ‡ Input bias currents of a FET-input operational amplifier are normal junction reverse currents, which are temperature sensitive, as shown in Figure 17. Pulse techniques must be used that maintain the junction temperatures as close to the ambient temperature as possible. operating characteristics, VCC ± = ± 15 V, TA = 25°C (unless otherwise noted) PARAMETER SR Slew rate at unity gain tr Rise time Overshoot factor TEST CONDITIONS VI = 10 V, RL = 2 kΩ, CL = 100 pF, VI = 10 V, TA = − 55°C 55 C to 125°C, 125 C, RL = 2 kΩ, See Figure 1 CL = 100 pF, VI = 20 mV, RL = 2 kΩ, CL = 100 pF, See Figure 1 MIN TYP 8∗ 13 0.05 f = 1 kHz Vn Equivalent input noise voltage RS = 20 Ω In Equivalent input noise current RS = 20 Ω, f = 1 kHz THD Total harmonic distortion VIrms = 6 V, f = 1 kHz AVD = 1, f = 10 Hz to 10 kHz RS ≤ 1 kΩ, RL ≥ 2 kΩ, UNIT V/µs 5∗ See Figure 1 MAX µs 20 % 18 nV/√Hz 4 µV 0.01 pA/√Hz 0.003 % ∗On products compliant to MIL-PRF-38535, this parameter is not production tested. POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 7 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 operating characteristics, VCC ± = ± 15 V, TA = 25°C TEST CONDITIONS PARAMETER SR Slew rate at unity gain tr Rise time VI = 10 V, RL = 2 kΩ, Overshoot factor VI = 20 mV, RL = 2 kΩ, Vn Equivalent input noise voltage RS = 20 Ω In Equivalent input noise current RS = 20 Ω, f = 1 kHz THD Total harmonic distortion VIrms = 6 V, f = 1 kHz AVD = 1, CL = 100 pF, CL = 100 pF, MIN TYP 8 13 See Figure 1 See Figure 1 f = 1 kHz f = 10 Hz to 10 kHz MAX UNIT V/ µs 0.05 µs 20 % 18 nV/√Hz µV 4 RS ≤ 1 kΩ, RL ≥ 2 kΩ, 0.01 pA/√Hz 0.003 % PARAMETER MEASUREMENT INFORMATION 10 kΩ − 1 kΩ VI + VI − OUT OUT CL = 100 pF RL = 2 kΩ + CL = 100 pF RL Figure 1 Figure 2 100 kΩ TL081 IN − − IN + + C2 OUT C1 500 pF N2 N1 − IN − 100 kΩ N1 OUT + 1.5 kΩ VCC − Figure 3 8 Figure 4 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS Table of Graphs FIGURE VOM AVD Maximum peak output voltage vs Frequency vs Free-air temperature vs Load resistance vs Supply voltage 5, 6, 7 8 9 10 Large-signal differential voltage amplification vs Free-air temperature vs Frequency 11 12 Differential voltage amplification vs Frequency with feed-forward compensation 13 PD Total power dissipation vs Free-air temperature 14 ICC Supply current vs Free-air temperature vs Supply voltage 15 16 IIB Input bias current vs Free-air temperature 17 Large-signal pulse response vs Time 18 VO CMRR Output voltage vs Elapsed time 19 Common-mode rejection ratio vs Free-air temperature 20 Vn THD Equivalent input noise voltage vs Frequency 21 Total harmonic distortion vs Frequency 22 MAXIMUM PEAK OUTPUT VOLTAGE vs FREQUENCY MAXIMUM PEAK OUTPUT VOLTAGE vs FREQUENCY ± 15 VCC ± = ± 15 V RL = 10 kΩ TA = 25°C See Figure 2 ± 12.5 ± 10 VCC ± = ± 10 V ± 7.5 ±5 VCC ± = ± 5 V ± 2.5 0 100 VOM − Maximum Peak Output Voltage − V VOM − Maximum Peak Output Voltage − V ± 15 RL = 2 kΩ TA = 25°C See Figure 2 VCC ± = ± 15 V ± 12.5 ± 10 VCC ± = ± 10 V ± 7.5 ±5 VCC ± = ± 5 V ± 2.5 0 1k 10 k 100 k 1M 10 M 100 f − Frequency − Hz 1k 10 k 100 k 1M 10 M f − Frequency − Hz Figure 5 Figure 6 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 9 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS† MAXIMUM PEAK OUTPUT VOLTAGE vs FREQUENCY MAXIMUM PEAK OUTPUT VOLTAGE vs FREE-AIR TEMPERATURE ± 12.5 RL = 10 kW TA = 25°C ± 10 TA = − 55°C ± 7.5 ±5 TA = 125°C ± 2.5 0 10 k ÎÎÎÎ ÎÎÎÎ ÎÎÎÎ ± 15 VCC ± = ± 15 V RL = 2 kΩ See Figure 2 VOM − Maximum Peak Output Voltage − V VOM − Maximum Peak Output Voltage − V ± 15 40 k 100 k 400 k 1M 4M ± 12.5 RL = 2 kW ± 10 ± 7.5 ±5 ± 2.5 VCC ± = ± 15 V See Figure 2 0 − 75 − 50 10 M − 25 75 100 VOM − Maximum Peak Output Voltage − V VCC ± = ± 15 V TA = 25°C See Figure 2 ± 10 ± 7.5 ±5 ± 2.5 RL = 10 kΩ TA = 25°C ± 12.5 ± 10 ± 7.5 ±5 ± 2.5 0 0.2 0.4 0.7 1 2 4 7 10 0 2 4 6 8 10 12 14 | VCC ± | − Supply Voltage − V RL − Load Resistance − kΩ Figure 10 Figure 9 † Data at high and low temperatures are applicable only within the rated operating free-air temperature ranges of the various devices. 10 125 ± 15 ± 15 VOM − Maximum Peak Output Voltage − V 50 MAXIMUM PEAK OUTPUT VOLTAGE vs SUPPLY VOLTAGE MAXIMUM PEAK OUTPUT VOLTAGE vs LOAD RESISTANCE 0 0.1 25 Figure 8 Figure 7 ± 12.5 0 TA − Free-Air Temperature − °C f − Frequency − Hz POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 16 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS† LARGE-SIGNAL DIFFERENTIAL VOLTAGE AMPLIFICATION vs FREE-AIR TEMPERATURE 1000 700 AVD − Large-Signal Differential Voltage Amplification − V/mV 400 200 100 70 40 20 10 7 4 VCC ± = ± 15 V VO = ± 10 V RL = 2 kΩ 2 1 −75 −50 −25 0 25 50 75 100 125 TA − Free-Air Temperature − °C Figure 11 LARGE-SIGNAL DIFFERENTIAL VOLTAGE AMPLIFICATION vs FREQUENCY 106 VCC ± = ± 5 V to ± 15 V RL = 10 kΩ TA = 25°C 104 Differential Voltage Amplification (left scale) 103 102 0° 45 ° Phase Shift AVD − Large-Signal Differential Voltage Amplification − V/mV 105 90 ° Phase Shift (right scale) 101 135 ° 1 1 10 100 1k 10 k 100 k 1M 180 ° 10 M f − Frequency − Hz Figure 12 † Data at high and low temperatures are applicable only within the rated operating free-air temperature ranges of the various devices. POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 11 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS† DIFFERENTIAL VOLTAGE AMPLIFICATION vs FREQUENCY WITH FEED-FORWARD COMPENSATION TOTAL POWER DISSIPATION vs FREE-AIR TEMPERATURE 250 VCC ± = ± 15 V C2 = 3 pF TA = 25°C See Figure 3 105 104 103 102 10 VCC ± = ± 15 V No Signal No Load 225 PD − Total Power Dissipation − mW AVD − Differential Voltage Amplification − V/mV 106 200 175 TL084, TL085 150 125 100 TL082, TL083 75 TL081 50 25 1 100 1k 10 k 100 k 1M 0 −75 10 M −50 −25 SUPPLY CURRENT PER AMPLIFIER vs FREE-AIR TEMPERATURE 50 75 100 125 SUPPLY CURRENT vs SUPPLY VOLTAGE 2.0 2.0 VCC ± = ± 15 V No Signal No Load 1.8 1.6 1.4 1.2 1.0 0.8 0.6 0.4 0.2 TA = 25°C No Signal No Load 1.8 I CC ± − Supply Current − mA I CC ± − Supply Current − mA 25 Figure 14 Figure 13 0 −75 0 TA − Free-Air Temperature − °C f − Frequency With Feed-Forward Compensation − Hz 1.6 1.4 1.2 1.0 0.8 0.6 0.4 0.2 −50 −25 0 25 50 75 100 125 0 0 2 TA − Free-Air Temperature − °C 4 6 8 10 12 14 | VCC ± | − Supply Voltage − V Figure 16 Figure 15 † Data at high and low temperatures are applicable only within the rated operating free-air temperature ranges of the various devices. 12 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 16 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS† INPUT BIAS CURRENT vs FREE-AIR TEMPERATURE VOLTAGE-FOLLOWER LARGE-SIGNAL PULSE RESPONSE 6 100 VCC ± = ± 15 V RL = 2 k Ω CL = 100 pF TA = 25°C Input and Output Voltages − V I IB − Input Bias Current − nA V CC ± = ± 15 V 10 1 0.1 4 Output 2 0 −2 Input −4 0.01 − 50 −6 − 25 0 25 50 75 100 125 0 0.5 TA − Free-Air Temperature − °C CMRR − Common-Mode Rejection Ratio − dB 89 VO − Output Voltage − mV 24 20 VCC ± = ± 15 V RL = 2 k Ω CL = 100 pF TA = 25°C See Figure 1 4 0 −4 0 0.2 0.4 2.5 3 3.5 COMMON-MODE REJECTION RATIO vs FREE-AIR TEMPERATURE 28 8 2 Figure 18 OUTPUT VOLTAGE vs ELAPSED TIME 12 1.5 t − Time − µ s Figure 17 16 1 0.6 0.8 1.0 1.2 VCC ± = ± 15 V RL = 10 kΩ 88 87 86 85 84 83 − 75 − 50 t − Elapsed Time − µ s − 25 0 25 50 75 100 125 TA − Free-Air Temperature − °C Figure 20 Figure 19 † Data at high and low temperatures are applicable only within the rated operating free-air temperature ranges of the various devices. POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 13 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 TYPICAL CHARACTERISTICS† EQUIVALENT INPUT NOISE VOLTAGE vs FREQUENCY TOTAL HARMONIC DISTORTION vs FREQUENCY 1 VCC ± = ± 15 V AVD = 10 RS = 20 Ω TA = 25°C 40 30 20 10 0.1 0.04 0.01 0.004 0.001 0 40 10 100 400 1 k 4 k 10 k VCC ± = ± 15 V AVD = 1 VI(RMS) = 6 V TA = 25°C 0.4 THD − Total Harmonic Distortion − % Vn − Equilvalent Input Noise Voltage − nV/ Hz 50 40 k 100 k 10 400 1k 4k 10 k 40 k 100 k f − Frequency − Hz f − Frequency − Hz Figure 22 Figure 21 † Data at high and low temperatures are applicable only within the rated operating free-air temperature ranges of the various devices. APPLICATION INFORMATION RF = 100 kΩ VCC + − Output − TL081 + CF = 3.3 µF Input R1 R2 C3 TL081 + 15 V 3.3 kΩ Output VCC − 1 kΩ −15 V R1 = R2 = 2(R3) = 1.5 MΩ R3 3.3 kΩ f= C1 9.1 kΩ 1 2π RF CF Figure 23 14 C2 C1 = C2 = C3 = 110 pF 2 1 = 1 kHz fo = 2π R1 C1 Figure 24 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 APPLICATION INFORMATION VCC + 1 MΩ − TL084 VCC + Output A + + 1 µF TL084 VCC + − Input − TL084 100 kΩ 100 kΩ 100 µF Output B + 100 kΩ VCC + VCC + 100 kΩ − TL084 Output C + Figure 25. Audio-Distribution Amplifier 6 sin ωt 1N4148 − 15 V 18 pF 18 pF 1 kΩ 18 kΩ (see Note A) VCC + − 1/2 TL082 + 88.4 kΩ VCC+ − 88.4 kΩ 1/2 TL082 VCC − 6 cos ωt + 18 pF VCC − 1 kΩ 15 V 1N4148 88.4 kΩ 18 kΩ (see Note A) NOTE A: These resistor values may be adjusted for a symmetrical output. Figure 26. 100-KHz Quadrature Oscillator POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 15 SLOS081G − FEBRUARY 1977 − REVISED SEPTEMBER 2004 APPLICATION INFORMATION 16 kΩ 16 kΩ 220 pF 220 pF VCC + 43 kΩ 43 kΩ 1/4 TL084 VCC + VCC + 43 kΩ 1/4 TL084 1/4 TL084 + + + 1.5 kΩ + − 1/4 TL084 220 pF VCC + − Input 220 pF 30 kΩ − 43 kΩ 43 kΩ 30 kΩ 1.5 kΩ VCC − − 43 kΩ VCC − VCC − VCC − Output A Output A Output B 2 kHz/div Second-Order Bandpass Filter fo = 100 kHz, Q = 30, GAIN = 4 2 kHz/div Cascaded Bandpass Filter fo = 100 kHz, Q = 69, GAIN = 16 Figure 27. Positive-Feedback Bandpass Filter 16 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 Output B PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 PACKAGING INFORMATION Orderable Device Status (1) Package Type Package Drawing 5962-9851501Q2A ACTIVE LCCC FK 5962-9851501QPA ACTIVE CDIP 5962-9851503Q2A ACTIVE LCCC 5962-9851503QCA ACTIVE TL081ACD ACTIVE TL081ACDE4 ACTIVE TL081ACDG4 Pins Package Eco Plan (2) Qty Lead/Ball Finish MSL Peak Temp (3) 20 1 TBD JG 8 1 TBD FK 20 1 TBD CDIP J 14 1 TBD A42 SNPB SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081ACDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081ACDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081ACDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081ACJG OBSOLETE CDIP JG 8 TBD Call TI TL081ACP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081ACPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081BCD ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081BCP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081BCPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081CD ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Addendum-Page 1 POST-PLATE N / A for Pkg Type A42 SNPB N / A for Pkg Type POST-PLATE N / A for Pkg Type N / A for Pkg Type Call TI PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 Orderable Device Status (1) Package Type Package Drawing Pins Package Eco Plan (2) Qty TL081CP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081CPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081CPSR ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CPSRE4 ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CPSRG4 ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081CPWLE OBSOLETE TSSOP PW 8 TBD Call TI TL081ID ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL081IP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081IPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL081MFKB OBSOLETE LCCC FK 20 TBD Call TI Call TI TL081MJG OBSOLETE CDIP JG 8 TBD Call TI Call TI TL081MJGB OBSOLETE CDIP JG 8 TBD Call TI Call TI TL082ACD ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082ACPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082ACPSR ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACPSRE4 ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082ACPSRG4 ACTIVE SO PS 8 2000 Green (RoHS & CU NIPDAU Level-1-260C-UNLIM Addendum-Page 2 Lead/Ball Finish MSL Peak Temp (3) Call TI PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 Orderable Device Status (1) Package Type Package Drawing Pins Package Eco Plan (2) Qty TL082BCD ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082BCP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082BCPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082CD ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CJG OBSOLETE CDIP JG 8 TBD Call TI TL082CP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082CPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082CPSR ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPSRG4 ACTIVE SO PS 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPW ACTIVE TSSOP PW 8 150 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPWE4 ACTIVE TSSOP PW 8 150 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPWG4 ACTIVE TSSOP PW 8 150 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPWLE OBSOLETE TSSOP PW 8 TL082CPWR ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPWRE4 ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082CPWRG4 ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Lead/Ball Finish MSL Peak Temp (3) no Sb/Br) TBD Addendum-Page 3 Call TI Call TI Call TI PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 Orderable Device Status (1) Package Type Package Drawing Pins Package Eco Plan (2) Qty TL082ID ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IDE4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IDG4 ACTIVE SOIC D 8 75 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IDR ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IDRE4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IDRG4 ACTIVE SOIC D 8 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IJG OBSOLETE CDIP JG 8 TBD Call TI TL082IP ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082IPE4 ACTIVE PDIP P 8 50 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL082IPWR ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IPWRE4 ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082IPWRG4 ACTIVE TSSOP PW 8 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL082MFK OBSOLETE LCCC FK 20 TL082MFKB ACTIVE LCCC FK 20 1 TBD TBD TL082MJG ACTIVE CDIP JG 8 1 TBD TL082MJGB ACTIVE CDIP JG 8 1 TL084ACD ACTIVE SOIC D 14 50 TL084ACDE4 ACTIVE SOIC D 14 50 TL084ACDG4 ACTIVE SOIC D 14 50 TL084ACDR ACTIVE SOIC D TL084ACDRE4 ACTIVE SOIC TL084ACDRG4 ACTIVE TL084ACN Lead/Ball Finish Call TI MSL Peak Temp (3) Call TI Call TI POST-PLATE N / A for Pkg Type A42 SNPB N / A for Pkg Type TBD A42 SNPB N / A for Pkg Type Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084ACNE4 ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084ACNSR ACTIVE SO NS 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084ACNSRE4 ACTIVE SO NS 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084ACNSRG4 ACTIVE SO NS 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCD ACTIVE SOIC D 14 CU NIPDAU Level-1-260C-UNLIM 50 Addendum-Page 4 Green (RoHS & no Sb/Br) PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 Orderable Device Status (1) Package Type Package Drawing Pins Package Eco Plan (2) Qty TL084BCDE4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCDG4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCDR ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCDRE4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCDRG4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084BCN ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084BCNE4 ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084CD ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CDE4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CDG4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CDR ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CDRE4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CDRG4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Lead/Ball Finish MSL Peak Temp (3) TL084CJ OBSOLETE CDIP J 14 TBD Call TI TL084CN ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084CNE4 ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084CNSLE OBSOLETE SO NS 14 TL084CNSR ACTIVE SO NS 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CNSRG4 ACTIVE SO NS 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPW ACTIVE TSSOP PW 14 90 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPWE4 ACTIVE TSSOP PW 14 90 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPWG4 ACTIVE TSSOP PW 14 90 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPWLE OBSOLETE TSSOP PW 14 TL084CPWR ACTIVE TSSOP PW 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPWRE4 ACTIVE TSSOP PW 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084CPWRG4 ACTIVE TSSOP PW 14 2000 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084ID ACTIVE SOIC D 14 CU NIPDAU Level-1-260C-UNLIM TBD TBD 50 Addendum-Page 5 Green (RoHS & no Sb/Br) Call TI Call TI Call TI Call TI Call TI PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 Orderable Device Status (1) Package Type Package Drawing Pins Package Eco Plan (2) Qty TL084IDE4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084IDG4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084IDR ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084IDRE4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084IDRG4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM Lead/Ball Finish MSL Peak Temp (3) TL084IJ OBSOLETE CDIP J 14 TBD Call TI TL084IN ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU Call TI N / A for Pkg Type TL084INE4 ACTIVE PDIP N 14 25 Pb-Free (RoHS) CU NIPDAU N / A for Pkg Type TL084MFK ACTIVE LCCC FK 20 1 TBD POST-PLATE N / A for Pkg Type TL084MFKB ACTIVE LCCC FK 20 1 TBD POST-PLATE N / A for Pkg Type TL084MJ ACTIVE CDIP J 14 1 TBD A42 SNPB N / A for Pkg Type TL084MJB ACTIVE CDIP J 14 1 TBD A42 SNPB N / A for Pkg Type TL084QD ACTIVE SOIC D 14 50 TBD CU NIPDAU Level-1-220C-UNLIM TL084QDG4 ACTIVE SOIC D 14 50 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM TL084QDR ACTIVE SOIC D 14 2500 TBD CU NIPDAU Level-1-220C-UNLIM TL084QDRG4 ACTIVE SOIC D 14 2500 Green (RoHS & no Sb/Br) CU NIPDAU Level-1-260C-UNLIM (1) The marketing status values are defined as follows: ACTIVE: Product device recommended for new designs. LIFEBUY: TI has announced that the device will be discontinued, and a lifetime-buy period is in effect. NRND: Not recommended for new designs. Device is in production to support existing customers, but TI does not recommend using this part in a new design. PREVIEW: Device has been announced but is not in production. Samples may or may not be available. OBSOLETE: TI has discontinued the production of the device. (2) Eco Plan - The planned eco-friendly classification: Pb-Free (RoHS), Pb-Free (RoHS Exempt), or Green (RoHS & no Sb/Br) - please check http://www.ti.com/productcontent for the latest availability information and additional product content details. TBD: The Pb-Free/Green conversion plan has not been defined. Pb-Free (RoHS): TI's terms "Lead-Free" or "Pb-Free" mean semiconductor products that are compatible with the current RoHS requirements for all 6 substances, including the requirement that lead not exceed 0.1% by weight in homogeneous materials. Where designed to be soldered at high temperatures, TI Pb-Free products are suitable for use in specified lead-free processes. Pb-Free (RoHS Exempt): This component has a RoHS exemption for either 1) lead-based flip-chip solder bumps used between the die and package, or 2) lead-based die adhesive used between the die and leadframe. The component is otherwise considered Pb-Free (RoHS compatible) as defined above. Green (RoHS & no Sb/Br): TI defines "Green" to mean Pb-Free (RoHS compatible), and free of Bromine (Br) and Antimony (Sb) based flame retardants (Br or Sb do not exceed 0.1% by weight in homogeneous material) (3) MSL, Peak Temp. -- The Moisture Sensitivity Level rating according to the JEDEC industry standard classifications, and peak solder temperature. Important Information and Disclaimer:The information provided on this page represents TI's knowledge and belief as of the date that it is provided. TI bases its knowledge and belief on information provided by third parties, and makes no representation or warranty as to the accuracy of such information. Efforts are underway to better integrate information from third parties. TI has taken and continues to take reasonable steps to provide representative and accurate information but may not have conducted destructive testing or chemical analysis on incoming materials and chemicals. TI and TI suppliers consider certain information to be proprietary, and thus CAS numbers and other limited information may not be available for release. Addendum-Page 6 PACKAGE OPTION ADDENDUM www.ti.com 11-Feb-2008 In no event shall TI's liability arising out of such information exceed the total purchase price of the TI part(s) at issue in this document sold by TI to Customer on an annual basis. Addendum-Page 7 PACKAGE MATERIALS INFORMATION www.ti.com 19-Mar-2008 TAPE AND REEL INFORMATION *All dimensions are nominal Device Package Package Pins Type Drawing SPQ Reel Reel Diameter Width (mm) W1 (mm) A0 (mm) B0 (mm) K0 (mm) P1 (mm) W Pin1 (mm) Quadrant TL081ACDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL081BCDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL081CDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL081CPSR SO PS 8 2000 330.0 16.4 8.2 6.6 2.5 12.0 16.0 Q1 TL081IDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082ACDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082ACDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082ACPSR SO PS 8 2000 330.0 16.4 8.2 6.6 2.5 12.0 16.0 Q1 TL082BCDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082CDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082CDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082CPSR SO PS 8 2000 330.0 16.4 8.2 6.6 2.5 12.0 16.0 Q1 TL082CPWR TSSOP PW 8 2000 330.0 12.4 7.0 3.6 1.6 8.0 12.0 Q1 TL082IDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082IDR SOIC D 8 2500 330.0 12.4 6.4 5.2 2.1 8.0 12.0 Q1 TL082IPWR TSSOP PW 8 2000 330.0 12.4 7.0 3.6 1.6 8.0 12.0 Q1 TL084ACDR SOIC D 14 2500 330.0 16.4 6.5 9.0 2.1 8.0 16.0 Q1 TL084ACDR SOIC D 14 2500 330.0 16.4 6.5 9.0 2.1 8.0 16.0 Q1 Pack Materials-Page 1 PACKAGE MATERIALS INFORMATION www.ti.com Device 19-Mar-2008 Package Package Pins Type Drawing SPQ Reel Reel Diameter Width (mm) W1 (mm) A0 (mm) B0 (mm) K0 (mm) P1 (mm) W Pin1 (mm) Quadrant TL084ACNSR SO NS 14 2000 330.0 16.4 8.2 10.5 2.5 12.0 16.0 Q1 TL084BCDR SOIC D 14 2500 330.0 16.4 6.5 9.0 2.1 8.0 16.0 Q1 TL084CDR SOIC D 14 2500 330.0 16.4 6.5 9.0 2.1 8.0 16.0 Q1 TL084CNSR SO NS 14 2000 330.0 16.4 8.2 10.5 2.5 12.0 16.0 Q1 TL084CPWR TSSOP PW 14 2000 330.0 12.4 7.0 5.6 1.6 8.0 12.0 Q1 TL084IDR SOIC D 14 2500 330.0 16.4 6.5 9.0 2.1 8.0 16.0 Q1 *All dimensions are nominal Device Package Type Package Drawing Pins SPQ Length (mm) Width (mm) Height (mm) TL081ACDR SOIC D 8 2500 340.5 338.1 20.6 TL081BCDR SOIC D 8 2500 340.5 338.1 20.6 TL081CDR SOIC D 8 2500 340.5 338.1 20.6 TL081CPSR SO PS 8 2000 346.0 346.0 33.0 TL081IDR SOIC D 8 2500 340.5 338.1 20.6 TL082ACDR SOIC D 8 2500 340.5 338.1 20.6 TL082ACDR SOIC D 8 2500 346.0 346.0 29.0 TL082ACPSR SO PS 8 2000 346.0 346.0 33.0 TL082BCDR SOIC D 8 2500 340.5 338.1 20.6 TL082CDR SOIC D 8 2500 346.0 346.0 29.0 TL082CDR SOIC D 8 2500 340.5 338.1 20.6 Pack Materials-Page 2 PACKAGE MATERIALS INFORMATION www.ti.com Device 19-Mar-2008 Package Type Package Drawing Pins SPQ Length (mm) Width (mm) Height (mm) TL082CPSR SO PS 8 2000 346.0 346.0 33.0 TL082CPWR TSSOP PW 8 2000 346.0 346.0 29.0 TL082IDR SOIC D 8 2500 346.0 346.0 29.0 TL082IDR SOIC D 8 2500 340.5 338.1 20.6 TL082IPWR TSSOP PW 8 2000 346.0 346.0 29.0 TL084ACDR SOIC D 14 2500 346.0 346.0 33.0 TL084ACDR SOIC D 14 2500 333.2 345.9 28.6 TL084ACNSR SO NS 14 2000 346.0 346.0 33.0 TL084BCDR SOIC D 14 2500 333.2 345.9 28.6 TL084CDR SOIC D 14 2500 333.2 345.9 28.6 TL084CNSR SO NS 14 2000 346.0 346.0 33.0 TL084CPWR TSSOP PW 14 2000 346.0 346.0 29.0 TL084IDR SOIC D 14 2500 333.2 345.9 28.6 Pack Materials-Page 3 MECHANICAL DATA MTSS001C – JANUARY 1995 – REVISED FEBRUARY 1999 PW (R-PDSO-G**) PLASTIC SMALL-OUTLINE PACKAGE 14 PINS SHOWN 0,30 0,19 0,65 14 0,10 M 8 0,15 NOM 4,50 4,30 6,60 6,20 Gage Plane 0,25 1 7 0°– 8° A 0,75 0,50 Seating Plane 0,15 0,05 1,20 MAX PINS ** 0,10 8 14 16 20 24 28 A MAX 3,10 5,10 5,10 6,60 7,90 9,80 A MIN 2,90 4,90 4,90 6,40 7,70 9,60 DIM 4040064/F 01/97 NOTES: A. B. C. D. All linear dimensions are in millimeters. This drawing is subject to change without notice. Body dimensions do not include mold flash or protrusion not to exceed 0,15. Falls within JEDEC MO-153 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 MECHANICAL DATA MLCC006B – OCTOBER 1996 FK (S-CQCC-N**) LEADLESS CERAMIC CHIP CARRIER 28 TERMINAL SHOWN 18 17 16 15 14 13 NO. OF TERMINALS ** 12 19 11 20 10 B A MIN MAX MIN MAX 20 0.342 (8,69) 0.358 (9,09) 0.307 (7,80) 0.358 (9,09) 28 0.442 (11,23) 0.458 (11,63) 0.406 (10,31) 0.458 (11,63) 21 9 22 8 44 0.640 (16,26) 0.660 (16,76) 0.495 (12,58) 0.560 (14,22) 23 7 52 0.739 (18,78) 0.761 (19,32) 0.495 (12,58) 0.560 (14,22) 24 6 68 25 5 0.938 (23,83) 0.962 (24,43) 0.850 (21,6) 0.858 (21,8) 84 1.141 (28,99) 1.165 (29,59) 1.047 (26,6) 1.063 (27,0) B SQ A SQ 26 27 28 1 2 3 4 0.080 (2,03) 0.064 (1,63) 0.020 (0,51) 0.010 (0,25) 0.020 (0,51) 0.010 (0,25) 0.055 (1,40) 0.045 (1,14) 0.045 (1,14) 0.035 (0,89) 0.045 (1,14) 0.035 (0,89) 0.028 (0,71) 0.022 (0,54) 0.050 (1,27) 4040140 / D 10/96 NOTES: A. B. C. D. E. All linear dimensions are in inches (millimeters). This drawing is subject to change without notice. This package can be hermetically sealed with a metal lid. The terminals are gold plated. Falls within JEDEC MS-004 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 MECHANICAL DATA MPDI001A – JANUARY 1995 – REVISED JUNE 1999 P (R-PDIP-T8) PLASTIC DUAL-IN-LINE 0.400 (10,60) 0.355 (9,02) 8 5 0.260 (6,60) 0.240 (6,10) 1 4 0.070 (1,78) MAX 0.325 (8,26) 0.300 (7,62) 0.020 (0,51) MIN 0.015 (0,38) Gage Plane 0.200 (5,08) MAX Seating Plane 0.010 (0,25) NOM 0.125 (3,18) MIN 0.100 (2,54) 0.021 (0,53) 0.015 (0,38) 0.430 (10,92) MAX 0.010 (0,25) M 4040082/D 05/98 NOTES: A. All linear dimensions are in inches (millimeters). B. This drawing is subject to change without notice. C. Falls within JEDEC MS-001 For the latest package information, go to http://www.ti.com/sc/docs/package/pkg_info.htm POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 MECHANICAL DATA MCER001A – JANUARY 1995 – REVISED JANUARY 1997 JG (R-GDIP-T8) CERAMIC DUAL-IN-LINE 0.400 (10,16) 0.355 (9,00) 8 5 0.280 (7,11) 0.245 (6,22) 1 0.063 (1,60) 0.015 (0,38) 4 0.065 (1,65) 0.045 (1,14) 0.310 (7,87) 0.290 (7,37) 0.020 (0,51) MIN 0.200 (5,08) MAX Seating Plane 0.130 (3,30) MIN 0.023 (0,58) 0.015 (0,38) 0°–15° 0.100 (2,54) 0.014 (0,36) 0.008 (0,20) 4040107/C 08/96 NOTES: A. B. C. D. E. All linear dimensions are in inches (millimeters). This drawing is subject to change without notice. This package can be hermetically sealed with a ceramic lid using glass frit. Index point is provided on cap for terminal identification. Falls within MIL STD 1835 GDIP1-T8 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265 IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by government requirements, testing of all parameters of each product is not necessarily performed. TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and applications using TI components. To minimize the risks associated with customer products and applications, customers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional restrictions. Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements. TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in such safety-critical applications. TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use. TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated products in automotive applications, TI will not be responsible for any failure to meet such requirements. Following are URLs where you can obtain information on other Texas Instruments products and application solutions: Products Amplifiers Data Converters DSP Clocks and Timers Interface Logic Power Mgmt Microcontrollers RFID RF/IF and ZigBee® Solutions amplifier.ti.com dataconverter.ti.com dsp.ti.com www.ti.com/clocks interface.ti.com logic.ti.com power.ti.com microcontroller.ti.com www.ti-rfid.com www.ti.com/lprf Applications Audio Automotive Broadband Digital Control Medical Military Optical Networking Security Telephony Video & Imaging Wireless www.ti.com/audio www.ti.com/automotive www.ti.com/broadband www.ti.com/digitalcontrol www.ti.com/medical www.ti.com/military www.ti.com/opticalnetwork www.ti.com/security www.ti.com/telephony www.ti.com/video www.ti.com/wireless Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2008, Texas Instruments Incorporated ANEXO 4 LM78XX Series Voltage Regulators General Description The LM78XX series of three terminal regulators is available with several fixed output voltages making them useful in a wide range of applications. One of these is local on card regulation, eliminating the distribution problems associated with single point regulation. The voltages available allow these regulators to be used in logic systems, instrumentation, HiFi, and other solid state electronic equipment. Although designed primarily as fixed voltage regulators these devices can be used with external components to obtain adjustable voltages and currents. The LM78XX series is available in an aluminum TO-3 package which will allow over 1.0A load current if adequate heat sinking is provided. Current limiting is included to limit the peak output current to a safe value. Safe area protection for the output transistor is provided to limit internal power dissipation. If internal power dissipation becomes too high for the heat sinking provided, the thermal shutdown circuit takes over preventing the IC from overheating. Considerable effort was expanded to make the LM78XX series of regulators easy to use and minimize the number of external components. It is not necessary to bypass the out- put, although this does improve transient response. Input bypassing is needed only if the regulator is located far from the filter capacitor of the power supply. For output voltage other than 5V, 12V and 15V the LM117 series provides an output voltage range from 1.2V to 57V. Features n n n n n n Output current in excess of 1A Internal thermal overload protection No external components required Output transistor safe area protection Internal short circuit current limit Available in the aluminum TO-3 package Voltage Range LM7805C 5V LM7812C 12V LM7815C 15V Connection Diagrams Metal Can Package TO-3 (K) Aluminum Plastic Package TO-220 (T) DS007746-3 DS007746-2 Bottom View Order Number LM7805CK, LM7812CK or LM7815CK See NS Package Number KC02A © 2000 National Semiconductor Corporation DS007746 Top View Order Number LM7805CT, LM7812CT or LM7815CT See NS Package Number T03B www.national.com LM78XX Series Voltage Regulators May 2000 LM78XX Schematic DS007746-1 www.national.com 2 Maximum Junction Temperature (K Package) (T Package) Storage Temperature Range Lead Temperature (Soldering, 10 sec.) TO-3 Package K TO-220 Package T If Military/Aerospace specified devices are required, please contact the National Semiconductor Sales Office/ Distributors for availability and specifications. Input Voltage (VO = 5V, 12V and 15V) Internal Power Dissipation (Note 1) Operating Temperature Range (TA) 35V Internally Limited 0˚C to +70˚C Electrical Characteristics LM78XXC 150˚C 150˚C −65˚C to +150˚C 300˚C 230˚C (Note 2) 0˚C ≤ TJ ≤ 125˚C unless otherwise noted. Symbol VO Output Voltage 5V 12V Input Voltage (unless otherwise noted) 10V 19V Parameter Output Voltage Conditions Min Tj = 25˚C, 5 mA ≤ IO ≤ 1A 4.8 PD ≤ 15W, 5 mA ≤ IO ≤ 1A 4.75 VMIN ≤ VIN ≤ VMAX ∆VO Line Regulation IO = 500 mA 5 4 4 mV Tj = 25˚C IO ≤ 1A V mV V 60 75 (20 ≤ VIN ≤ 26) V 10 12 12 5 mA ≤ IO ≤ 1.5A Tj = 25˚C 50 120 150 mV 60 75 mV 50 120 150 mV mA 8 8 8 8.5 8.5 8.5 mA 0.5 0.5 0.5 mA 1.0 mA Tj = 25˚C, IO ≤ 1A 1.0 1.0 VMIN ≤ VIN ≤ VMAX (7.5 ≤ VIN ≤ 20) (14.8 ≤ VIN≤ 27) IO ≤ 500 mA, 0˚C ≤ Tj ≤ +125˚C mV 25 Change 1.0 (17.9 ≤ VIN ≤ 30) 1.0 1.0 V mA (7 ≤ VIN ≤ 25) (14.5 ≤ VIN≤ 30) (17.5 ≤ VIN ≤ 30) V 40 75 90 µV 70 dB TA =25˚C, 10 Hz ≤ f ≤ 100 kHz f = 120 Hz mV (16 ≤ VIN ≤ 22) 5 mA ≤ IO ≤ 1A Ripple Rejection 150 (17.7 ≤ VIN ≤ 30) V (8 ≤ VIN ≤ 12) Quiescent Current Output Noise Voltage 150 (18.5 ≤ VIN ≤ 30) 120 (14.6 ≤ VIN ≤ 27) 150 (17.5 ≤ VIN ≤ 30) 120 (15 ≤ VIN ≤ 27) 25 VMIN ≤ VIN ≤ VMAX VN 120 14.5 ≤ VIN ≤ 30) 50 0˚C ≤ Tj ≤ +125˚C ∆IQ 50 (7.5 ≤ VIN ≤ 20) 5 mA ≤ IO ≤ 1A, 0˚C ≤ Tj ≤ +125˚C Quiescent Current V V 3 250 mA ≤ IO ≤ 750 mA IQ 15.6 15.75 V 0˚C ≤ Tj ≤ +125˚C Tj = 25˚C 15 12.6 14.25 50 ∆VIN 12.5 14.4 Units Typ Max (17.5 ≤ VIN ≤ 30) (8 ≤ VIN ≤ 20) ∆VIN Load Regulation 12 Min (14.5 ≤ VIN ≤ 27) (7 ≤ VIN ≤ 25) ∆VIN ∆VO 11.5 23V Typ Max 5.25 11.4 0˚C ≤ Tj ≤ +125˚C IO ≤ 1A 5.2 Min (7.5 ≤ VIN ≤ 20) Tj = 25˚C ∆VIN Typ Max 15V IO ≤ 1A, Tj = 25˚C or 62 IO ≤ 500 mA 62 80 55 72 55 54 54 dB 0˚C ≤ Tj ≤ +125˚C VMIN ≤ VIN ≤ VMAX RO Dropout Voltage Tj = 25˚C, IOUT = 1A Output Resistance f = 1 kHz 3 (8 ≤ VIN ≤ 18) (15 ≤ VIN ≤ 25) (18.5 ≤ VIN ≤ 28.5) V 2.0 2.0 2.0 V 8 18 19 mΩ www.national.com LM78XX Absolute Maximum Ratings (Note 3) LM78XX Electrical Characteristics LM78XXC (Note 2) (Continued) 0˚C ≤ TJ ≤ 125˚C unless otherwise noted. Output Voltage 5V Input Voltage (unless otherwise noted) Symbol VIN Parameter 12V 10V Conditions Min Typ Max 15V 19V Min Typ Max 23V Min Units Typ Max Short-Circuit Current Tj = 25˚C 2.1 1.5 1.2 A Peak Output Current Tj = 25˚C 2.4 2.4 2.4 A Average TC of VOUT 0˚C ≤ Tj ≤ +125˚C, IO = 5 mA 0.6 1.5 1.8 mV/˚C Tj = 25˚C, IO ≤ 1A 7.5 Input Voltage Required to Maintain 14.6 17.7 V Line Regulation Note 1: Thermal resistance of the TO-3 package (K, KC) is typically 4˚C/W junction to case and 35˚C/W case to ambient. Thermal resistance of the TO-220 package (T) is typically 4˚C/W junction to case and 50˚C/W case to ambient. Note 2: All characteristics are measured with capacitor across the input of 0.22 µF, and a capacitor across the output of 0.1µF. All characteristics except noise voltage and ripple rejection ratio are measured using pulse techniques (tw ≤ 10 ms, duty cycle ≤ 5%). Output voltage changes due to changes in internal temperature must be taken into account separately. Note 3: Absolute Maximum Ratings indicate limits beyond which damage to the device may occur. For guaranteed specifications and the test conditions, see Electrical Characteristics. www.national.com 4 LM78XX Typical Performance Characteristics Maximum Average Power Dissipation Maximum Average Power Dissipation DS007746-5 Peak Output Current DS007746-6 Output Voltage (Normalized to 1V at TJ = 25˚C) DS007746-7 Ripple Rejection DS007746-8 Ripple Rejection DS007746-10 DS007746-9 5 www.national.com LM78XX Typical Performance Characteristics (Continued) Output Impedance Dropout Voltage DS007746-11 Dropout Characteristics DS007746-12 Quiescent Current DS007746-14 DS007746-13 Quiescent Current DS007746-15 www.national.com 6 LM78XX Physical Dimensions inches (millimeters) unless otherwise noted Aluminum Metal Can Package (KC) Order Number LM7805CK, LM7812CK or LM7815CK NS Package Number KC02A 7 www.national.com LM78XX Series Voltage Regulators Physical Dimensions inches (millimeters) unless otherwise noted (Continued) TO-220 Package (T) Order Number LM7805CT, LM7812CT or LM7815CT NS Package Number T03B LIFE SUPPORT POLICY NATIONAL’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF NATIONAL SEMICONDUCTOR CORPORATION. As used herein: 1. Life support devices or systems are devices or systems which, (a) are intended for surgical implant into the body, or (b) support or sustain life, and whose failure to perform when properly used in accordance with instructions for use provided in the labeling, can be reasonably expected to result in a significant injury to the user. National Semiconductor Corporation Americas Tel: 1-800-272-9959 Fax: 1-800-737-7018 Email: support@nsc.com www.national.com National Semiconductor Europe Fax: +49 (0) 180-530 85 86 Email: europe.support@nsc.com Deutsch Tel: +49 (0) 69 9508 6208 English Tel: +44 (0) 870 24 0 2171 Français Tel: +33 (0) 1 41 91 8790 2. A critical component is any component of a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system, or to affect its safety or effectiveness. National Semiconductor Asia Pacific Customer Response Group Tel: 65-2544466 Fax: 65-2504466 Email: ap.support@nsc.com National Semiconductor Japan Ltd. Tel: 81-3-5639-7560 Fax: 81-3-5639-7507 National does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and National reserves the right at any time without notice to change said circuitry and specifications. This datasheet has been downloaded from: www.DatasheetCatalog.com Datasheets for electronic components. ANEXO 5 LM79XX Series 3-Terminal Negative Regulators General Description The LM79XX series of 3-terminal regulators is available with fixed output voltages of b5V, b8V, b12V, and b15V. These devices need only one external componentÐa compensation capacitor at the output. The LM79XX series is packaged in the TO-220 power package and is capable of supplying 1.5A of output current. These regulators employ internal current limiting safe area protection and thermal shutdown for protection against virtually all overload conditions. Low ground pin current of the LM79XX series allows output voltage to be easily boosted above the preset value with a resistor divider. The low quiescent current drain of these devices with a specified maximum change with line and load ensures good regulation in the voltage boosted mode. For applications requiring other voltages, see LM137 data sheet. Features Y Y Y Y Thermal, short circuit and safe area protection High ripple rejection 1.5A output current 4% tolerance on preset output voltage Typical Applications Connection Diagrams TO-220 Package Fixed Regulator Front View *Required if regulator is separated from filter capacitor by more than 3× . For value given, capacitor must be solid tantalum. 25 mF aluminum electrolytic may be substituted. TL/H/7340– 3 TL/H/7340–14 Order Number LM7905CT, LM7912CT or LM7915CT See NS Package Number TO3B C1995 National Semiconductor Corporation TL/H/7340 ² Required for stability. For value given, capacitor must be solid tantalum. 25 mF aluminum electrolytic may be substituted. Values given may be increased without limit. For output capacitance in excess of 100 mF, a high current diode from input to output (1N4001, etc.) will protect the regulator from momentary input shorts. RRD-B30M115/Printed in U. S. A. LM79XX Series 3-Terminal Negative Regulators November 1994 Absolute Maximum Ratings (Note 1) If Military/Aerospace specified devices are required, please contact the National Semiconductor Sales Office/Distributors for availability and specifications. Input Voltage b 25V (Vo e b5V) b 35V (Vo e b12V and b15V) Input-Output Differential (Vo e b5V) (Vo e b12V and b15V) 25V 30V Power Dissipation (Note 2) Operating Junction Temperature Range Storage Temperature Range Lead Temperature (Soldering, 10 sec.) Internally Limited 0§ C to a 125§ C b 65§ C to a 150§ C 230§ C Electrical Characteristics Conditions unless otherwise noted: IOUT e 500 mA, CIN e 2.2 mF, COUT e 1 mF, 0§ C s TJ s a 125§ C, Power Dissipation s 1.5W. Part Number b 5V Input Voltage (unless otherwise specified) b 10V Symbol Parameter VO DVO Conditions Output Voltage TJ e 25§ C 5 mA s IOUT s 1A, P s 15W Line Regulation TJ e 25§ C, (Note 3) Load Regulation DVO LM7905C Output Voltage Min Typ Max b 4.8 b 4.75 b 5.0 b 5.2 b 5.25 V V V 50 mV V mV V (b20 s VIN s b7) 8 (b25 s VIN s b7) 2 (b12 s VIN s b8) TJ e 25§ C, (Note 3) 5 mA s IOUT s 1.5A 250 mA s IOUT s 750 mA 15 5 1 IQ Quiescent Current TJ e 25§ C DIQ Quiescent Current Change With Line IOMAX mV mV 2 mA 0.5 mA V mA 0.5 TA e 25§ C, 10 Hz s f s 100 Hz Ripple Rejection f e 120 Hz Dropout Voltage TJ e 25§ C, IOUT e 1A 1.1 V Peak Output Current TJ e 25§ C 2.2 A Average Temperature Coefficient of Output Voltage IOUT e 5 mA, 0 C s TJ s 100§ C 0.4 mV/§ C 54 125 mV 66 (b18 s VIN s b8) dB V Variable Output TL/H/7340– 2 *Improves transient response and ripple rejection. Do not increase beyond 50 mF. Select R2 as LM7905CT LM7912CT LM7915CT 100 50 Output Noise Voltage Typical Applications (Continued) # R1 a R2 R2 follows: 300X 750X 1k VOUT e VSET 15 (b25 s VIN s b7) With Load, 5 mA s IOUT s 1A Vn Units J 2 Electrical Characteristics (Continued) Conditions unless otherwise noted: IOUT e 500 mA, CIN e 2.2 mF, COUT e 1 mF, 0§ C s TJ s a 125§ C, Power Dissipation e 1.5W. Symbol Part Number LM7912C LM7915C Output Voltage b 12V b 15V Input Voltage (unless otherwise specified) b 19V b 23V Parameter Conditions Min Typ Max Min Typ Units Max VO Output Voltage TJ e 25§ C 5 mA s IOUT s 1A, P s 15W b 11.5 b 12.0 b 12.5 b 11.4 b 12.6 (b27 s VIN s b14.5) b 14.4 b 15.0 b 15.6 b 14.25 b 15.75 (b30 s VIN s b17.5) V V V DVO Line Regulation TJ e 25§ C, (Note 3) 5 80 (b30 s VIN s b14.5) 3 30 (b22 s VIN s b16) 5 100 (b30 s VINs b17.5) 3 50 (b26 s VIN s b20) mV V mV V DVO Load Regulation TJ e 25§ C, (Note 3) 5 mA s IOUT s 1.5A 250 mA s IOUT s 750 mA 15 5 200 75 15 5 200 75 mV mV 3 1.5 3 mA IQ Quiescent Current TJ e 25§ C 1.5 DIQ Quiescent Current Change With Line 0.5 (b30 s VIN s b14.5) 0.5 With Load, 5 mA s IOUT s 1A Vn IOMAX Output Noise Voltage TA e 25§ C, 10 Hz s f s 100 Hz Ripple Rejection f e 120 Hz Dropout Voltage Peak Output Current Average Temperature Coefficient of Output Voltage IOUT e 5 mA, 0 C s TJ s 100§ C 0.5 (b30 sVIN s b17.5) 0.5 mA V mA 300 375 mV 54 70 (b25 s VIN s b15) 54 70 (b30 s VINs b17.5) dB V TJ e 25§ C, IOUT e 1A 1.1 1.1 V TJ e 25§ C 2.2 2.2 A b 0.8 b 1.0 mV/§ C Note 1: Absolute Maximum Ratings indicate limits beyond which damage to the device may occur. Operating Ratings indicate conditions for which the device is intended to be functional, but do not guarantee Specific Performance limits. For guaranteed specifications and test conditions, see the Electrical Characteristics. Note 2: Refer to Typical Performance Characteristics and Design Considerations for details. Note 3: Regulation is measured at a constant junction temperature by pulse testing with a low duty cycle. Changes in output voltage due to heating effects must be taken into account. Typical Applications (Continued) Dual Trimmed Supply TL/H/7340–4 3 Design Considerations Where: TJ e Junction Temperature TA e Ambient Temperature The LM79XX fixed voltage regulator series has thermal overload protection from excessive power dissipation, internal short circuit protection which limits the circuit’s maximum current, and output transistor safe-area compensation for reducing the output current as the voltage across the pass transistor is increased. Although the internal power dissipation is limited, the junction temperature must be kept below the maximum specified temperature (125§ C) in order to meet data sheet specifications. To calculate the maximum junction temperature or heat sink required, the following thermal resistance values should be used: Package TO-220 Typ iJC § C/W Max iJC § C/W Typ iJA § C/W Max iJA § C/W 3.0 5.0 60 40 e Power Dissipation iJA e Junction-to-Ambient Thermal Resistance iJC e Junction-to-Case Thermal Resistance iCA e Case-to-Ambient Thermal Resistance PD iCS e Case-to-Heat Sink Thermal Resistance iSA e Heat Sink-to-Ambient Thermal Resistance Typical Applications (Continued) Bypass capacitors are necessary for stable operation of the LM79XX series of regulators over the input voltage and output current ranges. Output bypass capacitors will improve the transient response by the regulator. The bypass capacitors, (2.2 mF on the input, 1.0 mF on the output) should be ceramic or solid tantalum which have good high frequency characteristics. If aluminum electrolytics are used, their values should be 10 mF or larger. The bypass capacitors should be mounted with the shortest leads, and if possible, directly across the regulator terminals. TJ Max b TA TJ Max TA or PD MAX e iJC a iCA iJA iCA e iCS a iSA (without heat sink) Solving for TJ: TJ e TA a PD (iJC a iCA) or e TA a PDiJA (without heat sink) High Stability 1 Amp Regulator TL/H/7340– 5 Load and line regulation k 0.01% temperature stability s 0.2% ² Determine Zener current ² ² Solid tantalum *Select resistors to set output voltage. 2 ppm/§ C tracking suggested 4 Typical Applications (Continued) Current Source *IOUT e 1 mA a 5V R1 TL/H/7340– 7 Light Controller Using Silicon Photo Cell TL/H/7340–8 *Lamp brightness increase until iI e iQ ( & 1 mA) a 5V/R1. ² Necessary only if raw supply filter capacitor is more than 2× from LM7905CT 5 Typical Applications (Continued) High-Sensitivity Light Controller TL/H/7340–9 *Lamp brightness increases until ii e 5V/R1 (Ii can be set as low as 1 mA) ² Necessary only if raw supply filter capacitor is more than 2× from LM7905 g 15V, 1 Amp Tracking Regulators TL/H/7340–1 Load Regulation at DIL e 1A Output Ripple, CIN e 3000 mF, IL e 1A Temperature Stability Output Noise 10 Hz s f s 10 kHz ( b 15) 40 mV 100 mVrms 50 mV 150 mVrms ( a 15) 2 mV 100 mVrms 50 mV 150 mVrms *Resistor tolerance of R4 and R5 determine matching of ( a ) and ( b ) outputs. **Necessary only if raw supply filter capacitors are more than 3× from regulators. 6 b 5V TL/H/7340–12 Schematic Diagrams 7 b 12V and b 15V TL/H/7340–13 Schematic Diagrams (Continued) 8 LM79XX Series 3-Terminal Negative Regulators Physical Dimensions inches (millimeters) TO-220 Outline Package (T) Order Number LM7905CT, LM7912CT or LM7915CT NS Package Number T03B LIFE SUPPORT POLICY NATIONAL’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT OF NATIONAL SEMICONDUCTOR CORPORATION. As used herein: 1. Life support devices or systems are devices or systems which, (a) are intended for surgical implant into the body, or (b) support or sustain life, and whose failure to perform, when properly used in accordance with instructions for use provided in the labeling, can be reasonably expected to result in a significant injury to the user. National Semiconductor Corporation 1111 West Bardin Road Arlington, TX 76017 Tel: 1(800) 272-9959 Fax: 1(800) 737-7018 2. A critical component is any component of a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system, or to affect its safety or effectiveness. National Semiconductor Europe Fax: (a49) 0-180-530 85 86 Email: cnjwge @ tevm2.nsc.com Deutsch Tel: (a49) 0-180-530 85 85 English Tel: (a49) 0-180-532 78 32 Fran3ais Tel: (a49) 0-180-532 93 58 Italiano Tel: (a49) 0-180-534 16 80 National Semiconductor Hong Kong Ltd. 13th Floor, Straight Block, Ocean Centre, 5 Canton Rd. Tsimshatsui, Kowloon Hong Kong Tel: (852) 2737-1600 Fax: (852) 2736-9960 National Semiconductor Japan Ltd. Tel: 81-043-299-2309 Fax: 81-043-299-2408 National does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and National reserves the right at any time without notice to change said circuitry and specifications.