How To Control a Stepper Motor with A4988 Driver and Arduino

Поделиться
HTML-код
  • Опубликовано: 11 июн 2024
  • howtomechatronics.com/tutoria... ► Find more details, circuit schematics and source codes here.
    In this tutorial we will learn how to control a Stepper Motor using the A4988 Stepper Driver.
    Visit HowToMechatronics.com for more Tutorials, Tips, Projects and How It Works videos:
    ► howtomechatronics.com/
    Like my page on Facebook:
    ► / howtomechatronics
    Add me on Google+:
    ►plus.google.com/+Howtomechatr...
    Music: Aduro by Jens Kiilstofte (machinimasound.com/music)
  • НаукаНаука

Комментарии • 368

  • @Maxspeed7Dab
    @Maxspeed7Dab 2 года назад +35

    for anyone that is having problems with a buzzing or freaking out motor, try to connect reset and sleep pins to 5v instead of each other, that worked for me.

  • @MaxMakerChannel
    @MaxMakerChannel 7 лет назад +50

    I cannot thank you enough for this. Every time I setup a new stepper, I use your video again! My last comment is 1 year old, in the meantime I started my own channel : )

    • @aneeshvempa8122
      @aneeshvempa8122 5 лет назад +1

      Max Maker sir, my stepper motor is 17ha0403-32n........it is not completing a revolution even after 700 steps....... How to know whether there is a problem in stepper motor or driver

    • @mmohsin1666
      @mmohsin1666 5 лет назад

      max maker i need ur help regarding stepper motor

    • @pepe6666
      @pepe6666 5 лет назад

      @@aneeshvempa8122 check the microstepping pins. it might be set to do microstepping. also check that you have pulled the sleep & rest pins high. if they are floating they can chop your movement up. also ensure you have the direction pin connected to something & not floating. that has no pullup or pulldown so it definitely will make your stepper wobble wrong

    • @ducksonplays4190
      @ducksonplays4190 3 года назад

      @@aneeshvempa8122 yours might be precise mine takes 4096 steps per rotation

  • @FanucM16i
    @FanucM16i 6 лет назад +4

    Great tutorial ! Straight to the point without a lot of distracting information. Thank you. I'm looking forward to setting up my system.

  • @menuxpressions9128
    @menuxpressions9128 3 года назад +2

    Your direct and complete explanation along with great video quality is the best I’ve seen on Arduino so far. Thanks for posting.

  •  4 года назад +3

    this channel is like a gold mine!

  • @smickandily
    @smickandily 6 лет назад +1

    what a great video! Thanks for the careful explanation. The voltage limiting bit was super helpful.

  • @sasatarle5393
    @sasatarle5393 8 лет назад +1

    great video! i like a detailed explanation of each step, its perfect for a beginner like me. hopefully, in the next one hour my motor will start rotating!

  • @stevestronczek4754
    @stevestronczek4754 5 лет назад

    This is the best explanation for the A4988 on RUclips. Thanks.

  • @rameshtripathy5978
    @rameshtripathy5978 3 года назад

    Very good description & demonstration! It is very use full & helpful for many projects ! Thank you so much Sir for your beautiful presentation .

  • @lirilsilvi
    @lirilsilvi 2 года назад +1

    A really helpful and informative video. I was struggling with running my stepper motor and I found this. You saved my lot of time.

  • @doctordhd
    @doctordhd 6 лет назад

    Works great! Thank you for this very helpful video!

  • @TheTruthHunters
    @TheTruthHunters 4 года назад +1

    It's now 2020 and still this comes in veeeeery handy for someone never built a 3D printer on his own - which is now my current task ( Removing all the crap electronics from an Anycubic Predator ). Thanks a lot, appreciate the info!

  • @maxwelllllllllllable
    @maxwelllllllllllable 7 лет назад

    Thank you so much for this tutorial!

  • @fritzwalter1112
    @fritzwalter1112 4 года назад +1

    just a brilliant video for beginners!

  • @gowrishankar8292
    @gowrishankar8292 7 лет назад

    The way of your Explanation was too good.i can understand entire thing,thanku dejan.
    its very useful to me..

  • @instasquid
    @instasquid 3 года назад

    This video is still helpful, even after 5 years. Thanks!

  • @rusticagenerica
    @rusticagenerica 4 года назад +1

    As usual, your tutorials are unbelievable. Your rock.

  • @mb3896
    @mb3896 7 лет назад +1

    Really nice tutorial ! Thanks for sharing :)

  • @damianbutterworth2434
    @damianbutterworth2434 Год назад

    I`m back again using your advice. This time for a telescope EQ drive. Thanks again.

  • @queenidog1
    @queenidog1 8 лет назад +3

    Excellent presentation. Flows well, I wasn't bored! Thanks for posting.

  • @GiangNguyen-up9mv
    @GiangNguyen-up9mv 8 лет назад

    thank you alot for this nice guide!!

  • @carlosc.2236
    @carlosc.2236 4 года назад +2

    During this lockdown I'm trying to make a focusing rail for macro photography, fortunately I have all the elements that you used. I still have some doubts about the code, but I will give it a try and then will make some twiking to make it to work in my project. Thank you very much!

    • @damianbutterworth2434
      @damianbutterworth2434 2 года назад +1

      I used a 180 degree servo motor to control my telescope focus. No wobble even with a 5 x barlow. I used hot glue to stick it all together lol.

  • @commandrone3338
    @commandrone3338 8 лет назад

    Thank you very much, it's very work!

  • @relhage100
    @relhage100 8 лет назад

    Thanks for the great tutorials. I recommend subscription.

  • @MaxMakerChannel
    @MaxMakerChannel 8 лет назад

    Thank you. This is a very good video. I just build the circuit and it works. Only had to increase the delay from 500 to 1000 microseconds. Otherwise the Nema 17 won´t move.

  • @Pupek497
    @Pupek497 6 месяцев назад

    Mega geiles Tutorial. Funktioniert wunderbar ya salamander.

  • @C4rL05
    @C4rL05 4 года назад +1

    Simply amazing. I followed you video and now I have my motor working exactly as I needed it. I just had to modify your code just a bit. Thank you very much.

  • @trondwell13
    @trondwell13 7 лет назад

    Thanks Dejan - very clear - I have different hardware so I will work though your example first......but i guess it might be easier to get some A4988's

  • @michor10
    @michor10 5 лет назад

    Excellent. Thank you!

  • @vitorcontedoamaral6729
    @vitorcontedoamaral6729 3 месяца назад

    Thanks for sharing your work, you really helped me in this one, excellent step by step

  • @janlukamichalski5990
    @janlukamichalski5990 6 лет назад

    Thanks a lot for this tutorial. It helped a lot. I have a question. If I try to run the program as is on an at tiny the motor behaves different than it does, when connected to the Arduino. It has less torque and runs not as smooth. Suggestions ?

  • @bastienbruyere972
    @bastienbruyere972 7 лет назад +1

    Thank you for tis amazing and verry clear video with lots of great information!!

    • @jstro-hobbytech
      @jstro-hobbytech 3 года назад

      I second that. Vref is explained piss poorly by almost everyone

  • @santiagon.2194
    @santiagon.2194 5 лет назад

    Look, I come from Uruguay, I've been searching for a video (in spanish) to understand those fucking drivers and I couldn't find any video to get its function... When I searched for it in english I found this video, I could understand it very quickly. Thank you very much! I wouldn't be able to keep my project without you

  • @jorgeacosta1198
    @jorgeacosta1198 2 года назад

    exelente tutorial despues de mucho consegui entender muchos detalles que no sabia gracias exito y salud

  • @3dprintwiz378
    @3dprintwiz378 6 лет назад

    I have another question though. If I was to do microstepping, say 1/2 microstep, so I only need to connect MS1 to +5v but leave MS2 and MS3 un connected or should I connect them to ground as well? I don't want to make a mistake in connecting microstepping pins coz it may fry my board. Thanks.

  • @aZnLy96
    @aZnLy96 5 лет назад +13

    I believe you should use pololus current limit formula which is
    current limit = VREF/ 8 * RCS
    in this case:
    current limit = 0.6/ 8 * 0.1
    for the fullstep mode
    current limit = 0.6/ 8 * 0.1 * 70/100 = 0.525 A
    im still new to this, but it seems more accurate in this and in my case.
    this video still helped, thanks!

    • @rrksama9314
      @rrksama9314 7 месяцев назад

      hi, does current limit mean that the provided current(to the a4988 motor driver) should at least be 0.5A, or does it mean the current should be higher than 0.5A?

  • @oq17
    @oq17 2 года назад

    Perfect - Thank you sir !

  • @DjalmaRibeiro
    @DjalmaRibeiro 5 лет назад +1

    I made all the connections you showed but my engine was vibrating or doing crazy moves. I solved the problem by reversing the two middle wires of the motors in the a4988 inputs.

  • @dr.manoharshankarbs8045
    @dr.manoharshankarbs8045 3 года назад

    Thank you sir, for the excellent website. Great teaching and knowledge sharing

  • @raksareza3645
    @raksareza3645 7 лет назад

    Thanks a lot its very useful :)
    i wanna ask, can we control the step of motor at 2 degree each step with this method??

  • @paphaju1
    @paphaju1 8 лет назад

    Thanks a lot its very useful.

  • @lacenaepronta
    @lacenaepronta 4 года назад

    Thank you 4 this excellent explanation

  • @raeedsh7070
    @raeedsh7070 6 лет назад

    Thanks..It helps me a lot

  • @Iboo30
    @Iboo30 6 лет назад

    If I want two motors to do this at the same time, can I just connect two more cables from pins 3 and 4 to the second driver or do I need to define two more output pins to do the same?

  • @rafikbouhouse9788
    @rafikbouhouse9788 3 года назад +1

    Hello, can I run a servo ac motor with the same program that starts the stepper motor(dir pulse)?

  • @SIMIKINGMOTO
    @SIMIKINGMOTO 7 лет назад

    Hi if this setup can drive bigger stepper motor? I want to mount motor to lathe carriage...

  • @maurofoti526
    @maurofoti526 7 лет назад

    Hi, thanks for this tutorial, is a 100 microfarad 25v capacitor ok for the circuit power?

  • @JimSteinbrecher
    @JimSteinbrecher 6 лет назад +14

    i tried this with a low-profile 400-step 36mm printer motor (36H12HM-0304A), and found that you can drive it from a 6 ~ 6.5 volt supply (ex., four AA batteries). although the driver says the minimum supply voltage is 8v, it still worked fine, down to pulses of approximately 700 us (ie, delays of 350 microseconds, using the example in this video). below 600 us (300 us delay), the motor started to skip.
    I also tried driving it from 4.7v (three AA batteries), but it did not work. there was still come current reaching the motor (i could feel the coils buzzing), but the voltage on the coil wires was very low (less than 2.5 volts), and not enough to turn the rotor. even a 3.3v micro motor would not run.

    • @pepe6666
      @pepe6666 5 лет назад

      thats good to know. i found this out as well but i had been nervous because my batteries would eventually go below the lovely 4v (got two, so 8v) and i had been concerned.

    • @lulabmaredilcastones9073
      @lulabmaredilcastones9073 4 года назад

      thank you from information it's helpful

  • @surajchari9715
    @surajchari9715 11 месяцев назад

    Best tutorial thank you very much sir

  • @kevinbelaen601
    @kevinbelaen601 7 лет назад

    Hello, how do I go about plotting the output speed of the motor? For my project I need to plot force from a load cell vs velocity of the motor. Thank you.

  • @RobytheFlorentine
    @RobytheFlorentine Год назад

    very good video, thank you

  • @grzegorzkulawik6895
    @grzegorzkulawik6895 8 лет назад

    Great vid!

  • @trentonmulnix3026
    @trentonmulnix3026 5 месяцев назад

    I followed this tutorial with all required hardware. I had issues with buzzing and losing consistent position. I used a NEMA17 stepper from an old 3D printer. I solved my issue by connecting sleep/reset pins, adjusting steps to 400 and 800 (0.09deg IPO 1.8deg), and slowly adjusted timing within loops (ended with 660ms). Hope this helps!

  • @zkhotty
    @zkhotty 5 лет назад

    Perfect video! What camera aru you use?

  • @nemuccio1
    @nemuccio1 7 лет назад

    Hi, I have an engine with 6 wire. The 2 wire power as I connect them?
    Thank you
    SANYO DENKI 103H546-0440

  • @threefour1598
    @threefour1598 2 года назад +7

    00:00 Video Intro
    00:18 A4988 Introduction
    00:40 Microstep Resolutions - "The driver provides 5 stepper resolutions: Full Step, Half Step, ..."
    00:49 A4988 General Specifications
    01:15 Pinout Of The Driver
    04:41 Complete Circuit Schematic
    07:15 The Example Code
    09:01 Demonstration Of Code & Parts In Practice
    09:15 One More Example
    09:25 Thanks For Watching & Outro

    • @fxsrider
      @fxsrider 2 года назад +1

      Thank you for taking the time to do that!

    • @threefour1598
      @threefour1598 2 года назад +1

      @@fxsrider Glad to be of help. As I found these timestamps useful in other videos, I decided to do it so that others and myself can benefit from this. Hope it helped

    • @fxsrider
      @fxsrider 2 года назад +1

      @@threefour1598 It helps everyone that dives into the comment section.

  • @ycmgxekwa
    @ycmgxekwa 6 лет назад

    Hi Dejan
    I am only able to run the stepper for maximum 2 minutes and where after the stepper and driver start to heat up. What could I be doing wrong?

  • @pablofernandez2894
    @pablofernandez2894 7 лет назад

    Excellent guide. Do you know of any stepper driver library that can control motors easily?

  • @tamgaming9861
    @tamgaming9861 6 лет назад

    Can i use the power suply wich is delivered with the arduino to rebuild the project? If not, which power supply do you recomend from amazon to buy? Thanks in advance :-)

  • @brunoespinoza8621
    @brunoespinoza8621 8 лет назад

    A very good explanation. Keep up the good work, Dejan!

  • @TheJavaSync
    @TheJavaSync 5 лет назад

    Dear friend, in order to use salvage stepper motor how to determine the microstep resolution - which one I have to choose ?

  • @invinciblesolitary
    @invinciblesolitary 8 лет назад

    Thank a lot for a good guide but it's so complicated for me

  • @saeedmardani3900
    @saeedmardani3900 7 лет назад

    Excelent explanation and everything, thanks Dejan, I used it a lot!

  • @Tjup
    @Tjup 4 года назад

    a setup like that, can it be done whitout Shield? and GRBL? im struggeling to make it work..

  • @beerborn
    @beerborn 7 лет назад

    What would be a recommended stepper motor for a GAF 3000s Super 8 projector so i can use it to do frame by frame capture.

  • @farajalyami2044
    @farajalyami2044 7 лет назад

    I would like to have the link of tutorial for driver stepper motor by potentiometer . Please can you show me the schematic diagram for the circuit

  • @academicsstudio
    @academicsstudio 3 года назад

    💝👍Excellent Tutorial

  • @brendanward9955
    @brendanward9955 7 лет назад

    Could I skip wiring the 12v power supply to the board if I just want to use a stander 12v adapter that plugs into the the barrel jack on the arduino?

  • @ArnoldNeto411
    @ArnoldNeto411 4 года назад

    Great!! Can we connect 6 or 6 step motors Nema 17 for example?

  • @Daniel-odanio
    @Daniel-odanio 5 лет назад

    does the Driverboard power the Arduino with 5 volts like the A3967 do?

  • @MPElectronique
    @MPElectronique 8 лет назад

    Very complete thank does your motor heats up?

  • @ele4853
    @ele4853 Год назад

    Cool. I have a stepper motor with three coils do you have a recommendation to what driver to use?

  • @crosshatchengineering
    @crosshatchengineering 7 лет назад

    Nice tutorial.
    Question, the stepper I am using rotates smoothly in one direction and vibrates the other direction but I have the code to have the same delay and steps, so why does it vibrate in one direction and not the other?
    Cheers.

  • @danielpuchta674
    @danielpuchta674 5 лет назад

    Thanks for the video. But how do the control system knows if the set of instruction which is sent to the motor via driver, was done? Because usually stepper motors are connected without any measuring device like rotary encoder so the system itself doesnt have any feedback if the rotation defined by steps was done. But in some cases (like if I use them for powering the axis of 3D printer) the system needs to know if the motor completed the rotation or not, and then the system can sent the command to other stepper motor to move in other axe/axis... Do the drivers have a dedicated signal for this purpose? (Like - was lastly sent set of instruction completed?). Or does it work by the principle of knowing the speed of rotation and the desired position, so the system calculates the time and after the time is reached, the system assume that the desired position was reached?

  • @anticrist2054
    @anticrist2054 8 лет назад

    how could I know the relationship of delay between steps with the read speed rotation?

  • @imerjajusufi6330
    @imerjajusufi6330 7 лет назад

    hi i used l298n after 1 min driver so hot . can you tell me the a4988 driver is stable and can play for long time ? thanks

  • @Markitos203
    @Markitos203 7 лет назад +2

    Quick question, you send 200 pulses to achieve a full revolution at full step. So that means i would have to sent 400 at half step, 800 pulses at 1/4 step and so on?

    • @ronniepaulinc
      @ronniepaulinc 6 лет назад

      the 200 you are talking about is the number of steps it takes for your stepper to make one full revolution... Micro-Steppers do exactly as you are describing but most people fail to understand why! The best way to explain it is to IMAGINE drawing a circle using only 4 points.. Draw a straight line between all four points and you get a square. Keep scaling that up in your mind until you get to 16k points... Basically what you are doing is creating a higher resolution.. Most desktop machines will never need anything more than what is called a half step.
      When you start getting to the Larger machines like a 4foot by 8foot then you will need more, MAYBE.. If you are cutting squares all day then you do not need any.
      Creators who make their own PCB might get some advantage from microstepping but to be honest bit run-out on small cuts is the biggest hit to quality so a good set of precision collets and chucks are their best investment!
      To get a good mental picture of run-out put a really long bit in your drill and spin it and real high speeds. look at the tip of the bit when it is spinning and you will see it does not spin as much as it goes in a circle. Getting that bit to sit in exact Zero so it spins dead straight is called run-out.
      Everyone who has ever drilled a hole has experienced run-out. When you put the bit to the surface and turn it on and the bit just walks away from where you are drilling! That is why center punching is used to to create a depression and keep the bit from "WALKING" When you get that in a CNC machine it creates CHATTER and that sends vibrations to your entire machine. Not to mention the final results of the cut under magnification looks more like someone chewed it rather than it being a polished finish. No amount of microstepping can fix this!

  • @speedracer77
    @speedracer77 2 года назад

    Sorry newbie question: where it says 12V, 1.5A Adapter, is that just where the battery would be? Or do I need some kind of adapter in between my battery and the driver board?

  • @kathiac3299
    @kathiac3299 6 лет назад

    I used the same code and wiring as you and i am applying 12 V and 2A but the circuit isnt doing anything. Do you have any sugestions?

  • @abdelalkuor6293
    @abdelalkuor6293 7 лет назад

    Hi, why did you choose 500us between each step? I have 17HS4401 stepper motor, how can I know the maximum operating frequency ? Thank you.

  • @jamesgalea8987
    @jamesgalea8987 5 лет назад

    Hi, I have connected everything as shown and the motor works fine in one direction however buzzes in the other direction. Any ideas as to what I can check for? I have tried a new driver and motor so they should not be an issue.

  • @qaisurrehman6377
    @qaisurrehman6377 3 года назад

    absolutely nice video

  • @Banana-qw7hd
    @Banana-qw7hd Месяц назад +1

    Is there a way I could get the motor to cycle a number of times at certain time of day every day?

  • @calvinbarajas5144
    @calvinbarajas5144 5 лет назад

    Awesome video Dejan, thank you sooo much. Is there a way to control speed (angular velocity) with software only (no potentiometer)?

    • @brendan3966
      @brendan3966 4 года назад

      Just change the delay time between digital writes.

  • @mysticalsoulqc
    @mysticalsoulqc 3 года назад

    Thank you, very well explained! accent passed! lol

  • @robvincentechon139
    @robvincentechon139 6 лет назад

    Hi sir, can I manipulate 2 stepper nema 17 using these? Im making my projects using voice commands sorry for my english btw thanks

  • @JJVgaming
    @JJVgaming 7 лет назад

    Do u connect the motor power and stepper while measuring the voltage?

  • @voxellab4339
    @voxellab4339 7 лет назад

    thank you!!

  • @sabercruiser.7053
    @sabercruiser.7053 4 года назад

    THANK YOU MAN SO MUCH

  • @havefun8962
    @havefun8962 2 года назад

    wow perfect tutorial...

  • @nukulkhadse5253
    @nukulkhadse5253 7 лет назад

    Can we use A4988 motor driver IC instead of adafruit motor shield if we want to control stepper motor using MATLAB?

  • @msindisimtengwane9456
    @msindisimtengwane9456 5 лет назад +1

    Hey man...great video. Thanks for sharing. Quick question. What size battery would I need in order to power this setup? I want to build something like this, but I won't have a power outlet where I will be using it so I wanted to use batteries.

    • @nizarworld2020
      @nizarworld2020 3 года назад

      I uses 1.5a 12 v regulated.its enough

  • @xianyangzhang2918
    @xianyangzhang2918 2 года назад

    hello, may I know what kind of adapter you used for the power source?

  • @roystervi
    @roystervi 2 дня назад

    Hi at time stamp 2:06 does it matter if 1A and 1B on the same coil is reversed? example on the chart is showing one coil (black A+ and blue A-)

  • @mohamedmohamed-qf2fh
    @mohamedmohamed-qf2fh 2 года назад

    HI i want to know what is the difference between TMC2130 and A4988 and does the TMC do full, half, 1/4, 1/8 and 1/16 step modes operate steps ??

  • @Brian24624
    @Brian24624 8 лет назад

    Is it okay if I use the 12V, 5A power adapter to motor supply rather than using 12V 1.5A adapter? (because I have only 12V 5A power adapter)

  • @ricardomiranda7737
    @ricardomiranda7737 7 лет назад

    There's only one step pin on the A4988 and I see that the output for the digitalWrite is for pin 3 (on arduino) alternating between Hi and Low in order to create the desired pulse pattern. But it seems to me that here we are only using one phase aren't we...how can you control which phase the pulse will be directed to (A1/A2 or B1/B2) for the individual windings...
    Also, on mine, it takes over 7,000 steps to make a full rotation instead of 200 using the exact same code.
    And, my motor is not as quiet.
    Any ideas where I'm going wrong...I'm using 9v battery to power the DC motor.

  • @__gyan_
    @__gyan_ 7 лет назад

    Hi ,
    I want to use tb6560 but this reduces the stop current to 50% of runnung current when motor is not geting any signal from driver .
    I want ask about how to increase this current to the 100% .
    Or is there there any driver which can supply full current to hold the load.
    volt(12 to 24 ) and 1 to 3 amps.
    Thanks

  • @labeej
    @labeej 3 года назад

    Hi,
    thanks for this great tutorial. Is there any solution to use only 1 power plug? Now you use one for powering the motor and one for the arduino.
    Thanks,
    Juris

  • @umargul5644
    @umargul5644 2 года назад

    Great job