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.
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.
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.
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.
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!
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
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😊
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!!
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 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.
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.
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
@@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.
Very informative video! I'm doing an at home project during my winter break from College. I'm curious, what would the code look like if you wanted to set the operational speed of the rotation? I know it would probably have to be in steps/sec instead of traditional rmp. Appreciate your help!
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. 😂😂😂😂😂
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.
🎯 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.*
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.
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. 😀
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)
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.
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?
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.
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.
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.
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.
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.
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.
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.
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!
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
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😊
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!!
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.
Can you please share your code? Thx
@@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.
This is phenomenal man! I’ve been looking for a good RUclips coach for controls programming! Thanks so much!!!!
Thanks a lot for your informatic video. Because of your video we have been able to build a mindblowing machine!!!!!!!
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.
Very useful fella thank you. I am currently working on making a machine and this information is priceless to me. Keep them coming 😊
Thank you Mr. Lee. I found this video very helpful and educational. Best regards from Australia. behai.
Thank you Sir. Finely someone who makes it a lot more easy to understand ,how this all works together. All my very best.
EXCELLENT!!! Best video on this subject I've seen yet! cant wait for more!
Sorry for my bad English, but why can I use a 5v driver with a 3.3v rasperry output?
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.
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
Mr Lee, Thank you . I'm working on a tracer unit for the cross slide on a lathe
Really good video. Code is very easy to follow and extremely well commented.
Thanks for the video. I always like micro processor programing. You did a great job.
Best explanation video I've found. Thank you!
Extraodrinary video. Thank you Sir !!!
Great explanation 👍
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.
That was going to be my question. What interface is used between Pi and computer program...
The Pi is the computer.
The Pi is the computer
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
@@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.
Very informative video! I'm doing an at home project during my winter break from College. I'm curious, what would the code look like if you wanted to set the operational speed of the rotation? I know it would probably have to be in steps/sec instead of traditional rmp. Appreciate your help!
Nicely paced tutorial. Thanks so much.
So awesome thank you sir, for taking the time to do this video
Mr. Lee. Great stuff please do more.
Thanks Lee. That was very helpful and practical example 👍😎👍
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
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. 😂😂😂😂😂
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
I found this to be very informative great demonstration
Very informative can you use this same setup to drive a weld positioner
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.
Very interesting, thanks for sharing, Lee!
Great video and explanation!!
Very interesting to be exposed to computer code!! Thanks
great explanation! i love your accent :)
Might I have a question, please? The power supply in the video, is that for three motors only, please?
🎯 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.*
Thank you!
what switches to turn on on the side of the driver
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.
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?
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. 😀
@@MrPragmaticLee Thank you, I look forward to learning more from you.
Very clear!
Great video 😁👌👍
Heck yeah! Is the project a CNC surface grinder?
I would love to see a Mr. Pragmatic Lee Python Tutorial!
Fun and interesting video.
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)
I got an instant error for missing a library it looks like. Any chance you installed additional support files to your stock OS image?
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.
can i drive to 600 rpm ? with raspberry pi ? i coudnt do that i tryed to everything my step driver dm860
I see the RPi 3 B+ is unavailable. Can the RPi 4 be used instead? That seems to be available.
Absolutely - i did all my development and testing in a 4.
Does the raspberry pi do the same thing an arduino does
What hapens if I use two ground pins from raspberry for PUL- and ENA-?
Should be okay if they are both connected to pins on the Raspberry Pi that are designated as a ground pin.
Hello MrPragmaticLee, was firmware loaded on the Raspberry Pi before booting?
No, you have to load the OS on the SIMM card.
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?
What interface is used between Pi and computer program...?
It’s a Python program with the GPIO library.
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.
@@briankelly3884 Thanks!
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.
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