Top Banner
SENA SERVICIO NACIONAL DE APRENDIZAJE Integrantes: Santiago Palacio Camilo vanegas David mejia CODIGO: 628121 ACTIVIDAD SISTEMA DE COMUNICACIÓN SERIAL
16

Comunicacion UART

Oct 04, 2015

Download

Documents

Este es un informe de comunicación UART
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

SENASERVICIO NACIONAL DE APRENDIZAJEIntegrantes:Santiago Palacio

Camilo vanegas

David mejiaCODIGO:

628121ACTIVIDAD SISTEMA DE COMUNICACIN SERIALFEBRERO, 2015OBJETIVOS-realizar un proyecto donde simulemos e implementemos un sistema de comunicacin serial

-aplicar conocimientos adquiridos en desarrollo de programacion y atgorismos

-interpretar el protocolo de serial UART

-hacer un buen uso de las librerias UART del microcontrolador PIC 16f887

-llevar a cabo un sistema controlado que monitorea y controla la temperatura atravez de un computador con las siguientes condiciones:- Comprender las funciones de configuracin y ejecucin de procedimientos de la librera UART.- Reconocer las sentencias de control bsicas para manejo de datos de entrada y salida del sistema de ,, comunicacin planteado.- Analizar cdigos e identificar funcionalidades de cdigos ejemplos suministrados o consultados.Simulacion y codigo

CODIGO

float Voltaje=0;

unsigned int ADC;

char tecla=0,cont=0;

// Lcd pinout settings

sbit LCD_RS at RD2_bit; //inicializacion del LCD//sbit LCD_EN at RD3_bit;

sbit LCD_D7 at RD7_bit;

sbit LCD_D6 at RD6_bit;

sbit LCD_D5 at RD5_bit;

sbit LCD_D4 at RD4_bit;

// Pin direction

sbit LCD_RS_Direction at TRISD2_bit;

sbit LCD_EN_Direction at TRISD3_bit;

sbit LCD_D7_Direction at TRISD7_bit;

sbit LCD_D6_Direction at TRISD6_bit;

sbit LCD_D5_Direction at TRISD5_bit;

sbit LCD_D4_Direction at TRISD4_bit;

char txtANA1[6];

char txtTEMP[6];

void main() {

ANSEL = 0x04; // Configure AN2 pin as analog

ANSELH = 0;

C1ON_bit=0;

C2ON_bit=0;

TRISA=0B11111101;

TRISD=0;

TRISB=255;

TRISC=0b11011111;

TRISE=255;

Lcd_Init();

UART1_Init(9600);

ADC_Init();

Lcd_Cmd(_LCD_CURSOR_OFF);

Lcd_Out(1, 1, "TEMPERATURA");

while(1){

ADC = ADC_Read(2);

Voltaje = ADC / 2.046; //formula para imprimir la temperatura//WordToStr(ADC,txtANA1); WordToStr(Voltaje, txtTEMP);

Lcd_Out(1, 1, "TEMPERATURA"); //imprime texto// Lcd_Chr(1,13, txtTEMP[3]);

Lcd_Chr(1,14, txtTEMP[4]);

Lcd_Out(1, 16, "C");

if (UART1_Data_Ready()) { // If data is received,

tecla = UART1_Read(); // read the received data,

}

switch(tecla){

case 'L': // IMPRIME TEMPERATURA //

UART1_Write_Text("TEMPERATURA ");

UART1_Write_Text(txtTEMP);

UART1_Write_Text(" C");

UART1_Write(10);

UART1_Write(13);

tecla=0;

break;

case 'A' : // ENCIENDE EL LED //

UART1_Write_Text("LED ON ");

Lcd_Out(2, 1, "LED ON ");

PORTA.B1=1;

UART1_Write(10);

UART1_Write(13);

tecla=0;

break;

case 'B' : // APAGA LED//

UART1_Write_Text("LED OFF ");

Lcd_Out(2, 1, "LED OFF");

PORTA.B1=0;

UART1_Write(10);

UART1_Write(13);

tecla=0;

break;

case 'C' : // ENCIENDE Y APAGA LED //

PORTA.B1=!PORTA.B1;

if(PORTA.B1==1){

UART1_Write_Text("LED ON "); // imprime texto// Lcd_Out(2, 1, "LED ON ");

} If(PORTA.B1==0){ //imprime texto// UART1_Write_Text("LED OFF ");

Lcd_Out(2, 1, "LED OFF");

}

UART1_Write(10); // ENTER //

UART1_Write(13);

tecla=0;

;break;

}

}

}Descripcion y circuitos de la implementacion

Un sistema micro controlado que monitorea y controla la temperatura en un ambiente tiene indicacin y control local de dicha variable, para su manipulacin se hace necesario el desplazamiento de un operario. Se monitorea y se hace control del proceso a travs de un computador. Para este proyecto usaremos el protocolo serial RS232, se propone que el sistema adems tenga control remoto usando una computadora a travs de su interfaz serial de la siguiente forma:Si se recibe el carcter L se debe transmitir el valor actual del ADC o de la temperatura. Si se recibe el carcter A un LED debe encenderse. Si se recibe el carcter B el LED debe apagarse. Si se recibe el carcter C el LED debe encenderse primero y luego de presionarse de nuevo, apagarse (El mismo comando activa y desactiva el LED).

CONCLUSIONES-Se llevo a cabo y con xito el proyecto propuesto por el profesor siguiendo asi la guia de apoyo y las reseas del profesor, nos parecio un ejercicio interesante ya que este protocolo UART es muy util para satisfacer las necesides en la vida cotidiana y en el mundo laboral y nos encaminamos asi hacia los protocolos de comunicacin.

-Se hizo un buen uso de las librerias de mikro C interpretando asi su funcionamiento

-Se realizo con efectividad todos lo logros y objetivos que se propusieron al inicio del proyecto.