miércoles, 8 de agosto de 2012

Utilice su PC como osciloscopio gratis.

 

Un osciloscopio es un instrumento de laboratorio utilizado para mostrar y analizar la forma de onda de las señales electrónicas. Aquí es un procedimiento sencillo, cómo hacer tu propio Osciloscopio para tu PC .

Un osciloscopio real es muy costosa y grande en tamaño, por lo que resulta poco accesible para los aficionados. Podemos utilizar esta alternativa un osciloscopio Virtua para PC .


Encontraras dos modelos que podras utilizar:


image

 

Descargar osciloscopio 2,51

image

Descargar Digital Osciloscopio


Cómo utilizar el osciloscopio

1) Descargue la aplicación y ejecutarlo.

El osciloscopio utiliza la tarjeta de sonido de su computadora (entrada MIC) para detectar señal, así que para proteger su tarjeta de sonido debemos hacer un pequeño circuito de interfaz mediante resistencias. (como se muestra en la figura a continuación)

image

Utilice cable coaxial para la medición de alta frecuencia, para evitar el ruido

Lista de materiales:-

1) 1 x Cable de Audio de 3.5 a 3.5 macho

2) Resistencias como se muestra en la figura

3) Sondas (puede utilizar sondas de cable multímetro)

4) Coaxial Cable para evitar ruidos durante la medición de señales de alta frecuencia.

Finalmente, tenemos un osciloscopio muy economico para las proyectos.

sábado, 28 de julio de 2012

Arduino LCD indicador de temperatura con LM35

Lector de temperaturas en grados Fahrenheit y centígrados, con display LCD, es un aplicación bastante simple e interesante.

Verdaderamente la plataforma Arduino es muy versátil, y además fácil de comprender. Durante muchos años estuve interesado en los microprocesadores y micro controladores, 8085, Pic, Paralax, Basic Stamp, AVR y otros pero los encontraba muy monótonos, pero cuando me tope con Arduino, me sorprendí, las aplicaciones que se le pueden dar son inmensas y los componentes que se pueden encontrar para esta plataforma, son súper interesantes, los GPS permiten la creación de equipos de vuelo parcialmente autónomos, con tan solo indicar las coordenadas, es un proyecto que más tarde mostrare, con los quadcopter..
También la robótica esta increíble con los Hexápodos, este será otro proyecto que mostrare más adelante, y las aplicaciones en CNC (Fresadoras), en fin son temas que mas adelante tocaremos.

Indicador de temperatura LCD
DSCF1611

image
Aqui tienen el sketch para arduino

/*
  Temperature Indicator F/C with LM35 sensor.
 
  apcexpert.blogspot.com 
 
  apcexpert.wordpress.com
*/
// LCD library code:
#include <LiquidCrystal.h>
// The numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// Variables
float TempC;
float TempF;
int TempPin = 1;
void setup(){
  // LCD's line position of columns and rows:
  lcd.begin(16, 2);
  lcd.print(" Temp Indicator");
  lcd.setCursor(0, 1);
  lcd.print("Temp");
}
void loop(){
  TempC = analogRead(TempPin);           //read the value from the sensor
  TempC = (5.0 * TempC * 100.0)/1024.0;  //convertion the analog data to temperature
  TempF = ((TempC*9)/5) + 32;            //convertion celcius to farenheit
  // print result to lcd display
  lcd.setCursor(11, 1);
  lcd.print(TempC,1);
  lcd.print("C");
  lcd.setCursor(5, 1);
  lcd.print(TempF,1);
  lcd.print("F");
 
  delay(1000);
}

Hasta la proxima.

Arduino IR Remote Control - Controlar 4 relays con un control remoto Infrerojo

Hoy les traigo un proyecto de como controlar un panel de 4 relays utilizando in control remoto infrarojo ( IR remote control ). se requiere tener la libreria del sensor infrerojo. Nota importante en esta libreria requiere una pequeña modificacion, solo cuando utilizas las verciones nuevas del programa de Arduino 1.0 y 1.0.1 en las anteriores no tendras problemas.

La modificacion consiste en remplazar #include <WProgram.h>
por #include <Arduino.h> en el archivo IRRemoteInt.h.

Si tienen algun problema me abisan, con gusto los ayudare.

 

Enlace: IR Reomote library


Conecciones electricas:
Pin 13 – canal 1
pin 12 – canal 2
pin 11 – canal 3
pin 10 – canal 4

pin 7 – señal del sensor infrarojo

image

Estoy utilizando el Control remoto modelo YK-001, lo pueden conseguir en ebay.com, en la imagen podrán ver los códigos de cada tecla, los necesitaran para su proyecto.

IR CONTROL YK-001 codes

Con el siguiente sketch de Arduino podrán localizar los códigos de otros controles, los códigos los podrán ver en el serial monitor, por si desean utilizar otro diferente:


//apcexpert.blogspot.com
// IR Remote Control Code Finder
#include <IRremote.h>
int RECV_PIN = 7; //define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
  Serial.println(results.value );
  irrecv.resume(); // Receive the next value
}
}


IR Sensor

Para finalizar, el Sketch de Arduino con el cual podremos controlar los cuatro relay como se ve en la imagen superior;


// apcexpert.blogspot.com

#include <IRremote.h>

int RECV_PIN = 7;

int Relay1_PIN = 13;
int Relay2_PIN = 12;
int Relay3_PIN = 11;
int Relay4_PIN = 10;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(Relay1_PIN, OUTPUT);
  pinMode(Relay2_PIN, OUTPUT);
  pinMode(Relay3_PIN, OUTPUT);
  pinMode(Relay4_PIN, OUTPUT);
 
  pinMode(6, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
}

int on = 1;


void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == 16724175) { // YK-001 button 1
       {
        on = !on;
        digitalWrite(Relay1_PIN, on ? HIGH : LOW);
      }
     }
{
    if (results.value == 16718055) { // YK-001 button 2
     
       {
        on = !on;
        digitalWrite(Relay2_PIN, on ? HIGH : LOW);
      }
      }   
  {
    if (results.value == 16743045) { // YK-001 button 3
     {
        on = !on;
        digitalWrite(Relay3_PIN, on ? HIGH : LOW);
      }
     }   
  {
    if (results.value == 16716015) { // YK-001 button
     {
        on = !on;
        digitalWrite(Relay4_PIN, on ? HIGH : LOW);
      }
     }     
    irrecv.resume(); // Receive the next value
  }
}}}}


Espero que no tengan problemas, pero de tenerlos pueden comunicarse y con gusto los ayudare en lo posible. Hasta la próxima.

viernes, 13 de julio de 2012

Arduino–Componentes para control de potencia

Estos son algunos componentes que se podrían utilizar con los proyectos de Arduino, mostrare algunos circuitos básicos para tener ideas de cómo aplicarlos.

1 – Los transistores – la imagen muestra cómo utilizarlos, el transistor debe seleccionarse según el voltaje y la corriente de operación, el especificado en la imagen es el TIP122 este transistor puede ser operado a un máximo de 100voltios y la corriente máxima de operación es de 5 amperios, recuerde que es el máximo, recomiendo utilizarlo al 70% de su capacidad, también aplicar los disipadores de calor.

 

Motor Transistor

image

Especificaciones del Tip122 ( Datasheet ) http://www.fairchildsemi.com/ds/TI/TIP120.pdf

2- Transistores MOSFET- Aunque luce similar al transistor, este no tiene que ver con la corriente que transcurre por su base, es solo el voltaje aplicado le Gate o compuerta de control (similar a la base del transistor), La ventaja con los mosfet es que podemos utilizar motores o cargas con mayor potencia ya que estos pueden manejar corrientes desde 10 hasta 100 amperios, estos son modelos muy comunes también encontraran de mayores capacidades pero son más costosos y no tan accesibles. mostrare algunas imágenes para sus aplicaciones sencillas.

 

arduino power_mosfet  image

image

3- Los Solid State Relay( Relevadores en estado sólido) – Esta alternativa lucirá mucho mas profesional si realizan un proyecto comercial o industrial, se utilizan en circuitos de corriente alterna, podrían remplazar los arrancadores magnéticos de motores, sin la necesidad de tener que remplazar contactos como en los controladores magnéticos que se utilizan en las industrias.

Pueden ser controlados con voltajes de 3 hasta 24Voltios DC, son muy versátiles, requieren disipadores de calor y si tienen ventilación será mucho mejor.

 

image

 image

Para motores trifasicos

image

 

como pueden ver hay diversas formas de contralar cargas desde Arduino. hasta la próxima.

martes, 10 de julio de 2012

Controlar 8 relays con Visual Basic y Arduino

Podrán ver como hacer que se puedan controlar 8 relays desde visual Basic 2010, tan solo con un solo botón podrás activar y desactivar. También podrán observar como los indicadores cambiaran de color verde a rojo cuando el relay este activado, Podrán comparar con la publicación anterior y podrán notar los cambios realizados en el Sketch de arduino y también en Visual Basic.
No solo podrán controlar relays, pueden apilarlo en diferentes proyectos como prender motores, lámparas, entre otras cosas. Espero les guste.

image
Podran utilisar diferentes paneles de relays :
   




Aquí les dejo el Sketch de Arduino




//apcexpert.blogspot.com
//Con este programa controlaras 8 relays con pulsar un boton para actibar y
//al pursarlo nuevamente se desactiva.

char inData[20]; // Allocate some space for the string
char inChar=-1; // Where to store the character read
byte index = 0; // Index into array; where to store the character
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
}
char PinOut(char* This) {
while (Serial.available() > 0) // Don't read unless
// there you know there is data
{
if(index < 19) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
if (strcmp(inData,This) == 0) {
for (int i=0;i<19;i++) {
inData[i]=0;
}
index=0;
return(0);
}
else {
return(1);
}
}
void loop()
{
if (PinOut("13 on")==0) { digitalWrite(13, HIGH);}
if (PinOut("13 off")==0) {digitalWrite(13, LOW);}
if (PinOut("12 on")==0) { digitalWrite(12, HIGH);}
if (PinOut("12 off")==0) {digitalWrite(12, LOW);}
if (PinOut("11 on")==0) { digitalWrite(11, HIGH);}
if (PinOut("11 off")==0) {digitalWrite(11, LOW);}
if (PinOut("10 on")==0) { digitalWrite(10, HIGH);}
if (PinOut("10 off")==0) {digitalWrite(10, LOW);}
if (PinOut("9 on")==0) { digitalWrite(9, HIGH);}
if (PinOut("9 off")==0) {digitalWrite(9, LOW);}
if (PinOut("8 on")==0) { digitalWrite(8, HIGH);}
if (PinOut("8 off")==0) {digitalWrite(8, LOW);}
if (PinOut("7 on")==0) { digitalWrite(7, HIGH);}
if (PinOut("7 off")==0) {digitalWrite(7, LOW);}
if (PinOut("6 on")==0) { digitalWrite(6, HIGH);}
if (PinOut("6 off")==0) {digitalWrite(6, LOW);}

}



Visual Basic 2010


Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
    ' Shared _continue As Boolean
    ' Shared _serialPort As SerialPort
    Dim pinout13 As Boolean = True
    Dim pinout12 As Boolean = True
    Dim pin11 As Boolean = True
    Dim pinout10 As Boolean = True
    Dim pinout9 As Boolean = True
    Dim pinout8 As Boolean = True
    Dim pinout7 As Boolean = True
    Dim pinout6 As Boolean = True

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Close()
        SerialPort1.PortName = "com4" 'Cambiar el numero de Puerto "COM"
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SerialPort1.Open()
        If pinout13 = True Then
            SerialPort1.Write("13 on")
            RectangleShape1.BackColor = Color.Red
        Else
            SerialPort1.Write("13 off")
            RectangleShape1.BackColor = Color.Lime
        End If
        pinout13 = Not (pinout13)
        SerialPort1.Close()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        SerialPort1.Open()
        If pinout12 = True Then
            SerialPort1.Write("12 on")
            RectangleShape2.BackColor = Color.Red
        Else
            SerialPort1.Write("12 off")
            RectangleShape2.BackColor = Color.Lime
        End If
        pinout12 = Not (pinout12)
        SerialPort1.Close()
    End Sub
    Private Sub RectangleShape1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape1.Click, RectangleShape8.Click
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        SerialPort1.Open()
        If pin11 = True Then
            SerialPort1.Write("11 on")
            RectangleShape3.BackColor = Color.Red
        Else
            SerialPort1.Write("11 off")
            RectangleShape3.BackColor = Color.Lime
        End If
        pin11 = Not (pin11)
        SerialPort1.Close()
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        SerialPort1.Open()
        If pinout10 = True Then
            SerialPort1.Write("10 on")
            RectangleShape4.BackColor = Color.Red
        Else
            SerialPort1.Write("10 off")
            RectangleShape4.BackColor = Color.Lime
        End If
        pinout10 = Not (pinout10)
        SerialPort1.Close()
    End Sub
    Private Sub RectangleShape3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape3.Click, RectangleShape6.Click
    End Sub
    Private Sub RectangleShape4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape4.Click, RectangleShape5.Click
    End Sub
    Private Sub RectangleShape2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape2.Click, RectangleShape7.Click
    End Sub
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        SerialPort1.Open()
        If pinout6 = True Then
            SerialPort1.Write("6 on")
            RectangleShape8.BackColor = Color.Red
        Else
            SerialPort1.Write("6 off")
            RectangleShape8.BackColor = Color.Lime
        End If
        pinout6 = Not (pinout6)
        SerialPort1.Close()
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        SerialPort1.Open()
        If pinout9 = True Then
            SerialPort1.Write("9 on")
            RectangleShape5.BackColor = Color.Red
        Else
            SerialPort1.Write("9 off")
            RectangleShape5.BackColor = Color.Lime
        End If
        pinout9 = Not (pinout9)
        SerialPort1.Close()
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        SerialPort1.Open()
        If pinout8 = True Then
            SerialPort1.Write("8 on")
            RectangleShape6.BackColor = Color.Red
        Else
            SerialPort1.Write("8 off")
            RectangleShape6.BackColor = Color.Lime
        End If
        pinout8 = Not (pinout8)
        SerialPort1.Close()
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        SerialPort1.Open()
        If pinout7 = True Then
            SerialPort1.Write("7 on")
            RectangleShape7.BackColor = Color.Red
        Else
            SerialPort1.Write("7 off")
            RectangleShape7.BackColor = Color.Lime
        End If
        pinout7 = Not (pinout7)
        SerialPort1.Close()
    End Sub
End Class

Hasta la proxima.


lunes, 9 de julio de 2012

Arduino y Visual Basic 2010–Controlar relay con un solo boton

En esta publicación controlaremos 4 relays utilizando un programa creado en Visual Basic 2010, mediante la comunicación del puerto USB nos conectaremos al Arduino UNO, y este a subes activara o desactivara los relay.
Lo prepare por una petición en los comentarios y aquí esta la respuesta.
Primero el ejemplo será con 4 Relays y en la próxima publicación será con 8 relays para que puedan ver los cambios realizados y sirva de ejemplo para todos. Espero les guste.

Arduino4ChRelaySinglePulse
El circuito utilizado será el mismo de la publicación anterior:


Conecciones electricas:
Pin 13 – canal 1
pin 12 – canal 2
pin 11 – canal 3
pin 10 – canal 4
 image
image

A continuación el Sketch de Arduino UNO




//apcexpert.blogspot.com
//Con este programa controlaras 4 relays con pulsar un botón para activar y
//al pulsarlo nuevamente se desactiva.

char inData[20]; // Allocate some space for the string
char inChar=-1; // Where to store the character read
byte index = 0; // Index into array; where to store the character
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);

}
char PinOut(char* This) {
while (Serial.available() > 0) // Don't read unless
// there you know there is data
{
if(index < 19) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
if (strcmp(inData,This) == 0) {
for (int i=0;i<19;i++) {
inData[i]=0;
}
index=0;
return(0);
}
else {
return(1);
}
}
void loop()
{
if (PinOut("13 on")==0) { digitalWrite(13, HIGH);}
if (PinOut("13 off")==0) {digitalWrite(13, LOW);}
if (PinOut("12 on")==0) { digitalWrite(12, HIGH);}
if (PinOut("12 off")==0) {digitalWrite(12, LOW);}
if (PinOut("11 on")==0) { digitalWrite(11, HIGH);}
if (PinOut("11 off")==0) {digitalWrite(11, LOW);}
if (PinOut("10 on")==0) { digitalWrite(10, HIGH);}
if (PinOut("10 off")==0) {digitalWrite(10, LOW);}


}


Continuamos con el codigo fuente de Visual Basic 2010


Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
    ' Shared _continue As Boolean
    ' Shared _serialPort As SerialPort
    Dim pinout13 As Boolean = True
    Dim pinout12 As Boolean = True
    Dim pin11 As Boolean = True
    Dim pinout10 As Boolean = True

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Close()
        SerialPort1.PortName = "com4" 'Cambiar el numero de Puerto "COM"
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SerialPort1.Open()
        If pinout13 = True Then
            SerialPort1.Write("13 on")
            RectangleShape1.BackColor = Color.Red
        Else
            SerialPort1.Write("13 off")
            RectangleShape1.BackColor = Color.Lime
        End If
        pinout13 = Not (pinout13)
        SerialPort1.Close()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        SerialPort1.Open()
        If pinout12 = True Then
            SerialPort1.Write("12 on")
            RectangleShape2.BackColor = Color.Red
        Else
            SerialPort1.Write("12 off")
            RectangleShape2.BackColor = Color.Lime
        End If
        pinout12 = Not (pinout12)
        SerialPort1.Close()
    End Sub
    Private Sub RectangleShape1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape1.Click
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        SerialPort1.Open()
        If pin11 = True Then
            SerialPort1.Write("11 on")
            RectangleShape3.BackColor = Color.Red
        Else
            SerialPort1.Write("11 off")
            RectangleShape3.BackColor = Color.Lime
        End If
        pin11 = Not (pin11)
        SerialPort1.Close()
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        SerialPort1.Open()
        If pinout10 = True Then
            SerialPort1.Write("10 on")
            RectangleShape4.BackColor = Color.Red
        Else
            SerialPort1.Write("10 off")
            RectangleShape4.BackColor = Color.Lime
        End If
        pinout10 = Not (pinout10)
        SerialPort1.Close()
    End Sub
    Private Sub RectangleShape3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape3.Click
    End Sub
    Private Sub RectangleShape4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape4.Click
    End Sub
    Private Sub RectangleShape2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RectangleShape2.Click
    End Sub
End Class


Suerte con el proyecto. Gracias




domingo, 8 de julio de 2012

Visual Basic 2010 y Arduino – Servo control con LCD display.

 

En el post anterior presente como controlar un servo utilizando un Slider en Visual BASIC 2010, ahora les traigo una actualización para mejorar su apariencia y añadir nuevas funciones. Espero les guste, para que les funcione idéntico tienen que instalar un tipo de letra digital si no la tienen los dígitos no lucirán iguales, lo encontraran en el mismo sitio que este archivo. ( 11569_DIGITAL.ttf )



Enlace a la publicación anterior:
Arduino – Visual Basic 2010 Servo control con LCD display
 
Arduino Sketch
_______________________________________________________________________

// apcexpert.wordpress.com
// servo control con LCD display position
#include <Servo.h>
#include <LiquidCrystal.h>
Servo myservo;
int servoPosition = 1;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
lcd.begin(16, 2);
lcd.print("Servo Position:");
myservo.attach(13);
Serial.begin(9600);
}
void loop() {
static int val = 0;
lcd.setCursor(0, 1);
if(Serial.available()) {
char ch = Serial.read();
switch(ch) {
case '0'...'9':
val = val * 10 + ch - '0';
break;
case 's':
myservo.write(val);
lcd.print((float)val);
val = 0;
break;
}
}
}
_____________________________________________________________



Aquí les dejo el código fuente para que puedan comparar las diferencias:

Public Class ServoController
Private serialPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
With serialPort
.PortName = “COM3”
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
End With
serialPort.Open()
serialPort.Write(“0s”)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
serialPort.Write(TrackBar1.Value & “0s“)
ProgressBar1.Value = (TrackBar1.Value * 10)
TextBox1.Text = TrackBar1.Value * 10 & (” “)
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressBar1.Click
End Sub
End Class

APC Expert Files
(ServoController2)

Lectura de valores en el puerto analogo de arduino

 

En este proyecto podremos visualizar como trabaja el puerto análogo, es sencillo pero al comprenderlo podemos aplicarlo a muchas ideas como, Voltímetro, control de temperaturas para unidades de acondicionadores de aire, controladores de carga para bancos de baterías de sistemas solares o eólicos (molinos de viento), en fin son muchísimas las aplicaciones que podemos darle al Arduino utilizando los puertos análogos.

arduinoLedPotSerial

Los componentes los podemos ver en la imagen. Publicare tres Sketch para poder comprender como funciona el puerto análogo.

El primer Sketch podremos ver como al variar la posición del pot la lectura en el puerto análogo (pin 0) se reflejara en la velocidad con que el led prende y apaga. La variación será en milisegundos.


/*
Pot sketch
blink an LED at a rate set by the position of a potentiometer
*/
const int potPin = 0; // select the input pin for the potentiometer
const int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin); // read the voltage on the pot
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // blink rate set by pot value (in milliseconds)
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // turn led off for same period as it was turned on
}


En el segundo Sketch podremos observar como Arduino interpreta la variación de voltaje en el puerto análogo (pin0) y nos la mostrara en el Serial Monitor del programa Arduino como lo podrán ver en la imagen.

Podremos notar que cuando en el pin sea 0 Voltios el serial les mostrara 0 y cuando sea 5 Voltios entonces el serial les mostrara 1023, Los valores serán entre 0 Hasta 1023.

image


/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}


En el siguiente Sketch combinare los dos Sketch anteriores haciendo unas modificaciones al segundo para incorporarlo al primero, para que sirva de ejemplo.


/*
Pot sketch
blink an LED at a rate set by the position of a potentiometer
*/
const int potPin = 0; // select the input pin for the potentiometer
const int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

void loop() {
val = analogRead(potPin); // read the voltage on the pot
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // blink rate set by pot value (in milliseconds)
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // turn led off for same period as it was turned on

// read the input on analog pin 0:
int val = analogRead(potPin);
// print out the value you read:
Serial.println(val);
delay(1); // delay in between reads for stability
}


Esta parte es importante comprenderla porque será la base para otros proyectos que mostrare, como obtener lecturas remotas, pero será mas adelante. Espero les sirva para practicar, luego mostrare como hacer el voltímetro y el control de temperatura, para la próxima.

Arduino – Visual Basic 2010 Servo control con LCD display

 

DSCF1603
Arduino servo control. En este proyecto se utiliza un servo que estará controlado por una PC atabes de una aplicación creada en VB2010, Donde un Slider controlara la posición del servo y será desplegada en un LCD display.


Los servos vienen con dos códigos de colores:

1) Amarillo = señal Rojo = Voltaje  Marrón = Tierra

2) Blanco = señal Rojo = Voltaje  Negro = Tierra


Conexión del servo, Señal = pin13
Conexiones del
LiquidCrystal lcd(8,9,4,5,6,7);

Arduino servo control Sketch

// apcexpert.wordpress.com
// servo control con LCD display position
#include <Servo.h>
#include <LiquidCrystal.h>
Servo myservo;
int servoPosition = 1;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
lcd.begin(16, 2);
lcd.print("Servo Position:");
myservo.attach(13);
Serial.begin(9600);
}
void loop() {
static int val = 0;
lcd.setCursor(0, 1);
if(Serial.available()) {
char ch = Serial.read();
switch(ch) {
case '0'...'9':
val = val * 10 + ch - '0';
break;
case 's':
myservo.write(val);
lcd.print((float)val);
val = 0;
break;
}
}
}


Codigo fuente Visual Basic 2010 (ServoController1)

image

Public Class ServoController
Private serialPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
With serialPort
.PortName = “COM3”
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
End With
serialPort.Open()
serialPort.Write(“0s”)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
serialPort.Write(TrackBar1.Value & “0s”)
End Sub
End Class

(ServoController1)

Controlando 4 relays con Arduino y Visual Basic 2010

 

image


Para este proyecto se requiere un panel con 4 relays para poder controlar equipos de mayor potencia como motores compresores o simplemente para iluminación de una residencia u un almacén, Las aplicaciones son variadas.
Este control relay board lo pueden conseguirse en ebay.com, no tiene que ser igual al ilustrado, vienen de 2, 4, 8 relays y más. Lo seleccionaran de acuerdo a su proyecto.
Abajo encontraras el sketch de Arduino y el código fuente de VB2010, también dejare el lugar para bajar el archivo (Arduino4ChRelayControl) VB2010.
Espero les funcione bien y recuerden seleccionar el puerto de comunicación USB cuando corran la aplicación en sus PC yo utilizo el Com3, Suerte con el proyecto. Hasta la próxima.

Conecciones electricas:
Pin 13 – canal 1
pin 12 – canal 2
pin 11 – canal 3
pin 10 – canal 4
100_1047
                 
Arduino Sketch

// By: apcexpert.blogspot.com

int RL4 = 13; // the number of the Relay pin
int RL3 = 12;
int RL2 = 11;
int RL1 = 10;


void setup() {
 Serial.begin(9600); // set serial speed

 pinMode(RL4, OUTPUT); // set Relay as output
 digitalWrite(RL4, LOW); //turn off Relay

 pinMode(RL3, OUTPUT);
 digitalWrite(RL3, LOW);

 pinMode(RL2, OUTPUT);
 digitalWrite(RL2, LOW);

 pinMode(RL1, OUTPUT);
 digitalWrite(RL1, LOW);




 }

void loop(){
 while (Serial.available() == 0); // do nothing if nothing sent
 int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

if (val == 4) { // test for command 1 then turn on Relay
 Serial.println("Relay 4 on");
 digitalWrite(RL4, HIGH); // turn on Relay
 }

if (val == 3) {
 Serial.println("Relay 3 on");
 digitalWrite(RL3, HIGH); 
 }

 if (val == 2) {
 Serial.println("Relay 2 on");
 digitalWrite(RL2, HIGH);
 }

 if (val == 1) {
 Serial.println("Relay 1 on");
 digitalWrite(RL1, HIGH);
 }


 else if (val == 8) // test for command 0 then turn off LED
 {
 Serial.println("Relay 4 OFF");
 digitalWrite(RL4, LOW); // turn off LED
 }


  else if (val == 7)
 {
 Serial.println("Relay 3 OFF");
 digitalWrite(RL3, LOW);
 }

  else if (val == 6)
 {
 Serial.println("Relay 2 OFF");
 digitalWrite(RL2, LOW);
 }

  else if (val == 5)
 {
 Serial.println("Relay 1 OFF");
 digitalWrite(RL1, LOW);
 }




 else // if not one of above command, do nothing
 {
 //val = val;
 }
 Serial.println(val);
 Serial.flush(); // clear serial port
 }



(Arduino4ChRelayControl) Visual Basic 2010


Imports System.IO
Imports System.IO.Ports
Imports System.Threading

Public Class Form1
Shared _continue As Boolean
Shared _serialPort As SerialPort

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.PortName = (“com3”) ‘change com port to match your Arduino portSerialPort1.Close()
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default ‘very important!
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.Open()
SerialPort1.Write(“1”)
SerialPort1.Close()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SerialPort1.Open()
SerialPort1.Write(“2”)
SerialPort1.Close()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
SerialPort1.Open()
SerialPort1.Write(“3”)
SerialPort1.Close()
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
SerialPort1.Open()
SerialPort1.Write(“4”)
SerialPort1.Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SerialPort1.Open()
SerialPort1.Write(“5”)
SerialPort1.Close()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
SerialPort1.Open()
SerialPort1.Write(“6”)
SerialPort1.Close()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
SerialPort1.Open()
SerialPort1.Write(“7”)
SerialPort1.Close()
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
SerialPort1.Open()
SerialPort1.Write(“8”)
SerialPort1.Close()
End Sub

End Class

(Arduino4ChRelayControl)

Nueva version para arduino–Arduino1.0.1

 

Lo podrán conseguir en la pagina oficial en ingles – Download the Arduino Software ya que en la pagina en español no está actualizada o lo pueden bajar directamente aquí.


Download

Arduino 1.0.1 (release notes), hosted by Google Code:


Pueden elegir esta versión que ya esta actualizada para utilizar el sensor Ultrasónico HC-SR04 y el Motor Control Shield, si lo desean pinchen el icono del SKY DRIVE.

Esta versión la estaré actualizando cada vez que incluya nuevos componentes de programación, como Bluetooth, GPS, entre otras cosas.


Arduino1.0.1ACP Updated

Como instalar Arduino a unaPC con Windows7

 

Para poder programar nuestro Arduino tenemos que configurar nuestra computadora y en este caso será con Windows 7. Le mostrare los pasos y también el enlace a la pagina oficial de Arduino, en la sección de instalación.

Primero deben tener instalado el programa de Arduino, la versión mas actualizada en este momento es la del sitio en ingles – (http://arduino.cc/en/Main/Software) y la explicación la encontraran en el sitio en español – (http://arduino.cc/es/Guide/Windows).

Comenzare con la instalación:

Deben tener a mano su Arduino UNO y su cable USB, lo conectaran al puerto de su computadora, la maquina reconocerá el panel Arduino , podrán verificar en el Device Managerde sus computadoras, cuando lo localicen, debe verse similar a la siguiente imagen.

DeviceManager

Como podrán notar el icono del Arduino tiene una indicación de color amarillo, esto representa algún problema o error al instalar. Picaremos sobre Arduino Uno con el ratón y presionamos el botón derecho, nos mostrara una ventana y en ella seleccionaremos Update Driver Softwarecomo se puede observar en la imagen a continuación.

DeviceManager1

Luego Veremos la siguiente ventana:

UpdateDriver

Seleccione Browse my computer y pasara a la próxima ventana, en esta sección deben localizar el archivo conde instalaron el programa de Arduino, en este ejemplo lo instale en el desktop de mi maquina, buscaremos el folder Drivers y presionan el botón OK

UpdateDriver1

La siguiente ventana que verán les indicara una advertencia, seleccionen Istall this driver software anyway

UpdateDriver2

Esperaremos que termine la instalación. Cuando finalice abra reasignado el puerto, Veamos en la próxima imagen.

DeviceManager2

Luego sabiendo que le asigno el Puerto de comunicación Com8, Pasaremos a abrir al programa de Arduino, localizar el Modelo de nuestro micro controlador y liego el puerto de comunicación. Como veremos en las siguientes imágenes:

ArduinoSoftware1

ArduinoSoftware2

Ya para este momento estaremos listos para programar nuestro Arduino UNO. Espero que no tengan problemas. Hasta la próxima.

Medidor de distancias con LCD 16×2 y Sensor ultrasonico HC-SR04.

 

Este circuito ya se complica más, utilizare un Shield LCD +Keypad y el sensor sónico HC-SR04.Es el que estaremos utilizando frecuentemente en las pruebas. En esta ocasión veremos las lecturas, sin utilizar el puerto USB de nuestra PC. Al utilizar este shield, nos ahorramos complicaciones, y resulta un proyecto con mayor estética, luce mas profesional.

Ver imagen:

100_1031

Las conecciones son importantes:

VCC = 5Voltios

Trig= Conectar al pin #12

Echo= Conectar al pin #13

Gnd = Tierra

Aquí les dejo el sketch para instalarlo en el arduino, está en “cm” centímetros pero es sencillo cambiarlo a pulgadas.


// Ultrasonic.h – Library for HR-SC04 Ultrasonic Ranging Module.
// Rev. 2 (06/2011)
// www.arduino.com.es

#include <Ultrasonic.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
Ultrasonic ultrasonic(12,13); // (Trig PIN,Echo PIN)

void setup() {
lcd.begin(16, 2);
}

void loop()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(ultrasonic.Ranging(CM)); // CM para metrico y INC para pulgadas
lcd.print(” CM”);
delay(500);
}


Espero que no tengan problemas, solo funciona si el programa de arduino esta actualizado para el sensor sónico. Cualquier complicación, me dejan un comentario y tratare de ayudarles.

Medidor de distancias con ultrasonidos HC-SR04.

 

100_1030

Hola, este circuito de pruebas, es para familiarizarse con el sensor ultrasinico, lo utilizare para tomar distancias, estas se reflejaran en “cm” . Basicamente mide distancias calculando el tiempo en que emite el pulso sonico y lo recibe, demodo que lo pocras ver en tu PC cuandi activas el monitor serial.

Les mostrare como activar este monitor, es sensillo.

Ver imagen:

serial monitor

Ver imagen de como se comunica con el monitor serial.

serial monitor1

Las conecciones son importantes:

VCC = 5Voltios

Trig= Conectar al pin #12

Echo= Conectar al pin #13

Gnd = Tierra

Este es el Sketch que instalaran en su arduino, solo les fincionara si su programa de arduino esta actualizado para el sensor ultrasonico HC-SR04.


// Ultrasonic.h – Library for HR-SC04 Ultrasonic Ranging Module.
// Rev. 2 (06/2011)
// www.arduino.com.es

#include <Ultrasonic.h>
Ultrasonic ultrasonic(12,13); // (Trig PIN,Echo PIN)

void setup() {
Serial.begin(9600);
}

void loop()
{
Serial.print(ultrasonic.Ranging(CM)); // CM or INC
Serial.println(” cm” );
delay(100);
}


Hasta la proxima.

Sensor ultrasonico HC-SR04

 

Para poder trabajar con este sensor ultrasónico debeos instalar un archivo en nuestro programa de Arduino 1.01, Debemos localizar el folder (libraries) y crear un subfolder (Ultrasonic) y hay copiaremos los archivos. Debería verse de esta manera si se realizo bien.

Ultrasonic.zip


ultrasonicFiles

Verificaremos en el programa de Ardiono para ver si esta correcto y se realizo bien, debería verse de esta manera.

ArduinoUltrasonic1

De aquí en adelante estaremos listos para realizar las diferentes pruebas o aplicaciones, que discutiré mas adelante.

Aqui esta el manual en formato pfd para referencias.

Manualhttp://www.accudiy.com/download/HC-SR04_Manual.pdf

HC-SR041