Se lee un sensor de temperatura LM61CIZ a travès deun canal analógico del ADC (A0/PTB0) y el resultado se muestra en la terminal serial y en un LCD 16x12.

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
CHRISTIAN_GSL
Date:
Tue Aug 04 18:41:32 2020 +0000
Commit message:
ok

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Aug 04 18:41:32 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Aug 04 18:41:32 2020 +0000
@@ -0,0 +1,88 @@
+
+/*******************************************************************************
+Nombre del Proyecto: SENSOR TEMPERATURA
+Se lee un sensor de temperatura LM61CIZ a travès deun canal analógico del ADC 
+(A0/PTB0) y el resultado se muestra en la terminal serial y en un LCD 16x12.
+Autor: Christian G.S.L.
+Fecha: 16-05-2019
+Software: MBED 
+Hardware: LCD16x2, LM61ciz
+Diagrama:
+                        Tarjeta KL25Z
+                     --------------------
+                 /|\|                    |
+                  | |                    |
+                  --|RST                 |
+                    |                    | 
+     LM61cizVout--->|PTB0                |----<LCD 16x2>
+    
+ Diagrama  de conexión al LCD.
+ ===============================================================================
+ LCD pin              Connect to
+ -------------------------------------------------------------------------------
+ 01 - GND             GND, pot
+ 02 - VCC             +5V, pot
+ 03 - Contrast        Pot wiper
+ 04 - RS              PTE20
+ 05 - R/W             GND
+ 06 - EN              PTE21
+ 07 - DB0             GND
+ 08 - DB1             GND
+ 09 - DB2             GND
+ 10 - DB3             GND
+ 11 - DB4             PTE22
+ 12 - DB5             PTE23
+ 13 - DB6             PTE29
+ 14 - DB7             PTE30
+ 15 - BL-             GND
+ 16 - BL+             +5V    
+*******************************************************************************/
+//ARCHIVOS DE CABECERA.    
+#include "mbed.h"
+#include "TextLCD.h"
+//******************************************************************************
+//DECLARACION DE FUNCIONES. 
+
+//******************************************************************************
+//INICIALIZACION.
+Serial pc(USBTX, USBRX); // tx, rx inicialización del puerto serial emulado.
+Serial uart1(PTE0, PTE1);// inicialización del puerto serial uart1 TX=PTE0, RX=PTE1
+
+//inicialización de pines para control de LCD 
+TextLCD lcd(PTE20, PTE21, PTE22, PTE23, PTE29, PTE30, TextLCD::LCD16x2); // rs, e, d4-d7, LCDType
+
+AnalogIn Sensor(PTB0); //inicialización de un canal del ADC
+
+ unsigned short int lectura_ADC;
+ float Vent;
+ float temperatura;
+ 
+//PROGRAMA PRINCIPAL.
+//******************************************************************************
+int main() 
+{
+  pc.baud(9600);//Velocidad bps (Taza de transmisión)
+  pc.format(8,Serial::None,1);//8 bits de datos,sin paridad,1 bit de paro
+  uart1.baud(9600);//Velocidad bps (Taza de transmisión)
+  uart1.format(8,Serial::None,1);//8 bits de datos,sin paridad,1 bit de paro
+  
+  lcd.locate(0,0);
+  lcd.printf("Temperatura ");
+  
+  while(1) //Bucle infinito
+  {
+      lectura_ADC = Sensor.read_u16();//Read the input voltage, represented as an unsigned short in the range [0x0000, 0xFFFF]. 
+      pc.printf("%d \n", lectura_ADC);
+      Vent = (2.30*lectura_ADC)/65535.0;
+      pc.printf("%f \n", Vent);
+      temperatura = (Vent-0.6)/0.01;
+      lcd.locate(0,1);//(col,row)
+      lcd.printf("%.2f",temperatura);
+      lcd.putc(223);    //imprime símbolo º
+      lcd.printf("C "); //imprime C
+      
+      pc.printf("%f \n", temperatura);
+      wait(0.5);//1/2 segundo para refrescar lectura del ADC wait_ms(250);wait_ms(250);
+  }
+}
+//******************************************************************************
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 04 18:41:32 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file