The very popular and easy to use and cheap easy driver module to actually drive the stepper motor. Now you might hear on the background we’re treaty printing, some parts right now in our shop and I’m, mentioning that because we’re using some treaty parts right now and weren’t sure if we wanted to offer those inside of our store at brainy bits. Because treaty parts tend to be, you know not the best looking parts but for some parts treaty printing it can be very useful what we’re, using today as treaty parts in this little project here, as you can see, we have a belt clip. So basically you take your belt, you put it on top of each other, and then you slide this little clip on and it holds your belt in place and we’re also using a true another treaty printed part and idler pulley, and we print those – and we put A 624 bearing in it and it works very good, it’s, very strong and that’s. Another part that is very useful when you’re playing around with motors, so we’re gon na offer these parts in our store from now on. So you guys can grab a couple of those if you want, if you’re buying a couple of parts grab a couple of those, and you can do projects like this very easily and as you can see also, we have brackets here that are cut out of acrylic, Because we have a laser cutter in our shop and we’re gon na start cutting little parts like this and offer those also because these are very useful, because we have a bracket here for a NEMA 17 motor and we have another type of bracket here.
That’S also for a NEMA 17 motor, but it all it also can be used for putting idler, pulleys and stuff. So all these parts are gon na be available in our star very soon and we’re just doing this, because these parts are hard to find and instead of importing them and all that, since we have the tools here, we’d rather, you know cut them ourselves and customize Them and stuff like that, and you know, help you guys out finding the right parts to do your project, alright enough of that. So the way we’re gon na do this today, we’re gon na use an analog joystick like I said so. This is connected fairly easily to our uno right here and we got the EZ driver that is connected to the motor. The motor is a bipolar motor idiot. It has only four wires connected to it, and the power is provided by our 12 volt power supply. These Nimmo motors consume, while they can work from 12 volt to 36 volts. I believe and they’re rated at point 4 amps, so 400 milliamps and, like I always say, go to our website you’ll see the schematic. We get more explanation. You know the specs for these guys and how to connect everything a little bit of background on how to use the stepper motors now that we’re going to do this today. As you can see, we have a belt looping around here and we have our belt clip that sits in the middle now.
What we’re gon na do these motors are one point, eight degrees steps, because this guy, the EZ driver can be configured to do full step. Half step quarter steps and I think almost I think, one eighth of a step of a step right now, it’s configured to do full steps. So one point, eight degrees per step: full rotation is 360 degrees, so basically, dividing 360 by 1.8 gives you 200 steps. What that means that it needs to do 200 steps to do a full revolution, so we calculated that for a distance of the belt and we ended up with two thousand 50 steps to do one full length of this, but this belt. So we divided that by two that gives us a thousand 25 to sit in the middle. So if by knowing these numbers now we can’t we can and know where this will sit in relation to the position. So when the joystick is resting at the middle it’ll be at the middle at 1025 and as I move my joystick it’s going to increase or decrease the number of steps until it gets to zero or 2050. So it will stop there and not try to loop back around now, as you can see, or maybe not see in this project we have here, we didn’t put any limit switches. Now let me switches are good, because if you go beyond a certain point, then it would hit a switch and we could code that in to say when you hit a switch, stop and that’s the way that CNC machines and the laser cutters and stuff like that.
Do there homing at the beginning, so basically they start moving until they hit a switch, and that tells it that this is the limit that it should go to now. We didn’t put any of these in here to make it simpler, but you know do this code and then you could add some limit switches to your own project, so it would do this automatically so for this project right here. I just need to make sure that when I turn on the power that my belt sits in the middle, because I coded that when the joystick is not being touched, it will go. It means that it’s at 1025. So I just need to make sure that when I start my project, this is in the middle, so we’re gon na go. Look at the code. Get some explanation. You’Ll understand the logic behind all this and then when we’re done, we’re gon na upload the code come back here and play around with it and move this belt around and see if it works so let’s go. Take a look and we’ll be right back. Alright! Welcome back so here we are in the code. Ok, so this is the code we might use to the stepper motor back and forth, using the joystick, so we’ll start at the top, so obviously we’re defining which pin is connected to what right here. So as an example, the step pin on the easy drivers connected to pin Tree on do you know, pin 2 is connected to the direction pin and ms one, ms two, which will control the the amount of stepping like quarter, steps, half step or full step are Connected to pin five and four sleep pin number seven and sleepin.
Basically, when you toggle that it turns off the motor, so you can move it and also it doesn’t overheat, the motor or the actual module – and we have our X pin, which is the x axis of the joystick, is connected to analog 0. Then we are defining a variable called direction which will hold the direction clockwise or counter clockwise of the motor, depending on which movement were doing with the joystick. Then we have step steps is at ten twenty five, because we know that there’s, two thousand and fifty step to do the whole distance of a belt run. So the middle would be ten twenty five. That assumes, of course, that the belt clip the thing that holds the two belts together will be in the middle when we start the program now, of course, like I said, we could have added some limit switches and we could have had the code just go talk Wise or counter clockwise until it hits the limit switch and then by hitting the limit switch. Basically, we would know that it would be at one end of the run and we could set that variable here, steps to zero or 2050, but for our tutorial we didn’t want to put that in so. But that is something that you guys could could put inside. Your project and then we do the setup over all our pins, they’re, all outputs and then we do add, writable write of the sleep pin too high.
So basically we’re waking up the easy driver. That means we’re sending current to our motor. If you set that to low, basically, you put the easy driver to sleep and then the current will not go to the motor. And here the configuration for MS 1, ms 2 pin to decide. If you want full staff, half step quarter, step or an eighth of a step so depending which pin you put high or low it will choose which one of those your your easy driver is going to be using in our example, we’re putting boat too low right Here so that equals to full step so we’ll have two other steps to do the to do one full rotation of the stepper motor. If you put a half step, then technically what that means that you multiply by two the number of steps needed to do a full rotation. So, instead of two hundred at half step, it would be four hundred. So this is what we’re doing here here: I’m. Just putting this as a comment, basically just a ride, the direction to the direction pin direction, pin high means that you’re, you want the motor to go anti clockwise and if you put it too low, then it goes. Clockwise and we’ll be using this stuff down here. To actually decide which direction we want the stepper motor to turn okay, so now we’re at the main domain loop and the way this work it’s all wild statement.
So while the joystick is pointing in one direction or another, we’re gon na move the stepper motor one way or the other, but we’re also going to be using that steps variable here to actually know where the stepper motor is at so we’re, starting in the middle Of the runs with ten twenty five, so let’s take the first one, while the analog well we’re gon na actually go with the middle one. This one here so while analog read X, pin is greater than 401, and so both these statements need to be true. For the while loop to run so, an analog reading of the joystick pen is smaller than and smaller and equal or equal to 600. So between 401 and 600, which is the middle position of an analog joystick. Because if you go far laughs, it’s zero and if you go far right, it’s 1024, so in the middle typically would be 512, but sometimes it’s, fluffs wait so that’s. Why we’re doing between 401 and 600? For us, that means that the joystick is at the middle position. So if it’s in the middle position by both these states meant being true, and if steps is smaller than 1025 at the beginning, it won’t be because we set it to 1025. But if it is smaller than 20 10 25, that means that the belt is on the left side of the middle portion. So we’re gon na do a digital right of the direction pin to low, which means that it we’re going talk wise Dan we’re gon na make the step remove by doing digital right of the step in hi a delay of one millisecond and then the step in Low so basically were switching the step, gun high and low very fast and that’s.
What makes a step in the stepper motor and then after that we’re going to say, okay we’ve done a step, so we’re going to increase the variable steps, plus plus meaning plus one. So let’s say the value of steps was, I don’t know a thousand every time we do a steps, a step by doing the high low Dan. The step is going to become plus one, so a thousand thousand one – and this is going to repeat until it. This part is no longer true. Step will not be smaller than ten twenty five. It will be ten twenty five at some point, so there’s another. If statement here, if the belt is actually on the right side of the middle meaning, the steps is e is bigger than ten 25. So if the steps bar d ball is bigger than ten 25, that means the belt is on the right. So we’re gon na do a direction pin of high, which means go anti clockwise, so we’re going the other way, but we’re doing the step portion. The exact same way by doing high delay low delay, but now we’re we’re gon na do step the variable steps, meaning one until we reached at ten twenty five, which is the middle right here. So, as you can see, this part is repeated. All these wire loops are doing the same thing, but they’re reading different values for the joystick like. If we take the last one here, nine hundred and ten twenty four.
That means we’re pushing the analog joystick all the way today right. So then, if the steps is smaller than 2050, which is the right side limit, then we’re doing the same thing years, plus plus, but in this portion. Since this is the end of the run, we don’t have to do if steps is greater than the 2050, because it will never happen and the same thing for the beginning here. This is the other side of the belt on the left side. So we’re only doing one if statement if this step is greater than zero, we don’t have to do hip steps smaller than zero, because that will not happen also, so there you go that’s the word we’re doing it basically it’s just with a while loops we’re just But we need to make sure that we start at the middle, because we don’t have limit switches and all that so it doesn’t know it can’t know. Unless we put that little belt clip that we saw in the video in the middle of our run, then this will work. If you wanted to make sure – and I have to position your belt on your own – then limit switches would be the way to go. So we’ve done everything here, so we’re gon na go ahead and verify our code and upload it to do. No and let’s go, take a look and try it up all right. So we’re back, we uploaded the code.
We were just looking at to do no and what we’re gon na do this. I already applied power to the EZ driver right here, so it’s receiving 12 volts right now and I’m gon na plug in the uno. Now now, like I said, like you saw in the code, we need to make sure that when we start this project that our belt clip sits in the middle obvious of the project, because when I apply power, it’s gon na assume, since the joystick analog value, is At around 512 that our belt is in the middle by default, like I said at the beginning, you could put limit switches, do a homing in your code that it would start going clockwise. If your limit switch is here until it hits the switch and then you would say that is the origin or zero, so right now for simplicity, we’re just doing it this way, but you can improve on this project a lot actually so I’m gon na plug in The you know now and there we go we’re plugged in ready to go. Nothing is moving because I didn’t touch the analog joystick yep, so now it’s assuming to that that the position has 1025 so I’m gon na start I’m gon na move just a little bit to hit the first limit, which is around the middle here and there we Go it stopped at that part, I’m gon na release comes back, go the other way come back.
Let me try to get this guy a little bit higher there. We go so let’s go again. First, go all the way stops, you can see. That’S, fine release comes back and the other way first and one more and all the way and release, and there you go. So let me remove this guy here now, as you can see, it responds fairly fast. Now, if I go here a little bit less, it stops at our first while loop. It goes all the way stops and I can move it around like this. There you go. We simplified the code as much as possible, we’re, not using any libraries at all we’re. Just using coding to actually step our motor back and forth clockwise or counter clockwise and it kind of knows its position in relation to the belt and, like I was saying when we looked at the code, the easy driver has a lot of pins that we’re not Using right now, there’s M 1 M 2 to select, if you want to do half step, quarter, steps right now, we’re doing full steps and there’s a sleep, and also that I could have connected to the joystick push button. So as I push down, it would go to sleep release the motors, because right now I can’t move them because the motor is getting I’m looking at it. Right now point three: two amps and when I move it’s using point 13 amps when I release and when it gets to the resting position, it’s getting the full power to prevent it from moving.
So we could use those. You could use those to actually make this code even even better, so there you know guys. I hope this helps you comprehend a little bit more, how to control motor using a uno and an easy driver. This is by no means the only way to do it. This is just you know, an introduction how to code for the you know to actually control a little like that very easily, using the easy driver. So there you go guys. I hope again. This helps you, like, I always say, go to our website. Brainless calm you’ll find these schematics all the parts that you see here. The treaty print parts, the laser cut parts, are gon na be available in our store very soon, we’re, just cutting them right now, making sure they are good and you know we’re putting them in our store to help. You guys find you know hard to find parts and you know make your project making a lot easier.
arduino motor Video
arduino motor news
Posted on Monday September 16, 2019Arduino snake robot kit can be controlled via your smartphone Geeky GadgetsA new robot snake kit has been created by Nevon Project which is powered using the Arduino Mega microcontroller and is equipped with 12 servos for. … Continue Reading »
Posted on Tuesday May 28, 2019Best Arduino Stepper Motors in 2019 All 3DPSo you need an Arduino stepper motor for your next project? Check the best available stepper motors fitting Arduino shields and drivers, plus a list of available … … Continue Reading »
Posted on Wednesday August 28, 2019A Home Cheesemaker, A Pain-Relief Patch & More Inventors DigestA smart home cheesemaker, a pain patch and more bright ideas from May 2019. … Continue Reading »
arduino motor Social