Beginners Guide To Using Large Stepper Motors: #087

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Great guide! As a person that’s new to the stepper motor world it was very easy to understand and keep up with! Thanks!

πŸ‘οΈŽ︎ 3 πŸ‘€οΈŽ︎ u/Tritheone69 πŸ“…οΈŽ︎ Dec 21 2020 πŸ—«︎ replies

Jeremy has such a great instructional style, his entire channel is full of simple breakdowns of complex machines and concepts and it's all fantastic.

πŸ‘οΈŽ︎ 3 πŸ‘€οΈŽ︎ u/svideo πŸ“…οΈŽ︎ Dec 21 2020 πŸ—«︎ replies

Thanks for this. Jeremy Fielding is just awesome, and this video really helped me out a lot with the basics. I'm looking to build a CNC in the future and this is on my saved tutorial list now.

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/tomatoblade πŸ“…οΈŽ︎ Dec 21 2020 πŸ—«︎ replies

You said it. Fantastic video.

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/shokgoblr πŸ“…οΈŽ︎ Dec 21 2020 πŸ—«︎ replies

Can you use just the arduino uno or do you need that cnc shield too ?

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/last-resort-4-a-gf πŸ“…οΈŽ︎ Dec 26 2020 πŸ—«︎ replies
Captions
it's likely the whole reason you're even considering a stepper motor or a servo motor is because of the high level of positional control as an example i've got this motor wired such that when i push this button it moves .18 degrees that means i've got 000 positions per rotation that's pretty incredible but just like everything else in engineering there's a trade-off you're not going to be able to just plug this guy into the wall and flip a switch on you're going to need some specialized hardware as well as do some programming but you shouldn't let that intimidate you i'm going to walk you through all of the hardware that you need as well as how to write the program in fact i've written most of it for you let's start with the stepper motor itself these guys come in a huge range of sizes as you can see here and they often have what's called a nema designation nema is a standard with the primary mission of making it so that you can use motors from different manufacturers that will fit in the same spot in this case neiman 34 which is what this motor is tells you about the dimensions of the faceplate this one happens to be 3.4 inches this one's nema 23 or 2.3 inches and so on but there are actually more numbers to the nema designation which tell you things like the size of the shaft and the length of the motor which can all vary for example here's another nema 23 and as you can see while they have the same face plate size the shaft sizes are significantly different and even looking at the mounting holes these mounting holes are smaller not to mention the motor itself is much less powerful and much smaller now these larger motors which is what we're going to focus on today usually have four wires and if i'm remembering these correctly most of the time the designation is black and green for the a winding and blue and red for the b winding although that's not always the case sometimes the colors are mixed up or sometimes they even use different colors like this one doesn't even have a black wire so again this is information that's going to be specific to the stepper motor that you buy from that specific manufacturer now these little guys will often have five or even six wires as you can see here you can usually drive these with these same bigger drives but the way you wire is going to be a little bit different and depending upon which wire you connect to what terminal you're going to get different performance characteristics some will give you lower speeds and more torque and vice versa but because of the variability and options i'll let you look at the manual and we'll just cover the four wire setup today now here's where things get interesting in order to get this motor to move the right distance you're gonna need to supply power to one or both windings with the right polarity and in the right order that can get pretty complicated so most of the time we use a controller to do this automatically here we have a few examples of stepper motor controllers that i happen to have laying around my shop the same way we have different size steppers we need different size drivers in order to match the current limits of the particular motor this one doesn't require very much current and therefore the pins and wiring can be significantly smaller now even though these drives look very different they're all pretty much identical in the way that they function and the way that they're wired and we're going to talk more about wiring later but there is one thing i want to point out now you do need to make sure that the drive is capable of handling the power needs of the motor usually the drives come with a range and then you adjust the current setting to match your motor and that's what all of this information is here on the top there's a list which allows you to adjust how many steps there are per revolution that is how many positions the motor can stop at per rotation and also you need to set the current limit in this case you can see here on the label it says 5.6 amps so i need to set this drive to 5.6 amps why does it need to be 5.6 because if you set it too high the motor is going to overheat and burn itself out the motor will pull as much current as it can if you set it to low you're not going to get the full performance of the motor this particular model has dip switches on the side and this one also has dip switches although they are really tiny down there in the inside this one if i remember correctly there's a little potentiometer there it is right there and you adjust that with a screwdriver in my case i want to match the rms current and that's 5.6 amps so that tells me that dip switch 1 2 and 3 all need to be in the off position driving this motor to its full potential i'm going to need to adjust these switches all to the off position like so so at this point we've got our stepper motor which is going to position our load we've got our driver which knows how to control the stepper but we also need to tell the driver what to do you see the driver can control the stepper but it doesn't know how fast to go it doesn't know how far to go we need something to control the driver also i like to think of this as sort of a symphony the stepper motor is our violin the driver is our violinist and we need somebody to conduct this symphony in that case that's going to be our arduino an arduino is a programmable microcontroller i like to think of it as just a tiny computer where i can write out instructions and it will run that program over and over and over again until i turn it off there are other micro controllers as well like i'm using a raspberry pi to automate my table saw this guy can control multiple stepper motors sending commands to our drivers who will play our instruments in any case you're going to need something to send instructions to our controller one more thing i want to say about the physical connections of the arduino before we start wiring things as you can see here on the top it's got these little pinholes which is where you push all the wires in to make your connections now that's fantastic for prototyping on your bench top and you know little toy projects or training with your kids but i absolutely hate those little tiny pinholes i want something more robust than that so what i normally do is buy something like this this is another arduino mega and this is called a shield it's a screw terminal shield it essentially converts all those pins to screw terminals and that's going to be way more robust in fact you can see it's got the din rail mount which is what you will find in most industrial cabinets so this is what i use for all my projects but is by no means required anyway i'll put links to all this stuff in the description if you want to use that yourself the last component you're going to need is some kind of power supply this particular one is 60 volts and it falls right into the range to match my drives this one can take anywhere from 24 to 80 i think this one's 1880 it is the important thing is that the voltage matches your drive and that it can handle the current limits of each or all of your stepper motors if you're driving multiple stepper motors continuing with our orchestra analogy our violinist knows what song to play we just need to control how fast to play it and when to start and stop similarly our drive needs to be told when to move from one position to the next and which direction to go whether it's going clockwise or counterclockwise those are really the only two inputs we need to give to the drive it's going to do everything else down here at the bottom you're going to always see the four leads for your motor so let's go ahead and connect those now i use these for prototyping around the shop so rather than look up what colors do what each time i usually just write it right here on the side of the motor i've already set our rms current to 5.6 amps which means the first three diff switches are all off and they are number four controls whether you want half the current or the full current whenever i have a stepper motor that's not working very hard in a stopped position for example if i'm moving a load laterally and then when it stops it doesn't take very much power from the motor to hold it there i'll put this setting on half that'll keep your motor a little bit cooler but it also puts out less torque from the motor so if you're holding something up vertically and you need to fully torque with the motor you're going to want to leave this switch set on full power 5 6 7 and 8 control their steps per revolution we're going to set ours to 400 so that it's easy to see the motor moving and in that case they should all be on so five six seven and eight are all in the on position next we have our enable pins and this can come in two configurations it can be enabled by default or disabled by default and what i mean by that is in this case it's enabled by default if there's no voltage across these pins then the drive will work if i supply 5 volts across these two pins for this particular drive that actually turns off power to the motor and you can freely spin the motor but every once in a while it's the other way around it's disabled by default and when you supply 5 volts that actually enables the drive which means if you want it to work you're going to need to keep five volts across those pins continuously finally we have our post pins and sometimes it'll say step like this one says step instead of post but it's exactly the same thing essentially when you supply five volts here and then remove it that's a full cycle the voltage goes on and then off the motor will move one step forward changing those pins as i showed you earlier can make that increment apparently as small as 50 000 which is insane this drive requires 24 to 80 volts so i'm gonna turn on my power supply and we'll set it to 48 volts i've got this switch wired in between my 5 volt power supply which is just a little wall wart that's plugged into the floor and this switch so when i push this switch you see that the motor moves 1 400 of a rotation of course pushing a button like this is insane right you wouldn't want to have to control this system like this not only can you not push it fast enough to get decent speeds we also want to automate the control of the direction and things like that what we're going to do is program this microcontroller to push the buttons for us and of course this can push the button way faster than we possibly could so let's take a look at how we can write our control scheme out and have an arduino do it for us digging around i found a smaller arduino this is the arduino uno or a knockoff version of it we're going to use this one since this one's a little cheaper than the other one for our demonstration you're going to need to start by downloading some software i'll put a link to this in the description but you're going to go to arduino's website come over and download the appropriate version for the computer that you're using you have an option to donate or just download i've already got this downloaded but you'll download and install this software then we're gonna open the arduino software and here you're looking at the code that we're going to be using today now my goal is not to teach you how to write code from scratch in fact i've only been writing code for a few months myself but i do want to show you how to generally read through what i've given you so that you have something to start with this first line basically tells it to install the excel stepper library and then we define some pins these numbers here represent physical pins on the arduino over here i'm giving names to those pins so that later on i can call up those names instead of calling up the pin numbers this is really important for very long codes if i want to change this pin for some reason and use pin number nine instead of pin number five then i've got to chase down every place in my code where i use pin number five and change it if i do it this way all i have to do is change the pin here and everywhere it says stepper one pulse it will automatically know what pin number to use then i go on to define some terms down here motor one speed motor to position because i'm controlling them differently and you can see the rest of the terms there for minimum speed maximum speed and so on when it comes to excel stepper it's got three parameter inputs this first input tells you what kind of control scheme we're using the number one indicates that we're using a stepper driver the second input is going to be what pin is receiving the pulse input you see i'm using a name but what that actually tells it is to use pin number five because i'm using the name stepper one pulse same for direction the second input is going to be the direction input i'm using two different steppers so i'm calling the first one step one and the second one step two so now excel stepper knows that when i call for step one these are the parameters to use and when i call for step two these are the parameters to use then we go down to void setup this part of the program will only run when it first initializes it's going to set our max speed set speed acceleration and so on for these different parameters after we tell the excel stepper library what these parameters are we need to tell the arduino how to use these pins so we have pin mode and that's the pin number we're setting that as an output that just lets the arduino know that it's going to be sending information out on that pin instead of trying to receive information you could put input here as well and then so on for the other pins and then i've got digital write in the setup which tells it to set these pins to zero volts or low and this one's set to 5 volts then we get down to the void loop which is relatively short because this program is pretty simple the first thing in our void loop is motor one speed which we initially started at zero but now we're going to tell it to read the potentiometer instead the arduino is going to immediately convert the position of the potentiometer to a number between 0 and 1023 i want to change that to numbers between speed min and speed max and those are variables i set up here above for pulses per second and you can make that number whatever you want when i turn the potentiometer up to max the arduino is going to read that as 1023 and then it's going to translate that to 4000 based on the numbers i've inputted here immediately after that i'm going to tell the excel stepper library to use the motor speed 1 that i just mapped and make that to speed so set speed next we're going to tell it to start running at that speed and that's it for the first motor and then the second motor i'm doing something very similar now you're going to notice that this one says run speed and this one just says run that's actually a quirk from the excel stepper library when you want to move the position of a motor you use the run command and when you want to change the speed of a motor you use run speed in fact let's take a quick look at the website where you can see all of the inputs that you can get from the excel stepper library this shows you everything that the excel stepper library can do all the parameters how to set them up and even if you don't understand exactly what something does basically what i did as an experiment is i will put it in my code and see what it does and you'll quickly figure out what all these things do and how to use them to write your code this part of the code will run over and over again very rapidly so each time i change the position of the potentiometer all of this happens over and over again it's going to recheck the potentiometer change the speed start running the motor if you've never used the excel stepper library before you will need to install that first so we're going to go up here to sketch include library manage libraries and then up here at the top we'll do a search excel stepper here it is now mine is already installed but you would just select a version you want and click install once you've done that you can load this guide to your arduino and you do that by simply hitting upload now there's one more thing to think about here and that is if there's a problem with your sketch for example if this is missing you can hit verify and it'll tell me there's a problem and what that means down here it looks like the wrong line is highlighted but i learned that it usually means that something right before that is the problem and in this case the semicolon is missing each line has to end with the semicolon now i have pre-wired this to another shield another screw terminal shield for the arduino uno but what i'll do instead of showing you all these wires which is kind of messy i'm going to draw out a diagram for you and just put that on the screen at this point we've got our code uploaded to our arduino and i'm just powering it from the pc you could also use a 9-volt plug like this within a battery you could even get one of those wall adapters and plug it in the wall made for arduino any of those options will work it does not have to stay connected to the pc so here's our position part and i know that this guy will go about 75 of the way around and this controller is set to 2000 steps per revolution [Music] so as you see in the program i set it to about 1600 and that should get me really close sure looks like it is all right that's more fun than it should be so that's that and then we have speed control on this side so this is a plugged into a0 [Music] and here we have speed control with the [Music] [Laughter] potentiometer and i also want you to notice that i've got some acceleration built into this one and you can see it's speeding up and slowing down as it goes through its positions and these numbers are totally adjustable right if we go to our code acceleration for stepper two is set to a thousand right now let's make it ten thousand now that the acceleration is turned all the way up you don't get a chance to see it speeding up and slowing down but you get the idea this is easy to adjust so this shows you how to control the primary parameters that you probably want to have control over speed acceleration and position but they're going to be other parameters that you want to control as well like for example say you had a camera on the track and you wanted to run until it hits the end of the track maybe a limit switch and when it hits that switch it knows to go the other direction well i can't show you all the possible variations but there are a lot of sample codes in here for example if we go to file examples excel stepper there's one called bounce i think is the one there it is so if we look at bounce bounce pretty much does what i just described instead of hitting a limit switch though it just goes a fixed number of steps and then it turns around but there's no reason you can't cut and paste little snippets of pieces that you need to get the code that you want now i'm a fairly new coder myself in fact i've only been doing this for a few months that is writing code in c plus and in python but my goal in telling you that is to let you know that this is approachable even though things like leaving off a semicolon will frustrate you to death trying to figure out what's wrong when you get it it is totally worth it now this video is actually the first in a series of videos that i'm going to be doing on robotics and automation for beginners and my plan is to make things like servo motors and act linear actuators i want to make that stuff approachable to somebody who's interested but doesn't quite know how to bridge that gap yet so there's a lot more to come you should hit that subscribe button if you're interested in that kind of content i also want to say thank you to these fine people who are scrolling up your screen these are patrons who have been supporting the channel it's you guys who make it possible for me to make this kind of content free on youtube and for that i am so grateful i hope to see you guys in the next video which will be about actually i don't know which one's coming next but it's coming soon so stay tuned and thanks for watching
Info
Channel: Jeremy Fielding
Views: 122,858
Rating: undefined out of 5
Keywords:
Id: QMgckRoRy38
Channel Id: undefined
Length: 19min 49sec (1189 seconds)
Published: Sun Dec 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.