How To Control a Stepper Motor with A4988 Driver and Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 มิ.ย. 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)
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 366

  • @Maxspeed7Dab
    @Maxspeed7Dab 2 ปีที่แล้ว +33

    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.

    • @noweare1
      @noweare1 3 หลายเดือนก่อน +1

      Spent a day trying to figure that out, lol.

  • @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.

  • @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

  •  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!

  • @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!

  • @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.

  • @stevestronczek4754
    @stevestronczek4754 5 ปีที่แล้ว

    This is the best explanation for the A4988 on TH-cam. Thanks.

  • @gowrishankar8292
    @gowrishankar8292 7 ปีที่แล้ว

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

  • @C4rL05
    @C4rL05 3 ปีที่แล้ว +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.

  • @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 .

  • @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.

  • @carlosc.2236
    @carlosc.2236 3 ปีที่แล้ว +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.

  • @rusticagenerica
    @rusticagenerica 4 ปีที่แล้ว +1

    As usual, your tutorials are unbelievable. Your rock.

  • @trentonmulnix3026
    @trentonmulnix3026 4 หลายเดือนก่อน

    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!

  • @doctordhd
    @doctordhd 6 ปีที่แล้ว

    Works great! Thank you for this very helpful video!

  • @instasquid
    @instasquid 3 ปีที่แล้ว

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

  • @fritzwalter1112
    @fritzwalter1112 4 ปีที่แล้ว +1

    just a brilliant video for beginners!

  • @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?

  • @mb3896
    @mb3896 7 ปีที่แล้ว +1

    Really nice tutorial ! Thanks for sharing :)

  • @queenidog1
    @queenidog1 8 ปีที่แล้ว +3

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

  • @damianbutterworth2434
    @damianbutterworth2434 ปีที่แล้ว

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

  • @maxwelllllllllllable
    @maxwelllllllllllable 7 ปีที่แล้ว

    Thank you so much for this tutorial!

  • @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

  • @GiangNguyen-up9mv
    @GiangNguyen-up9mv 8 ปีที่แล้ว

    thank you alot for this nice guide!!

  • @vitorcontedoamaral6729
    @vitorcontedoamaral6729 2 หลายเดือนก่อน

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

  • @commandrone3338
    @commandrone3338 8 ปีที่แล้ว

    Thank you very much, it's very work!

  • @jorgeacosta1198
    @jorgeacosta1198 2 ปีที่แล้ว

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

  • @relhage100
    @relhage100 8 ปีที่แล้ว

    Thanks for the great tutorials. I recommend subscription.

  • @Pupek497
    @Pupek497 6 หลายเดือนก่อน

    Mega geiles Tutorial. Funktioniert wunderbar ya salamander.

  • @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

  • @bastienbruyere972
    @bastienbruyere972 7 ปีที่แล้ว +1

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

    • @jstro-hobbytech
      @jstro-hobbytech 2 ปีที่แล้ว

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

  • @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 ?

  • @michor10
    @michor10 5 ปีที่แล้ว

    Excellent. Thank you!

  • @zkhotty
    @zkhotty 5 ปีที่แล้ว

    Perfect video! What camera aru you use?

  • @lacenaepronta
    @lacenaepronta 4 ปีที่แล้ว

    Thank you 4 this excellent explanation

  • @oq17
    @oq17 2 ปีที่แล้ว

    Perfect - Thank you sir !

  • @raeedsh7070
    @raeedsh7070 6 ปีที่แล้ว

    Thanks..It helps me a lot

  • @dr.manoharshankarbs8045
    @dr.manoharshankarbs8045 2 ปีที่แล้ว

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

  • @MPElectronique
    @MPElectronique 8 ปีที่แล้ว

    Very complete thank does your motor heats up?

  • @paphaju1
    @paphaju1 8 ปีที่แล้ว

    Thanks a lot its very useful.

  • @pablofernandez2894
    @pablofernandez2894 7 ปีที่แล้ว

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

  • @ele4853
    @ele4853 ปีที่แล้ว

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

  • @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.

  • @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??

  • @brunoespinoza8621
    @brunoespinoza8621 8 ปีที่แล้ว

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

  • @maurofoti526
    @maurofoti526 7 ปีที่แล้ว

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

  • @surajchari9715
    @surajchari9715 11 หลายเดือนก่อน

    Best tutorial thank you very much sir

  • @DumbledoreMcCracken
    @DumbledoreMcCracken 5 ปีที่แล้ว

    Advice: by-polar not be-polar. Thank you for your excellent video.

  • @saeedmardani3900
    @saeedmardani3900 7 ปีที่แล้ว

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

  • @invinciblesolitary
    @invinciblesolitary 8 ปีที่แล้ว

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

  • @RobytheFlorentine
    @RobytheFlorentine ปีที่แล้ว

    very good video, thank you

  • @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

  • @ArnoldNeto411
    @ArnoldNeto411 4 ปีที่แล้ว

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

  • @qaisurrehman6377
    @qaisurrehman6377 3 ปีที่แล้ว

    absolutely nice video

  • @grzegorzkulawik6895
    @grzegorzkulawik6895 8 ปีที่แล้ว

    Great vid!

  • @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.

  • @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.

  • @spatialguy5571
    @spatialguy5571 5 ปีที่แล้ว

    Really REALLY good video - can’t thank you enough. You have my 👍 and subscription. Thank you.

  • @academicsstudio
    @academicsstudio 3 ปีที่แล้ว

    💝👍Excellent Tutorial

  • @voxellab4339
    @voxellab4339 7 ปีที่แล้ว

    thank you!!

  • @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?

  • @hamzaswailem3979
    @hamzaswailem3979 5 ปีที่แล้ว +1

    amazing vidio i made a project

  • @rafikbouhouse9788
    @rafikbouhouse9788 3 ปีที่แล้ว +1

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

  • @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.

  • @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 :-)

  • @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

  • @somdov
    @somdov 3 ปีที่แล้ว +1

    I had identical parts and it took days of research to figure out why mine wasn't working.
    My motor would beep and whine and struggle to move, but in the end I solved this by adding one wire.
    All I had to do was apply 5V to the linked RESET and SLEEP pins.
    This can be done by running one wire from the same breadboard row as the A4988 VDD pin and running it to the RESET row.
    Hope this helps someone!

    • @woodstock5056
      @woodstock5056 3 ปีที่แล้ว +1

      bro you're a lifesaver ! can't thank you enough for this

    • @somdov
      @somdov 3 ปีที่แล้ว

      @@woodstock5056 Pleased I could help! There really was nowhere else on the internet explaining this.

  • @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

  • @sabercruiser.7053
    @sabercruiser.7053 4 ปีที่แล้ว

    THANK YOU MAN SO MUCH

  • @havefun8962
    @havefun8962 2 ปีที่แล้ว

    wow perfect tutorial...

  • @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.

  • @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

  • @nabilderradji332
    @nabilderradji332 4 ปีที่แล้ว

    good job thank you

  • @umargul5644
    @umargul5644 2 ปีที่แล้ว

    Great job

  • @kcmacros9470
    @kcmacros9470 8 ปีที่แล้ว

    Thanks!!

  • @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?

  • @edisongarcia9231
    @edisongarcia9231 6 ปีที่แล้ว +1

    Thanks

  • @TheJavaSync
    @TheJavaSync 5 ปีที่แล้ว

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

  • @the21robot
    @the21robot 8 ปีที่แล้ว

    Nice tutorial, just wondering, does the stepper need two PWM pins or can it operate off of two digital input/output pins?

    • @the21robot
      @the21robot 8 ปีที่แล้ว

      +Dejan Nedelkovski thx

  • @artekaz18
    @artekaz18 8 ปีที่แล้ว

    thanks a lot.

  • @bikefarmtaiwan1800
    @bikefarmtaiwan1800 6 ปีที่แล้ว

    Hey Dejan, thank for an interesting and informative video. Am I missing something here...your code gives a 500microsecond delay in the loop for ontime and off time which would amount in a one step / second speed of rotation right?That would give a 200 second long single revolution which is not what you show. I know this time can be shortened but still the speed of rotation is ( as you mentioned) governed by the delay which wont work much below 10 microseconds if you are using step code. PMW is something different of course. Ít would be great to get your thoughts on that.

    • @dejayrezme8617
      @dejayrezme8617 6 ปีที่แล้ว

      Hey something I can answer :D
      1 second = 1000 milliseconds = 1000000 microseconds = 1000000000 nanoseconds

  • @akroutsamo
    @akroutsamo 8 ปีที่แล้ว +17

    current limit = vref * 2.5

    • @JimSteinbrecher
      @JimSteinbrecher 6 ปีที่แล้ว

      depends on the controller. on the last ones i got from ebay, it seem to be about 1.75 x vref.

  • @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.

  • @3dprintwiz378
    @3dprintwiz378 6 ปีที่แล้ว

    Hi, very nice informative vid. Just wanted to ask if you have experience jitter when turning on the arduino the first time on stepper? Mine jitters when turning on the arduino the first time. What could be wrong on what I am doing, I followed your circuit diagram.

    • @3dprintwiz378
      @3dprintwiz378 6 ปีที่แล้ว

      Problem solved by adjusting vref to .5v, but still seeing a little, one step movement before full movement, maybe a little mechanical load will eliminate it completely.

    • @JimSteinbrecher
      @JimSteinbrecher 6 ปีที่แล้ว

      you might need to increase the delay (microseconds), some motors will skip if you send step commands too fast.

  • @HowIWetYoMother
    @HowIWetYoMother 2 ปีที่แล้ว

    Could you control several motors this way? If so, how would they need to be connected so that everything works?

  • @damianbutterworth2434
    @damianbutterworth2434 2 ปีที่แล้ว

    Used this to make auto stepper motor blinds with a RTC.

  • @user-qe4yd9gp9f
    @user-qe4yd9gp9f 4 ปีที่แล้ว

    thanks!

  • @JJVgaming
    @JJVgaming 7 ปีที่แล้ว

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

  • @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?

  • @xianyangzhang2918
    @xianyangzhang2918 2 ปีที่แล้ว

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

  • @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.

  • @SIMIKINGMOTO
    @SIMIKINGMOTO 7 ปีที่แล้ว

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

  • @musaesin5163
    @musaesin5163 5 ปีที่แล้ว +1

    Thankss

  • @danwilbanks340
    @danwilbanks340 5 ปีที่แล้ว

    I need to generate 32 individual steps in one rotation of the stepper. Would the A4988 be the best choice for doing this? I like the fact it only deals with two perimeters - rotation and speed. Your video is probably the most clearly explained on this specific topic. Thanks.

    • @HowToMechatronics
      @HowToMechatronics  5 ปีที่แล้ว +1

      Well this stepper motor needs 200 steps to make a 360 degrees cycle in full step mode. 200/32 is 6.25, so would need to progress 6.25 steps in order to make 360 degrees cycle in 32 steps. However you cannot use such values for driving the stepper, only full numbers. Still there is way, and that's if you would use a different stepping resolution. For example if you use 1/8th stepping resolution, you would need 200*8 = 1600 steps for 360 degrees cycle. So now, 1600/32 is 50 steps. In this case you can achieve you 32 steps for making 360 degrees with progressing 50 1/8th steps each step.

  • @prameethkotian2235
    @prameethkotian2235 5 ปีที่แล้ว

    Are you Swedish? Nice content btw.

  • @Tjup
    @Tjup 4 ปีที่แล้ว

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

  • @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?