Big Stepper Motors with Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we've looked at stepper motors before but today in the workshop we'll be working with a big stepper motor will see how to read stepper specifications and choose a driver for your motor we'll also use an Arduino to control everything we're taking some big steps today so welcome to the workshop [Music] hello and welcome to the workshop and today we're going to be working with stepper motors again now we've looked at stepper motors before we did an entire video about stepper motors and in that video I explained how a stepper motor differs from the other types of motors that we've used in our projects what the different types of coil windings are your bipolar and unipolar stepper motor windings how to drive stepper motors using dedicated driver modules and also using H bridges and concepts like micro step and while we've covered all that so that's not what we're going to cover today today what we're going to cover is what we need to do in order to drive a large stepper motor now this is a very big step promoter this is a NEMA 23 size stepper motor that consumes a good amount of current 4.2 amperes in order to get the full capacity out of it and it's a very powerful motor now this motor is too powerful for the modules and H bridges that we looked at before so we've got two choices one choice would be to build our own drivers out of MOSFETs which was not what we're going to do today instead what we're going to do is we're going to use a controller now this is an industrial-sized stepper motor controller and there are a variety of these out there what we're going to learn today is how to read the specs on our stepper motor in order to select a controller for it and then we're going to see how we can hook this up to an Arduino and control the stepper motor so we're going to start off first by learning how to read the specifications on our stepper motor to determine what type of a driver and module we need to select in order to use it so let's go take a look at that right now now we've already covered the basic specifications of stepper motors in my previous video so if you need an update please go and see that what I want to show you is in the real world how you would read the specifications on a stepper now this is a stepper motor that we're going to be using today so let's take a look at some of the specs that are listed on the step online website now here are the electrical specifications now this is a bipolar stepper motor and in the previous video we covered the difference between bipolar and unipolar stepper --zz it has a step angle of 1.8 degrees meaning on one full step the motor shaft will move 1.8 degrees and of course we can micro step this to get finer resolution by calculating that you can see that it would take 200 steps for this to make a full rotation now here's the holding torque specified both Newton meters and announced inches and now here is probably the most important specification in the entire electrical specs and that's the current per phase and that's 4.2 amperes now this will be where it gives its maximum torque also keep in mind that if you're going to micro step this and you likely are using this controller then you will actually have to double that current requirement when choosing a power supply because this is per phase so it means each one of the coils could be at 4.2 amperes simultaneously now here conversely is the least important specification here the voltage three point seven eight volts what in the world is that all about as I said earlier I am going to be driving this with my bench power supply and I'm planning on using 24 volts and some people may be using sixty volts or 48 volts to power this motor why does it say 3.78 well this is the reason the phasor resistance this is the electrical resistance of each of the coils and 0.9 ohms well if you're good at math try multiplying four point two by 0.9 guess what you're going to get as a result this is just simply a calculated voltage this has nothing to do with the maximum voltage that the stepper motor can be operated at and I'll show you another example of that in a few seconds now this is the inductance which is a very useful thing to know if you're actually designing the stepper motor driver or if you're trying to Herman what the maximum frequency you could drive the motor is act then after that we get into some physical specifications now this is a NEMA 23 size motor so these specs are all fairly consistent and the connections which is a very important thing of course to know because this is coil a plus and a minus and B plus and B minus and this gives you the color codes of those wires now this also links out to a couple of spec feeds let's go take a look at those because they have some information as well plus you may not be going to a website for your stepper motor you may indeed just get a couple of spec sheets included with the motor now here's the first one which goes over most of the physical specifications for the motor and again the electrical specs which are as we have seen before and notice they put the amps and the resistance at the very top notice also if you're going down through here you won't even find the voltage listed because again that's just a calculation based upon these two and these are all the same specifications we've seen before other than things like step accuracy and inertia etc and the weight of the motor itself now the other diagram they have is actually very interesting it's a torque diagram now this is the pullout torque and notice that this is rated at 36 volts despite the fact that this motor was only specified at under 4 volts this is another example of how little the voltage reading actually means in the stepper motor specs and this is at 36 volts at 4.2 amperes and notice it is half steps so in other words two coils will have been activated at the same time in this configuration now let's go down to this chart and take a look at it now this is the pull of torque and notice that the torque decreases as the speed increases on the stepper motor now they start this off at 60 rpm which is one revolution per second and notice that it says you need four hundred pulses per second well remember it takes two hundred pulses in full step mode to turn the motor so it would take four hundred pulse in half step so this relates both the frequency and pulses and the speed in rpm for you which you can also of course is calculate mathematically and again as you can see the torque will decrease as the stepper motor is moving faster and so this is basically how you read the specifications when you are selecting a stepper motor all right now here's the stepper motor that I'm going to be using and as you can see this thing is quite the Beast it's NEMA 23 size so you can see it's got a very large d output shaft over here and the NEMA 23 standard mount on it this is a bipolar stepper motor it specs are it has a stall current of 4.2 amperes and it has a stall torque of 425 bounce inches which is quite a lot of torque that's also the same as three Newton meters if that means more to you and as a bipolar motor it's about four output leads which has come up to bare wire over here and I've got a multimeter over here so we can measure the coil resistance and as you'll see it's quite low and yeah 0.9 of an ohm as what I'm reading over there so there's a very low coil resistance on this now it's nominal voltage is rated at three point seven eight volts of courses we just saw that voltage grading is just basically a mathematical calculation of the stall current and the resistance of the coils so this is the big beast that we're going to be working with today all right now that we understand a bit more about reading stepper motor specifications and we've also looked at the stepper motor I'm using today it's time to focus our attention on the driver now this is the driver module I'm going to be using but I want to make it clear that you don't need to use the identical module that I'm using I have based my selection of the module on the current requirements of my stepper motor and that's what you should do as well and there are a variety of modules that look just like this one and that can work in the same Arduino circuitry they're hooked up the same and they can use the same code the only difference is their voltage and their current ratings as well you're going to see there are some dip switches on the side of the driver and the selections you make for your particular motor and Driver combination may be different than the ones I'm using but otherwise you can use basically any one of these drivers I got this one on Amazon you can get them on eBay at electronic and electrical supply stores as well so let's take a closer look at the driver right now now here's the motor driver that I'm going to be using today as I said this is typical of most micro stepper motor drivers now they'll have connectors on the side and these connectors at the top over here where it says power and fault is where you're actually going to put the input connector from the Arduino so we're going to control both the direction and the pulses of the stepper motor by feeding signals into here and they come in a derp - derp + pulse - pulse plus an able - enable + if you'll find when we do the wiring it's going to be a little bit different than what you expect we're actually going to be using a common 5 volt and not a common ground for these now down at the bottom you've got the connections that go to the motor itself so one coil the a plus and a minus and the other coiled B plus and the B - and at the bottom over here we have the power supply connection now this particular one will work on both AC or DC so if you're using DC you put the positive here and the negative one over here AC of course you can connect either wire anyway and this one has arranged this particular one of 18 to 80 volts AC or 24 to 110 volts DC this is actually about the same range if you multiply by 1.40 1/4 which is what you do when you have a full wave rectifier you'll find that you're pretty well in the 25 to 113 volt DC range by supplying AC now these connectors are kind of nice they are screw connectors but they also just come off like this so that you can connect your wires externally and then mount everything on to here just by plugging it in and that's very handy because as you can see this is a pretty big beast over here now on the side they have a table and the table tells you how to set it up for things like current-limiting and so it gives you the different currents that you can set it up for and also for micro stepping for the number of pulses per revolution and this is the table that determines that over here and you set all of this up on the side over here on a dip switch they have a switch on the side that you can use to set everything up now this is quite the Beast it's in a metal case and on the back you can see it's got a heatsink that has a fan as well on it so this is expecting to dissipate quite a bit of heat and should be mounted in an area where that heat convent so there you have it the motor driver that we're going to be using in today's big stepper motor experiments so we've seen the motor we've seen the driver it's time to hook everything up now there's one other component that we haven't looked at yet and that is the power supply now I'm going to be using the power supply on my other workbench today because it's a variable supply and it can supply up the 30 volts at 5 amperes and that should be sufficient to be able to drive the motor and in my case I'm driving my motor at 24 volts now remember your power supply is going to be determined by your driver and your motor and so you may be using a different voltage and a different current and that's fine as long as your power supply is capable of supplying the driver you can also note that many drivers including the one I just showed you have a built-in rectifier and can accept AC voltage as well as DC voltage so you could use an AC transformer instead of a DC power supply if you have that type of drivers now the Arduino will be powered from your computer's USB power supply so it isn't affected by the power supply in the driver so let's take a look now at how we hook up our motor and our driver and our power supply to arduino now for our first experiment you are going to need of course your motor driver and your stepper motor as well as an Arduino I'm using an Arduino Uno here in addition you're going to want a push-button switch a pull-up resistor for the push-button switch I used a 10k resistor and a potentiometer any linear part of a value of 5k or above will suffice I'm using a 10k pod let's start by connecting the motor driver to the Arduino pin 6 from the Arduino ghosts the derp - connection on the stepper motor driver pin 7 from the Arduino goes to the pul - connection on the Droid or driver both the derp plus and pol plus connections on the motor driver are connected to the 5 volt output of the Arduino one side of the push-button switch is connected to pin 2 of the Arduino a 10k resistor is also made from this connection up to the 5 volts on the Arduino the other side of the push-button switch is connected to the Arduino is ground one side of the potentiometer is connected to the Arduinos ground the other side to the 5 volts from the Arduino and the wiper of the potentiometer is connected to analog input a 0 and that last make your connections to the stepper motor and to the power supply your stepper motors would be connected looking at your motor specifications with one coil going to the be positive and be negative and the other coil going to the a positive and a negative you will also need a power supply whose specifications depend upon your motor driver and to some degree your stepper motor now I'm using a 24 volt power supply and it's a DC supply so I'm observing polarity as I connect it to my motor driver my motor driver will also accept an AC input but some won't a gain look at the specs of your motor driver and your motor to determine the requirements for your power supply and now that this is all hooked up let's take a look at a simple sketch we can use to test everything out now the first sketch that we're going to run on the Arduino is going to be very simple all we're going to do is we're going to pick up the movement of the potentiometer and use it to control the speed of the stepper motor now we are not going to be using any libraries in this sketch we're just going to be pulsing the motor directly through the Arduino code but what this sketch will do is it will give you a good idea of how easy it is to work with the motor controller and how the different control signals work so let's go take a look at that sketch right now now here's the sketch that we're going to use to test our large stepper motor now it's a pretty simple sketch that doesn't require any libraries we're going to start off by defining a number of pins and so a reverse switch is where we've connected the switch and that's pin number two now of course I've used a push button here but bear in mind this could easily be a limit switch and you could even have more than one of them in parallel so for example if you're trying to move the motor between two extremes you could put a switch on each end and also this does not of course have to be a mechanical switch in fact it would probably be better to be an electronic slip such as a Hall effect sensor or an optical slick so just some food for thought over there now this variable defines where we send the pulse pin this is the PL input on our motor driver so we set that to pin seven and pin six we've set to the driver for the der pin and we have our potentiometer and it's connected to pin analog a0 now a couple of variables now PD is the pulse delay period now this is the inverse of the frequency and we're going to set it to an initial value of 500 and we also define a boolean and we call it set derp and we initially set it as low now this is going to set the direction and so toggling this will reverse the motor now we have an interrupt handler which I'm calling Rev motor and all it does is it takes this set d'oeuvre area below and inverts it so whatever set derp is the inverse out if it slow going in it's high going out or vice versa okay now down to our setup the setup is very simple we set the pin modes for the two pins that we've defined to connect to the motor controller as outputs and we also attach the interrupt to the reverse switch the switch that we've defined on pin to now this is the correct format of attaching it interrupts you use the digital pin to interrupt function and give it the pin number as opposed to the interrupt number which you could also have inserted over here and then when that interrupts is triggered we call rev motor and we trigger that interrupt on a following pulse now remember that line is held high so if the push button is depressed the line will go low and that will be a falling condition and that will trigger the interrupt which in turn will call this interrupt handler over here now down into the loop and again this is quite simple we have to determine the pulse duration first and we do that by reading the speed using an analog read remember this is connected to pin a zero and we map that using the map command or the map function excuse me from a value of 0 to 1023 because that's what the input value is going to be and we map it to a value of 2,000 250 now notice we're going in the opposite direction here this is so the speed increases as we go clockwise because again the pulse duration is the inverse of the frequency so the larger this number is the slower the motor is going to spin next we write out our direction to the set with the center value to the driver derp in so whatever that value happens to be it'll set the direction of the motor and then over here we're going to send the pulse pin high we're going to delay it for the period of the pulse the width or the pulse delay and then we're going to send it low and delay it for the same period so what we're doing with these four statements is essentially creating a pulse and then this is a loop we just continue to repeat this over and over again so quite a simple sketch let's take a added an action right now so here's the test setup that I've got to test my large stepper motor now because of the amount of torque that this motor gives out I didn't want to just leave it on the workbench because it could be a bit of a danger especially as you can see I'm using a miniature vise grip as my indicator of the motor shaft position so I put the entire combination here into my bench vise and over here of course you can see the stepper driver I've got it connected to the stepper motor plus the power supply that you can't see that's going to be supplying 24 volts to it and down here in my connections to the Arduino at the back I've got the potentiometer I'm going to use for controlling the motor speed and the switch I'm going to use to reverse the motor and remember this switch could also be another type of slipped an optical switch or a Hall effect switch and you could use it at the end of the travel of the motor or whatever the motor is driving to make the motor go in the other direction you could even put two of them in parallel if you wanted to now I haven't done any debouncing on this slip so occasionally when I press it it's kind of think it's being pressed twice but if you used an optical or electronic switch you wouldn't have that problem so what I'm going to do right now is fire the power up and as you can see the motors rotating and as I move the pot I can get it faster now right now by the way I have this set so that one revolution is 800 pulses using the dip switches on the side here and of course as you might percept this differently the speed will change now I'm going to move it up a bit more [Music] now there it's going pretty fast that's pretty scary actually watching that vice-grip go around I hope it holds hot that's their dad to his lower speed that okay now let's hit the switch you can see the D bouncing an effect there it goes in reverse reverse reverse again so as you can see aside from perhaps a few D bouncing considerations this seems to work pretty well so as you can see it's pretty easy to use a stepper motor with the Arduino and some simple code but we can improve our code by using a library now the excel stepper library is one that we've used before it is a very very common library for stepper motors and with this library you can achieve some very precise control of your stepper so we're going to do another demonstration using excel stepper now keep in mind that since this is such a common library there are a lot of sketches out there that make use of this library and so now armed with the information you have you can take those sketches and use them with your large servo motors so let's take a look at excel stepper now now in my original video on stepper motors I went through the accel stepper motor library in some detail so I won't repeat myself over here if you were following those videos you probably already have the excel stepper library installed in your arduino ide but if you don't you'll need to go through the library manager and do it so go down under sketch to include library and then go to manage libraries once the library manager is open dis filters search by typing accel stepper and here is Excel step four now I've already got mine installed but if yours is not installed when you highlight it with the mouse and install button will appear like it does with this library I don't have installed so just hit the install button on sell stepper and that will install the library for you once it's installed you can use some of the built-in example sketches in order to run your motor controller all you need to do is change the initial line in the sketch a place to let me tell you I'll go down and open examples and then scroll down to examples from custom libraries and you see a cell stepper and there are a number of different examples you can try there's one over here called bounce let's just take a look at that one for a second this is a pretty simple one this one essentially sends the motors from one limit to another and it accelerates and decelerates as well so that's actually kind of a nice feature now the only thing you need to do is at the beginning over here is you need to define the object stepper in a different fashion so what I would do is I would just remark that one out give myself another line here and this is the fashion that you want to do it so what you're telling a cell stepper to do is create an object called stepper the mode over here is number one just indicates the way that it communicates with the stepper and that's the correct mode for our modules and seven and six are where we have connected our pulses and our dur connections so just do it in that particular format for any of these examples and it'll work fine so let's go and take a look at the bounce sketch right now running on our stepper motor example so I've loaded the bounce example from accel stepper up to my Arduino now you can try some of the other examples as well all you have to do is remember when you're defining the stepper object to use the syntax that I showed you and you can change any of the existing examples you can of course also use other code that uses Excel stepper using one of these drive modules so all that remains to do is to put some power on and we've got it right at the end now Excel step four what it does is it accelerates the speed and then it rotates and then it decelerates and comes to a stop and then reverses and does the whole thing all over again and there you go now one thing you probably can't hear because I think my noise reduction technology is muting it for you but on the stepper drive where the fan does come on every time that I power it up and I haven't really felt any heat off of this I ran this the other day for a few hours there was a bit of warmth on the stepper motor of course I'm not driving at it anywhere near its full capacity its full torque so what I'm going to do now is I'm still stepping this at 800 pulses per revolution I'm going to turn the power off for a moment and I'm going to use the dip switch on the side now they have a diagram here that tells you the microstepping as well as the current set up and so you need to set this up correctly make sure not to exceed the current of your stepper but I'm going to press this one down and that should cause it to only use four hundred pulses in order to do a revolution so let's try it back on and it is moving faster definitely and so using micro stepping and the speed controls in Excel stepper or whatever skeptic are using you can control both the speed of your motor and to some degree its torque because different micro stepping modes will give you more torque okay well that about wraps it up for today's video I hope that you enjoyed it and I hope that you're now inspired to start building things with really big stepper motors but before you run out and start building all of those things I just need to caution you that big stepper motors like all other big motors can exert a great deal of torque and therefore can be dangerous if you have your hands or other appendages in the wrong places when you're working with them so do be careful when working with these motors now if you need some more information about driving big step for motors with the arduino you can calculate the article in the durham bot workshop comm website and you'll find a link to that article right below this video while you're on the website please consider subscribing to the newsletter it's my way of staying in touch and to finding out what content you would like me to create for you in terms of both videos and articles and if you haven't yet please subscribe to the youtube channel I'd very much love to have you as one of my subscribers so until the next time we meet take care of yourself be careful with those big stepper motors and we'll see you soon again here in the journal bot workshop good bye for now [Music]
Info
Channel: DroneBot Workshop
Views: 674,480
Rating: 4.9240284 out of 5
Keywords: stepper motor, stepper motor driver, stepper motor arduino, arduino, microstep driver
Id: iY_4YOlpqyI
Channel Id: undefined
Length: 29min 43sec (1783 seconds)
Published: Sat May 25 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.