Está en la página 1de 15

DC-EA-MP-01

UNIVERSIDAD TECNOLOGICA DEL SURESTE DE VERACRUZ

REVISION: 0 FECHA: 30/05/2012 PAG. 1 DE

TITULO Interfaz en LabView de un conversor ADC con microcontrolador usando comunicacin USB Carrera: Ing. Mecatrnica rea: automatizacin Grupo: 302 ASIGNATURA: Diseo de interfaces electrnicas

UNIDAD TEMTICA I. Acondicionamiento de seales analgicas

INTEGRANTES:
Gomez Hamilton David Ivan De la Fuente Marquez Abiel Virgen Ramos Erick Medina Antonio Mayra De Paz Salinas Jair de Jesus Sierra Barrera Jorge

DOCENTE: ING. Jesus Tadeo Garcia Morales.

OBJETIVO:

El alumno elaborar una interfaz en Labview con conversor ADC mediante un microcontrolador para sensar temperatura usando comunicacin USB.
Nanchital, Ver. 03 de Agosto del 2012

INTRODUCCION En esta prctica veremos la conversin analgica a digital que cuenta los microcontroladores internamente sin la necesidad de usar un integrado para ello funcionando de manera similar para realizar un sensor de temperatura con el LM35 mostrndolo en un LCD visualizando la medicin con una interfaz hecha en Labview usando la comunicacin USB.

MARCO TEORICO Configuracin de control de bits del puerto A/D:

Diagrama de pins

Enva un archivo por puerto serie. Abre el archivo en modo binario y extrae su contenido. Si hay error al leer el archivo, termina el programa. Sino, extrae el nombre y MD5 del archivo y lo une con el contenido en un cluster. En primer lugar se enva el tamao del cluster recin armado y luego el cluster. Se cierra la conexin y termina el programa.

Archivo a enviar Ruta del archivo a enviar.

Puerto (COM1) VISA resource name specifies the resource to be opened. This control also specifies the session and class. Baudios (57600) Velocidad de transferencia. Debe ser la misma que en la otra PC. error in error in can accept error information wired from VIs previously called. Use this information to decide if any functionality should be bypassed in the event of errors from other VIs. Right-click the error in control on the front panel and select Explain Erroror Explain Warning from the shortcut menu for more information about the error. status status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. code code is the error or warning code. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. source source describes the origin of the error or warning. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. error out error in can accept error information wired from VIs previously called. Use this information to decide if any functionality should be bypassed in the event of errors from other VIs. Right-click the error in control on the front panel and select Explain Erroror Explain Warning from the shortcut menu for more information about the error. status status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred. Right-click the error in control on the front panel and select Explain

Error or Explain Warning from the shortcut menu for more information about the error. code code is the error or warning code. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. source source describes the origin of the error or warning. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

Recibe un archivo por puerto serie. Se abre la conexin y se comprueba si hay bytes esperando para ser ledos en el puerto (estaran almacenados en el cach). Si no hay bytes esperando, se cierra la conexin y termina. Si hay bytes esperando, se leen 4 bytes, que representa un int y que contiene el tamao del cluster, en bytes, que se espera recibir. Luego se lee esa cantidad de bytes desde el puerto y se arma el cluster. Se pide al usuario un nombre de archivo, sugiriendole el mismo nombre que tena en la otra PC. Se crea el archivo con el nombre sugerido, se guardanen l los datos y se cierra el archivo. Se comprueba si el hash MD5 del archivo recin creado es el mismo que el recibido de la otra PC. Sino, se enva un mensaje de error. Se podran hacer otras comprobaciones, como por ejemplo si el usuario cancel la operacin presionando cancelar cuando se le pidi un nombre para el archivo. Pero si ocurre esto, simplemente habr un error al crear el archivo con un nombre no vlido en el siguiente paso y se propagar por los siguientes SubVIs. Y simplemente se terminar con un error.

Puerto (COM1) VISA resource name specifies the resource to be opened. This control also specifies the session and class. Baudios (57600) Velocidad de transferencia. Debe ser la misma que en

la otra PC. error in error in describes error conditions that occur before this VI or function runs. status status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE. code code is the error or warning code. The default is 0. source source specifies the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string. error out error in can accept error information wired from VIs previously called. Use this information to decide if any functionality should be bypassed in the event of errors from other VIs. Right-click the error in control on the front panel and select Explain Erroror Explain Warning from the shortcut menu for more information about the error. status status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. code code is the error or warning code. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error. source source describes the origin of the error or warning. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

DESARROLO 1. Se hace la programacin en PCWen leguaje C++ usando el ADC del microprocesador 18f4550 como se muestra: #INCLUDE <18f4550.h> #FUSES NOWDT,HSPLL,PLL1,NOWDT,NOPROTECT,USBDIV,CPUDIV1 #device adc=10 #use delay(clock=4mhz) //# use rs232( baud=9600 , UART1) // 9600 es la velocidad en baudios de transmision de datos, esta debe ser la misma en el microcontrolador como en labview #define use_portb_lcd TRUE #include <lcd.c> #include "usb_cdc.h" // Descripcin de funciones del USB. #include "usb_desc_cdc.h" //Descriptores del dispositivo USB. # use standard_io (B) void main () { delay_ms(500); lcd_init(); //Inicia LCD delay_ms(150);

lcd_putc("\f"); //Limpia pantalla

while(true) { lcd_gotoxy(1,1); //Acomoda cursor LCD

setup_adc_ports(AN0|VSS_VREF); setup_adc(ADC_CLOCK_INTERNAL); set_adc_channel(0); float temp= read_adc(); delay_us(4); int temp2=(temp*150)/1023; lcd_gotoxy(1,1); printf(lcd_putc,"Temperatura:"); printf(lcd_putc,"%2i",temp2); lcd_putc(0xdf); printf(lcd_putc,"C"); delay_ms(500);

usb_cdc_init(); // Configuramos al puerto virtual. usb_init(); // Inicializamos el stack USB. while(!usb_cdc_connected()) // espera a detectar una transmisin de la PC (Set_Line_Coding). { { usb_task(); if (usb_enumerated()){ // Espera a que el dispositivo sea enumerado por el host.

printf(usb_cdc_putc,"%2i",temp2); //enviando el valor temperatura } } } } }

2. Se disea el circuito en ISIS Proteus Professional como se muestra en la siguiente imagen:

3. Se direcciona el programa el cual es el archivo .hex al 18f4550 como se muestra en la figura siguiente:

4. Se simula en Proteus para verificar que la programacin este correcta como se observa en la figura siguiente:

5. Se arma el circuito fsicamente en protoboard como se observa en la figura siguiente:

6. Se el diagrama para la comunicacin serial en Labview y su interfaz como se muestra en la siguientes imagenes:

CONCLUSIONES: La conversin ADC en los PIC es de igual forma que un integrado ADC con la entrada del voltaje analgico y su voltaje de referencia para hacer la conversin digital exacta para ser en este caso procesada por el PIC para que se pueda visualizar en el LCD. En todo ADC el conjunto de bits obtenidos a la salida sea un reejo lo ms exacto posible del valor analgico correspondiente. Si el ADC, est situado a la salida de un sensor (que habitualmente aportan una seal de amplitud dbil) es esencial que en la etapa de conversin no se genere un nivel de ruido que impida la conversin real de la seal de entrada.

REFERENCIAS: http://www.danielmunoz.com.ar/blog/2009/04/30/labview-comunicacion-rs-232-entre-pcs/ http://ww1.microchip.com/downloads/en/devicedoc/39632c.pdf

También podría gustarte