{"id":1235,"date":"2017-11-13T01:02:27","date_gmt":"2017-11-13T06:02:27","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/taws\/?p=1235"},"modified":"2017-11-13T01:02:27","modified_gmt":"2017-11-13T06:02:27","slug":"control-velocidad-y-sentido-de-motor-dc","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/taws\/2017\/11\/13\/control-velocidad-y-sentido-de-motor-dc\/","title":{"rendered":"CONTROL VELOCIDAD Y SENTIDO DE MOTOR DC"},"content":{"rendered":"<p><span style=\"font-weight: 400\">En esta gu\u00eda vamos a controlar la velocidad y el sentido de un motor DC a trav\u00e9s de un potenci\u00f3metro desde Arduino.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Materiales:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Arduino Uno<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Un switch<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Un puente H L293d <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Un potenci\u00f3metro <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Jumpers<\/span><\/li>\n<\/ul>\n<p><b>Arduino uno<\/b><\/p>\n<p><a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/arduino.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1236\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/arduino-300x204.png\" alt=\"\" width=\"300\" height=\"204\" srcset=\"https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/arduino-300x204.png 300w, https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/arduino.png 476w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">Es un microcontrolador basado en ATmega328, tiene un voltaje de funcionamiento de 5V, el voltaje de entrada recomendado va de 7V a los 12V, con voltaje l\u00edmites de 6V a 20V, cuenta con 14 pines de entrada y salida (de los cuales 6 proporcionan salida PWM), 6 pines para entrada anal\u00f3gica, y una memoria flash de 32 KB.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>Switch<\/b><\/p>\n<p><span style=\"font-weight: 400\">El switch o interruptor, es un dispositivo que permite desviar o interrumpir el curso de una <\/span><a href=\"https:\/\/es.wikipedia.org\/wiki\/Corriente_el%C3%A9ctrica\"><span style=\"font-weight: 400\">corriente el\u00e9ctrica<\/span><\/a><span style=\"font-weight: 400\">. En el mundo moderno sus tipos y aplicaciones son innumerables, desde un simple interruptor que apaga o enciende una <\/span><a href=\"https:\/\/es.wikipedia.org\/wiki\/L%C3%A1mpara_incandescente\"><span style=\"font-weight: 400\">bombilla<\/span><\/a><span style=\"font-weight: 400\">, hasta un complicado selector de transferencia autom\u00e1tico de m\u00faltiples capas, controlado por <\/span><a href=\"https:\/\/es.wikipedia.org\/wiki\/Computadora\"><span style=\"font-weight: 400\">computadora<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/p>\n<p><b>Puente H L293d<\/b><\/p>\n<p><a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/puenteh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1237\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/puenteh.png\" alt=\"\" width=\"281\" height=\"126\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">El puente H es un circuito electr\u00f3nico que permite a un motor el\u00e9ctrico DC girar en ambos sentidos.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Se construye con 4 interruptores (S1,S2,S3,S4). Cuandos los interruptores S1 y S4 est\u00e1n cerrados (S2 y S3 abiertos) se aplica una tensi\u00f3n haciendo girar el motor en un sentido. Abriendo los interruptores S1 y S4 (cerrando S2 y S3), el voltaje se invierte, permitiendo el giro en sentido inverso del motor.<\/span><\/p>\n<p><a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/cricuito1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1240\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/cricuito1-300x191.png\" alt=\"\" width=\"300\" height=\"191\" srcset=\"https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/cricuito1-300x191.png 300w, https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/cricuito1.png 329w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/tabla-verdad.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1241\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/tabla-verdad.png\" alt=\"\" width=\"235\" height=\"178\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">El circuito interno del L293D forma 2 puentes H, por lo que podemos manejar 2 motores. En este caso el manejo ser\u00e1 bidireccional, con frenado r\u00e1pido y con posibilidad de implementar f\u00e1cilmente el control de velocidad. Se puede manejar cargas de potencia media, en especial peque\u00f1os motores y cargas inductivas, con la capacidad de controlar corriente hasta 600 mA en cada circuito y una tensi\u00f3n entre 4,5 V a 36 V.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>POTENCI\u00d3METRO:<\/b><\/p>\n<p><a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/potenciometro.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1238 aligncenter\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/potenciometro-300x150.png\" alt=\"\" width=\"300\" height=\"150\" srcset=\"https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/potenciometro-300x150.png 300w, https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/potenciometro.png 511w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">Un potenci\u00f3metro es una resistencia variable, el diagrama interno del potenci\u00f3metro para la conexi\u00f3n hecha en el proyecto es como el que se muestra en la imagen de la derecha, donde al girar la perilla van a variar los valores de R1 y R2, haciendo que la se\u00f1al de voltaje Vout tambien cambie, y de forma proporcional a este cambio, la velocidad del motor var\u00eda.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>PWM<\/b><\/p>\n<p><span style=\"font-weight: 400\">El PWM o<\/span><i><span style=\"font-weight: 400\"> Modulador por anchura de pulsos <\/span><\/i><span style=\"font-weight: 400\">es una se\u00f1al digital cuadrada en el cual podemos variar el ciclo de trabajo (tiempo ON) sin variar la frecuencia.<\/span><span style=\"font-weight: 400\"><br \/>\n<a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/pwm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1239 aligncenter\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/pwm-231x300.png\" alt=\"\" width=\"231\" height=\"300\" srcset=\"https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/pwm-231x300.png 231w, https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/pwm.png 291w\" sizes=\"auto, (max-width: 231px) 100vw, 231px\" \/><\/a><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400\">En pocas palabras, consiste en aumentar el tiempo en el cual se mantiene la se\u00f1al alta de voltaje, hasta que el tiempo en el que se encuentre en 0V sea tan peque\u00f1o que se perciba como una se\u00f1al continua con voltaje alto. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Para controlar la velocidad y el giro del motor, usaremos las entradas PWM de nuestro Arduino.<\/span><\/p>\n<p>El v\u00eddeo de la simulaci\u00f3n del proyecto lo puedes encontrar aqu\u00ed:\u00a0<a href=\"https:\/\/www.dropbox.com\/s\/uwuhi1t2el98nbq\/bandicam%202017-11-12%2012-17-26-828.avi?dl=0\">https:\/\/www.dropbox.com\/s\/uwuhi1t2el98nbq\/bandicam%202017-11-12%2012-17-26-828.avi?dl=0<\/a><\/p>\n<p><b>DIAGRAMA DE CONEXI\u00d3N:<\/b><\/p>\n<p><a href=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/Screenshot-from-2017-11-13-00.45.46.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1243 aligncenter\" src=\"http:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/Screenshot-from-2017-11-13-00.45.46-300x145.png\" alt=\"\" width=\"598\" height=\"289\" srcset=\"https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/Screenshot-from-2017-11-13-00.45.46-300x145.png 300w, https:\/\/blog.espol.edu.ec\/taws\/files\/2017\/11\/Screenshot-from-2017-11-13-00.45.46.png 605w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><b>C\u00d3DIGO:<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">int in1=8; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Entrada 2 del L293D<\/span><\/p>\n<p><span style=\"font-weight: 400\">int in2=9; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Entrada 7 del L293D<\/span><\/p>\n<p><span style=\"font-weight: 400\">int enable1=10; \u00a0\u00a0\/\/Entrada 1 del L293D<\/span><\/p>\n<p><span style=\"font-weight: 400\">int sw = 7; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/recibe el estado del Switch<\/span><\/p>\n<p><span style=\"font-weight: 400\">int pote=A0; \u00a0\u00a0\u00a0\u00a0\u00a0\/\/Potenci\u00f3metro<\/span><\/p>\n<p><span style=\"font-weight: 400\">int valorpote; \u00a0\u00a0\u00a0\u00a0\/\/Variable que recoge el valor del potenci\u00f3metro<\/span><\/p>\n<p><span style=\"font-weight: 400\">int pwm; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Variable del pwm<\/span><\/p>\n<p><span style=\"font-weight: 400\">int giro; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/variable para definir el sentido de giro del motor<\/span><\/p>\n<p><span style=\"font-weight: 400\">void setup()<\/span><\/p>\n<p><span style=\"font-weight: 400\">{<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Inicializamos los pins de salida<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pinMode(in1,OUTPUT);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pinMode(in2, OUTPUT);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pinMode(enable1, OUTPUT);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pinMode(sw,INPUT);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pinMode(pote,INPUT);<\/span><\/p>\n<p><span style=\"font-weight: 400\">}<\/span><\/p>\n<p><span style=\"font-weight: 400\">void loop()<\/span><\/p>\n<p><span style=\"font-weight: 400\">{<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Almacenamos el valor del potenci\u00f3metro en la variable<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0valorpote=analogRead(pote);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Almacena el estado del switch que define el sentido de giro<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0giro = digitalRead(sw);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Como la entrada anal\u00f3gica del Arduino es de 10 bits, el rango va de 0 a 1023.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/En cambio, la salidas del Arduio son de 8 bits, quiere decir, rango entre 0 a 255.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Por esta raz\u00f3n tenemos que mapear el n\u00famero de un rango a otro usando este c\u00f3digo.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0pwm = map(valorpote, 0, 1023, 0, 255);<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Cuando el Switch esta abierto entonces el motor girar\u00e1 en un sentido.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0if (giro==HIGH){<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0digitalWrite(in1, LOW);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0digitalWrite(in2, HIGH);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0analogWrite(enable1, pwm);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0}<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\/\/Cuando el Switch esta cerrado entonces el motor girar\u00e1 en el otro sentido.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0else{<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0digitalWrite(in1, HIGH);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0digitalWrite(in2, LOW);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0\u00a0\u00a0analogWrite(enable1, pwm);<\/span><\/p>\n<p><span style=\"font-weight: 400\"> \u00a0}<\/span><\/p>\n<p><span style=\"font-weight: 400\">}<\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En esta gu\u00eda vamos a controlar la velocidad y el sentido de un motor DC a trav\u00e9s de un potenci\u00f3metro desde Arduino. Materiales: Arduino Uno Un switch Un puente H L293d Un potenci\u00f3metro Jumpers Arduino uno Es un microcontrolador basado en ATmega328, tiene un voltaje de funcionamiento de 5V, el voltaje de entrada recomendado va [&hellip;]<\/p>\n","protected":false},"author":10270,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1257],"tags":[586196],"class_list":["post-1235","post","type-post","status-publish","format-standard","hentry","category-actualidad","tag-arduino"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/posts\/1235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/users\/10270"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/comments?post=1235"}],"version-history":[{"count":1,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/posts\/1235\/revisions"}],"predecessor-version":[{"id":1244,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/posts\/1235\/revisions\/1244"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/media?parent=1235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/categories?post=1235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/taws\/wp-json\/wp\/v2\/tags?post=1235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}