Raspberry Pi Stepper Motor Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2017
  • This tutorial demonstrates how to control bi-polar stepper motors on a Raspberry Pi in Python using a DRV-8825 stepper motor driver.
    Notes, schematics, code, updates and other resources are available on my website: www.rototron.info/raspberry-pi...
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @boatalarm5920
    @boatalarm5920 4 ปีที่แล้ว +86

    OMG... This guy KNOWS HOW TO MAKE A GREAT TUTORIAL! Fast, concise and NO music!!! FIVE STARS!!!!!

    • @VincentFischer
      @VincentFischer 3 ปีที่แล้ว +2

      Who doesn't like some loud energetic dubstep when you try to memorize stuff

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

      Yag

  • @thebunyip
    @thebunyip 6 ปีที่แล้ว +33

    You do a fantastic job of presenting a complex (probably not for you) system. I am an old school mainframe programmer from the 60's-70's. I have two Raspberry Pi's and am programming the hell out of them but you put my playing to shame. Kudos and love your tutorials

  • @neoc03
    @neoc03 6 ปีที่แล้ว +67

    This is far and away the best tutorial on this! Thank you so much for being so clear and concise.

    • @furman87
      @furman87 6 ปีที่แล้ว +2

      Agreed. I learned more about stepper motors and how to control them in this tutorial than anywhere else I looked. After mocking up something on a breadboard and getting it working, I transferred that onto a Raspberry Pi HAT breadboard and it works fantastically

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

      May be, but I can not understand the language of this video. For me it is therefore useless.

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

      Thk u

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

      I also agree A+++ on raspberry code explain and wiring info

  • @tomd7841
    @tomd7841 3 ปีที่แล้ว +2

    One of the clearest tutorials I've ever seen. Great work. Thanks very much!

  • @chop661
    @chop661 4 ปีที่แล้ว +13

    Perfect explanation, concise, to the point and well presented. Thank you!

  • @graceyee9067
    @graceyee9067 2 ปีที่แล้ว +3

    Wow, this is the most concise and informative tutorial I've ever watched, thank you for taking the time to make it!

  • @akshayd211
    @akshayd211 4 ปีที่แล้ว +2

    I am 100% sure that this is the best video tutorial on this topic in the WORLD.

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

    This is so informative that it should reach every stepper motor enthusiast out there....

  • @ghost2coast296
    @ghost2coast296 4 ปีที่แล้ว +2

    thank you! I really like how you took the time to walk through all the code and explain it to us

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

    thank you for this work as it did open some aspects of the PI to me, but also covered the method of telling what your stepper driver is doing, so that you can set it ahead of time to around what you need with a lot less fidgeting to get the output for a given motor, (if you know the values it is supposed to receive) to get it set up, the first time. Again thank you.

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

    Great tutorial, very clear explanations. Easy to understand & well structured. Thanks heaps!

  • @JimEckhardt
    @JimEckhardt 10 หลายเดือนก่อน +1

    Best stepper vid I've come across yet! So many useful little nuggets in there.

  • @sandro-nd6ir
    @sandro-nd6ir ปีที่แล้ว +2

    This is simply one of the best tutorials I have ever seen. Thank you so much :)

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

    Awesome tutorial with a great amount of details shared. Thank you!

  • @FabricioRWitt
    @FabricioRWitt 5 หลายเดือนก่อน +1

    This is an exceptionally excellent tutorial and class. Thank you so much for sharing your knowledge! I'm currently studying stepper motors for usage on precision peristaltic pumps for prototyping a dosing machine. Thank you once more, you're great!

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

    Excellent tutorial, explanations are just crisp and clear.

  • @tomrouillard3908
    @tomrouillard3908 6 ปีที่แล้ว +4

    Excellent job - hugely informative and useful. Thank you.

  • @johnrobie9694
    @johnrobie9694 4 ปีที่แล้ว +2

    A lot of clever little tricks sprinkled throughout this video. Thanks!

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

    Hey... Gotta say that this video was worth watching!!!

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

    By far one of the best tutorial about the Raspberry Pi and Stepper motor i have seen

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

    Great work & nice to see something without having to listen through background music .

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

    This was exactly what I needed to see. Thank you so very much!

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

    This is the best tutorial I have ever seen!

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

    thank you for this tutorial! your effort is deeply appreciated.

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

    Timely, succinct and complete ... *THANKS*

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

    Excellent tutorial! Clear and concise! bravo!

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

    Why can't every tutorial video be this good?

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

    Wow. Such a clear explanation 👏 excellent job!

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

    Great tip using the LED to figure out the pairs. I had headers wired the wrong way till I tried this. Thanks.

  • @parameciumcheese
    @parameciumcheese 6 ปีที่แล้ว +4

    Fantastic video! Thanks for taking the time to make this. Answered all my questions and more.

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

    This has been so helpful. Thank you for this

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

    every time you upload amazing video thank you for your affairs

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

    You are a hero! Thanks a lot for explaining this to us this clearly! I needed someone to explain this to me like I'm braindead!

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

      me too! I'm really good at blinking a lot

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

    Very Good.You have solved many questions. The BIG AH HUrH. THANK YOU.

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

    This video will help me so much, Thank you!

  • @arbjful
    @arbjful 10 หลายเดือนก่อน

    Nanotec makes some really great stepper motors and drivers, we use these a lot for our industrial applications

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

    EXcellent video, just what I needed 😄

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

    Wow this is really dense. Great tutorial, thank you :)

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

    This is an awesome video. I have been struggling to use a RPI with a serial port HAT to control bipolar stepper motors using old Shopbot control boards and the Shopbot DOS program through an emulator. It works, but the DOS emulation is not powerful enough to run the motors at full speed. It looks like I need to try a DRV-8825 and learn some Python. Thank you!

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

    Brilliant tutorial, to the point and no waffling. Really useful thanks very much

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

    Excellent tutorial. Would also like to see one with C++ control.

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

    Best tutorial ever!

  • @venkateshyadla9503
    @venkateshyadla9503 4 ปีที่แล้ว +2

    THAnk you boss... thanks for deep explanantion..

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

    Very good video, very helpful! Thanks you.

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

    Excellent video!

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

    Very informative video. I hope you keep it up.

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

    Amazing video, very informative

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

    This helped me a lot! Thank you

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

    This is an awesome tutorial

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

    This was super helpful!! Thank you

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

    Wonderful video. Engaging and informative.

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

    very clear, thank you

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

    IT WORKS thank you.

  • @eajinarc4425
    @eajinarc4425 4 ปีที่แล้ว +47

    After watching this video...
    Me: "OK, I got it, let's try it"
    My Raspberry Pi: "No, you didn't"

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

      same to me but maybe its the version that we use... depend on version tha for i in range( in my case) is different to python 2.7

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

      For real cuz . exactly how I feel Xd

  • @vladimirpotapov7050
    @vladimirpotapov7050 2 ปีที่แล้ว +1

    Nice tutorial, thank you a lot !

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

    Liked, subscribed and favorited! This is awsome!

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

    Hi guy thanks for your explain is vero complete congratulations

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

    Great video !!

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

    Awesome video! Thank you!!

  • @BLau-oi4zc
    @BLau-oi4zc 3 ปีที่แล้ว

    It worked! Thank you very much!!

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

    Great explanation

  • @aboudezoa
    @aboudezoa 2 ปีที่แล้ว +1

    Very well explained

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

    You are a genius. you should be woking for space x

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

    Brilliant. very informative

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

    top class knowledge

  • @VinayKumar-kv4yu
    @VinayKumar-kv4yu 6 ปีที่แล้ว

    excellent tutorial..

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

    Excellent Thank You

  • @boredbritgamercouk
    @boredbritgamercouk 4 ปีที่แล้ว +3

    Hi, firstly this code (including the micro-steps) all worked great for me. I was just wondering if you could further customise the code to allow manual control of the motor (ie typing a positive or negative value into terminal so motor moves clockwise or anti-clockwise a number of steps) and then controlling multiple motors at once? I'd love to run up to 4 motors and I think this is such a solid base setup for code but looking for some help! Thanks :)

  • @Bianchi77
    @Bianchi77 2 ปีที่แล้ว +1

    Nice info, thanks :)

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

    thank you

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

    wow you're genius

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

    Nice job.

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

    Great Video,
    I need to move my stepper motor as a function of sine wave
    lets say for time in incrementing from 0to 100s
    y=amplitude*sin(2*pi*frequency*t)
    so displacement of stepper motor should as per change in y
    could you help me in that

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

    Most excellent

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

    Thanks

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

    THANKS

  • @Q24H
    @Q24H 7 ปีที่แล้ว +2

    Great tutorial, was just planning on playing with some stepper motors! For the current limiting calibration, if I'm using a 12V 0.4A Nema, I should set the Vref to 0.2v?

    • @rdagger
      @rdagger  7 ปีที่แล้ว +3

      Yes, the maximum Vref would be 0.2V because Current Limit = Vref × 2
      Actually, if you are only running in *full step* mode the maximum Vref would be about 0.28V because there is an additional 71% limit.
      It's always a good idea to monitor the motor and driver temperature. I like to use a 5 second rule. If I can touch the motor and driver for at least 5 seconds without burning my fingers then the current is probably OK. Please note that the current can also be limited by the coil resistance. If your coil resistance is greater than 30 ohms then your current won't exceed 0.4A at 12V because of Ohm's law.

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

      Thank you this fixed my problem!

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

    can I setup a set of If then commands to follow up with an small toy machine?? like an small excavator???

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

    exellent

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

    very nice.

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

    Hello, what would be the ideal voltage of drv 8825 driver if usinf a nema stepper with 1.5A current at 12V. I want to make a button presser to press button of 1.6N in a full step mode but its skipping a step while pressing a button thus not presing it all the time

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

    I wonder if its possible to integrate PID control in this as well

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

    I found this video to be incredibly helpful. I'm currently working on a project that requires me to drive 5 NEMA​ 17 motors. I was wondering if I would be able to use 5 of these drivers for this task. If so, would I just need to wire each driver to its own pin and then connect them all to the same 3.3 v and ground pins on the pi? Thanks for the help.

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

      Yes in theory you should be able to control multiple stepper drivers depending on your timing requirements. At least 1 pin would be required per driver (2 if direction required.)

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

    awesome!!

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

    This is the best tutorial I have seen. However, could you tell me please how the code becomes if we want adjust the speed of a stepper motor by selecting a specific frequency (example :1010 Hz) using hardware_PWM(18, frequency, duty cycle) and then rotate the motor with a specific angle at that speed ?

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

      To accurately control both frequency and steps, I think you would need to use the PiGPIO _generate_ramp()_ method. I’m not sure if it supports the hardware PWM which would afford more precise frequency control. It might automatically switch to hardware if you use GPIO 18. You would have to hook up a scope to determine if you are getting the correct frequency. You could also ask Joan the creator of PiGPIO. She is very good about responding to questions and she might have additional recommendations.

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

    First example which actually made my motor run using Python on the Raspberry, a lot of other tuts did not make my motor run. I used Livecode too, which also works, but the graphic interface interferes with the motor strangely. With the GPIO i got errors like: please use GPIO.setmode(GPIO.BCM) which i did, so i don't understand this error, also it also run only CW and not CCW, could see the motor react on it and stalled.

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

    Hi I starting my small project with stepper motor and I found your solution for controlling it , I am very impressive of you work , The last part using hardware_PWM is great and doing exactly what I need , but one thing :) how to change the direction instead slowing down. I mean the motor will do one ramp on CW direction then another ramp but on CCW direction .

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

      I'm not sure I understand your question. It has been a long time since I used this library, but you should be able to set the direction using pi.write(DIR, 0) or pi.write(DIR, 1).

    • @maiodab670
      @maiodab670 3 หลายเดือนก่อน

      @@rdagger Thanks a lot, I have solved my problem .

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

    Nice work. How any stepper motors can be controlled using this driver?

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

      Generally speaking, one stepper motor per stepper driver. In theory you could run 2 motors but I haven't tried it. You would probably need to double the current if running in parallel or double the voltage if running in series. I've heard there are issues using the DRV8255 in parallel so series would probably be the best bet.

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

    I am using nema 17 and the torque reduced substantially compared to when I ran the stepper with 12V with arduino uno.... any help is appreciated

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

    thank you

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

    Thumbs up!

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

    Is it a good idea to connect STEP pin to hardware PWM pin on RPi? Thanks!

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

    First off thank you for such a clear and detailed explanation of this process. I have been successful in performing your steps. My application has a need for switch controlled movement with a pair of momentary buttons. ex. button 1 press moves ccw until released and a press of button 2 moves cw until released. Any guidance for this capability would be appreciated. I don't want to have to change over to an Arduino solution if i don't have to. My application is for a Z-axis bed for a laser engraver that will be controlled separately. Again thanks for your videos..

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

      My example with the toggle switch would work. You just need to change the main loop to something like:
      dc = 128
      if pi.read(SWITCH1) == 0:
      pi.write(DIR, 0)
      elif pi.read(SWITCH2) == 0:
      pi.write(DIR, 1)
      else:
      dc = 0
      pi.set_PWM_dutycycle(STEP, dc)
      sleep(.1)

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

      @@rdagger thanks for the head start... i'll be giving this a try soon.

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

    I am wanting to use a Raspberry Pi Pico to run a NEMA 34 stepper motor. IMO using a raspberry pi to run a stepper motor is like driving an 18 wheeler to the store to buy milk and eggs. Granted the Pico was released after this video was made. The problem with the Arduino is the frequency is not high enough to run the NEMA 34 at maximum speed. I am going to experiment with the DRV-8825 Controller since it takes up less Real Estate then a standard Stepper Controller.

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

    Hi! Thanks for the tutorial! I'd like to ask how I would implement multiple motor controllers to the Pi. Would I be able to use the multiple GPIO ports and establish what ports I am using in the code?

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

      I’ve been asked that questions multiple times and I will probably address it in another video when I have more free time. The short answer is yes, but it depends on the type of precision and timing you need. For example CNC or 3D printing would probably require a dedicated controller. Please take a look at github.com/Nikolay-Kha/PyCNC

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

    Hey great video! Would you have any advice on using the TB67S128FTG instead of the DRV8825? I love the wiring diagram you show with the RPi, motor driver, and stepper motor. However, I can't find a similar one for the TB67S128FTG.

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

      Haven't used it but Pololu has some resources: www.pololu.com/product/2998/resources

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

    can you make a video on how to control a motor using serial communication with modbus rtu rs485 usb converter and python

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

    i wish there would be a implementation for gpio in ugs or bcnc or something, so you can actually use your rpi directly without having to connect a extral driver board. it's just a matter of programming, but nope.... non existing, or at least, not to be found.

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

    Dear respected sir, I'm very happy for your awesome video. I trying to control my CNC machine by Raspberry pi where I need to use 3 stepper motor. Please could you help me?

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

      I don't have any experience using a Pi for CNC. I use Mach3 with a dedicated controller board for my CNC machine which uses Geckos. There are numerous examples of using the Pi for CNC such as:
      blog.protoneer.co.nz/raspberry-pi-cnc-board-hat
      github.com/Nikolay-Kha/PyCNC
      hackerspacepardubice.cz/cnc/

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

      Thanks a lot for your information.
      You know arduino is much slower than Raspberry pi. Therefore, If I use Raspberry pi instead of arduino, Will it be much faster?

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

      I don’t know. Perhaps it’s an ambiguous comparison because many solutions off-load the processing to external hardware. For example, the Protoneer Pi CNC hat uses an embedded Arduino for its micro-controller. Again, I haven’t done any CNC with the Pi.

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

    Awesome tutorial! Thanks much! One question, if I want to run 2 stepper can I use 14,15,18 for both stepper to set the resolution? Or does each motor need extra 3 pins for resolution?

    • @rdagger
      @rdagger  5 ปีที่แล้ว +2

      You can share the pins.

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

      rdagger68 thanks!! And another question :-) .. can you recommend any node.js module to run steppers instead of using python?

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

      Sorry I don't have any node.js recommendations other than just searching npmjs.com for stepper motor.