Documentos de Académico
Documentos de Profesional
Documentos de Cultura
DE CARTAGENA
AUTOMATIZACIÓN DE
ENVASADORA DE LÍQUIDOS
CON INTERFAZ HTML
Índice
Resumen ........................................................................................................................................ 3
Abstract ......................................................................................................................................... 4
1. Introducción .............................................................................................................................. 5
2. Objeto del trabajo ...................................................................................................................... 6
3. Motivación ................................................................................................................................ 7
4. Metodología .............................................................................................................................. 7
4.1. Asesoramiento ................................................................................................................... 7
4.2. Trabajos a realizar ............................................................................................................. 7
4.3. Consideraciones previas .................................................................................................... 8
4.4. Documentación.................................................................................................................. 9
5. Componentes del sistema .......................................................................................................... 9
5.1. Sensores Switch de posición ............................................................................................. 9
5.2. Motor paso a paso ........................................................................................................... 10
5.2.1. Requisitos .......................................................................................................................... 11
5.2.2. Selección del motor ........................................................................................................... 11
5.2.3. Posicionamiento ................................................................................................................ 12
5.3. Driver para control de motor de paso .............................................................................. 13
5.3.1. Requisitos .......................................................................................................................... 13
5.3.2. Selección del driver ........................................................................................................... 14
5.4. Elección de hardware controlador ................................................................................... 14
5.5. Módulo para conexión Smartphone-Arduino .................................................................. 15
5.5.1. Requisitos .......................................................................................................................... 15
5.5.2. Selección del módulo ........................................................................................................ 15
5.6. Relación de engranajes para unir motor y tornillo .......................................................... 16
5.6.1. Requisitos .......................................................................................................................... 16
5.6.2. Selección de los engranajes ............................................................................................... 16
5.6.3. Posicionamiento ................................................................................................................ 17
5.7. Mangas de llenado y válvulas antirretorno...................................................................... 17
6. Estudio, cálculo y programación de los movimientos del motor ............................................ 18
6.1. Sentido de giro ................................................................................................................ 18
6.2. Pasos por vuelta y relación distancia switch/giro motor. ................................................ 19
6.3. Programación .................................................................................................................. 20
7. Resultados experimentales ...................................................................................................... 21
7.1. Experimentación con autómata ....................................................................................... 21
7.2. Experimentación con nuevo sistema integrado ............................................................... 22
7.2.1. Control de motor paso a paso ............................................................................................ 22
7.2.2. Cambio de formatos preestablecidos................................................................................. 23
7.2.3. App Formatos Envasadora ................................................................................................ 23
8. Conclusiones ........................................................................................................................... 24
Referencias .................................................................................................................................. 25
ANEXOS..................................................................................................................................... 25
1
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Índice de Figuras
Figura 1. Esquema de la llenadora. (Empakando, 2018)............................................................... 5
Figura 2. Esquema industria 4.0 (Larraioz, 2018) ......................................................................... 6
Figura 3. Esquema gráfico del funcionamiento de la envasadora. (Elaborada por autor) ............ 7
Figura 4. Cilindro de doble efecto con sensores magnéticos (Velázquez, 2012) .......................... 8
Figura 5. Sensor Switch Modelo CS1-U. (RS Componentes, 2018)............................................. 9
Figura 6. Sensores Switch instalados en la llenadora. (Elaborada por autor) ............................. 10
Figura 7. Clasificación de motores eléctricos (Área Tecnología, 2012) .................................... 10
Figura 8. Encoder óptico para contar vueltas del motor (Suppress, 2008) ................................. 11
Figura 9. Motor de paso unipolar de imán permanente (RS Components, 2018) ....................... 12
Figura 10. Diseño de la instalación del motor en la envasadora. (Elaborada por autor) . ........... 13
Figura 11. Tipos de drivers de control para motores eléctricos. (Elaborada por autor) . ............ 13
Figura 12. Módulo Pololu A4988 para motores de paso. (ElectroCrea 2018) . .......................... 14
Figura 13. Arduino modelo UNO. (Arduino, 2012).................................................................... 15
Figura 14. Módulo Bluetooth HC-06. (Prometec, 2017) ............................................................ 16
Figura 15. Engranajes para el motor y para la varilla roscada. (RS Components, 2018) ............ 17
Figura 16. Diseño de la instalación de los engranajes. (Elaborada por autor) ............................ 17
Figura 17. Mangas y válvulas de la llenadora. (Elaborada por autor) ......................................... 18
Figura 18. Esquema de conexiones entre Arduino, A4988 y motor de paso (RobotStore)......... 18
Figura 19. Líneas de código con condiciones if () ...................................................................... 20
Figura 20. Líneas de código con bucle for () .............................................................................. 21
Figura 21. Llamada a la librería de Bluetooth ............................................................................. 21
Figura 22. Interfaz App Control Motor de Paso (Elaborada por autor) ...................................... 22
Figura 23. Interfaz App Cambio de Formatos Preestablecidos (Elaborada por autor)............... 23
Figura 24. Interfaz App Envasadora (Elaborada por autor) ........................................................ 24
Índice de Tablas
Tabla 1. Tipos de envasadoras. (Cortés, 2010) ........................... ¡Error! Marcador no definido.
Tabla 2. Distancia recorrida en función de las vueltas de la varilla ............................................ 19
Tabla 3. Volúmenes y distancias de llenado .............................................................................. 20
Tabla 4. Relación entre volumen y pasos del motor ................................................................... 19
Anexos
Anexo A. Programa en Ladder de control con autómata.
Anexo B. Datasheet sensores Switch del pistón.
Anexo C. Datasheet Motor de Paso.
Anexo D. Datasheet Driver A4988.
Anexo E. Datasheet Arduino UNO.
Anexo F. Datasheet Módulo Bluetooth HC-06.
Anexo G. Datasheet Engranaje eje motor.
Anexo H. Datasheet Engranaje varilla roscada.
Anexo I. Programa Arduino.
Anexo J. Programa bloques App.
2
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Resumen
En la actualidad en cualquier tipo de industria se busca la automatización de la mayor parte
de los componentes y máquinas, ya que de este modo se consiguen mejores resultados en cuanto
a producción, costes económicos y esperas que conlleven pérdidas. Por otro lado, el hecho de
tener automatizado un proceso brinda al fabricante más información (y en tiempo real) de qué
está sucediendo en una línea de fábrica.
En concreto, las industrias que trabajan envasando líquidos requieren de una gran red de
sensores y autómatas, los cuales se encargarán junto con el personal de planta, de evitar problemas
que puedan provocar derrames, contaminación, incluso la rotura por cortocircuito de equipos
eléctricos y electrónicos.
La fase experimental del trabajo se ha dividido en 4 etapas: Control del sistema con autómata,
instrumentación de la plataforma, selección de hardware (Arduino) y programación del sistema.
El control del sistema con autómata se ha realizado con un PLC Siemens S7-1200 a través del
programa TIA Portal. La instrumentación de la plataforma se ha completado añadiendo a los
componentes de serie de la máquina un motor de paso, un Arduino UNO con un módulo Bluetooth
HC-06 y un driver A4988 y unos engranajes para optimizar el uso del par de giro del motor. Como
se ha mencionado, el hardware es el modelo UNO de Arduino, el cual será controlado con su
propio programa, y la aplicación móvil será programada a través del MIT APP Inventor 2 para
Android.
La solución más óptima para el problema que se plantea con esta envasadora ha sido asignar
en la aplicación botones que controlan el sentido de giro del motor, así como varias velocidades
de giro, para poder situar el Switch de posición en el lugar deseado para llenar botellas de un
volumen u otro. De este modo la regulación de la máquina es mucho más rápida que de forma
manual. Sin duda hay hardwares más robustos que Arduino, con los cuales se puede obtener un
sistema más fiable respecto a salpicaduras y ruido electrónico, pero con éste es suficiente para
obtener el funcionamiento deseado.
3
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Abstract
Nowadays, in any type of industry, the automation of most of the components and machines
is required, in this way, better results are achieved in terms of production, economic costs and
waiting times that lead to losses. On the other hand, having an automated process gives the
manufacturer more information (in real time) about what is happening on a production line.
In particular, the industries that work with liquid packaging require a large network of sensors
and automatons, which together with the plant personnel will be in charge of avoiding problems
that may cause spillage, contamination, or even breakage due to short-circuit of electrical and
electronic equipment.
The aim of this project is to automate a bottle filler of various formats, which consists of a
horizontal deposit with two non-return valves (one in each direction), which is filled and emptied
through the movement of a double-acting pneumatic cylinder. What will be done to automate this
machine is to install a stepper motor in the worm screw that moves the switch for the extended
piston, and with the help of an Arduino and an App for smartphones it will be possible to control
the volume of the tank to be filled, and therefore the size of the bottles to be used.
The experimental phase of the project is divided into 4 stages: System control with PLC,
platform instrumentation, hardware selection (Arduino) and system programming. The control of
the system with PLC has been carried out with a Siemens S7-1200 PLC through the TIA Portal
program. The platform's instrumentation has been completed by adding a stepper motor, an
Arduino UNO with a Bluetooth HC-06 module and an A4988 driver and gears to the machine's
standard components to optimize the use of the engine's torque. As mentioned, the hardware is
Arduino's UNO model, which will be controlled with its own program, and the mobile application
will be programmed through MIT APP Inventor 2 for Android.
The most optimal solution to the problem with this machine has been to assign buttons in the
application that control the direction of rotation of the motor, as well as several speeds of rotation,
to be able to place the position switch in the desired place to fill bottles of one volume or another.
This makes machine adjustment much faster than manual adjustment. There are certainly more
robust hardware than Arduino, with which you can obtain a more reliable system with respect to
splashes and electronic noise, but with this one is enough to obtain the desired operation.
4
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
1. Introducción
Una envasadora de líquidos es aquella máquina que se encarga de extraer una cantidad de
fluido de un tanque para introducirlo en un recipiente o envase de menor tamaño, en función de
cómo se realice este movimiento del líquido, existen varios tipos. Partimos de que todas ellas
pueden ser manuales, semiautomáticas, o automáticas.
Por gravedad Sin ayuda para realizar el llenado
Por bomba El líquido se bombea desde el
tanque a los recipientes. Fluidos
densos.
Por pistón Un pistón o pistones se encargan
de absorber y verter el líquido en
los envases (nuestro caso)
Por medición de caudal De alta precisión, un caudalímetro
mide el líquido exacto que fluye
Por presión o vacío Se controla por soplado o aspirado
la presión interna del envase
Tabla 1. Tipos de envasadoras. (Cortés, 2010)
Este trabajo va a realizarse sobre una llenadora por pistón, la cual absorbe el fluido del tanque
cuando el pistón se retrae, y lo suelta hacia el envase cuando el pistón vuelve a salir por
accionamiento neumático. La composición original de la máquina, sin tener todavía añadidos el
motor, engranajes, Arduino, etc. es la que vemos en la figura 1.
Este tipo de llenadoras se utilizan para líquidos generalmente densos, como pueden ser geles
y champús, así como otros productos de higiene (cremas, suavizantes…), por otro lado en el
ámbito de la alimentación se emplean para trabajar con masas, o salsas ligeramente densas, es por
ello por lo que se emplea un pistón neumático con un gran empuje para mover los fluidos.
5
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Hoy en día se está implantando en gran cantidad de factorías lo que se conoce como Industria
4.0, la cual consiste en tener los procesos automatizados, información de los sensores en tiempo
real, grandes bases de datos almacenados para conocer como evoluciona el trabajo, etc. Como
puede contemplarse es necesario tener todo relacionado y ligado a través de dispositivos
conectados a una red interna, y así poder controlar y medir lo que está sucediendo desde cualquier
punto de la fábrica.
Para lograr este objetivo se seguirá un procedimiento que se divide en 3 etapas: entender y
conseguir el funcionamiento de la llenadora con ayuda de un autómata o PLC, tras esto, añadir
un sistema físico para situar el sensor del émbolo y más adelante será programada una App (apk
de MIT App Inventor 2) para smartphones y tablets (Sistema operativo Android) con la cual se
controlarán ciertas funciones de un Arduino UNO, que dará las ordenes propias al motor que será
instalado en la máquina original, con esto podrá seleccionarse un formato u otro con el que
trabajará la llenadora.
En la figura 3 puede verse un esquema gráfico del funcionamiento del sistema una vez
terminado, en el cual aparecen los principales componentes de la máquina (los cuales serán
explicados más adelante) y señalados con colores los flujos de líquido que se dan en el proceso.
6
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
3. Motivación
El hecho de poder tener un control en tiempo real de un proceso en una línea de llenado facilita
el trabajo por parte de los operarios de fábrica, y da a conocer a los encargados o supervisores
aquello que está pasando en todo momento, incluidos los posibles fallos o problemas que puedan
darse en la maquinaria. Todo esto implica un ahorro económico notable y un rendimiento de
producción más elevado.
4. Metodología
4.1. Asesoramiento
En primer lugar, el asesoramiento ha sido por parte del Departamento de Ingeniería de
Sistemas y Automática, cuyos docentes han sido de gran ayuda en la toma de decisiones sobre los
montajes y la instalación eléctrica. Por otro lado, el departamento de Electrónica también ha sido
de ayuda para la programación de Arduino con ciertos componentes como la fuente de tensión o
el driver del motor de paso. En tercer lugar, cabe mencionar a la empresa Inquivisa S.L. Una
empresa de productos químicos con numerosas envasadoras/llenadoras de distintos modelos y
totalmente automatizadas, que sirven de apoyo para visualizar el funcionamiento y la posición de
sensores y actuadores.
7
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
contemplar soluciones al problema al cual nos enfrentamos. Más adelante será diseñada e
implantada la solución mecánica al sistema, y tras esto, se efectuará una búsqueda meticulosa de
los componentes más adecuados para cumplimentar dicha solución (compra de motor, engranajes,
fuente de tensión, módulos electrónicos…), solamente quedará diseñar la aplicación y comprobar
el correcto funcionamiento del bloque depurando el programa y haciéndolo lo más robusto
posible.
➢ Localización del émbolo: el pistón dispone de dos sensores Switch de posición que
detectan el lugar donde se encuentra el émbolo (extendido o recogido), y el sensor de
cilindro estirado será el que podrá ser desplazado y con el que trabajaremos.
➢ Reducción de engranajes: para transformar el giro del motor de paso en movimiento
longitudinal del sensor ya comentado, será necesaria una reducción de engranajes que
permitan ligar las partes y transformar el movimiento.
➢ Modificaciones físicas: la máquina no podrá ver afectado el bloque sobre el que se
encuentra montada, por lo que se buscará una forma de instalar el motor que no afecte
a la solidez y diseño del conjunto, por lo que se montará externamente.
➢ Consideraciones mecánicas de los componentes: son numerosos los tipos de motores
que existen en el mercado, así como optoacopladores, módulos de control, drivers y
hardwares para automatizar sistemas, etc. Por ello se debe realizar una búsqueda
meticulosa y consultando con el director del proyecto cual es la elección más óptima.
➢ Coste económico: ya que se efectuará alguna compra en la realización del trabajo,
tendrá que contemplarse y compararse entre proveedores el precio de cada uno de los
elementos que vayan a ser comprados.
Se parte de la idea principal de que se desea que el cambio de posición del sensor de la
llenadora sea más rápido que girando el tornillo sin fin manualmente, lo cual implica un gran
gasto de tiempo, y es el problema básico que queremos solventar.
La flecha roja de la figura 4 indica el sensor que se puede desplazar sobre el tornillo sin fin,
con el cual se modificará el volumen de llenado que envasa nuestro sistema.
8
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
4.4. Documentación
Para documentarse respecto al proyecto que se trata se ha acudido a diversas webs y empresas
que trabajan con máquinas similares y automatizadas, para asimilar el funcionamiento y poder
llevar esos conocimientos a nuestro caso.
En primer lugar, ha servido de gran apoyo la maquinaria de la empresa Inquivisa S.L. con
hasta 10 líneas de llenado de productos químicos, y entre las llenadoras, 2 muy similares a la
envasadora por pistón que se trata en el proyecto. Dichas llenadoras son automatizadas por medio
de autómatas, estos aparatos funcionan de una manera parecida al hardware que vamos a utilizar,
pero la solución que se ha planteado debe realizarse con una plataforma como es Arduino.
Por otro lado, se ha contactado con proveedores de componentes eléctricos y electrónicos con
conocimientos en el campo de llenadoras de líquidos y sistemas automáticos, algunas de las
empresas con las que se ha intercambiado información para implantar la mejor solución en
dispositivos y materiales son: Sumymaq, Electromain S.L., RS España.
De cara a la programación para el control del motor de paso unipolar se ha recurrido a la web
E-Elektronic.com, con numerosos ejemplos de programas para controlar motores con y sin
optoacoplador por medio de Arduino y un driver A4988 como el que se instalará en la máquina.
Por otro lado, el switch que se cierra cuando el pistón sale es móvil, lo cual significa que con
ayuda de un tornillo sin fin puede ser desplazado en dirección longitudinal en ambos sentidos
para aumentar o reducir el volumen de llenado del aparato. Esto es lo que va a dar juego a la
máquina y el parámetro que se va a automatizar, en la figura 6 se contempla la instalación.
9
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
10
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
5.2.1. Requisitos
Se precisa un motor con una velocidad nominal alta, pero no demasiado para no llegar a
descontrolarse cuando esté en funcionamiento. La función del motor será, a través de una cadena
de engranajes, girar la varilla o tornillo sin fin donde se encuentra alojado el switch del vástago
extendido. Con ello, el par de dicho motor tampoco necesita ser muy elevado, ya que como puede
experimentarse en la máquina, el giro del tornillo es muy suave.
Respecto a la alimentación, los motores de alterna suelen tener aplicaciones más industriales
y normalmente tienen características que sobrepasan nuestro caso, a la vez que tienen precios
mayores. Por lo tanto, se busca un motor de continua y una fuente de tensión CC para poder
utilizarlo, obviamente.
La instalación del motor será sobre un sistema o estructura con placas metálicas de un grosor
de 2 mm, así que el peso no debe ser muy notable (los motores tienen incluidos electroimanes con
grandes devanados y esto aumenta su peso) para no doblar ni provocar vibraciones en el conjunto.
Por último, algo que se debe poder hacer con el motor es controlar su movimiento y contar las
vueltas que da para situar de la mejor manera posible el sensor en su posición.
Figura 8. Encoder óptico para contar vueltas del motor (Suppress, 2008)
11
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
El problema de esta solución es que los ejes de los motores a los que se le puede conseguir un
encoder son demasiado pequeños, sumándose a esto que las combinaciones se ven reducidas y se
complica la búsqueda del conjunto notablemente.
Puesto que el motor-encoder queda descartado, se optará por buscar entre los motores de paso
a paso, los cuales tienen un sistema formado por varios bobinados que nos permiten (con una
serie de cables) contar o medir los pasos que gira el motor. Con ello se cubren todos los requisitos
buscados. Entre los motores de paso existen los bipolares y los unipolares, la diferencia está en
las salidas que contienen (4 los bipolares, 6 u 8 los unipolares), pero independientemente de esto
el funcionamiento y la conexión es muy similar. El modelo escogido es un motor paso a paso,
7.5° de giro por paso, bobinado unipolar, tipo imán permanente, 6 Cables, Par 0.24Nm, 12,7 Vdc,
del fabricante Crouzet, con referencia nº 82940003. Toda la información técnica del motor está
recogida en el anexo C (RS Components).
5.2.3. Posicionamiento
El posicionamiento del motor se realizará en una placa metálica de 2 mm de grosor, la cual se
atornillará en el lateral de la bancada de la llenadora original. Dicha placa soportará al motor de
forma horizontal, de modo que un engranaje en el eje del mismo interactúe con otro colocado en
el tornillo sin fin del sensor switch. En la figura 10 puede verse un diseño o simulación de cómo
quedará el motor instalado sobre el sistema.
12
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Figura 10. Diseño de la instalación del motor en la envasadora. (Elaborada por autor)
Figura 11. Diferentes tipos de drivers de control para motores eléctricos. (Elaborada por autor)
5.3.1. Requisitos
Para el motor que se ha seleccionado, se requiere que el driver pueda controlar un dispositivo
que trabajará con unos 12 voltios de continua, por lo tanto, a la salida del driver será esto lo que
se contemple. Por otro lado, el stepper tiene 6 salidas (de las cuales utilizaremos 4, ya que 2 son
13
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
comunes que no es necesario conectar) así que se busca un driver para motores de paso de 12 Vdc
y 4 entradas.
Respecto al controlador, la gran mayoría de estos “cerebros” electrónicos dan una tensión de
salida de 5 Vdc, la cual va a recibir el driver y por lo tanto ya se conoce cómo van a ser la entrada
y salida del aparato.
Figura 12. Módulo Pololu A4988 para motores de paso. (ElectroCrea 2018)
14
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
5.5.1. Requisitos
Los requisitos de esta conexión son bastante básicos, debe realizarse de manera inalámbrica,
lo cual evite al operario estar junto a la máquina cuando esté controlándola y permitirle estar a
cierta distancia (una red wifi local de la empresa permitiría el control desde cualquier punto de la
fábrica).
15
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
5.6.1. Requisitos
Estos engranajes van a sufrir valores de par relativamente bajos, por lo tanto, la resistencia
mecánica del material del que estén constituidos no tiene por qué ser muy elevado. En cuanto a
requisitos físicos, el engranaje en el que se aloja el motor debe tener un diámetro de acoplamiento
de 6 milímetros, y el de la varilla del sensor, de 8 milímetros.
Se conoce por la teoría de engranajes de mecánica de máquinas que para que dos engranajes
engranen deben tener un mismo módulo, así que se buscará una pareja de engranajes de distintas
características fijas, pero con un mismo módulo o relación dientes-diámetro primitivo.
𝑑𝑖á𝑚𝑒𝑡𝑟𝑜 𝑝𝑟𝑖𝑚𝑖𝑡𝑖𝑣𝑜
𝑚ó𝑑𝑢𝑙𝑜 =
𝑛º 𝑑𝑖𝑒𝑛𝑡𝑒𝑠
16
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Figura 15. Engranajes para el motor (izquierda) y para la varilla roscada (derecha). (RS Components, 2018)
5.6.3. Posicionamiento
El posicionamiento de los engranajes va a realizarse mediante adhesivos en ambos ejes, y la
localización exacta es la que puede observarse en la figura 16, donde se ha realizado una
simulación mediante el programa Solidworks con la que se puede ver la instalación al completo.
17
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Figura 18. Esquema de conexiones entre Arduino, A4988 y motor de paso unipolar (RobotStore, 2016)
18
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Puede observarse claramente en la parte inferior izquierda del driver, que una patilla de
dirección va conectada al microcontrolador (Arduino UNO en nuestro caso). Dicha entrada va a
valer unos 5 Voltios (medida realizada con el polímetro en el laboratorio) cuando el programa le
mande un estado HIGH (alto, excitado), y unos 0 Voltios cuando reciba un estado LOW (bajo,
sin excitación). Esto se traduce directamente en el movimiento del motor, el cual girará en un
sentido u otro en función del programa de Arduino. Esto nos hace posible indicar en la aplicación
hacia dónde debe moverse el switch según se haya seleccionado un formato.
Puede verse la tendencia de la relación de forma clara, con esto ya se tendría una primera línea
de cálculo para llegar a saber cuántas veces debe girar el motor para pasar de un formato de envase
a otro. Lo siguiente que se va a obtener es la relación de reducción de los engranajes, recordando
que el mayor de los dos va acoplado a la varilla del switch.
𝑉𝑢𝑒𝑙𝑡𝑎𝑠𝑔𝑟𝑎𝑛𝑑𝑒 𝑁𝑝𝑒𝑞𝑢𝑒ñ𝑜 1 · 50
= ; 𝑉𝑢𝑒𝑙𝑡𝑎𝑠𝑝𝑒𝑞𝑢𝑒ñ𝑜 = = 1.5625
𝑉𝑢𝑒𝑙𝑡𝑎𝑠𝑝𝑒𝑞𝑢𝑒ñ𝑜 𝑁𝑔𝑟𝑎𝑛𝑑𝑒 32
Con la anterior relación se conoce que, para dar una vuelta completa al tornillo sin fin, el eje
del motor debe completar 1.5625 vueltas. Por último, el cálculo restante es la relación que existe
entre la posición del switch con el volumen de líquido que a envasar. Esto se logra conocidas las
medidas del tanque de llenado y la fórmula del volumen de un cilindro.
𝑉(𝑐𝑚3 )
𝑉 = 𝜋 · 𝑅2 · 𝐿 ; 𝐿(𝑐𝑚) =
𝐷(𝑐𝑚)2
𝜋· 4
Se extrae de aquí la tabla 3 con diferentes formatos y la longitud de depósito que debe
recorrerse para completar el envasado.
19
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Con todos estos valores numéricos conjuntos puede realizarse la tabla 4, más sencilla, que
representa los pasos que debe dar el motor para que el sensor recorra cierta distancia y así
programar el Arduino con variables utilizadas como contadores. Cabe señalar que en la aplicación
final (presentada más adelante) se parte de una referencia inicial de un litro, y de ahí se mueve el
motor en una u otra dirección.
6.3. Programación
Programación de Arduino: Se trata del lenguaje de programación conocido como C++. La
estructura del programa está basada en sentencias condicionales del tipo if () else () y de bucles
for (). Estos comandos son unos de los pilares fundamentales de la programación estructurada.
En el caso de las sentencias de condición if () else (), están basadas en ejecutar una línea de
programa si se cumple una premisa descrita en el programa, o de lo contrario no ejecutar dicha
línea de código y saltar a la sentencia else ().
Los bucles for () son, como su propio nombre indica, “circuitos” cerrados de código que se
repiten para la condición dada por el programador, mientras dicha premisa se cumpla el programa
estará ejecutándose repetidas veces.
20
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Para tratar los diferentes casos o formatos que pueden ser seleccionados en la aplicación, lo
que se hace es situar el switch inicialmente en una referencia (equivalente a 1 litro), y de ahí se
van contabilizando los pasos que da el motor e introduciéndolos en una variable. Con dicho valor
pueden estudiarse todas y cada una de las condiciones que deben darse para ir de uno a otro de
los formatos. Los condicionales que provienen del módulo bluetooth se identifican como
caracteres, y es que cada una de las teclas de la aplicación se traduce en letras o números que el
propio Arduino identifica y compara para conocer hacia dónde ha de girar el motor (véanse anexos
I y J).
7. Resultados experimentales
En este apartado se procederá a explicar el funcionamiento conseguido con cada una de las
pruebas realizadas en la máquina. Asimismo, se desarrollarán las diferentes etapas y la evolución
del diseño de la aplicación para smartphones finalmente obtenida.
21
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
líquido en el envase a través de la tobera de salida. El pedal debe ser pulsado hasta que el fluido
termine de salir hacia la botella en cuestión.
Figura 22. Interfaz App Control Motor de Paso (Elaborada por autor)
22
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Figura 23. Interfaz App Cambio de Formatos Preestablecidos (Elaborada por autor)
Dicha app podría servir de solución al problema que nos atañe, pero aún así se debe conseguir
una cierta “inteligencia” por parte del programa que permita conocer al microcontrolador hacia
donde moverse en función del lugar en el que se encuentra en cada momento. Es decir, si estamos
llenando botellas de dos litros, y quiero pasar a llenar un litro o tres litros con tan solo pulsar un
botón, el sistema debe saber cuántos pasos debe girar el motor y en qué dirección.
23
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
La programación que hay tras esta última aplicación puede verse reflejada en los anexos I
(Arduino) y J (App Inventor).
8. Conclusiones
En este último apartado del proyecto se van a exponer las conclusiones que han sido obtenidas
tras la realización del trabajo. En un primer lugar se debe señalar que la complejidad fundamental
del proyecto se ha encontrado en la manera de hallar la solución mecánica y en la programación
del sistema. En cuanto dicha solución mecánica, eran numerosas las posibilidades de compra de
los diversos componentes, como ya se ha visto en este documento, hay cantidad de tipos de
motores eléctricos, materiales, controladores, etc. Por lo que llevó varias semanas el proceso de
elección y compra de los dispositivos una vez diseñado el montaje. En lo que respecta a la
programación, son numerosas las webs que existen relacionadas con Arduino y con la creación
de aplicaciones, pero de nuevo son muy diversos los ejemplos y combinaciones de elementos de
cara a escribir un código para nuestro caso.
Para continuar, se debe remarcar que la solución aportada es la óptima con los materiales y
recursos disponibles. Siendo un sistema de bajo coste y que suele dar problemas con ruido
electromagnético y debilidad operando en ciertas situaciones, el Arduino UNO ha cumplido las
expectativas y ha permitido resolver el trabajo sin mayor complicación. Es cierto que con un
autómata programable y un sistema más robusto podría dotarse a la máquina de una fiabilidad
aún mayor, pero obviamente más caro y sin llegar a permitir más desarrollo o simplicidad en la
operación.
24
AUTOMATIZACIÓN DE ENVASADORA DE LÍQUIDOS CON INTERFAZ HTML
Jaime Marín Miñano
Por último, es preciso señalar que el trabajo ha sido completo, tocando temas de diferentes
ámbitos que han sido estudiados a lo largo del grado como son la automatización, la electrónica,
el diseño de máquinas, el diseño industrial, etc. Se ha desarrollado continuamente la capacidad de
resolución de problemas y de mejora, ya que han sido numerosos los contratiempos a la hora de
realizar el montaje físico, la programación de la aplicación o el montaje eléctrico para las pruebas
con el autómata.
Referencias
RS Components. (Julio de 2018). RS COMPONENTS WEBSITE. Obtenido de
https://es.rsonline. com/web/
Motores paso a paso con Arduino y driver A4988. (Junio de 2017). Luis Llamas. Ingeniería,
informática y diseño. Obtenido de https://www.luisllamas.es/motores-paso-paso-arduino-driver-
a4988-drv8825/
Formas de envasado de productos líquidos. (2011). Elección de maquinaria para el envasado de
productos líquidos. Miguel Cortés, MAQUIENVAS S.L.
Llenadora manual de pistón LP-ACT (2016). EMPAKANDO S.L. www.empakando.com
Farnell. (Julio de 2018). FARNELL ELEMENTS. Obtenido de https://es.farnell.com/
Motor con reductora y encoder. (Julio 2018). BRICOGREEK https://tienda.bricogeek.com/
ANEXOS
25
Anexo A. Programa
del Autómata
Totally Integrated
Automation Portal
Main
Nombre Tipo de datos Valor predet. Comentario
Input
Initial_Call Bool Initial call of this OB
Remanence Bool =True, if remanent data are available
Temp
Constant
%M0.0
"M0"
S
%M0.0
"M0"
R
%I0.1
%M0.1 "S1.Modo %M0.2
"M1" Manual" "M2"
S
%M0.1
"M1"
R
%M0.2
"M2"
R
%M0.3
"M3"
R
%M0.3
"M3"
R
%M0.4
"M4"
R
%M0.4
"M4"
R
%M0.7
"M7"
R
%M1.0
"M8"
R
%I0.3
%M0.3 "S3.Parada %M0.1
"M3" Emer." "M1"
S
%M0.3
"M3"
R
%I0.3
%M0.4 "S3.Parada %M0.1
"M4" Emer." "M1"
S
%M0.4
"M4"
R
Segmento 3: Actuadores
%M0.7 %Q0.0
"M7" "H1.C1 sale"
%M0.0
"M0"
%M0.4
"M4"
%M0.6
"M6"
%M0.3 %Q0.1
"M3" "H2.C1 recoge"
%M0.5
"M5"
%M1.0
"M8"
%I0.1
%M0.1 %I0.2 "S1.Modo %M0.5
"M1" "S2.Modo Auto" Manual" "M5"
S
%M0.1
"M1"
R
%M0.5
"M5"
R
%M0.6
"M6"
R
%I0.3
%M0.6 "S3.Parada %M0.1
"M6" Emer." "M1"
S
%M0.6
"M6"
R
%I0.3
%M0.5 "S3.Parada %M0.1
"M5" Emer." "M1"
S
%M0.5
"M5"
R
Unipolare 4-Phasen-Schrittmotoren
Instruction Leaflet
Bedienungsanleitung Motores unipolares paso a paso de 4 fases
Hojas de instrucciones
Feuille d’instructions Moteurs pas à pas unipolaires tétraphasés
Foglio d’instruzioni
Betjeningsvejledning
Instructies Motori passo-passo unipolari a 4 fasi
Instruktionsfolder
4 fasede, enpolede stepmotorer DK
4 c 3
C
2 c 1
2
3 4
2
Suitable drive boards connections / Anschlüsse geeigneter Treiberplatinen / Conexiones con la tarjeta controladora /
Connexions appropriées sur cartes d’entraînement / Collegamenti alle schede di controllo
Egnede driverkorttilslutninger / Geschikte aansluitingen besturingskaarten / Passande drivkortsanslutningar
V8963
2
- Unipolar - 2A Drive board / - Unipolare Treiberplatine, 2A/ Tarjeta controladora unipolar de 2A, / Carte d’entraînement 2A unipolaire, /
Scheda di controllo 2A - Unipolare / Enpolet - 2A driverkort / Enkelpolig - 2 A besturingskaart / Unipolärt – 2 A drivkort
332-098 A B
0V +V
C
D
E 1
27 32 31 30 29 28
F 25 R* R*
G 24
332-098
H 23
Ø1 Ø2 Ø3 Ø4
I 22 J
13
12
10
9 O
7
K L 6
4
3
N M
V8963
c a 2
2 B
Ø1 Ø1
Ø1 N/C
4
Ø2 Ø2
6 Ø2
Ø3
1 2 3
8 Ø3 Ø3
Ø4
10 Ø4 Ø4
N/C
12 C
D
14
3
E
16
A
18
20 F
G
22
H
24
26 I +12V
J Q
28 K
R T 1kΩ to V
30 10kΩ
M N
CW CCW
32 L
O P S U W X Y Z
1. 4 Lead motor 1. Motor mit 4 Anschlüssen
2. 6 Lead motor 2. Motor mit 6 Anschlüssen
3. 8 Lead motor (Parallel connections) 3. Motor mit 8 Anschlüssen (Parallelschaltungen)
A. Board A. Platine
B. Motor supply (+12V to +36V) B. Motorbetriebsspannung (+12V bis +36V)
C. Synch I/O C. Synchronisiereingang/-ausgang
D. Home Ø1 output D. Home Ø1-Ausgang
E. Step clock input E. Schrittakteingang
F. Overload output F. Überlastausgang
G. Overtemp output (optional 1) G. Übertemperaturausgang (optional 1)
H. VCO clock output H. Oszillatortaktausgang
I. Aux 12V output (50mA max.) I. Hilfsausgang (12V, max. 50mA)
J. Aux 5V output (50mA max.) J. Hilfsausgang (5V, max. 50mA)
K. Logic supply (+15V to +24V) K. Logikspannung (+15V bis +24V)
L. Common OV L. Masse 0V
M. Run M. Start
N. Stop N. Stopp
O. Stop/run No ramping O. Stopp/Start ohne Hochlauframpe
P. Base speed values 10kΩ to ∞ P. Basisdrehzahlwerte (10kW bis ∞)
Q. Base speed optional Q. Basisdrehzahl (optional)
R. Base R. Basis
S. Base/high ramps between base and high speedsor zero and high speeds S. Basis-/Hoch-Rampen zwischen Hochdrehzahlen oder Null- und Hochdrehzahlen,
if no base speed pot is fitted. falls kein Basisdrehzahl-Potentiometer montiert ist.
T. High T. Hoch
U. High speed values 1kΩ to 10kΩ U. Hochdrehzahlwerte (1kΩ bis 10kΩ)
V. Optional V. Optional
W. Current program normally uses on-board DIP switch W. Aktuelles Programm nutzt normalerweise die DIP-Schalter auf der Platine.
X. Output disable X. Ausgang deaktivieren
Y. Reset Ø1 state Y. Ø1-Zustand zurücksetzen
Z. Half/full Z. Halb/Voll
* These components are only required if on-board VCO has been fitted. * Diese Bauteile sind nur dann notwendig, wenn auf der Platine ein
spannungsgesteuerter Oszillator montiert ist.
i. This facitlity requires the fitting of a thermal switch. i. Diese Funktion setzt voraus, daß ein Thermoschalter montiert wird.
ii. Logic may share motor supply if between +15V and +24V. ii. Die Logik kann auch an der Motorbetriebspannung liegen, sofern diese
iii. If the on-board VCO has been fitted the VCO output may be connected zwischen +15V und +24V beträgt.
directly to the step clock input. iii. Falls der spannungsgesteuerte Oszillator auf der Platine montiert ist,
kann der Oszillatortaktausgang direkt mit dem Schrittakteingang verbunden werden.
5
V8963
6
1. Motor de 4 hilos A. Moteur à 4 lignes
2. Motor de 6 hilos B. Moteur à 6 lignes
3. Motor de 8 hilos Velocidad base (opcional) C. Moteur à 8 lignes (montage en parallèle)
V8963
A. Carte
A. Tarjeta B. Alimentation du moteur (+12 V à +36V)
B. Alimentación del motor (+12V a +36V) C. Synchro E/S
C. E/S sincr. D. Sortie Home Ø1
D. Salida retorno Ø1 E. Entrée de l’horloge de pas
E. Entrada reloj pasos F. Sortie de surcharge
F. Salida sobrecarga G. Sortie de surchauffe (option 1)
G. Salida exceso temperatura H. Sortie d’horloge commandée en tension
H. Salida reloj VCO I. Sortie 12 V auxiliaire (50 mA max.)
I. Salida auxiliar 12V (50mA máx.) J. Sortie 5 V auxiliaire (50 mA max.)
J. Salida auxiliar 5V (50mA máx.) K. Alimentation de la logique (+15 V à +24 V)
K. Alimentación lógica (+15V a +24V) L. 0 V commun
L. Común OV M. Marche
M. Marcha N. Arrêt
N. Parada O. Marche/arrêt sans rampe
O. Parada/marcha sin rampa P. Valeurs à la vitesse de base 10 kΩ à ∞
P. Valores de velocidad base 10kΩ a ∞ Q. Vitesse de base (option)
Q. Velocidad basica (opcional) R. Base
R. Base S. Rampes base/haute vitesse entre hautes vitesse ou entre zéro et hautes
S. Base/alto Rampas entre velocidad base o alta, o entre elocidad cero o vitesse s’il n’y a pas de module de vitesse de base
alta si no lleva potenciómetero de velocidad base T. Haute vitesse
T. Alta U. Valeurs à haute vitesse 1 kΩ à 10 kΩ
U. Valores de velocidad alta 1kΩ a 10kΩ V. Option
V. Opcional W. Le programme actuel utilise normalement un commutateur DIP interne
W. El programa de corriente emplea normalmente un conmutador DIP en la tarjeta X. Désactivation de sortie
X. Inhabilite salida Y. Remise à zéro état Ø1
Y. Reinicialice estado Ø1 Z. Demi-pas/pas complet
Z. Medios/enteros * Ces composants sont nécessaires uniquement si un oscillateur à tension
* Estos componentes sólo son necesarios si se ha integrado un VCO. asservie interne a été monté.
i. Esta función exige la instalación de un interruptor térmico i. Cette installation nécessite un interrupteur thermique.
ii: El lógico puede compartir el suministro de alimentación del motor si éste se encuentra entre ii. La logique peut partager l’alimentation du moteur si celle-ci est comprise
los +15 V y los +24 V entre +15 V et +24 V.
iii. Si se ha integrado el VCO, la salida de VCO se puede conectar directamente a la entrada iii. Si l’oscillateur à tension asservie interne a été monté, la sortie VCO peut
del reloj de velocidad gradual. être directement connectée à l’entrée de l’horloge de pas.
DK
7
V8963
8
NL SE
A. Besturingskaart A. Kort
B. Motorvoeding (+12 V tot +36 V) B. Strömförsörjning till motor (+12 till +36 V DC)
C. Synchronisatie I/O C. In/utgång för synkronisering
D. Uitgang rust Ø1 D. Utgång hemmaläge Ø1
E. Ingang stappenklok E. Ingång för stegklocka
F. Uitgang overbelasting F. Överlastutgång
G. Uitgang overtemperatuur (optioneel 1) G. Övertemperaturutgång (tillval 1)
H. Uitgang klok VCO H. Oscillatorklockutgång
I. Uitgang hulpspanning 12 V (maximaal 50 mA) I. Hjälputgång 12 V, max. 50 mA
J. Uitgang hulpspanning 5 V (maximaal 50 mA) J. Hjälputgång 12 V, max. 50 mA
K. Voeding logica (+15 tot +24 V) K. Strömförsörjning till logik (+15 till +24 V)
L. 0 V gemeenschappelijk L. Gemensam 0 V
M. In bedrijf M. Kör
N. Uit bedrijf N. Stopp
O. Uit bedrijf/in bedrijf geen gelijkmatige belastingtoename O. Stopp/kör utan ramp
P. Waarden basistoerental 10kΩ tot ∞ P. Grundvarvtalsvärden 10–8 kΩ
Q. Basistoerental (optioneel) Q. Grundvarvtal (tillval)
R. Basis R. Grund
S. Basis/hoge oploop tussen hoge toerentallen of tussen nul en hoge toerentallen S. Grund/högramper mellan höga varvtal eller noll och höga varvtal
als er geen basistoerentalpotentiometer is bevestigd. om ingen grundvarvtalspotentiometer är installerad.
T. Hoog T. Hög
U. Waarden hoog toerental 1kΩ tot 10kΩ U. Högvarvtalsvärden 1–10 kΩ
V. Optioneel V. Tillval
W. Huidige programma gebruikt gewoonlijk een op de besturingskaart aangebrachte W. Det aktuella programmet utnyttjar normalt en DIP-omkopplare
DIP-schakelaar. på kortet
X. Uitgang blokkeren X. Avstängning av utgång
Y. Reset Ø1 status Y. Återställ tillstånd Ø1
Z. Halve/volledige Z. Halv/hel
* Deze componenten zijn alleen nodig indien VCO op de besturingskaart is aangebracht. * Dessa komponenter är de enda som krävs om spänningsstyrd oscillator är installerad.
i. Voor deze voorziening dient een thermische schakelaar te worden gemonteerd i. Denna funktion kräver att en termobrytare installeras.
ii. Logica en motor kunnen tussen +15 V en +24 V dezelfde voeding gebruiken ii. Logiken kan drivas från samma strömförsörjning som motorn, om spänningen
iii. Als VCO op de besturingskaart is gemonteerd, kan de VCO-uitgang rechtstreeks är mellan +15 och +24 V.
op de ingang stappenklok worden aangesloten. iii. Om den spänningsstyrda oscillator är installerad, kan dess utgång anslutas
direkt till stegklockans ingång.
V8963
7.5° step angle, Holding torque (mNm) 7,5° Schrittwinkel, Haltedrehmoment (mNm)
20mNm 440-262 20 mNm 440-262
52mNm 440-284 52 mNm 440-284
155mNm 440-290 155 mNm 440-290
240mNm 440-307 240 mNm 440-307
15° step angle, Holding torque (mNm) 15° Schrittwinkel, Haltedrehmoment (mNm)
14.5mNm 199-863 14.5 mNm 199-863
RS Components haftet nicht für Verbindlichkeiten oder Schäden jedweder Art (ob auf
Fahrlässigkeit von RS Components zurückzuführen oder nicht), die sich aus der
Nutzung irgendwelcher der in den technischen Veröffentlichungen von RS
enthaltenen Informationen ergeben.
9
V8963
Ángulo de paso: 7,50˚ Par de retención (mNm) Angle de pas de 7,5° Couple statique (mNm)
20mNm 440-262 20 mNm 440-262
52mNm 440-284 52 mNm 440-284
155mNm 440-290 155 mNm 440-290
240mNm 440-307 240 mNm 440-307
Ángulo de paso: 15˚ Par de retención (mNm) Angle de pas de 15° Couple statique (mNm)
14,5mNm 199-863 14,5mNm 199-863
Se trata de una serie de motores paso a paso de imán permanente, Gamme de moteurs pas à pas à aimant permanent, idéaux pour les
ideales para la gama de tarjetas controladoras de motores paso a paso cartes d’entraînement à moteur pas à pas RS. Ces moteurs
RS. Pueden interconectarse facilmente con sistemas electrónicos s’interfacent facilement sur les circuits électroniques simples à basse
sencillos para lograr un sistema económico de control de velocidad y puissance, ce qui permet de contrôler de façon économique le
movimiento. Debido a sus rotores de imán permanente, estos motores déplacement et la vitesse. Grâce à leur rotor à aimant permanent, ces
tienen par de frenado aunque no estén bajo tensión. Este par de moteurs exercent un couple de rupture même lorsqu’ils ne sont pas
retención (residual) se caracteriza por su utilidad en la integridad de sous tension. Il s’agit du couple de détente (résiduel), qui est utile pour
posicionado. assurer l’intégrité du positionnement.
RS Components no será responsable de ningún daño o responsabilidad de cualquier La société RS Components n’est pas responsable des dettes ou pertes de quelle que
naturaleza (cualquiera que fuese su causa y tanto si hubiese mediado negligencia de nature que ce soit (quelle qu’en soit la cause ou qu’elle soit due ou non à la
RS Componentscomo si no) que pudiese derivar del uso de cualquier información négligence de la société RS Components) pouvant résulter de l’utilisation des
incluida en la documentación técnica de RS. informations données dans la documentation technique de RS.
10
V8963
RS Codici. RS Varenr
DK
Angolo passo 7,5° Coppia di tenuta (mNm) 7,5° stepvinkel Låsemoment (mNm)
20mNm 440-262 20mNm 440-262
52mNm 440-284 52mNm 440-284
155mNm 440-290 155mNm 440-290
240mNm 440-307 240mNm 440-307
Angolo passo 15° Coppia di tenuta (mNm) 15° stepvinkel Låsemoment (mNm)
14.5mNm 199-863 14,5mNm 199-863
Una gamma di motori passo-passo a magnete permanente Et sortiment af permamagnetstepmotorer, der er velegnede til RS-
particolarmente adatti per la gamma RS delle schede di controllo dei sortimentet af driverkort. De kobles nemt sammen med simpel
motori passo-passo. Sono facilmente interfacciati tramite semplici lavspændingselektronik og giver dermed økonomisk drivkraft og
circuiti elettronici a bassa potenza e forniscono un sistema economico hastighedsstyring. På grund af deres rotorer med permanente
di controllo del movimento e della velocità. Grazie ai rotori a magnete magneter har disse motorer et låsemoment, selv når de ikke er slået til.
permanente, questi motori sono dotati di una coppia frenante anche Det er dette bremse-(residual)moment, der er en nyttig funktion til
quando non sono eccitati. Si tratta di una coppia (residua) di fermo positionel integritet.
utile per la precisione posizionale.
Stepsekvens (helstep)
Sequenza di passi (passo intero) Startposition Stepantal. 1 2 3 4
Posizione di avvio (vilkårlig) TIL FRA FRA TIL
(arbitraria) Passo n. 1 2 3 4 1 TIL FRA TIL FRA Med uret
ON OFF OFF ON Senso 2 FRA TIL TIL FRA
1 ON OFF ON OFF antiorario (vilkårlig) 3 FRA TIL FRA TIL
(arbitraria) 2 OFF ON ON OFF 4 TIL FRA FRA TIL Mod uret
3 OFF ON OFF ON 5 TIL FRA TIL FRA
4 ON OFF OFF ON Senso Over
Ripetizione 5 ON OFF ON OFF orario sekvensgentagelse
della sequenza
Stepsekvens (halvstep)
Sequenza di passi (mezzo passo)
Stepantal. 1 2 3 4
Posizione di avvio Passo n. 1 2 3 4 Startposition TIL FRA TIL FRA
ON OFF ON OFF 1 TIL FRA FRA FRA
1 ON OFF OFF OFF Senso 2 TIL FRA FRA TIL Mod uret
2 ON OFF OFF ON antiorario 3 FRA FRA FRA TIL
3 OFF OFF OFF ON 4 FRA TIL FRA TIL
4 OFF ON OFF ON 5 FRA TIL FRA FRA Med uret
5 OFF ON OFF OFF Senso 6 FRA TIL TIL FRA
6 OFF ON ON OFF orario 7 FRA FRA TIL FRA
Ripetizione 7 OFF ON OFF OFF 8 TIL FRA TIL FRA
della sequenza 8 ON OFF ON OFF 9
9 Over
sekvensgentagelse
La RS Components non si assume alcuna responsabilità in merito a perdite di RS Components frasiger sig ethvert ansvar eller økonomisk tab (uanset årsag og
qualsiasi natura (di qualunque causa e indipendentemente dal fatto che siano dovute uanset, om dette måtte skyldes RS Components' uagtsomhed), der opstår, som følge
alla negligenza della RS Components), che possono risultare dall’uso delle af brugen af oplysningerne i RS’ tekniske materiale
informazioni fornite nella documentazione tecnica.
11
V8963
RS Voorraadnummer RS Lagernummber
NL SE
Staphoek 7,5° Houdmoment (mNm) Stegvinkel 7,5° Hållmoment
20 mNm 440-262 20 mNm 440-262
52 mNm 440-284 52 mNm 440-284
155 mNm 440-290 155 mNm 440-290
240 mNm 440-307 240 mNm 440-307
Staphoek 7,5° Houdmoment (mNm) Stegvinkel 15° Hållmoment
14,5 mNm 199-863 14,5 mNm 199-863
Een assortiment stappenmotoren met permanente magneten, bij Ett sortiment stegmotorer med permanentmagneter, idealiska för RS
uitstek geschikt voor het assortiment besturingskaarten voor stegmotordrivkort. Motorerna lämpar sig väl att koppla till enkel
stappenmotoren van RS. Deze motoren kunnen gemakkelijk worden elektronik med låg effekt och ger därmed en ekonomisk rörelse och
gekoppeld aan eenvoudige elektronische apparaten met een laag varvtalsreglering. På grund av sina permanentmagnetrotorer har dessa
vermogen en zorgen zo op een voordelige manier voor bewegings- en motorer ett bromsmoment också då de är spänningslösa. Detta
toerentalregeling. Dankzij de rotors met permanente magneten hebben (rest)bromsmoment är en mycket användbar egenskap för säker
deze motoren zelfs als ze niet zijn geactiveerd een remmoment. Dit is positionering.
het (rest)klinkmoment, wat een nuttige voorziening is voor de
positionele integriteit Stegsekvens (helsteg)
Startposition
Steg nr 1 2 3 4
Volgorde stappen (volledige stappen) (godtycklig)
På Av Av På
Startpositie Stapnummer. 1 2 3 4 1 På Av På Av
(willekeurig) (godtycklig)
Aan Uit Uit Aan 2 Av På På Av
Moturs
1 Aan Uit Aan Uit 3 Av På Av På
(willekeurig) 2 Uit Aan Aan Uit Linksom 4 På Av Av På
Sekvensen
3 Uit Aan Uit Aan 5 På Av På Av
Herhaling ovan Medurs
4 Aan Uit Uit Aan
bovenstaande Rechtsom upprepas
5 Aan Uit Aan Uit
volgorde
Stegsekvens (halvsteg)
Volgorde stappen (halve stappen) Steg nr 1 2 3 4
Stapnummer. 1 2 3 4 På Av På Av
Startpositie Startposition 1 På Av Av Av
Aan Uit Aan Uit
1 Aan Uit Uit Uit 2 På Av Av På
3 Av Av Av På Moturs
2 Aan Uit Uit Aan
3 Uit Uit Uit Aan Linksom 4 Av På Av På
4 Uit Aan Uit Aan 5 Av På Av Av
6 Av På På Av Medurs
5 Uit Aan Uit Uit
6 Uit Aan Aan Uit Rechtsom 7 Av Av På Av
Sekvensen 8 På Av På Av
7 Uit Aan Uit Uit
Herhaling ovan 9
8 Aan Uit Aan Uit
bovenstaande upprepas
9
volgorde
RS Components ska inte vara ansvarigt för någon som helst skuld eller förlust av
vilken art det vara må (hur denna än har orsakats och om den är orsakad av
RS Components accepteert geen aansprakelijkheid met betrekking tot enige
försumlighet från RS Components eller ej) som kan resultera från användning av
verantwoordelijkheid of enig verlies (door welke oorzaak dan ook en al of niet te wijten
någons som helst information som tillhandahålls i tekniska skrifter från RS
aan nalatigheid van de zijde van RS Components) die zou kunnen ontstaan in
Components.
verband met het gebruik van gegevens die in de technische documentatie van RS
Components zijn opgenomen.
Anexo D. Datasheet
Driver A4988
A4988
DMOS Microstepping Driver with Translator
And Overcurrent Protection
Features and Benefits Description
▪ Low RDS(ON) outputs The A4988 is a complete microstepping motor driver with
▪ Automatic current decay mode detection/selection built-in translator for easy operation. It is designed to operate
▪ Mixed and Slow current decay modes bipolar stepper motors in full-, half-, quarter-, eighth-, and
▪ Synchronous rectification for low power dissipation sixteenth-step modes, with an output drive capacity of up to
▪ Internal UVLO 35 V and ±2 A. The A4988 includes a fixed off-time current
▪ Crossover-current protection regulator which has the ability to operate in Slow or Mixed
▪ 3.3 and 5 V compatible logic supply decay modes.
▪ Thermal shutdown circuitry
▪ Short-to-ground protection The translator is the key to the easy implementation of the
▪ Shorted load protection A4988. Simply inputting one pulse on the STEP input drives
▪ Five selectable step modes: full, 1/2, 1/4, 1/8, and 1/16 the motor one microstep. There are no phase sequence tables,
high frequency control lines, or complex interfaces to program.
The A4988 interface is an ideal fit for applications where a
Package: complex microprocessor is unavailable or is overburdened.
28-contact QFN
with exposed thermal pad During stepping operation, the chopping control in the A4988
5 mm × 5 mm × 0.90 mm automatically selects the current decay mode, Slow or Mixed.
(ET package) In Mixed decay mode, the device is set initially to a fast decay
for a proportion of the fixed off-time, then to a slow decay for
the remainder of the off-time. Mixed decay current control
results in reduced audible motor noise, increased step accuracy,
and reduced power dissipation.
RESET SENSE2
4988-DS, Rev. 5
A4988 DMOS Microstepping Driver with Translator
And Overcurrent Protection
Description (continued)
Internal synchronous rectification control circuitry is provided The A4988 is supplied in a surface mount QFN package (ES), 5 mm
to improve power dissipation during PWM operation. Internal × 5 mm, with a nominal overall package height of 0.90 mm and an
circuit protection includes: thermal shutdown with hysteresis, exposed pad for enhanced thermal dissipation. It is lead (Pb) free
undervoltage lockout (UVLO), and crossover-current protection. (suffix –T), with 100% matte tin plated leadframes.
Special power-on sequencing is not required.
Selection Guide
Part Number Package Packing
A4988SETTR-T 28-contact QFN with exposed thermal pad 1500 pieces per 7-in. reel
0.22 µF 0.1 µF
DAC OUT1A
OUT1B
PWM Latch
Blanking OCP
Mixed Decay SENSE1
STEP
DIR Gate
Drive DMOS Full Bridge RS1
VBB2
RESET
Control
Translator
MS1 Logic
OUT2A
MS2 OCP
OUT2B
MS3
PWM Latch
ENABLE Blanking SENSE2
Mixed Decay
SLEEP
RS2
DAC
VREF
THERMAL CHARACTERISTICS
Characteristic Symbol Test Conditions* Value Units
Package Thermal Resistance RθJA Four-layer PCB, based on JEDEC standard 32 ºC/W
3.50
3.00
Power Dissipation, PD (W)
2.50 R
θJ
A =
32
2.00 ºC
/W
1.50
1.00
0.50
0
20 40 60 80 100 120 140 160
Temperature, TA (°C)
tA tB
STEP
tC tD
Functional Description
Device Operation. The A4988 is a complete microstepping the home position which is by default common to all step modes.
motor driver with a built-in translator for easy operation with
minimal control lines. It is designed to operate bipolar stepper Mixed Decay Operation. The bridge operates in Mixed
motors in full-, half-, quarter-, eighth, and sixteenth-step modes. decay mode, at power-on and reset, and during normal running
The currents in each of the two output full-bridges and all of the according to the ROSC configuration and the step sequence, as
N-channel DMOS FETs are regulated with fixed off-time PWM shown in Figures 9 through 13. During Mixed decay, when the
(pulse width modulated) control circuitry. At each step, the current trip point is reached, the A4988 initially goes into a fast decay
for each full-bridge is set by the value of its external current-sense mode for 31.25% of the off-time, tOFF . After that, it switches to
resistor (RS1 and RS2), a reference voltage (VREF), and the output Slow decay mode for the remainder of tOFF. A timing diagram for
voltage of its DAC (which in turn is controlled by the output of this feature appears on the next page.
the translator).
Typically, mixed decay is only necessary when the current in the
At power-on or reset, the translator sets the DACs and the phase winding is going from a higher value to a lower value as determined
current polarity to the initial Home state (shown in Figures 9 by the state of the translator. For most loads automatically-selected
through 13), and the current regulator to Mixed Decay Mode for mixed decay is convenient because it minimizes ripple when the
both phases. When a step command signal occurs on the STEP current is rising and prevents missed steps when the current is falling.
input, the translator automatically sequences the DACs to the For some applications where microstepping at very low speeds is
next level and current polarity. (See Table 2 for the current-level necessary, the lack of back EMF in the winding causes the current to
sequence.) The microstep resolution is set by the combined effect increase in the load quickly, resulting in missed steps. This is shown
of the MSx inputs, as shown in Table 1. in Figure 2. By pulling the ROSC pin to ground, mixed decay is set
When stepping, if the new output levels of the DACs are lower to be active 100% of the time, for both rising and falling currents, and
than their previous output levels, then the decay mode for the prevents missed steps as shown in Figure 3. If this is not an issue, it
active full-bridge is set to Mixed. If the new output levels of the is recommended that automatically-selected mixed decay be used,
DACs are higher than or equal to their previous levels, then the because it will produce reduced ripple currents. Refer to the Fixed
decay mode for the active full-bridge is set to Slow. This auto- Off-Time section for details.
matic current decay selection improves microstepping perfor- Low Current Microstepping. Intended for applications
mance by reducing the distortion of the current waveform that where the minimum on-time prevents the output current from
results from the back EMF of the motor. regulating to the programmed current level at low current steps.
Microstep Select (MSx). The microstep resolution is set by To prevent this, the device can be set to operate in Mixed decay
the voltage on logic inputs MSx, as shown in Table 1. The MS1 mode on both rising and falling portions of the current waveform.
and MS3 pins have a 100 kΩ pull-down resistance, and the MS2 This feature is implemented by shorting the ROSC pin to ground.
pin has a 50 kΩ pull-down resistance. When changing the step In this state, the off-time is internally set to 30 µs.
mode the change does not take effect until the next STEP rising
edge. Reset Input ( R̄¯ Ē
¯ S̄
¯ Ē
¯ T̄
¯ ). The R̄¯ Ē¯ S̄¯ Ē¯ T̄¯ input sets the translator
to a predefined Home state (shown in Figures 9 through 13), and
If the step mode is changed without a translator reset, and abso-
turns off all of the FET outputs. All STEP inputs are ignored until
lute position must be maintained, it is important to change the
¯ Ē
the R̄ ¯ S̄¯ Ē
¯ T̄
¯ input is set to high.
step mode at a step position that is common to both step modes in
order to avoid missing steps. When the device is powered down,
or reset due to TSD or an over current event the translator is set to Step Input (STEP). A low-to-high transition on the STEP
Missed
Step
Mixed Decay
No Missed
ILOAD 500 mA/div. Steps
Figure 3: Continuous Stepping Using Automatically-Selected Mixed Stepping (ROSC pin grounded)
input sequences the translator and advances the motor one incre- ▪ ROSC through a resistor to ground — off-time is determined
ment. The translator controls the input to the DACs and the direc- by the following formula, the decay mode is automatic Mixed
tion of current flow in each winding. The size of the increment is decay for all step modes except full step whic is set to slow
determined by the combined state of the MSx inputs. decay.
tOFF ≈ ROSC ⁄ 825
Direction Input (DIR). This determines the direction of rota-
tion of the motor. Changes to this input do not take effect until the Where tOFF is in µs.
next STEP rising edge. Blanking. This function blanks the output of the current sense
comparators when the outputs are switched by the internal current
Internal PWM Current Control. Each full-bridge is con- control circuitry. The comparator outputs are blanked to prevent
trolled by a fixed off-time PWM current control circuit that limits false overcurrent detection due to reverse recovery currents of the
the load current to a desired value, ITRIP . Initially, a diagonal pair clamp diodes, and switching transients related to the capacitance
of source and sink FET outputs are enabled and current flows of the load. The blank time, tBLANK (µs), is approximately
through the motor winding and the current sense resistor, RSx. tBLANK ≈ 1 µs
When the voltage across RSx equals the DAC output voltage, the
current sense comparator resets the PWM latch. The latch then Shorted-Load and Short-to-Ground Protection.
turns off the appropriate source driver and initiates a fixed off If the motor leads are shorted together, or if one of the leads is
time decay mode shorted to ground, the driver will protect itself by sensing the
overcurrent event and disabling the driver that is shorted, protect-
The maximum value of current limiting is set by the selection of
ing the device from damage. In the case of a short-to-ground, the
RSx and the voltage at the VREF pin. The transconductance func- ¯ Ē
¯ ¯ P̄¯ input goes
device will remain disabled (latched) until the S̄ L̄ Ē
tion is approximated by the maximum value of current limiting,
high or VDD power is removed. A short-to-ground overcurrent
ITripMAX (A), which is set by event is shown in Figure 4.
ITripMAX = VREF / ( 8 × RS) When the two outputs are shorted together, the current path is
through the sense resistor. After the blanking time (≈1 µs) expires,
where RS is the resistance of the sense resistor (Ω) and VREF is the sense resistor voltage is exceeding its trip value, due to the
the input voltage on the REF pin (V). overcurrent condition that exists. This causes the driver to go into
a fixed off-time cycle. After the fixed off-time expires the driver
The DAC output reduces the VREF output to the current sense
turns on again and the process repeats. In this condition the driver
comparator in precise steps, such that
is completely protected against overcurrent events, but the short
is repetitive with a period equal to the fixed off-time of the driver.
Itrip = (%ITripMAX / 100) × ITripMAX This condition is shown in Figure 5.
(See Table 2 for %ITripMAX at each step.) During a shorted load event it is normal to observe both a posi-
It is critical that the maximum rating (0.5 V) on the SENSE1 and tive and negative current spike as shown in Figure 3, due to the
direction change implemented by the Mixed decay feature. This
SENSE2 pins is not exceeded.
is shown in Figure 6. In both instances the overcurrent circuitry is
Fixed Off-Time. The internal PWM current control circuitry protecting the driver and prevents damage to the device.
uses a one-shot circuit to control the duration of time that the
Charge Pump (CP1 and CP2). The charge pump is used to
DMOS FETs remain off. The off-time, tOFF, is determined by the generate a gate supply greater than that of VBB for driving the
ROSC terminal. The ROSC terminal has three settings: source-side FET gates. A 0.1 µF ceramic capacitor, should be
▪ ROSC tied to VDD — off-time internally set to 30 µs, decay connected between CP1 and CP2. In addition, a 0.1 µF ceramic
mode is automatic Mixed decay except when in full step where capacitor is required between VCP and VBB, to act as a reservoir
decay mode is set to Slow decay for operating the high-side FET gates.
▪ ROSC tied directly to ground — off-time internally set to Capacitor values should be Class 2 dielectric ±15% maximum,
30 µs, current decay is set to Mixed decay for both increasing or tolerance R, according to EIA (Electronic Industries Alliance)
and decreasing currents for all step modes. specifications.
100.00
70.71
See Enlargement A
IOUT 0
–70.71
–100.00
Enlargement A
toff
tFD tSD
IPEAK
Slow Decay
Mixed Decay
IOUT
Fa
st
De
ca
y
Symbol Characteristic
toff Device fixed off-time
IPEAK Maximum output current
tSD Slow decay interval
tFD Fast decay interval
IOUT Device output current
Application Layout
Layout. The printed circuit board should use a heavy ground- The two input capacitors should be placed in parallel, and as
plane. For optimum electrical and thermal performance, the close to the device supply pins as possible. The ceramic capaci-
A4988 must be soldered directly onto the board. Pins 3 and 18 tor (CIN1) should be closer to the pins than the bulk capacitor
are internally fused, which provides a path for enhanced thermal (CIN2). This is necessary because the ceramic capacitor will be
dissipation. Theses pins should be soldered directly to an exposed responsible for delivering the high frequency current components.
surface on the PCB that connects to thermal vias are used to The sense resistors, RSx , should have a very low impedance
transfer heat to other layers of the PCB. path to ground, because they must carry a large current while
supporting very accurate voltage measurements by the current
In order to minimize the effects of ground bounce and offset
issues, it is important to have a low impedance single-point sense comparators. Long ground traces will cause additional
ground, known as a star ground, located very close to the device. voltage drops, adversely affecting the ability of the comparators
By making the connection between the pad and the ground plane to accurately measure the current in the windings. The SENSEx
directly under the A4988, that area becomes an ideal location for pins have very short traces to the RSx resistors and very thick,
a star ground point. A low impedance ground will prevent ground low impedance traces directly to the star ground underneath the
bounce during high current operation and ensure that the supply device. If possible, there should be no other components on the
voltage remains stable at the input terminal. sense circuits.
Solder
A4988
Trace (2 oz.)
Signal (1 oz.)
Ground (1 oz.)
PCB
Thermal (2 oz.)
Thermal Vias
RS1 RS2
C7 C9 VBB
C2
OUT2A
OUT1A
VBB2
SENSE2
NC
SENSE1
VBB1
1
OUT2B OUT1B
ENABLE A4988 NC
PAD DIR
GND
CP1
C3 GND R3
CP2 REF
C4
VCP STEP R2
NC VDD
VDD
RESET
SLEEP
ROSC
VREG
MS1
MS2
MS3
C1 C8
C6 R6
R1
8V 40 V
PGND GND
8V
MS1
VBB MS2 VBB
MS3 OUT
VREG SENSE VREG DIR
VREF DMOS
ROSC Parasitic
DMOS 8V
10 V SLEEP DMOS
Parasitic
Parasitic
GND GND GND GND GND
100.00
100.00 Mixed*
70.71
70.71
Slow Slow Slow Slow
Phase 2 Phase 2 Mixed Mixed Mixed
IOUT2A IOUT2B
0.00 0.00
Direction = H Direction = H
(%) (%)
–70.71 –70.71
–100.00
–100.00
*With ROSC pin tied to GND
*With ROSC pin tied to GND
DIR= H DIR= H
Figure 9: Decay Mode for Full-Step Increments Figure 10: Decay Modes for Half-Step Increments
STEP
100.00
92.39
70.71
Mixed*
38.27
Phase 1
Slow Mixed Slow Mixed Slow
IOUT1A
0.00
Direction = H
Home Microstep Position
(%) –38.27
–70.71
–92.39
–100.00
100.00
92.39
70.71 Mixed*
38.27 Slow
Phase 2
Mixed Slow Mixed Slow Mixed
IOUT2B
0.00
Direction = H
(%) –38.27
–70.71
–92.39
–100.00
DIR= H
Figure 11: Decay Modes for Quarter-Step Increments
STEP
100.00
92.39
83.15
70.71
55.56
38.27 Mixed*
Phase 1
19.51
IOUT1A Slow Mixed Slow Mixed
0.00
Direction = H –19.51
Home Microstep Position
(%) –38.27
–55.56
–70.71
–83.15
–92.39
–100.00
100.00
92.39
83.15
70.71
55.56
38.27 Mixed*
Phase 2 19.51
IOUT2B Mixed Slow Mixed Slow
0.00
Direction = H –19.51
(%) –38.27
–55.56
–70.71
–83.15
–92.39
–100.00
*With ROSC pin tied to GND
DIR= H
STEP
100.00
95.69
88.19
83.15
77.30
70.71
63.44
55.56
47.14
Mixed*
38.27
29.03
19.51
Phase 1 9.8
IOUT1A Slow Mixed Slow Mixed
0.00
Direction = H –9.8
(%)
–19.51
–29.03
–38.27
Home Microstep Position
–47.14
–55.56
–63.44
–70.71
–77.30
–83.15
–88.19
–95.69
–100.00
100.00
95.69
88.19
83.15
77.30
70.71
63.44
55.56
47.14
Mixed*
38.27
29.03
19.51
Slow
Phase 2 9.8
IOUT2B Mixed Slow Mixed Slow
0.00
Direction = H
–9.8
(%)
–19.51
–29.03
–38.27
–47.14
–55.56
–63.44
–70.71
–77.30
–83.15
–88.19
–95.69
–100.00
*With ROSC pin tied to GND
DIR= H
Pin-out Diagram
27 SENSE2
23 SENSE1
26 OUT2A
24 OUT1A
28 VBB2
22 VBB1
25 NC
OUT2B 1 21 OUT1B
ENABLE 2 20 NC
GND 3 19 DIR
CP1 4 PAD 18 GND
CP2 5 17 REF
VCP 6 16 STEP
NC 7 15 VDD
MS2 10
RESET 12
ROSC 13
SLEEP 14
MS3 11
8
9
VREG
MS1
Terminal List Table
Name Number Description
CP1 4 Charge pump capacitor terminal
CP2 5 Charge pump capacitor terminal
VCP 6 Reservoir capacitor terminal
VREG 8 Regulator decoupling terminal
MS1 9 Logic input
MS2 10 Logic input
MS3 11 Logic input
R̄¯ Ē
¯ S̄
¯ Ē
¯ T̄
¯ 12 Logic input
ROSC 13 Timing set
S̄¯ L̄¯ Ē
¯ Ē
¯ P̄
¯ 14 Logic input
VDD 15 Logic supply
STEP 16 Logic input
REF 17 Gm reference voltage input
GND 3, 18 Ground*
DIR 19 Logic input
OUT1B 21 DMOS Full Bridge 1 Output B
VBB1 22 Load supply
SENSE1 23 Sense resistor terminal for Bridge 1
OUT1A 24 DMOS Full Bridge 1 Output A
OUT2A 26 DMOS Full Bridge 2 Output A
SENSE2 27 Sense resistor terminal for Bridge 2
VBB2 28 Load supply
OUT2B 1 DMOS Full Bridge 2 Output B
¯ N̄¯ Ā
Ē ¯ B̄
¯ L̄¯ Ē¯ 2 Logic input
NC 7, 20, 25 No connection
PAD – Exposed pad for enhanced thermal dissipation*
*The GND pins must be tied together externally by connecting to the PAD ground plane
under the device.
1
2 A 1
3.15
29X D C
SEATING 4.80
0.08 C PLANE
+0.05 C PCB Layout Reference View
0.25 –0.07 0.90 ±0.10
0.50
Revision History
Revision Revision Date Description of Revision
4 January 27, 2012 Update IOCPST
5 May 7, 2014 Revised text on pg. 9; revised Figure 8 and Table 2
"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version
1.0 will be the reference versions of Arduno, moving forward. The Uno is the latest in a series of USB
Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions,
see the index of Arduino boards.
EAGLE files: arduino-duemilanove-uno-design.zip Schematic: arduino-uno-schematic.pdf
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
32 KB of which 0.5 KB used by
Flash Memory
bootloader
SRAM 2 KB
EEPROM 1 KB
Clock Speed 16 MHz
The Arduino Uno can be powered via the USB connection or with an external power supply. The power
source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter
can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a
battery can be inserted in the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V
pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage
regulator may overheat and damage the board. The recommended range is 7 to 12 volts.
• VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to
5 volts from the USB connection or other regulated power source). You can supply voltage through
this pin, or, if supplying voltage via the power jack, access it through this pin.
• 5V. The regulated power supply used to power the microcontroller and other components on the
board. This can come either from VIN via an on-board regulator, or be supplied by USB or another
regulated 5V supply.
• 3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
• GND. Ground pins.
The Atmega328 has 32 KB of flash memory for storing code (of which 0,5 KB is used for the bootloader); It
has also 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).
Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and
digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and
has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have
specialized functions:
• Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. TThese pins are
connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip .
• External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a
rising or falling edge, or a change in value. See the attachInterrupt() function for details.
• PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
• SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which,
although provided by the underlying hardware, is not currently included in the Arduino language.
• LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is
on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By
default they measure from ground to 5 volts, though is it possible to change the upper end of their range
using the AREF pin and the analogReference() function. Additionally, some pins have specialized
functionality:
• I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library.
• AREF. Reference voltage for the analog inputs. Used with analogReference().
• Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to
shields which block the one on the board.
See also the mapping between Arduino pins and Atmega328 ports.
The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other
microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial communication over USB
and appears as a virtual com port to software on the computer. The '8U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, an *.inf file is required..
The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the
Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-
serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1).
A SoftwareSerial library allows for serial communication on any of the Uno's digital pins.
The ATmega328 also support I2C (TWI) and SPI communication. The Arduino software includes a Wire
library to simplify use of the I2C bus; see the documentation for details. To use the SPI communication,
please see the ATmega328 datasheet.
The Arduino Uno can be programmed with the Arduino software (download). Select "Arduino Uno w/
ATmega328" from the Tools > Board menu (according to the microcontroller on your board). For details,
see the reference and tutorials.
The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new code
to it without the use of an external hardware programmer. It communicates using the original STK500
protocol (reference, C header files).
You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial
Programming) header; see these instructions for details.
The ATmega8U2 firmware source code is available . The ATmega8U2 is loaded with a DFU bootloader,
which can be activated by connecting the solder jumper on the back of the board (near the map of Italy) and
then resetting the 8U2. You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac
OS X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer
(overwriting the DFU bootloader).
Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is designed in a
way that allows it to be reset by software running on a connected computer. One of the hardware flow control
lines (DTR) of the ATmega8U2 is connected to the reset line of the ATmega328 via a 100 nanofarad
capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The
Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the
Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR
can be well-coordinated with the start of the upload.
This setup has other implications. When the Uno is connected to either a computer running Mac OS X or
Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or
so, the bootloader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything
besides an upload of new code), it will intercept the first few bytes of data sent to the board after a
connection is opened. If a sketch running on the board receives one-time configuration or other data when it
first starts, make sure that the software with which it communicates waits a second after opening the
connection and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can
be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset
by connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for details.
The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and
overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer
of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection
until the short or overload is removed.
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the USB connector
and power jack extending beyond the former dimension. Three screw holes allow the board to be attached to
a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple
of the 100 mil spacing of the other pins.
Arduino can sense the environment by receiving input from a variety of sensors and can affect its
surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is
programmed using the Arduino programming language (based on Wiring) and the Arduino
development environment (based on Processing). Arduino projects can be stand-alone or they can
communicate with software on running on a computer (e.g. Flash, Processing, MaxMSP).
Arduino is a cross-platoform program. You’ll have to follow different instructions for your personal
OS. Check on the Arduino site for the latest instructions. http://arduino.cc/en/Guide/HomePage
Once you have downloaded/unzipped the arduino IDE, you can Plug the Arduino to your PC via USB cable.
File>Sketchbook>
Arduino-0017>Examples>
Digital>Blink
In Tools>Board select
1.1 The producer warrants that its products will conform to the Specifications. This warranty lasts for one (1) years from the date of the sale. The
producer shall not be liable for any defects that are caused by neglect, misuse or mistreatment by the Customer, including improper installation or testing,
or for any products that have been altered or modified in any way by a Customer. Moreover, The producer shall not be liable for any defects that result from
Customer's design, specifications or instructions for such products. Testing and other quality control techniques are used to the extent the producer deems
necessary.
1.2 If any products fail to conform to the warranty set forth above, the producer's sole liability shall be to replace such products. The producer's liability
shall be limited to products that are determined by the producer not to conform to such warranty. If the producer elects to replace such products, the
producer shall have a reasonable time to replacements. Replaced products shall be warranted for a new full warranty period.
1.3 EXCEPT AS SET FORTH ABOVE, PRODUCTS ARE PROVIDED "AS IS" AND "WITH ALL FAULTS." THE PRODUCER DISCLAIMS ALL OTHER
WARRANTIES, EXPRESS OR IMPLIED, REGARDING PRODUCTS, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
1.4 Customer agrees that prior to using any systems that include the producer products, Customer will test such systems and the functionality of the
products as used in such systems. The producer may provide technical, applications or design advice, quality characterization, reliability data or other
services. Customer acknowledges and agrees that providing these services shall not expand or otherwise alter the producer's warranties, as set forth
above, and no additional obligations or liabilities shall arise from the producer providing such services.
1.5 The Arduino products are not authorized for use in safety-critical applications where a failure of the product would reasonably be expected to cause
severe personal injury or death. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the
operation of nuclear facilities and weapons systems. Arduino products are neither designed nor intended for use in military or aerospace applications or
environments and for automotive applications or environment. Customer acknowledges and agrees that any such use of Arduino products which is solely
at the Customer's risk, and that Customer is solely responsible for compliance with all legal and regulatory requirements in connection with such use.
1.6 Customer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements concerning its
products and any use of Arduino products in Customer's applications, notwithstanding any applications-related information or support that may be
provided by the producer.
2. Indemnification
The Customer acknowledges and agrees to defend, indemnify and hold harmless the producer from and against any and all third-party losses, damages,
liabilities and expenses it incurs to the extent directly caused by: (i) an actual breach by a Customer of the representation and warranties made under this
terms and conditions or (ii) the gross negligence or willful misconduct by the Customer.
In no event the producer shall be liable to the Customer or any third parties for any special, collateral, indirect, punitive, incidental, consequential or
exemplary damages in connection with or arising out of the products provided hereunder, regardless of whether the producer has been advised of the
possibility of such damages. This section will survive the termination of the warranty period.
4. Changes to specifications
The producer may make changes to specifications and product descriptions at any time, without notice. The Customer must not rely on the absence or
characteristics of any features or instructions marked "reserved" or "undefined." The producer reserves these for future definition and shall have no
responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The product information on the Web Site or Materials is
subject to change without notice. Do not finalize a design with this information.
MODEL :
DRAWN BY : Ling Xin HC-06
Description::
CHECKED BY : Eric Huang BC04 has external 8M Flash and EDR module
HC-06 is industrial, and compatible with civil HC-04
Former version
HC-06 is the higher version of LV_BC_2.0. Linvor is the former of wavesen.
introduction
Contents
1. Product’s picture
2. Feature
3. Pins description
5. Block diagram
6. Debugging device
7. Characteristic of test
8. Test diagram
9. AT command set
1. Product’s picture
2. Feature
Wireless transceiver
Sensitivity (Bit error rate) can reach -80dBm.
The change range of output’s power: -4 - +6dBm.
Function description (perfect Bluetooth solution)
Has an EDR module; and the change range of modulation depth: 2Mbps - 3Mbps.
Has a build-in 2.4GHz antenna; user needn’t test antenna.
Has the external 8Mbit FLASH
Can work at the low voltage (3.1V~4.2V). The current in pairing is in the range of 30~40mA.
The current in communication is 8mA.
Standard HCI Port (UART or USB)
USB Protocol: Full Speed USB1.1, Compliant With 2.0
This module can be used in the SMD.
It’s made through RoHS process.
The board PIN is half hole size.
Has a 2.4GHz digital wireless transceiver.
Bases at CSR BC04 Bluetooth technology.
Has the function of adaptive frequency hopping.
Small (27mm×13mm×2mm)
Peripherals circuit is simple.
It’s at the Bluetooth class 2 power level.
Storage temperature range: -40 ℃ - 85℃,work temperature range: -25 ℃ - +75℃
Any wave inter Interference: 2.4MHz,the power of emitting: 3 dBm.
Bit error rate: 0. Only the signal decays at the transmission link, bit error may be produced. For
example, when RS232 or TTL is being processed, some signals may decay.
Application fields:
Bluetooth Car Handsfree Device
Bluetooth GPS
Bluetooth PCMCIA , USB Dongle
Bluetooth Data Transfer
Software
CSR
3.PINs description
pull-up
CMOS input with
SPI_CLK 19 weak internal Serial peripheral interface clock
pull-down
CMOS input with
Serial peripheral interface data
SPI_MISO 18 weak internal
Output
pull-down
USB_- 15 Bi-Directional
USB_+ 20 Bi-Directional
Default :
1.8V
1.8V 14 1.8V external power supply input
internal powe
r supply.
PCM_CLK 5 Bi-Directional
PCM_SYNC 8 Bi-Directional
5. Block diagram
HC-04/06 master device has a function of remembering the last paired slave device. As a master
device, it will search the last paired salve device until the connection is built. But if the WAKEUP
bottom is pressed, HC-04/06 will lose the memory and research the new slave device.
6. Debugging device
6.1 Device
PC, hardware, 3G,3G Frequency Counter (SP3386), 3.15V DC power supply, Shielding,Bluetooth
Test box.
6.2 Software
7. Characteristic of test
Test Condition 25℃ RH 65%
Min Typ Max Unit
1. Carrier Freq. ( ISM Band ) 2.4 2.4835 MHz
2. RF O/P Power -6 2 4 dBm
3. Step size of Power control 2 8 dB
4. Freq. Offset ( Typical Carrier freq.) -75 75 KHz
5. Carrier Freq. drift ( Hopping on, drift rate/50uS ) -20 20 KHz
1 slot packet -25 25 KHz
3 slot packet -40 -40 KHz
6. Average Freq. Deviations ( Hopping off, modulation ) 140 175 KHz
Freq. Deviation 115 KHz
Ratio of Freq. Deviation 0.8
7 . Receive Sensitivity @< 0.1% BER( Bit error rate )-83 dBm
8. Test diagram
3GHz Ferq.
Counter RS232
CH C
COM 1
RF O/P
LPT1
UUT Interface
Computer
circuit
SPI
Shielding Box
GPIB
Bluetooth test
Computer
set
RF I/P COM 1
LP1
RS232
RF Port
UUT SPI
Shielding Box
5. No parity check ( The version, higher than V1.5, can use this command )
Send: AT+PN (This is the default value)
Back: OK NONE
6. Set odd parity check ( The version, higher than V1.5, can use this command )
Send: AT+PO
Back: OK ODD
7. Set even parity check( The version, higher than V1.5, can use this command )
Send: AT+PE
Back: OK EVEN
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
Anexo H. Datasheet
Engranaje varilla
roscada
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
ENGLISH
RS, Professionally Approved Products, gives you professional quality parts across all products categories. Our range has
been testified by engineers as giving comparable quality to that of the leading brands without paying a premium price.
Anexo I. Programa
Arduino
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(0,1); // RX/TX
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
bluetooth.begin(9600);
pinMode(steppin,OUTPUT); // declaramos como salidas
pinMode(dirpin,OUTPUT); // declaramos como salida
//pinMode(reset, OUTPUT);
}
void loop() {
if(Serial.available()>0){
estado = bluetooth.read(); }
if (estado == 'A')
{
if (contador==0) //El switch se mueve de la referencia/1L a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<9216;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<7680;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<6144;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<10752;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 4/8 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == '7')
{
if (contador==0) //El switch se mueve de la referencia/1L a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<9216;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<7680;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<6144;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<10752;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 4/8 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 4/8 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == 'B')
{
if (contador==0) //El switch se mueve de la referencia a 2 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 2 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<1536;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 2 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<6144;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 2 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<4608;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 2 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 2 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<9216;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == 'C')
{
if (contador==0) //El switch se mueve de la referencia a 1.5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<1536;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a 1.5 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<1536;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 1.5 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<7680;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 1.5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 1.5 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<4608;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 1.5 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<10752;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
if (estado == 'F')
{
if (contador==1536) //El switch se mueve de 1.5 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<1536;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<9216;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a la ref/1L
{digitalWrite (dirpin,LOW);
for(int x=0;x<1536;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<6144;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<12288;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == '3')
{
if (contador==1536) //El switch se mueve de 1.5 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<1536;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<9216;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a la ref/1L
{digitalWrite (dirpin,LOW);
for(int x=0;x<1536;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<6144;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5 Litros a la ref/1L
{digitalWrite (dirpin,HIGH);
for(int x=0;x<12288;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == '2')
{
if (contador==0) //El switch se mueve de 1L/ref a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<1536;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5L a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2L a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<4608;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<7680;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<10752;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 0.5 litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<13824;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == '4')
{
if (contador==0) //El switch se mueve de la referencia a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<6144;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<4608;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 3/6 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<7680;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2L a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 3 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<6144;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}
if (estado == '6')
{
if (contador==0) //El switch se mueve de la referencia a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<6144;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<4608;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 3/6 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<3072;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<7680;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2L a 3/6 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==12288) //El switch se mueve de 5L a 3 Litros
{digitalWrite (dirpin,HIGH);
for(int x=0;x<6144;x++,contador--)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
if (estado == '5')
{
if (contador==0) //El switch se mueve de la referencia/1L a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<12288;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==1536) //El switch se mueve de 1.5 Litros a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<10752;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==3072) //El switch se mueve de 2 Litros a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<9216;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==-1536) //El switch se mueve de 0.5 Litros a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<13824;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==6144) //El switch se mueve de 3L/6L a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<6144;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}else
if (contador==9216) //El switch se mueve de 4L/8L a 5 Litros
{digitalWrite (dirpin,LOW);
for(int x=0;x<3072;x++,contador++)
{
digitalWrite(steppin,HIGH);
delay(tiempo);
digitalWrite(steppin,LOW);
delay(tiempo);
}
}
}