Chapter 10 - Exploring Stepper Motors (28-BYJ-48) with an Arduino
Summary
TLDREste script ofrece una introducción a cómo controlar el motor paso a paso 28BYJ-48 con Arduino, una herramienta popular para proyectos de electrónica. Se discute la estructura del motor, su alto torque a baja velocidad y su uso en aplicaciones que requieren control preciso de posición y velocidad. Se explica cómo se organizan las bobinas en fases y cómo se activan secuencialmente para mover el rotor. Se presenta un diagrama esquemático del controlador ULN2003 y cómo se conecta a Arduino. Además, se incluye un ejemplo de código para controlar el motor, así como una discusión sobre la precisión y especificaciones técnicas del motor, incluyendo su relación de reducción de engranajes y el ángulo de paso. Finalmente, se menciona la biblioteca de Arduino para steppers y se comparan las secuencias de 4 y 8 pasos, así como se habla de las placas de motor (shields) como una alternativa para controlar motores.
Takeaways
- 😀 El video es una introducción al control de motores paso a paso 28BYJ-48 con Arduino.
- 🔧 Se utiliza un motor paso a paso popular y ampliamente disponible para demostraciones.
- 📚 Se recomienda revisar capítulos 4, 5, 8 y 9 para comprender mejor este resumen.
- 🤖 Los motores paso a paso son útiles para aplicaciones que requieren posicionamiento preciso y control de velocidad.
- 🌀 Estos motores ofrecen alto torque a baja velocidad, pero tienen menos torque a alta velocidad y consumen corriente constante.
- 🪢 El motor 28BYJ-48 es unipolar, con cuatro bobinas asociadas a cables de colores que se controlan mediante un driver ULN2003.
- 🔌 El controlador ULN2003 utiliza transistores y diodos para conectar las bobinas al motor y se controla con señales de Arduino.
- 🔋 Se debe verificar la especificación de voltaje y corriente del motor para asegurarse de que Arduino pueda manejar la carga.
- 📝 Se muestra cómo conectar los pines de Arduino al controlador y un potenciómetro al pin analógico para control de velocidad.
- 🔄 Se discuten las secuencias de pulsos necesarias para mover el motor en sentido horario e antihorario.
- 🎛 El ángulo de paso del motor y la relación de reducción de engranajes son clave para la precisión en el posicionamiento del motor.
- 🔄 Se menciona la posibilidad de desalineación o 'slippage' debido a la complejidad de los engranajes internos del motor.
- 📚 Se presenta la biblioteca de Arduino para motores paso a paso, que simplifica el proceso de control del motor.
- 🛠 Se mencionan alternativas como las shields de motor que facilitan la conexión y control de motores con Arduino.
Q & A
¿Qué es un motor paso a paso y cómo funciona?
-Un motor paso a paso es un tipo de motor DC que se puede controlar para moverse en pasos discretos, lo cual es ideal para aplicaciones que requieren una posición y control de velocidad precisos. Funciona a través de múltiples bobinas organizadas en fases que, al ser electrificadas secuencialmente, hacen girar la motor en pasos sucesivos.
¿Por qué se usan motores paso a paso en lugar de otros tipos de motores?
-Los motores paso a paso son útiles debido a su alta precisión y control de posición y velocidad, además de ofrecer un alto torque en precisión a bajas velocidades, algo que no es típico en los motores DC comunes.
¿Cuáles son las desventajas de usar motores paso a paso?
-Los motores paso a paso tienen menos torque a altas velocidades, consumen corriente constante independientemente de la carga, lo que significa que no son tan eficientes, y a diferencia de los servos, no tienen un mecanismo de retroalimentación para determinar su posición.
¿Qué es el controlador de motor ULN2003 y cómo se utiliza con un motor paso a paso?
-El controlador de motor ULN2003 es un chip que contiene transistores y diodos útiles para electrificar las bobinas múltiples de un motor paso a paso. Se utiliza para controlar la dirección y velocidad de la rotación al determinar la secuencia utilizada para llevar a tierra cada una de las bobinas.
¿Cómo se conecta un motor paso a paso 28BYJ-48 a un Arduino?
-El motor 28BYJ-48 es unipolar, y sus cables naranja, rosa, amarillo y azul están asociados con cuatro bobinas diferentes. Se conecta a un Arduino utilizando el chip de controlador de motor ULN2003, donde los pines de Arduino se conectan a este chip para controlar qué bobina se electrifica.
¿Qué es la relación de reducción de engranajes y cómo afecta el motor paso a paso?
-La relación de reducción de engranajes se refiere a cómo el eje del motor gira las salidas de engranajes. En el caso del motor 28BYJ-48, una relación de 1 a 64 significa que 64 revoluciones del eje del motor giran un eje de salida completo.
¿Cuál es el ángulo de paso del motor paso a paso 28BYJ-48 y cómo se calcula?
-El ángulo de paso del motor 28BYJ-48 es de 5.625 grados por paso en una secuencia de 8 pasos, resultando en 64 pasos por revolución. Se calcula dividiendo 360 grados entre el ángulo de paso por paso.
¿Cómo se puede controlar la dirección y velocidad de un motor paso a paso con Arduino?
-La dirección y velocidad de un motor paso a paso se pueden controlar mediante la secuencia y el tiempo de los impulsos en los pines de Arduino que están conectados al controlador de motor ULN2003.
¿Qué es la biblioteca de motor paso a paso de Arduino y cómo se utiliza?
-La biblioteca de motor paso a paso de Arduino permite construir objetos de tipo 'Stepper'. Al definir estos objetos, se le indica el número de pasos necesarios para una revolución en el eje de salida del motor y los pines de Arduino que están conectados al motor. La biblioteca proporciona funciones como 'step' para inducir rotación.
¿Qué son las placas de motor y cómo facilitan el uso de motores con Arduino?
-Las placas de motor, o motor shields, son hardware que se puede adjuntar a un Arduino que maneja todos los transistores, diodos y puentes H,简化了布线工作。 Proporcionan bibliotecas personalizadas que simplifican la escritura de programas para tus proyectos.
¿Cómo se puede corregir el error de la posición del eje de salida debido al deslizamiento rotativo en un motor paso a paso?
-El deslizamiento rotativo puede introducir un error de hasta tres grados en la posición del eje de salida. Para corregir esto, se puede calibrar el código agregando pasos adicionales, como se menciona en el script, para alcanzar los ángulos deseados.
Outlines
🤖 Introducción al control de motores paso a paso con Arduino
El primer párrafo presenta una introducción al control de motores paso a paso 28BYJ-48 utilizando Arduino. Se menciona que la presentación se basa en recursos en línea y es la última en una serie de 10 capítulos para un espacio de hackers en Tucson, Arizona. Se sugiere que los capítulos 4, 5, 8 y 9 sean revisados para comprender mejor este resumen. Los motores paso a paso son DC que se controlan en pasos discretos, ideales para aplicaciones que requieren posicionamiento preciso y control de velocidad. A pesar de su alto torque en bajas velocidades, presentan desventajas como menor eficiencia a altas velocidades y la falta de un mecanismo de retroalimentación de posición. Se describe cómo funcionan los motores paso a paso, con múltiples bobinas organizadas en fases que, al ser activadas secuencialmente, hacen girar el motor. Además, se introduce el uso del controlador de motor ULN 2003 para gestionar la activación de las bobinas.
🔌 Configuración y conexión del motor paso a paso a Arduino
Este párrafo se enfoca en la configuración y conexión del motor paso a paso al Arduino. Se discuten las especificaciones de voltaje y corriente que soporta el motor, indicando que no se necesita una fuente de alimentación externa si no hay carga significativa. Se describe el proceso de conexión de los pines del Arduino al controlador del motor y el uso de un potenciómetro conectado a un pin analógico para controlar la velocidad del motor. Se sugiere el uso de un código de ejemplo y se ofrece un enlace al mismo en el sitio web del presentador. Se detalla cómo se encierra todo en una caja para una demostración más práctica y cómo se realiza la conexión entre los pines del Arduino y el controlador del motor, así como el potenciómetro.
🔄 Funcionamiento y control del motor paso a paso
El tercer párrafo explica cómo funciona el motor paso a paso y cómo controlarlo. Se describe el proceso de generación de un campo magnético al aplicar corriente a las bobinas, lo que induce el movimiento del rotor. Se ilustra cómo se puede controlar la dirección y velocidad del motor variando la secuencia y el tiempo de encendido de los pines del Arduino. Se detalla el código utilizado para inducir movimientos en sentido horario y antihorario, y se muestra cómo se activan las bobinas a través de los pines del Arduino. Además, se menciona la utilización de LEDs en el controlador del motor para visualizar el funcionamiento del motor.
📏 Precisión y especificaciones del motor paso a paso
Este segmento se centra en la precisión y especificaciones técnicas del motor paso a paso. Se discute el concepto de relación de reducción de engranajes, que indica cómo muchas vueltas del eje del motor son necesarias para una vuelta en el eje de salida. Se calcula que 64 pasos del eje del motor resultan en una vuelta completa del eje de salida. Se describe el ángulo de paso del motor, que es la cantidad de rotación que produce cada paso en el eje del motor, y cómo esto se traduce en pasos necesarios para una vuelta completa del eje de salida. Se realiza un cálculo para determinar la cantidad de secuencias de pasos que deben ser llamadas para obtener una vuelta completa o parcial del eje de salida.
🔍 Solución de problemas y consideraciones adicionales
En este párrafo, el autor narra su experiencia al enfrentarse a un problema de precisión en el motor paso a paso. Después de varias pruebas y ajustes, se descubre que hay un margen de error debido al deslizamiento rotativo en el eje de salida, lo que puede introducir una diferencia de hasta tres grados. Esto llevó al autor a calibrar su código añadiendo pasos adicionales para alcanzar ángulos precisos. También se menciona la biblioteca de motores paso a paso incluida en el software de Arduino, que simplifica el proceso de construcción de objetos 'stepper' y el control de los mismos, aunque utiliza una secuencia de cuatro pasos en lugar de la secuencia de ocho pasos que se había estado utilizando hasta ese momento.
🛠️ Uso de shields de motor y conclusiones
El sexto y último párrafo habla sobre los shields de motor, que son piezas de hardware que se pueden adjuntar a Arduino para manejar transistores, diodos y puentes H,简化布线过程. Se hace hincapié en la importancia de revisar las especificaciones y limitaciones de potencia de cualquier shield que se considere, y se comparan opciones de proveedores confiables con clones más baratos disponibles en línea. Se concluye la serie de 10 capítulos desarrollada para el hackerspace, animando a los espectadores a dar like y suscribirse para futuras demostraciones y códigos asociados con las invensiones del presentador.
Mindmap
Keywords
💡Arduino
💡Motor paso a paso 28BYJ-48
💡Unipolar
💡Controlador de motor ULN2003
💡Potenciometro
💡Resolución de paso
💡Relación de reducción de engranajes
💡Secuencia de paso
💡Biblioteca de motor paso a paso de Arduino
💡Placa de motor
Highlights
Introduction to controlling the 28BYJ-48 stepper motor with Arduino.
Stepper motors are suitable for precise positioning and speed control applications.
28BYJ-48 is a unipolar stepper motor with four coils controlled via a common 5V center tap.
ULN2003 motor driver chip explanation for managing multiple coils in stepper motors.
Wiring the Arduino to control the stepper motor direction and speed.
Explanation of stepper motor phases and how they induce motion in the rotor.
Use of a potentiometer to control motor speed in the demonstration setup.
Demonstration of the stepper motor's rotation and control using Arduino code.
Understanding the gear reduction ratio and its impact on output shaft rotation.
Calculating the number of motor shaft steps needed for a full output shaft revolution.
Difference between 4-step and 8-step sequences for stepper motors.
Adjustments needed for using the Arduino stepper library with the 28BYJ-48.
Practical demonstration of the stepper motor making full and half revolutions.
Issue of rotational slip in stepper motors and its effect on precision.
Using motor shields for simplified stepper motor control with Arduino.
Recommendations for purchasing motor shields and considerations for specifications.
Conclusion of the 10-part series on Arduino with a call to action for feedback and subscription.
Transcripts
hello and welcome to this introduction
to Arduino in this chapter I'll
demonstrate how to control the popular
and widely available 28 byj 48 stepper
motor with your Arduino this
presentation borrows from many online
sources so thanks in advance to all of
you who posted your own research online
to help me reverse engineer how these
little motors work this is the final
chapter in a 10 part series developed
for local hackerspace here in Tucson
Arizona if you haven't already I
recommend reviewing chapters 4 5 8 and 9
in order to get the most out of this
summary but if you're short on time
don't worry too much about it so this is
the setup that I'll be using throughout
this presentation to demonstrate
steppers these are just DC motors that
can be controlled so that they move in
discrete steps and for this reason
they're great for applications that
require precise positioning and speed
control they also offer hight torque in
precision at low speed which is not
typical of common DC motors on the
downside they have less torque at
high-speed draw constant current
independent of load so they're not as
efficient and unlike servos have no
feedback mechanism for determining their
position also understanding and
programming these can be a little tricky
which is why broke steppers out from
chapter 9 on motors and servos in order
to help the move in discrete steps
stepper motors have multiple coils that
are organized in groups called phases
surrounding magnets on a rotor by
energizing each phase in sequence the
motor will rotate one step at a time
here's a simple conceptual model of how
these steppers work in this simple
demonstration we have a magnet on a
rotor adjacent to a coil that has no
current flowing through it as such
there's nothing to induce motion of the
magnet however if we apply current to
the coil the magnetic field generated by
that coil will attract the magnet
attached to the rotor until the magnetic
fields are aligned
now if we Orient many of these coils
around our magnet you can see how we can
pulse those coils to induce continuous
movement in the rotor these are two
examples of how we might drive a stepper
motor each method has its benefits and
limitations as we'll discuss shortly I
haven't seen stepper motors included in
most starter kits so if you'd like to
play with 128 byj 48 stepper is a good
place to start these appear to be quite
popular for use with Arduinos and
there's plenty of documentation online
on how to do the same the 28 byj 48 is a
unipolar stepper in this stepper the
orange pink yellow and blue leads are
associated with one of four different
coils as shown in the schematic on the
right all of the coils are attached to a
common 5 volt Center tap which is what
makes this a unipolar stepper with this
stepper we can determine which coil to
energize by pulling the terminal end of
a coil of interest to ground
as will demonstrate shortly we can
control the direction of rotation by
determining the sequence used to ground
each one of these coils
so how do you manage which coil to
ground
well this stepper usually comes with a
ul n 2003 motor driver chip this chip
contains a series of transistors and
diodes useful for grounding the multiple
coils in your stepper motor as was
described in chapter 9
specifically by pulsing transistors with
signals from your Arduino pins
here's a schematic of the uln 2003 with
some annotations to help explain how the
current flows on the left you can see we
have four Arduino pins attached to the
motor driver chip you can use any GPIO
pins on your Arduino for the same on the
right we have for motor coils attached
to a common 5 volt tab the common tab is
the design used for unipolar motors
although these coils have a 5 volt
potential the coils cannot ground
because of the transistors in the uln
2003 as such there's no current flowing
through the coils we can change this by
sending some current to the transistor
vo one of the Arduino pins this allows
the potential running through the coil
to ground thus inducing current flow
through the respective coil the
resulting magnetic field in the coil
will induce movement in stepper motor we
can control the direction and speed of
the stepper depending on the sequence
and timing for the firing of those
Arduino pins as will be demonstrated
shortly
when exploring the stepper with Arduino
we should check the specifications for
the voltage and the current draw for
this stepper we can expect maximum
current draw of three hundred and twenty
milli amps which is just under what we
can pull off our five volt pin when
running our Arduino off a USB cable so
assuming nothing else is plugged into
our dwee no and we're not putting a
significant load on the motor we
shouldn't need an external power supply
although many online references may
recommend using auxiliary power which is
fine to demonstrate stepper logic
I'll use this code source to one of the
forums on steppers source to the Arduino
Creative Commons website this along with
other sketches will demonstrate our copy
to my own website in the description of
this video first let's go over how to
wire things up
notice that will be using pins 8 9 10
and 11 of your Arduino to control the
stepper through the controller board and
will also be using a potentiometer wire
to analog pin number 2 also notice that
the control board power input is wired
to the 5 volt pin on the Arduino which
can provide us with up to 400 milliamps
when running off USB or 9 hundred
milliamps when plugged to an auxiliary
power supply for my demonstration I've
encased this whole thing in a box hot
glued some piano wire to a motor shaft
and added a template that lets me follow
the angle of rotation of the motor this
isn't necessary but it's a relatively
inexpensive way to create something
concrete that you can use to play with
over time if you're interested in
reproducing some of the demonstrations
that are coming up you can download the
code and the template for the 360
degrees circle from my website found in
the description of this video
the Arduino is conveniently hidden
inside the box and the wiring to the uln
2003 is fed through a hole in the back
of the box
this shows how we wire the Arduino
digital pins to the motor driver and
this shows how to wire a potentiometer
to analog pin 2 on this particular
Arduino if your Arduino doesn't come
with the second 5 volt pin like this one
you may have to attach things through a
breadboard as was shown in the original
wiring diagram a few slides back
next let's break down the sketch right
at the top of the sketch is where we
define our global variables
we build these variables for controlling
our steppers specifically through pins
eight nine ten and eleven on the arduino
and as we mentioned previously we have
our potentiometer wired up to analog pin
number two
and finally we have two variables motor
speed and pot value that will help us
set the speed of the motor as well as
store data from our potentiometer
and here's our setup block here we're
defining the Arduino pins attached to
the motor driver as output pins these
pins will engage the transistors in the
motor driver chip resulting in specific
coils being grounded in much the same
way we were grounding the DC motor coil
in our chapter 8 demonstration by
grounding the coil will induce a
magnetic field that induces the motor to
turn and here's the loop part of our
sketch the first thing we do is check
the value of our potentiometer and store
it in the variable pot value we then use
a conditional to see if pot value is
greater than or less than 535 which
determines whether to call the clockwise
or counterclockwise function
the variable pot value is also used to
calculate a value for the variable motor
speed
as mentioned earlier the sequence of
pulses on the stepper motor coils will
determine the direction of rotation here
we can see how to induce a clockwise
motion on the stepper by pulsing the
four color-coded leads coming off the
motor our sketch will induce the
sequence by setting those leads attached
to our dueño pins
8 9 10 and 11 either high or low where
the dashes in this table indicate high
and the blanks indicate low
and this is the code where we'll do that
I'll also include a snapshot of our
motor pin definitions so we know which
leads are being pulled high or low as we
go through this sequence finally I'll
also add a physical diagram of the
stepper motor itself so that we can see
how coils are being energized to induce
motion on the rotor before we walk
through this just take notice that this
function uses the motor speed value we
calculated in our loop to calculate a
delay between each step this gives us a
way to control how fast that stepper
motor turns as it's moving clockwise
here you can see that the first step of
the sequence shows that will only be
setting motor pin for high which is
attached to the orange lead and coil
number four in the stepper the other
pins will be kept low by creating a
magnetic field in coil for the steppers
rotor is induced to move next will
engage both motor pins four and three
this continues the clockwise motion in
the stepper now let's continue firing
the noted pins in the half step
switching sequence to keep that motion
going
you
and here is the total sequence shown in
the table for the half step switching
sequence for clockwise rotation
well that's fine for clockwise rotation
but what if I want to induce
counterclockwise rotation for this let's
move the clockwise function to the side
and compare it to the counterclockwise
function here you can see that the
counterclockwise function is essentially
reversing the order that those pins are
being fired in essence this is the same
as starting with a step seven in our
step sequencing table and essentially
what we're doing is running that
sequence backwards and by running a
clockwise sequence backwards this will
induce a counter clockwise sequence in
the Stuber
and here's the example stuffer one
sketch we've just outlined in action as
mentioned in my description of the code
you can see here that I'm controlling
the direction and speed of the stepper
motor using the potentiometer a really
nice thing about the uln 2003 motor
driver chip that comes with the steppers
that we can actually see the pins that
are being said I via suite of LEDs a
nice bonus for exploring out these
steppers work and if you listen closely
it almost sounds like like a little
motorcycle or the closest automotive
analogy I can come up with is it's kind
of like a rotor under a distributor cap
that's essentially making contact with
the spark plugs in an engine just kind
of cool
and this is the example stepper to
sketch here I've set the motor speed to
a large constant and this increases the
pause between each steps so that you can
see which pins are firing via the LEDs
on the motor driver chip well that's
fine for turning things forwards or
backwards but what about all that
precision positioning that steppers are
known for in order to take advantage of
that capability we need to delve a
little deeper into the stepper
specifications for this motor the specs
indicate a gear reduction ratio of 1 to
64
well what does this mean to understand
this it might help if we take the motor
apart
gear reduction has to do with the way
the motor shaft drives the output shaft
via a series of gears one two sixty four
means that sixty-four revolutions of the
motor shaft translates to one revolution
of the output shaft if you study the
gears you can kind of see how multiple
turns of the motor shaft would be needed
to create one revolution of the output
shaft but there's an easier way to
visualize this
effectively the work of all those gears
is the same as having a small gear
driving a larger gear via chain although
this drawing is not to scale you can see
that it would take many revolutions of
the small gear to generate one
revolution of the larger gear in the
case of our stepper motor it takes 64
revolutions of the motor shaft gear to
generate one revolution of the output
shaft
in order to control the motor precisely
we also have to understand the step
angle for our stepper the specifications
indicate that each step generates five
point six to five degrees of rotation on
the motor shaft in an eight step
sequence resulting in 64 steps per
revolution now that's a lot of
information so in order to understand
how this might translate to other Stuber
motors let's break this down a little
further
specifically this means that each step
in an eight step sequence will generate
five point six to five degrees of
rotation in our stepper motor shaft for
this particular sequence
since five point six to five degrees is
a fraction of the total 360 degrees
needed for a full rotation the next
question is how many of those five point
six to five degrees steps do we need to
complete one full revolution of the
stepper motor shaft
well we know that one revolution of the
motor shaft is equal to 360 degrees and
we're also told that each step produces
five point six to five degrees of
rotation if that's the case then 360
degrees can be divided by five point six
to five degrees per step and that gives
us 64 steps so that tells us that
sixty-four steps will result in one
revolution of the motor shaft which
matches the specification given for this
particular motor
well now that we understand how to
control the motor shaft we'll next want
to understand the number of motor shaft
steps it takes to generate one
revolution of the output shaft this is
important because anything we attach to
the stepper will be via the output shaft
not the motor shaft here we can see it
takes 4096 steps of the motor shaft to
generate one revolution of the output
shaft that's fine but again it really
helps to understand how they come up
with these numbers if we want to
understand how to control other steppers
outside of this one
well we know it takes 64 revolutions of
our motor shaft to generate one
revolution in our output shaft let's
write that down as our first term as we
just calculated we also know it takes 64
steps to generate one revolution of our
motor shaft if we multiply these two
terms together we get 4096 steps
necessary to generate one revolution in
our output shaft as per the given motor
specification
while that's fine for calculating the
steps I need to induce a full 360 degree
turn of my output shaft but in my sketch
I have this sequence of eight steps
embedded in a function so it's necessary
to ask how many times do I have to call
this full sequence to generate a full
revolution of the output shaft well I
know that 4096 steps will generate one
revolution of the output shaft and I
also know that one half step sequence is
made up of eight steps so if I do the
math on this this means that I have to
call this sequence 512 times to generate
one revolution of the output shaft
okay so that's fine for a full turn but
what if I wanted just a half a turn or
180 degrees on the output shaft here's
the math for that one I already know
that I need five hundred and twelve
sequences to generate one revolution of
my output shaft if I only want half a
revolution of the output shaft I just
multiply it accordingly when I do the
math I get 256 sequences so that's the
same as calling that clockwise function
256 times in my program and here's some
code to test the math you can see that
in the first for loop
I'm calling the clock wise function 512
times which should generate a full 360
degree turn in my hub foot shaft in a
clockwise motion and then I call the
counterclockwise function 512 times
which should bring the pointer on my
output shaft all the way back to 0 and
then I test the same clockwise and
counterclockwise functions using 256
which should cause a 180 degree turn
forward clockwise and then bring it back
to 0 so now let's demonstrate the
example stepper 3 sketch which includes
those 4 loops that I just summarized the
first thing I'm gonna do is try to get
this thing lined up I'm gonna reset it
and uploading and there goes my first
for loop clockwise and here it comes
back now something interesting is going
to happen you'll notice it didn't come
back all the way back to 0 here's the
180 forward here's the 180 back so that
seems a little short to
so this really bugged me because after
all I mean we just walked through all
these calculations and talked about how
precise these stuffers can be and how
you can control them with a great deal
of precision so really rack my brain to
figure out what was going on here so
what happened first it took note of this
little disclaimer that shows that the
gear reduction ratio is actually smaller
than 1 to 64 but if this were the source
of the error the step angle would be
larger and my code should be
overshooting the full and half circle
not undershooting it specifically if you
do the math with more precise gear
reduction ratio you're going to get 510
sequences instead of 512 for a full
circle and yet the code I tested has 512
and still wasn't closing the circle so
this isn't the source of the problem
well I checked the wiring in the event
coil wasn't firing correctly or in the
right order that was ok then I tried
slowing down the motor speed by an order
of magnitude in the event the coils were
firing too quickly and skipping a step
that didn't help so then I even tried
testing a second stepper and controller
board to ensure there wasn't something
wrong with the one I had set up
originally I didn't have any luck so
something else must be going on
finally I came across this thread by an
individual who tested several variations
of these steppers most important he drew
my attention to the fact that because of
all the gearing in this motor there's an
opportunity for what's known as
rotational slip in the position of the
output shaft as such this can introduce
plus or minus three degrees of error
this prompted me to calibrate my code
and after many tests I observed a need
to add four additional steps to get very
close to what I was expecting for my
half and full circle so this is just
something to keep in mind when playing
with this particular stepper if you're
trying to land on a specific angle with
your code next let's briefly talk about
the Arduino stepper library included
with our Arduino software this library
lets us construct objects of type
stepper when we first define these
objects note that we need to tell it the
number of steps needed to generate one
revolution in our output shaft in this
case we've already calculated that to be
4096 we also need to specify the Arduino
pins that are attached to our stepper
motor by using this library and the
stepper constructor to create a my
stepper object we now have access to
functions like step for inducing
rotation when using this function we
just need to indicate how many steps the
object my stepper should take when we
execute this line of code having such a
library eliminates us from having to
write complicated functions since these
are already included in the stepper dot
H library but it certainly doesn't hurt
that we went through the code since now
you have a better understanding of how
these little Stoppers are controlled
and reviewing the stepper motor
specifications notice that we're given
the heads-up that the Arduino stepper
library uses something known as a four
step sequence rather than the eight step
sequence we've been experimenting with
up to this point
so what's the difference well when
running the eight step sequence
sometimes we're grounding one coil
and sometimes we're grounding too this
gives us the ability to produce a
smaller step angle and thus greater
resolution but we do lose some torque
relative to the four step sequence we'll
discuss next
when using a four-step sequence we're
always firing two coils this improves
our torque and speed performance but at
the expense of greater power demand and
a lower stepping resolution
so instead of using the 8 step sequence
specifications we need to follow the 4
step sequence which results in double
the step angle from five point six to
five degrees to eleven point two five
degrees because the step angle has
doubled we only need half as many steps
to make a full revolution of our output
shaft or 2048 steps rather than 4096
steps
in fact you can find an example sketch
in the arduino ide called stepper one
revolution but we'll have to make a few
modifications to get it to work with the
28 byj 48 stepper for starters we need
to tell the sketch how many steps we
need per revolution of our stepper
output shaft here you can see that 200
is defined but for our stepper running
in 4 step sequence the steps will
actually be 2048 also the library
included with the arduino software
expects the stepper to be wired a little
differently so we'll need to modify this
as well as shown
finally the speed is much too high
relative to what the stepper can handle
so we want to make sure that the speed
is set to 12 or less I've saved this
code as stepper 1 revolution
2 for download from my website let's
save this code and give it a spin
finally we can't close out our
discussion of motors without mentioning
motor shields this is hardware that you
can attach to your Arduino that takes
care of all those transistors diodes and
H bridges thus saving you the trouble of
having to do much of the wiring yourself
if you're purchasing from reputable
dealers like Adafruit or spark fun
you'll get the added benefit of custom
libraries that greatly simplify writing
sketches for your inventions
one thing that you want to pay attention
to are the general specifications and
power limitations of the shield that
you're investigating for this one
offered by Adafruit you can see that we
have 1.2 amp power limitation per Bridge
it allows up to 3 amps for brief periods
of up to 20 milliseconds but you
certainly wouldn't want to exceed that
or you'd risk burning out your equipment
you can find clones at a much lower cost
on sites like eBay but don't count on
getting the great customer service
online form support or the satisfaction
of knowing that you're supporting
innovative companies like out of fruit
or spark fun having said that I'll admit
I sometimes purchase from eBay but make
sure to pay close attention to
specifications of what's being purchased
for instance here you can see that this
shield only supports half the peak
current of the board sold by Adafruit so
I hope this chapter in the series has
given you enough information to start
playing with steppers and exploring this
stepper library that comes with your
Arduino software this concludes the 10
part series developed for 0 craft so if
you found this series helpful please
give this video a thumbs up thanks for
watching and please consider subscribing
for future demonstrations and code
associated with some of my own
inventions until next time
[Music]
[Music]
関連動画をさらに表示
✅ El más usado en Robótica para controlar Motores DC, Motores de Pasos, Driver L298N Puente H
¿De qué manera funciona el motor Paso a Paso? Parte 1 Tipos de motores paso a paso
¿Cómo conectar correctamente un Driver de motor paso a paso con cualquier plc?||Guía Completa
PWM Explicado | Cómo hacer un controlador de velocidad de motores DC
Servomotor Explicado
Simulación de Variador de Frecuencia en CADe SIMU _ Parte 2
5.0 / 5 (0 votes)