TB6612FNG H-Bridge Motor Controller - Better than L298N?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we'll be working with an improved h-bridge motor controller we'll see how to use the TV 66 1/2 F ng H bridge and how it provides better performance than the popular L 2 98 n we're building better bridges today so welcome to the workshop [Music] hello and welcome to the workshop and today we're going to be controlling a couple of small DC motors using an H bridge and we'll take the whole assembly and we'll put that into a robot car base now if this sounds a bit like deja vu I'm not surprised we've done this several times in fact a couple of years ago I did a video about doing exactly what we are doing today plus we have done a number of videos using small robot car bases and all of these videos has been one common element the L 298 and H birds controller well today we're going to do all of the above with a different H bridge controller the t be 66 1/2 F ng H bridge now the t be 66 1/2 F ng or I'm just going to call it the t be 66 1 2 for short is a MOSFET based H bridge and it's available in a number of inexpensive modules this like the L 2 98 n is and one beauty about this age bridge is that it has similar specifications to the L 2 98 n so you can use it in a lot of the same applications in fact it uses similar control signals so it's very easy to take an old sketch that you used with the L 2 98 N and move it to this H bridge well why would you want to do this while this H bridge has a number of performance advantages because it uses MOSFETs and not bipolar transistors so let's take a look right now at the t be 66 1/2 F ng H bridge so let's take a closer look at this motor controller module the TB 66:1 to FNG is a dual-channel h-bridge motor controller the device is constructed with MOSFETs for improved performance over devices constructed with bipolar Junction transistors it has a motor supply voltage that ranges from 2.5 to 13 point 5 volts the logic supply voltage can range from 2 point 7 to 5 point 5 volts making the device compatible with both 3.3 and 5-volt logic the TV 66:1 to FNT has an output current of 1.2 and fears continuous with 3.2 ampere Peaks this h-bridge module has four functions a clockwise rotation a counterclockwise rotation a short break function and a stop function now let's take a look at the pin outs of a typical tbh 66 1/2 F ng module you'll note that with most of these modules the outputs and the inputs are in opposite sides of the module the VM connection is the motor voltage input the VCC is a logic voltage input there is a ground pin a 0 1 and a 0 2 are the outputs to motor a B 0 1 and B 0 2 are the outputs to motor B and there is an additional ground connection on the other side the PWM a is the a channel PWM input to control the motor speed the AI 1 and AI 2 pins are the input controls for channel a this determines what mode the channel is in stby is the standby input this allows you to place the device and low current standby mode VI 1 and VI 2 are the B channel input controls PWM B is the B Channel PWM input and there is an additional ground connection this h-bridge has built-in thermal shutdown it also has low voltage protection circuitry the device has a standby power mode which allows you to place it in a very low current draw mode when it is not being used the tbh 66 1/2 F ng is available in many popular modules shields through the Arduino and hats for the Raspberry Pi so now let's take a closer look at one of these modules now here we have a TV 66 1/2 F ng module and as you can see this is a very tiny device now they package it like this along with a couple of male header pins that you can solder on to it and I've sought it a couple onto this one over here so as you can see they've got on this particular style all of the connections are written on the bottom which makes it a little more difficult when you breadboard now Sparkfun makes a module dislike this one and they also have distilled screening on the top and you might find that a lot easier to use but as you can see it is a very tiny module now here's an ell 298 NH bridge motor controller by comparison and as you can see the size difference this is about a quarter of the size plus height wise of course you've got this huge heatsink on the L 298 n and there's no heat sink on these devices although you could put a heatsink on this tip if you thought you're going to be running it at its maximum rating constantly you could even make things smaller by not soldering the pins onto this and disconnecting wires directly to the motor control module so a very tiny module to replace the L 298 n module so as you can see the TB 66 1/2 FNG has a definite size advantage over the L 298 n and that is because it is a smaller module to begin with and also does not require a large heatsink although you can attack a small heatsink to the module if you feel that it is getting a bit too warm but of course size as they say is not everything and there are other aspects to consider when you are choosing a motor controller and so what I want to do right now is this quickly compare the specifications of the TB 66:1 to fnd to the l2 98n and see how they stack up against each other let's just go and do that right now let's compare a few parameters of the TB 66 1 to F and G and the l2 98 and H bridge motor controllers the motor voltage range for the TB 66 1/2 F ng is 2.5 to 13 point 5 volts DC the l2 98n has a motor voltage range of 4.5 246 volts DC so the l2 98n can certainly handle higher voltage motors however it cannot handle low voltage motors such as 3 volt motors which can be used with the TB 66:1 to FNG the TB 66:1 2 has a 1.2 ampere constant current rating the l2 98n has a 2 ampere constant current rating the TB 66:1 2 has a 3.2 amp peak current rating and the l2 98n has a 3 ab peak current rating so for current rating the devices are very similar the TB 66:1 to fnd is available in very small modules that do not require a heatsink the l2 98n is on larger modules that do require a heatsink note that there is a version of the l2 98 that does not need a heatsink but it does not have the current capability of the l2 98n efficiency is where the TB 66:1 to FNG really shines it has an efficiency rating of 91 to 95 percent the l2 98n has an efficiency rating of 40 to 70% this means that 91 to 95 percent of the energy that is sent into the TB 66 1/2 is delivered to the motor where the l2 98n at best delivers 70% of that energy incidentally the efficiency of the l2 98n improves at higher motor voltages the voltage drop in the TB 66:1 to FNG is very low because of its use of MOSFETs and it varies over the voltage range the drop is from 0.05 to 0.1 3 volts DC the voltage drop on the elf to 98n is a pretty constant one point 4 volts DC because of the two bipolar Junction transistors it employs the TB 66:1 to FNG has a low current standby mode there is no low current standby mode on the l2 98n so now that we've seen how the T V 66 1 2 stacks up against the l2 98n let's actually hook it up to an Arduino and start using it now as I've already shown you it is very compatible with the l2 98n so much so that what I've decided to do is repurpose one of my older Arduino sketches that was based on the l2 98 and and use it with the TB 66 1 2 so let's go ahead and take a look at the wiring I'll show you the sketch and then we'll run a couple of motors off of our little H bridge for our experiment you will need in our dwee no blue no a TB 66 1 2 FNG motor control module a couple of DC motors that I'm calling motor a and motor B I'm using 6 volt motors you'll need a power supply for those motors so I'm using a 6 volt power supply and a couple of potentiometers to control the speed of the a and the B motors we'll start by connecting the 5 volt output of the Arduino to the VCC on the motor controller well connect the ground from the Arduino to one of the ground pins on the motor controller will also connect 5 volts to one end of each potentiometer and we'll connect 5 volts to the standby lead on the motor controller well ground the other side of the potentiometers and then connect the wiper of pot a to analog input a zero pot B will go to analog input a1 next we'll connect the motor controller control leads pin 3 of the Arduino will go to the AI 1 connection on the or controller on some models this will be labeled as a in one pen for will go to AI or a in to pin 5 to the PWM a input pin 6 to the PWM be input pin 7 to the bi or B in 1 and pin 8 to be I or B in to the positive 6 volt will go to the VM connection that's the motor supply voltage and will ground the other side of the supply to another ground lead and then we'll connect the motors motor a will be connected to a o 1 which is a output 1 and a o2 and motor be connected to be a 1 and B 0 2 and this completes the wiring now here's the sketch that we're going to be using to control the TV 66 1 2 F and G H bridge and as you'll see this is a very simple sketch now we start off by defining the connections to the motor controller and also the connections to the two potentiometers that we're using to control the speed we also set up a couple of variables that are going to hold the speed of the motors now in the setup we set all the pins up as outputs and we move on to the loop now we begin the loop by setting both motor a and motor B forward and we do that by applying a hi to the in 1 and a low to the in 2 on both of the motor controls now of course we could reverse those and make the motor spin backwards if we wished and then in this statement over here we're going to both read the potentiometers and convert those values to a range of 0 to 255 so inside the statement we do an analog read of the potentiometer and then we're using a map command to convert that from a value 0 to 1023 to a value of 0 to 255 because that's what we need for PWM and then we simply pass that value to the pwm pins on the motor controller using an animal right command and go back and do the loop over and over again so as you can see this is a very simple sketch I want to show you another sketch now this is a bit of a blast from the past this comes way back from 2017 and this is a sketch that I used in a fairly similar circuit to control two motors with an l2 98n and as you can see the sketch is virtually identical in fact the only changes are in the loop I kind of tighten this up and made this all into one statement instead of two but I wanted to show you this because it illustrates that you can pretty well take any sketch made for the l2 98n and substitute a TB 66:1 to FNG in fact if you change the input pins around to Mac your original sketch you wouldn't have to rewrite any code whatsoever so now that we've seen our sketch through the TB 66:1 to FNG let's take a quick look at it in action and so here's our demonstration as you can see i've got the two potentiometers this is a and this is B and I've got my two motors mounted up here with a couple of wheels on them so we can watch them spin and this is a and this one over here is B I've got my power supply which in this case consists of four double A batteries to provide six volts here on this breadboard buried behind all these wires is the actual motor controller itself the TV 66:1 to FMG and of course my Arduino Uno and so now that I've got this all hooked up let's just simply take a look at it working I'm going to turn the pot from motor a turn it up the speed the motor be [Laughter] and I can vary the speed to both motors [Music] and so as you can see that works pretty well now for our final experiment with the TB 66 1/2 F and G I thought it might be fun to take the two motors that I've got and put them on to a robot car base now I'm sure you've seen these robot car bases before there's a little plexi glass or acrylic models that you can get that are very inexpensive and are great for experimenting with robotics now in all my previous designs of course I've used an L 2 98 and when I've worked with these cars but today we're just going to use a TB 66 1/2 F and G pretty well wired up exactly as we saw before with a few slight modifications another modification is instead of writing directly to the motor controller as I did in the last sketch and indeed as I have for all my L to 98 n sketches I'm going to be making use of a library sparkfun has a library specifically made for this motor controller and I'm going to make use of it and some of their sample code in order to drive my robot car and make it move around the room on its own so let's go and take a look at the hook-up and the sketch that we're going to be using and then we'll drive our little robot car around the floor now for our robot car experiment we're essentially going to be using the same circuit that we did for our initial experiment with a couple of slight modifications the first is that we are going to get rid of the two potentiometers next we will disconnect the five volts from the standby lead on the TB 66:1 to FN key will also require a 9-volt battery this will be used to power the arduino uno in our robot you could also use a USB power bank if you wanted to and feed that into the USB supply instead we'll connect pin 9 of our Arduino to the standby lead on the TB 66:1 to FNG and the 9-volt battery will be connected to the power connection on the Arduino Uno and this completes the wiring for the robot car now to program our robot car I'm going to take a slightly different approach sparkfun has created the library for the TB 66 1/2 FNG and i'm going to make use of that now the library is available on github is illustrated over here and you'll also find this link in the article accompanying this video now in order to install a zip library you download the library into a known location and then you go to sketch and then you go to include library and add zip library navigate to where you've downloaded it in my case my downloads directory and select the library and click OK I'm not going to do that because I've already installed my library once you do that the library will now be part of your Arduino IDE now there is an example sketch that comes with the library that we can use for our robot car so go into file go into examples and move down until you get to the sparkfun motor driver library this will be in the examples from custom libraries section you'll notice there's something here called motor test run and this is the sketch that we're going to be using now I've got the sketch over here it needed one modification and the modification was this originally was set to two I have set it to three and that's because I've connected my AI 1 or 8 in one pin to pin 3 and not pin 2 you could also just move the wire over to pin 2 if you wanted to keep the sketch as it is but otherwise I haven't modified the sketch at all now the sketch is actually very simple and it's a very simple way to work with the motor controller use first of all include the library itself of course and define the pins that you are going to be using for the motor controller after that you can simply set up an object they're calling the motor 1 and motor 2 and this is how they're defined that's motor and then all of the pins in that particular order after that you can simply use the functions in order to drive the motor so there are functions like motor drive which you pass the speed the duration that you want in milliseconds and if you pass a negative speed the motor will go backwards so you no longer need to control the motor direction through your code you just simply pass it either a positive or negative speed there's also a brake function on it and as you can see what they do over here is they simply exercise the motor through a number of different speed and brake and directing changes in fact they describe it up over here at the top it says it'll cause your robot to do a little jig and so what we'll do is we'll upload this to our robot and watch it do its little jig and so ladies and gentlemen boys and girls let me present to you probably the ugliest robot car that I've ever seen certainly the quickest one I've ever built and this is probably a good lesson on how not to build a robot car as you can see I haven't even bothered to remove the brown paper off of the plexiglass which normally is the first thing that you do after you make markings on it as to where you want to drill holes but this again is a very temporary thing I've kept pretty well the same circuit we had before on the sagas breadboard connected the standby pin to pin nine is the only difference over here I've literally used a piece of double-sided masking tape to hold my battery on here and I've got one spacer holding my Arduino on down over here yes this is pretty ghetto Roma car the batteries over here of course are held on that's actually held down by a screw but when I put everything together I found the thing was a bit top-heavy it kept going like this so I put a C clamp on the back over here to weight it down so this is obviously not how you're going to want to build a permanent robot car but for this experiment that could work so I've got my six volt power source already connected to the breadboard my nine volts is over here when I place it onto the Arduino everything should [Music] [Music] and so as you could see it does work again not the best robot car I've ever built but it certainly illustrates that you can use these modules in place of the l2 98n in your robot car designs and so with that we bring to a close our look at the TB 66 1/2 H bridge motor controller now as you can see this is a pretty versatile device and I think for most projects that pretty well replaces the l2 98n now I'm not gonna suggest that you go back into your old projects and remove the l2 98 ends and replace them although if they're battery-powered projects you might want to consider it you will gain some battery life by doing this now if you want more information about this eighth grader if you liked some of the sketches that I use today you'll find that on the article that accompanies this video and that's on the drum bots workshop comm website and there's a link to that article directly below the video you'll also find a few other links directly below the video as well one of them is to join the newsletter this is not a sales letter by any means it's just my way of keeping in touch with you and so if you haven't signed up for the newsletter please do that if you'd like to discuss this or anything electronic the best place to do that is on the drone bot workshop forums and you will find a link to the forum directly below this video all kinds of links and one last thing if you haven't subscribed to the YouTube channel please do that and so until the next time we meet please take care of yourselves and I hope to see you again very soon here in the workshop good bye for now [Music]
Info
Channel: DroneBot Workshop
Views: 73,684
Rating: 4.9612589 out of 5
Keywords: tb6612fng motor driver, tb6612fng motor driver arduino, h-bridge motor driver, h-bridge motor driver using mosfet, TB6612FNG vs, tb6612fng vs l298n, h bridge, motor driver, dc motor
Id: JPPTRj0KWbg
Channel Id: undefined
Length: 25min 7sec (1507 seconds)
Published: Sun Dec 15 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.