Control Large DC Motors with Arduino! SyRen Motor Driver Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi folks welcome to another episode of NYC C&C in the Wednesday widget today let's talk about Arduino and motors Arduino --zz are awesome I love them and the reason I got into them whenever they came out I think is like 2006 is to control motors that to me is the coolest thing taking input from something and an output to something else and I've done a lot of work with Arduino Zand motors and I've even published two other videos so you can see here below that we're pretty popular one on was controlling big stepper motors and then the other one was on controlling smaller motors lots of different ways with relays and transistors and so forth today though let's talk about big DC gear motors these are brushed motors these have a huge amount of power they're pretty inexpensive they're actually incredibly easy to control with an Arduino we just need to use an external driver and today I want to walk you through a driver that I really like and it's really powerful and it's gonna be a lot of fun this episode is also going to be sort of a framework start for some projects I've got coming up where I want to use our dwee nose and these big motors to hopefully do some pretty cool stuff here in the shop so without further ado I thought I'd do the typical NYC CNC walkthrough here we'll take a look at the hardware we'll take a look at the pin layout and the wiring of it and then we'll take a look at the Arduino code I'm going to show two different examples one is going to be a simple example it shows you just how little code you need so if you're intimidated by Arduino or if you're new to Arduino you're going to see this is really really really basic then what I'm going to do is we're going to hook up a couple of potentiometers and a couple of sensors we're going to have this motor rotate back and forth with a little hammer I machine mostly just for fun but again to show the control and the speed and the capabilities of this so what do we have here for today's project first off we've got a 12 volt bench top power supply you can use a 12 volt battery like a lead acid or gel cell type battery is fine whatever needs to suit the motor you're working with I have this bench off supply for this use because it's a 50 amp output and where you run this with a big motor and I need that kind of power we've got an Arduino Uno we've got a breadboard with some potentiometers on it and then here is our driver this is made by dimension engineering and it's their siren model 50 so it controls up to 50 amps all of this information like always folks is going to be available right here on the Wednesday widget I'll have a parts list off of the arduino code i'll post a photograph of the layout so you can take a closer look and all that good stuff the motor we're controlling today is this guy right here it is powerful got a from surplus Center and their specs state it's over horsepower 900 watts something like 1900 inch pounds that's a lot of torque folks and it's a standard DC brushed gear motor so with 12 volts hooked up you could control it by just an on-off switch and you could even control with an Arduino and a like a beefcake relay which I've dusted other videos on very very easy to do but that's not the kind of control that I want to focus on today and it's also one reason why these kind of controls are awesome because as you're going to see here we've got much greater levels of precision fail-safes safety's braking etc so let's dive in there are two reasons I love these controllers from dimension engineering one they're just so darn easy to use with Arduino in my opinion and again I'll show you the code here in a minute the other reason is they're actually pretty affordable the one I'm using controls 50 amps it's 120 dollars you don't need such a large motor they have a $50 driver that will control up to 10 amps and I think that's continuous 50 at peak of 15 amps for a few seconds so again you get the same functionality and in fact the same code will work with this 10 amp version there's a lot more information out there they talk about even on their product webpage here you can see the four different main control modes our analog radio controller RC and then there's two different serial control modes we're going to actually work on one of those serial modes because I think it's a really cool way to work with them because the level of precision and the nature of how you're controlling it but again these controllers are great when you read down on the product specs on the we're using today you know you can use combat combat robots very heavy traditional type robots you can use these things for scooters and in vehicles that need to be controlling a lot of weight anything like that with brushed DC motors so pretty darn cool and I think that's what a lot of folks out there with our drina's are looking to do one of the reasons I make these videos is hopefully to make it easier for you guys to get your projects going and one of the things that I think is frustrating if you look at the Flyers that they include they mentioned that the control scale is zero up to one 255 so zero is full reverse 255 is full forward and then right in the middle 128 is stop unfortunately and it's kind of frustrating to me that's wrong the way these things are actually programmed is instead of being zero to 255 they're negative 127 to positive 127 with zero being stopped it's an imp it's a simple fix but you could spin your wheels for a while if you're trying to figure out how to make one of these things work the dip switches also are not complicated but for some of you folks out there that aren't interested in becoming experts on the driver but rather want them to just get to work hopefully this video is helpful so again like I said information available here on the NYC CNC web site here is the motor we're using from surplus Center you can see the specs here 40 rpm at the output shaft 12 volts and amps ranges depend on how much power you're draw but over a horsepower about 1900 inch pounds but again it's a lot of power and we want to control that with the Arduino so let's go take a look at this really simple example so you do need the library for the sirens and again go to the NYC we see website for the links we're going to set up a siren we're going to call it st and we're going to start it at serial 9600 and this matters on the siren on the dip switches if you look on the products webpage they have a dip switch wizard and if you chew you go through it and actually I'll just walk through with you so we are using not using the lithium batteries so we'll do click this one we're going to control it with serial not analog or RC and we're going to do the simplified mode and we're only controlling one so here we go this has the different baud rates we're doing 9600 so if you look closely at the little dip switches we've got them on off on off on on perfect so back to the code when we start it what we do is we do st motor one is means we're identifying the first control board so you'll never need to change one especially if you're only using one siren or one motor and 0 which 0 again is for stop so in our our arduino loop in this simple example what we're going to do is say again the same thing zero for stop delay 2,000 milliseconds to seconds and then we'll say go 60 so remember I'll make a comment here negative 127 is full reverse zero is stopped and then 127 I'll put positive in front of it is full forward so 60 should be about half speed forward continue running that full half speed forward for about two seconds stop it pause two seconds and then go backward about half speed so let's upload that code and see what she looks like okay you see how easy that is let's change the speed let's increase the speed one way D here's to the other and decrease the delays just you can quickly see the difference and how we can control it you should also take a look what's really cool is these things can break and stop on a dime and reverse and so forth okay real quick one last simple code will just accelerate everything a little so you can see the speed at which it can start stop reverses accelerate etc so how do you hook this stuff up well I've got a lot of wires here that's actually only because of the footage I'm about to show you which is using this thing with the potentiometers and some external proximity sensors all that you need to do for what we just took a look at was connect pin s1 on the siren over to Arduino digital pin 1 which is the TX pin pretty darn simple over here on the left side of the siren the outside two pins are your motor leads they call them M 1 and M 2 but that's not for motor 1 and motor two it's just the two leads of one motor and then the inside two are your power source for your motor they talked about using batteries in this instance I've got the power supply it is very important that you not don't mix those up but they're labeled B minus and B plus minus B negative positive plus being the positive so hard to screw that up in my opinion now let's take a look at what I really want to do which is using this with the Arduino and sensors and being able to adjust the speed on the fly so I machine this little hammer on the tormach PC and see mill you can see a quick shot of the footage here let's do just for fun no real practical purpose other than demonstrating the video but what I've got is 2 proximity sensors mounted on this strip here I love these sensors they're not the cheapest sensors out there they are you know somewhere between 10 to 10 and 20 dollars or even $25 but they have incredibly they're very well made they're sealed they're weatherproof or waterproof and they're non-contact so you can detect you can detect a signal in front of it without actually contact so some applications it's great to have a non-contact sensor so what we'll do is we'll just throw our little hammer on here all the code is going to do is alternate this hammer back and forth between the two sensors pivoting and we'll be able to use the two potentiometers to adjust the speed in each direction so take a quick look at the wiring again we've got the siren hooked up via this yellow cable to Arduino digital pin 1 digital pins 2 & 3 are the proximity sensors over here to the side those sensors are also hooked to ground via this blue cable and they take 12 volts so I've got a yellow wire here that's connected via this red wire back to the 12 volt power supply for the motors that's also helping feed those sensors because otherwise we've only got 5 volts on this board other than that all you've got is the one switch here and then two potentiometers the switch is pulled high with a 10k and when you push it in it goes over to digital pin 7 on the Arduino and then the potentiometers are analog outputs so they're connected to analog one into again one side of the potentiometer is connected to ground the other side is 2 5 volts and then the middle pin is your analog signal pin it's just that simple we're obviously establishing a ground and a 5 volt on the breadboard rail from the Arduino and that's actually it folks pretty darn simple so let's take a look at this code again it's available to download on the NYC cnc website a quick walk through the stop pin we just button the stop button we just mentioned is pin 7 the forward and reverse those are the proximity sensors are on 2 & 3 and then the analog are 1 & 2 we have a number of states which you'll see here below this is the same code we talked about in this simple version we define a siren mode siren and then we define a motor on it started as a at the stopped position and then all we're doing is we're using the forward state to hold the digital read of the forward button so basically that is determining the forward button is the proximity sensor and it's determining if that's high or low we do that once in the setup because what I want to do is establish one set of values for everything but then I don't want to reread everything down below I'm only going to reread it under certain conditions so we read we do have to reread the buttons that you can't avoid as you're looping through the code and what you do is if you if the forward state is low and that would mean that that forward the proximity button is triggered then it defines the current state as one if the other switches is pulled low or trigger then the current state is - and if the stop button is triggered the current state is zero and we immediately stop the motor because we want that to happen with no delay otherwise after you have stored these states you actually go through and say okay if the current state is zero well we know that stopped so you stop the motor actually already should have been stopped with this up above but nevertheless good to have we also delay for 500 milliseconds as sort of deep bounce if up above it saw hey ice on the arduino and i see that the forward states which is low so i've set the current state as 2/1 here if you say here we're saying okay that state is equal to one so let's do this let's do the motor at the forward speed and in when it's moving forward I can adjust that pot potentiometer and change the speed so what how do you do that well forward speed is an analogue read of the forward speed pin that's at analog one or two whichever one is for forward and then what you do is you map it and we want to say okay well we know that the potentiometer can range from zero to 123 or 10:23 but we only want that range to be 1 to 127 but we actually want it to be inverted so that when you rotate the potentiometer clockwise it increases the speed that's what feels natural you do the exact same for the other state if the other switch is triggered then you say okay let's move the motor at the reverse speed what is the reverse speed we'll let's read that potentiometer and we're going to map that potentiometer range which is as y2 0 to 1023 but we only want to control it from scale it down rather from negative 1 to negative 127 and again I have it going this order negative 127 to negative 1 so that as you rotate the potentiometer clockwise you increase the speed of the motor so that's all the code there is folks let's upload this and take a look how she runs actually before we put a little hammer on here I thought I'd show these proximity sensors just so you can see they're non-contact so if I hover this is actually an old harley-davidson piston at least that's what I was told it was my grandfather gave it to me as a punch works great and this will have an LED red LED that'll light up when it's triggered like so and then same thing over here hmm you can see our motors working switching the directions like so I'll use the potentiometer to increase the speed a little bit and the cool thing is these also work with aluminum a little shorter sensing range though just like so hit our stop button here put our hammer back on now my original hope was you could run this thing pretty quickly and have it reverse without touching these doesn't look like that's actually going to be possible when I was experimenting that has to do with the Arduino Bob the Arduino processor rate although you know I was thinking and this is something I'm going to do more experimenting with is if you increase the baud rate of the serial protocol that we're using maybe I can get a little bit about better reversing and performance out of it so again if you're interested in this type of stuff whether it's motors and Arduino and machining and prototyping and fabrication definitely subscribe I'll have more of this stuff to come and again this is just the framework again setting this stuff up because I've got one project in mind I'm going to be putting this into and doing the video series on it so looking forward to that let's go ahead here just turn down a little bit so we're not starting at full speed or anything and I will just start it by tripping one of the sensors so I tripped this one it should go down to this one first perfect now this is slow enough and I'll zoom in in a second that they should not contact because it's able to reverse and enough time to prevent that okay so let's turn up the speed a little bit so you can see if they're not hitting its darn yeah they're hitting this is its darn close but it's not stressing you hear or see will slow this down slo-mo and we easier actually see when I'm in production here in final cut a little more speed and that's bending that bar just a hair okay that's basically it let's just before we wrap up here let's throw a little bit of weight on the end of that hammer and see how she does had a piece of lead pure lead 5.5 pounds sitting around had a hole through it so hard argue with that just about as dense as you can get for the size now five pounds is uh isn't bad at all and you're out here maybe six inches so that would be the equivalent of something like thirty inch pounds and this motors got way more power than that but nevertheless this is a pretty good amount of power and it's more than what you normally see on a lot of you are doing the level stuff so hopefully this will sort of prove the point of how good these controllers are so we'll start off slow not that slow okay so you get the point there no problem at all increase the speed a little and just for kicks you know you can start it stop it boom anywhere no problem at all restart all day long you and you can go fast one way and slow the other way will speed up the other way even a little more and see so hope you've enjoyed that Wednesday widget I love these motors lots of people ask about servos or steppers and those are great as well but I think sometimes folks don't understand is you can control a DC gear motor or brush motor like this very accurately and there's so much more you can do with these you'll one thing that immediately comes to mind is you can put an encoder on this and turn it into a sort of synthetic device stepper or servo where you're able to control location and positional accuracy and so forth so much more to come on this if you guys are interested in this type of stuff please subscribe to my channel more Arduino prototyping fabrication machining all that good stuff you guys know I appreciate the thumbs up the likes the comments the shares with that I will see you guys next Wednesday if not sooner take care
Info
Channel: NYC CNC
Views: 456,814
Rating: 4.9204154 out of 5
Keywords: Arduino (Computing Platform), Big, Robot, Electronics, DIY, nyc, cnc, nyccnc, stepper, motor, drive, contol, lathe, mill, machine, turn, Do It Yourself (Website Category), Driving, tutorial, driver, syren, sabertooth, program, combat, large, torque, servo, micro controller, howto
Id: OW-Bf3yjUyE
Channel Id: undefined
Length: 21min 56sec (1316 seconds)
Published: Tue Oct 07 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.