viernes, 26 de abril de 2013

Velocidad y sentido | Speed and direction:

Además de controlar la velocidad también nos interesa controlar el sentido de la marcha. Para lograr esto sin necesidad de utilizar componentes electromecánicos como los relés existen varias soluciones, una de ellas es el puente H.

Un puente H consta de 4 interruptores que dejan pasar la electricidad en un sentido o en otro. Veamos el siguiente esquema:
In addition to controlling the speed we also want to control the direction of travel. To accomplish this without the use of electromechanical elements as relays as there are several solutions, one of which is the H bridge.

An H bridge consists of 4 switches that let electricity in one direction or another. Consider the following diagram:


Puente H.
H Bridge.


Si cerramos SW3 y SW2 dejamos pasar la corriente desde el polo positivo del motor al negativo, por lo tanto el tren se mueve hacia adelante. Si por el contrario, cerramos SW1 y SW4 dejamos pasar la corriente al revés y el tren se moverá hacia atrás. Este circuito se puede construir con cualquier tipo de interruptor, ya sea manual o electromecánico, pero lo óptimo es hacerlo con transistores. De hecho existen en el mercado circuitos integrados que contienen el puente H. Uno de estos circuitos es el L293 (36V 1A).

Para controlar este circuito con Arduino necesitamos una salida PWM y dos salidas digitales para controlar el sentido de giro del motor.Una de estas salidas controla SW1 y SW4, y la otra controla SW2 y SW3.
If we close SW3 and SW2 then the current pass from the positive pole to the negative pole of motor, so the train moves forward. If, however, we close SW1 and SW4 the current pass backwards and the train will move back. This circuit can be built with any type of switch, either manual or electromechanical, but it is optimal to do with transistors. In fact exist on the market integrated circuits containing the H bridge. One of these circuits is the L293 (36V 1A).

To control this circuit with Arduino we need a PWM output and two digital outputs for controlling the rotational direction of the motor. One of these outputs controls SW1 and SW4, and the other one controls SW2 and SW3.


Ejemplo de conexiones.
Example of connections.

Esquema.
Schematic.


El siguiente bloque de código muestra la forma de cambiar de sentido, simplemente activando y desactivando los pins asignados al L293:
The following piece of code shows how to change direction by simply activating and deactivating the assigned pins to the L293:



 
...
void SetDirection()
{
  switch(_dir)
  {

    case Left:
      digitalWrite(dirPin0, LOW);
      digitalWrite(dirPin1, HIGH);
      break;

    case Right:
      digitalWrite(dirPin0, HIGH);
      digitalWrite(dirPin1, LOW);
      break;
      
    default:
      digitalWrite(dirPin0, LOW);
      digitalWrite(dirPin1, LOW);
      break;

  }

}
...
 


Como en el artículo anterior, he hecho un pequeño ejecutable en VB.Net 4.0 para controlar tanto la velocidad como el sentido del tren.
As in the previous post, I made a small executable in VB.Net 4.0 to control both the speed and the direction of the train.


Ejecutale VB.
VB Executable.




Descargas:
Downloads:


ArduinoL293.zip



Enlaces:
Links:


L293 (EN): http://www.ti.com/lit/ds/symlink/l293d.pdf
Puente H (ES): http://es.wikipedia.org/wiki/Puente_H_(electrónica)
H Bridge (EN): http://en.wikipedia.org/wiki/H_bridge




No hay comentarios:

Publicar un comentario