Controlling Large Stepper Motor With Raspberry Pi

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024

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

  • @rexmyers991
    @rexmyers991 Год назад +25

    Mr. Lee, I am 80:years old and that is the FIRST time I have understood computer code. THANK YOU SO MUCH. I am a self taught machinist (starting 15 years ago) and your videos have helped me to be a much better skilled machinist. CNC (and stepper motor logic) are way beyond my goals, but at least it’s not a mystery anymore.

  • @vanbehainguyen9069
    @vanbehainguyen9069 8 дней назад

    Thank you Mr. Lee. I found this video very helpful and educational. Best regards from Australia. behai.

  • @MCobra3050
    @MCobra3050 8 месяцев назад +1

    Switch 4 for half current reduces the current when the stepper is not running. It helps keep the heat down when not stepping. It has no effect on operation. Excellent video.

  • @jamesbowenjr.3022
    @jamesbowenjr.3022 11 месяцев назад +1

    So now this will eliminate the motor with the adjustable arm that you had on the surface grinder awhile back. This looks much better and easier I think. Thanks for all the detail.

  • @fredberry1342
    @fredberry1342 Год назад +2

    It's nice to see you combine a little bit of programming with a little bit of rock and roll. Thanks for the videos sir.

  • @AmateurRedneckWorkshop
    @AmateurRedneckWorkshop Год назад +2

    You have made me very curious as to what you are going to do with that stepper motor. Of course I bet you meant to do just that. One of my viewers gave a a raspberry pi one time and I let if set around until I no longer know where it is. I was getting older then and did not want to learn another programming language. Getting old has the effect of making you not want to change how you do things. Thanks for the video keep on keeping on.

  • @RobertLBarnard
    @RobertLBarnard 9 месяцев назад

    I'm an old programmer too, also setup a hobby machine shop. But i haven't retired yet, so I'm living a bit vicariously watching what kind of trouble you can get into. Lol😊

  • @ClearlyCero
    @ClearlyCero 4 месяца назад

    Honestly, I can't describe how much I appreciate your content. I'm currently in the tech industry and also taken up machining as a hobby! I've wanted to mess with cnc and controlling iot devices using a web ui on my lan. Thanks to you, I think I can finally achieve it!

  • @benjaminweiss2252
    @benjaminweiss2252 10 месяцев назад

    This is phenomenal man! I’ve been looking for a good RUclips coach for controls programming! Thanks so much!!!!

  • @hellospam879879
    @hellospam879879 4 месяца назад

    I'm going to get those parts and do what you did! Great tutorial! Just what I needed to know how to wire this stuff up without guessing.

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

    Thanks a lot for your informatic video. Because of your video we have been able to build a mindblowing machine!!!!!!!

  • @chirots
    @chirots 11 месяцев назад +1

    I have got experience on Pi pico. The way to define pins is a little different to Pi, Hence I couldn't fully understand GPIO on pi and how you generated the pulse.
    After a few reading on GPIO module on pi, I now fully understand you generate pulse via High/Low of pulse_pin. Really appreciate your effort to make this educational videos for everyone to learn

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

    Lee, your videos are incredibly informative. While some is foreign language to me I like to watch because I get to learn a bit. God bless you, If I only you could show me around your shop. I can dream! You are a hardworking fellow. I envy you! Have a great week buddy!!

  • @HB-co2uq
    @HB-co2uq 25 дней назад

    Very useful fella thank you. I am currently working on making a machine and this information is priceless to me. Keep them coming 😊

  • @duongthanhnhan1568
    @duongthanhnhan1568 7 месяцев назад +2

    Sorry for my bad English, but why can I use a 5v driver with a 3.3v rasperry output?

    • @stephenp2140
      @stephenp2140 4 месяца назад

      I am also trying to understand how you got this to work. The stepper driver needs 5v to trigger but the GPIO only outputs 3.3v. I've seen a diagram for different wiring using transistors with the 5v hot output from the Raspberry Pi but I don't know how the wiring shown in this video could work.

  • @edo3388
    @edo3388 9 месяцев назад

    Really good video. Code is very easy to follow and extremely well commented.

  • @rusticagenerica
    @rusticagenerica Месяц назад +1

    Extraodrinary video. Thank you Sir !!!

  • @Mad-Duk_Machine_Werkes
    @Mad-Duk_Machine_Werkes Год назад +1

    EXCELLENT!!! Best video on this subject I've seen yet! cant wait for more!

  • @holdendp
    @holdendp 9 месяцев назад

    Nicely paced tutorial. Thanks so much.

  • @teropiispala2576
    @teropiispala2576 Год назад +4

    I've been using raspberry pi to drive my mill for few years. I use my own fast direct io library and c++ to drive the stepper. I run my control loop in 1us cycle time, which might sound overkill, but it's best to reserve one core for driving task anyway. There are lots of benefits, allowing smoother run and easier code structure.
    When using delay, excecution time of the code affects on loop speed. It's also difficult to drive several motors at the time using delays.
    My approach poll the timer and starts loop in a proper moment, no matter how long code excecution has taken. Cycle time is short enough to allow max 200khz pulse frequency for controller. It means fast speeds with high microstepping.
    I use 64 bit integer as a counter, and copy highest bit for motor pulse output after every cycle. I also have signed 64 bit number as a speed value. That number is added to counter in every cycle. In a start if the cycle, sign of that counter is copied into direction pin.
    With this approach, I can drive several motors with any speed and direction just changing the speed value, and pulses are as uniform and jitter free as possible. I can read encoders in same loop if I need to.
    If controller have timing requirements for direction, they must not violated. It can be done by adding required delay for direction change.

    • @hello81642
      @hello81642 10 дней назад

      Can you please share your code? Thx

    • @teropiispala2576
      @teropiispala2576 9 дней назад

      @@hello81642 I coud share the IO library and for example the basic stepper control class. Entire program would be too much work to document into level that it’s usable. I take some shortcuts in my hobby projects, what comes to documentation.
      Currently I’m quite busy with other stuff, but maybe in a month or so, I could have time to separate some simple frame app. If you are really interested to try, I could send it privately to see what you get from it.
      I don’t have a time for large scale support, where I could end up, if I publish something that looks interesting but have too much open questions.

  • @jessephilippi2615
    @jessephilippi2615 2 месяца назад

    Best explanation video I've found. Thank you!

  • @coolmj007
    @coolmj007 29 дней назад

    Hi Mr Lee, very interesting video. Would you have few minutes to talk about the python code? Also need advice on how to mount the motor on a rail

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

    Thank you Sir. Finely someone who makes it a lot more easy to understand ,how this all works together. All my very best.

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

    Mr. Lee. Great stuff please do more.

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

    you made my day with this as want to add automation to my Eagle surface grinder excellent explanation on the coding thank you so much

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

    Thanks for the video. I always like micro processor programing. You did a great job.

  • @vanbehainguyen9069
    @vanbehainguyen9069 8 дней назад

    Might I have a question, please? The power supply in the video, is that for three motors only, please?

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

    So awesome thank you sir, for taking the time to do this video

  • @theundergroundesd
    @theundergroundesd Год назад +5

    Good job but I want to see how to hookup the pie to the computer and bring up the pie program on the computer screen. Keep up the good work.

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

      That was going to be my question. What interface is used between Pi and computer program...

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

      The Pi is the computer.

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

      The Pi is the computer

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

      Lee. I know the pie is a computer but how do you input programs into it to control other devices? I not really a computer guy so I have a hand time wrapping my head around it. Keep up the good work

    • @hellospam879879
      @hellospam879879 4 месяца назад

      @@theundergroundesd Something like this: the Pi is the computer and it can accept an SD card to which you have previously written an operating system (maybe Raspian) and it will run Python and Python can be used to send pulses to the GPIO pins. So you would write little code using Python (easy - see some tutorials) and then when you run your Python script those pulses will start everything going. So you would need to understand a bit of Python coding.

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

    Mr Lee, Thank you . I'm working on a tracer unit for the cross slide on a lathe

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

    Very interesting to be exposed to computer code!! Thanks

  • @gatosalamanca
    @gatosalamanca 2 месяца назад

    Great video and explanation!!

  • @907jl
    @907jl Год назад

    Very interesting, thanks for sharing, Lee!

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

    I found this to be very informative great demonstration

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

    Great video! I had hopes for a PM electronic lead screw (yes, I’ve seen Clough 42’s version for Grizzly) until you said “pulley” and “table” in the same sentence. 😂😂😂😂😂

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

    Thanks Lee. That was very helpful and practical example 👍😎👍

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

    That was excellent thank you I have some projects later on and I was going to see if I could do the same thing thanks for the video

  • @jimdean7335
    @jimdean7335 Год назад +1

    Seems you are planning to apply a stepper motor to your surface grinder. I’ve considered doing the same so I’m interested to see if the step action has an impact on the surface finish.

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

    I would love to see a Mr. Pragmatic Lee Python Tutorial!

  • @asp.entwickler
    @asp.entwickler 2 месяца назад

    Thank you!

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

    Very informative can you use this same setup to drive a weld positioner

  • @edworks7718
    @edworks7718 10 месяцев назад +1

    I am intrigued by the following observation. When I wired my setup, I shared your approach, put DIR- and PUL- to ground, and sent PUL+ to a GPIO pin and DIR+ to a GPIO pin. This is consistent with how I understand GPIO pins work. I am worried about this because my motor stalls once per revolution and I suspect my wiring can be improved. I watched your video and you agreed with my approach. Next, I watched a video by Jeremy Fielding and he wired PUL+ and DIR+ to +5v while sending the DIR- and PUL- to two GPIO pins. I watched a video on the Dronebot Workshop and he did likewise, +5v to PUL+ and DIR+ while sending DIR- and PUL- to the GPIO pins. Do you have any thoughts on why these wiring diagrams differ so much? It is me with zero views and you with 4,800 views against Jeremy with 1.2 million views and the Dronebot Workshop with 1.1 million views. Have you seen the movie "300"? While we are the underdogs, are we Spartans?

  • @aseeker2109
    @aseeker2109 Год назад +1

    This is brilliant, just what I need, thank you. Are you planning to use a Touchscreen to select variable input values to the program you are using?

    • @MrPragmaticLee
      @MrPragmaticLee  Год назад +1

      I’ll likely add a touch screen and onscreen keyboard later, but just using an old flat screen monitor for now - seems I’ve got several of them - I don’t seem to be able to throw anything away. 😀

    • @aseeker2109
      @aseeker2109 Год назад +1

      @@MrPragmaticLee Thank you, I look forward to learning more from you.

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

    since pi does not have real time kernel, does skipping steps occur often ? i did a similiar program and measured with perf_counter each step, it occurs several time in one rotation.

  • @rishikakade6351
    @rishikakade6351 9 месяцев назад

    great explanation! i love your accent :)

  • @titusfx
    @titusfx 10 месяцев назад

    🎯 Key Takeaways for quick navigation:
    00:18 📌 *In this video, MrPragmaticLee demonstrates how to control a Nema23 stepper motor with a Raspberry Pi.*
    01:01 📌 *MrPragmaticLee introduces himself as a retired programmer who runs a hobby machine shop and occasionally combines programming with machining in his videos.*
    02:08 📌 *He explains that he's using a Raspberry Pi 3B+ with GPIO pins to control the stepper motor.*
    03:28 📌 *MrPragmaticLee differentiates stepper motors from standard DC motors, emphasizing precise movement achieved through step pulses.*
    06:59 📌 *He shows the wiring of the stepper motor, Raspberry Pi, and stepper driver, including the connection of GPIO pins.*
    08:10 📌 *MrPragmaticLee mentions the importance of setting a switch on the stepper driver to the 5-volt position when using a Raspberry Pi.*
    09:23 📌 *He briefly goes over the overall wiring diagram of the setup.*
    13:16 📌 *MrPragmaticLee demonstrates the physical wiring of the Raspberry Pi GPIO pins to the stepper driver.*
    19:35 📌 *He starts explaining the Python program used to control the stepper motor.*
    25:33 📌 *MrPragmaticLee discusses the use of try-except blocks in Python for handling exceptions, specifically keyboard interrupts.*
    28:10 📌 *The video goes into detail about sending pulses to control the stepper motor, with sleep intervals for timing.*
    31:36 📌 *The video concludes with the cleanup of GPIO pins using gpio.cleanup to ensure proper shutdown.*
    31:48 🤖 *The program uses GPIO pins on the Raspberry Pi to control the direction and pulses sent to a stepper motor driver.*
    32:27 🧰 *A Python program demonstrates controlling a stepper motor. It can specify the direction and number of pulses, allowing precise control.*
    35:16 🔄 *The program allows for dynamic adjustments to the number of revolutions and speed of the stepper motor, making it suitable for various applications.*
    37:47 💡 *The demonstration provides a practical overview of hooking up a 48-volt power supply, stepper motor driver, and Raspberry Pi for motor control.*

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

    Very clear!

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

    Heck yeah! Is the project a CNC surface grinder?

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

    Hello MrPragmaticLee, was firmware loaded on the Raspberry Pi before booting?

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

      No, you have to load the OS on the SIMM card.

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

    Fun and interesting video.

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

    can i drive to 600 rpm ? with raspberry pi ? i coudnt do that i tryed to everything my step driver dm860

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

    Great video 😁👌👍

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

    Does the raspberry pi do the same thing an arduino does

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

    I got an instant error for missing a library it looks like. Any chance you installed additional support files to your stock OS image?

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

      What library is missing? If it’s the GPIO library, that’s only available on Raspberry Pi. I’ll take a look at the code a little later this morning and review the imports.

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

    Darn that makes the Gcode I create seem way simpler. I guess this type of code is what makes the Gcode work kinda. I recently learned to set my Arduino settings in two of my CNC machines you type $$ to see the settings then change the lines by like on line 13 (Inches) you would type $13=1 ( I think that's right)

  • @jamesbowenjr.3022
    @jamesbowenjr.3022 10 месяцев назад

    I see the RPi 3 B+ is unavailable. Can the RPi 4 be used instead? That seems to be available.

    • @MrPragmaticLee
      @MrPragmaticLee  10 месяцев назад

      Absolutely - i did all my development and testing in a 4.

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

    What hapens if I use two ground pins from raspberry for PUL- and ENA-?

    • @edworks7718
      @edworks7718 10 месяцев назад

      Should be okay if they are both connected to pins on the Raspberry Pi that are designated as a ground pin.

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

    What interface is used between Pi and computer program...?

    • @MrPragmaticLee
      @MrPragmaticLee  Год назад +1

      It’s a Python program with the GPIO library.

    • @briankelly3884
      @briankelly3884 Год назад +1

      raspberry pi has several different base environments (if you choose the one with the recommended software from the main website, will have everything you need to duplicate this project) which you can download and write onto a SD card from your windows computer, you just put the card in the pi after its done and it has its own desktop and programs similar to windows. The device has usb ports and hdmi outs. It functions as a slower but still capable computer with easy access to multiple digital I/Os.

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

      @@briankelly3884 Thanks!

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

    Hi Sir
    Good day i can you share the code to us is a great try i want to learn from it ,
    Many Thanks,
    Tan Meow Soon

  • @hello-sz1jp
    @hello-sz1jp 3 месяца назад

    I'm 41 yrs old and watching this video ,I feel like I wasted my entire life.
    Not taking life serious enough, by not taking advantage of learning all I could ,while young and healthy.