Vous êtes sur la page 1sur 11

INFORME DEL

PROYECTO

CARRERA: INFORMATICA INDUSTRIAL

MATERIA: INFORMATICA Y LABORATORIO

INTEGRANTES:LIMBERTH PEREDO SANCHEZ


AXEL ROJAS SANDOVAL

DO CENTE: LIC. JOSEFINA ROJAS


Introducción
Diseño de un motor controlado mediante tres salidas de un PIC16F877A la cual es
controlado desde una interfaz de control diseñado en Microsoft Visual Studio.
Esta interfaz envía por un USB serial una señal la cual activa el consumidor que esté
conectado a la salida del PIC como un motor, una ventiladora, un foco,
leds.
Problema
El problema que vi hoy en día es que el hombre moderno ya lo ve como anticuado manipular leds,
motores y otros dispositivos desde un Switch, por la cual se plantea la manipulación mediante un
software.

Objetivo general
Diseñar una interfaz para controlar un circuito de leds de un motor y un sensor de
temperatura.
Objetivos específicos
• Manipular cuatro leds a requerimiento del usuario mediante una interfaz que permite encender el
led correspondiente.
• Encender un motor para controlar la puerta de tu garaje, o de tu habitación, etc.
• Visualizar la temperatura ambiente.

Materiales
• Protoboard
• Cables
• Capacitor
• Resistencias (220,330)
• Leds
• PIC16F877A
• Pulsador
Simulación del circuito de control

Interfaz de control

Programación en Visual C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using
System.Drawing; using
System.Linq; using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports; namespace
comunicacionArduino {
public partial class Form1 : Form {
int flag = 0, time = 0, temperatura;

string lectura;>
public SerialPort myPort;
public Form1()
{

InitializeComponent();
initicializarArduino(); button2.Enabled =
false;
LED1.Enabled = false;
LED2.Enabled = false;
LED3.Enabled = false;
LED4.Enabled = false; lbtexto.Text =
"Temperatura: ";
chart1.Titles.Add("Temperatura");
}

private void Form1_Load(object sender,


EventArgs e) {
}
private void button1_Click(object sender,
EventArgs e) {
flag = 1;
button1.Enabled = false; button2.Enabled =
true;
LED1.Enabled = true;
LED2.Enabled = true;
LED3.Enabled = true;
LED4.Enabled = true; lbtexto.Text =
"Temperatura: "; chart1.Series[0].Points.
Clear(); progressBar1.Value = 0; time = 0;
}
private void initicializarArduino()
{
try
{
myPort = new SerialPort();
myPort.BaudRate = 9600;
myPort.PortName = "COM5";
; //si no se
myPort.DtrEnable = true coloca

esto el Arduino sigue su loop sin parar


myPort.Open();coloca como una suma
serialPort1_DataReceived;//se
} myPort.DataReceived +=
catch
{
MessageBox.Show("error en el com3");
}
// button1.Enabled = true;
// button2.Enabled = false;
}
private void button2_Click(object sender,
EventArgs e)

{ ' w
flag = 2;
button1.Enabled = true; button2.Enabled =
false;
LED1.Enabled = false;
LED2.Enabled = false;
LED3.Enabled = false;
LED4.Enabled = false; myPort.Write("2");
LED1.Checked = false; myPort.Write("4");
LED2.Checked = false; myPort.Write("6");
LED3.Checked = false; myPort.Write("8");
LED4.Checked = false;

}
private void button3_Click(object sender, EventArgs e)
{
myPort.Close();
Close();
}
//desde qui
private void serialPort1_DataReceived(object sender,
System.IO.Ports.SerialDataReceivedEventArgs e)
{
if (flag == 1)
{
lectura = myPort.ReadLine(); double temp =
Convert.ToDouble(lectura); temperatura =
Convert.ToInt16(temp); temperatura =
temperatura /100;//dato muy alto nos manda el pic
Invoke(new
EventHandler(progressBar1_Click));
}
}
private void LED1_CheckedChanged(object
sender,EventArgs e)
{
if (flag == 1)
{
if (LED1.Checked == true)
myPort.Write("1");
{ }
else
{
myPort.Write("2");
}
}
}
private void LED2_CheckedChanged(object sender,
EventArgs e)
{
if (flag == 1)
{
if (LED2.Checked == true) {
myPort.Write("3");
}
else
{
myPort.Write("4");
}
}
}

private void LED3_CheckedChanged(object sender, EventArgs


e)

{
if (flag == 1)
{
if (LED3.Checked == true)
{ myPort.Write("5");
}
else
{
myPort.Write("6");
}
}
}
private void LED4_CheckedChanged(object sender, EventArgs
e)
f fllAIL
{

if (flag == 1)
{
if (LED4.Checked == true)
{
myPort.Write("7");
}
else
{
myPort.Write("8");
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (flag == 1)
{
myPort.Write("9"); time++;
if (time == 10)
{
time = 0;
chart1.Series[0].Points.Clear();
} M \WL
chart1.Series["Temperatura"].Points.AddY(temperatura);
}
}
private void progressBar1_Click(object sender, EventArgs
e)

{
progressBar1.Value = temperatura;
if (temperatura <= 20)
// progressBar1.Value
{ = 0;
lbtexto.Text = "Temperatura: " +
temperatura.ToString() + "°C Frio";
}
if (temperatura > 20 && temperatura < 50)
{
lbtexto.Text = "Temperatura: " +
temperatura.ToString() + "°C Templado";
}
if (temperatura >= 50)
{
lbtexto.Text = "Temperatura: " +
temperatura.ToString() + "°C Caliente";
} }
//asta aquí para leer datos
}
}

Código en PIC C Compiler


#include <16f877a.h>
#device adc=10 #include <stdio.h>
#include <math.h>
#fuses Hs, NOPROTECT, NOWDT #use delay (clock=20M)
#use rs232 (baud=9600, parity=N, xmit=pin_c6, rcv=pin_c7, bits=8) void
temperatura(); char dato; float temp;
#int_rda void rda_isr()
{
dato=getc();
switch(dato)
{
case '1' : output_high(pin_b7); break;
case '2' : output_low(pin_b7); break;
case '3' : output_high(pin_b6); break;
case '4' : output_low(pin_b6); break;
case '5' : output_high(pin_b5); break;
case '6' : output_low(pin_b5); break;
case '7' : output_high(pin_b4); break;
case '8' : output_low(pin_b4); break;
case '9' : temperatura(); break;
}

void main()
{
enable_interrupts(int_rda);
enable_interrupts(global);

while(true)
{

}
}

void temperatura()
{
setup_adc_ports(AN0);
setup_adc(adc_clock_div_64);
set_adc_channel(0);
delay_us(50);

temp=(read_adc())/2; printf("%0.2f\r\n",temp);
}

Alcance
Tiene como ventaja que facilita al usuario manipular leds desde su hardware con el
interfaz que se diseño en este proyecto, también controlar un motor, y ver la
temperatura ambiente.
Y su desventaja es que no puedes controlar un foco de corriente alterna, para lo cual
si quieres controlar primero tienes que hacer una modificación como aumentar un
relé y desde ahí recién puedes controlarlo. Tampoco puedes activar un motor más
grande.

Conclusión
Este proyecto nos deja como conclusión, que existen diferentes maneras de controlar
circuitos desde un software, ya que todos son semejantes, pero a la vez diferente en
su funcionamiento y además la construcción de estés circuitos con una comunicación
serial requiere ciertas precauciones y distintos materiales según requiera el circuito
que vas diseñar
Bibliografía
https://m.youtube.com/watch?=4Q18tyi8J-Y

Vous aimerez peut-être aussi