{"id":245,"date":"2021-12-19T20:19:47","date_gmt":"2021-12-19T20:19:47","guid":{"rendered":"http:\/\/archive.gagvani.com\/?p=245"},"modified":"2021-12-19T20:19:48","modified_gmt":"2021-12-19T20:19:48","slug":"getting-started-with-the-pololu-tb9051ftg-motor-driver","status":"publish","type":"post","link":"https:\/\/archive.gagvani.com\/index.php\/2021\/12\/19\/getting-started-with-the-pololu-tb9051ftg-motor-driver\/","title":{"rendered":"Getting Started with the Pololu TB9051FTG Motor Driver"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is the TB9051FTG?<\/h2>\n\n\n\n<p>The Toshiba TB9051FTG is a <strong>brushed DC motor driver. <\/strong>From Pololu&#8217;s website:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>The TB9051FTG from Toshiba is an H-bridge motor driver IC that can be used for bidirectional control of a single brushed DC motor at 4.5 V to 28 V. It can supply up to about 2.6 A continuously, and it can deliver peak currents up to 5 A (typical) for a few seconds.<\/p><cite><a href=\"https:\/\/www.pololu.com\/product\/2997\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.pololu.com\/product\/2997<\/a><\/cite><\/blockquote>\n\n\n\n<p>Since a standard, hobby-grade DC motor such as <a href=\"https:\/\/www.google.com\/url?sa=i&amp;url=https%3A%2F%2Fwww.robotshop.com%2Fca%2Fen%2F6v-250ma-brushed-dc-motor.html&amp;psig=AOvVaw2K6p2-MatscPjVLHZ1tEbb&amp;ust=1635780959722000&amp;source=images&amp;cd=vfe&amp;ved=0CAsQjRxqFwoTCICOyor99PMCFQAAAAAdAAAAABAH\" title=\"RobotShop 250 mA motor\" target=\"_blank\" rel=\"noreferrer noopener\">this one<\/a> draws less than 1 A in normal operation, and less than 3-4 A in a stall condition, the TB9051FTG is a fine choice for many small robotics applications, or other projects where motor control is needed. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What differentiates the TB9051FTG from other motor drivers?<\/h2>\n\n\n\n<p>There are many, many different variations of motor drivers available. Some are for stepper motors, others are for brushless motors, still others can only drive very small motors. Some motor drivers even have microcontrollers embedded inside them. <\/p>\n\n\n\n<p>One of the most popular motors drivers is the L298N. This motor driver uses an H-Bridge to control up to 2 motors. Thus, it is useful in some robots which use 2 separate motors for differential drive. However, the TB9051FTG has some useful features that are uncommon on other motor drivers:<\/p>\n\n\n\n<ul><li><strong>Current Monitoring &#8211; <\/strong>The motor driver reports how much current the motor is drawing<\/li><li><strong>Over-Current Response<\/strong> &#8211; Normally, a motor controller would simply stop working if the motor connected to it draws excessive current, however, this motor controller can limit the peak current the motor uses. <\/li><li><strong>Brake Modes &#8211; <\/strong>The TB9051FTG can be configured to either coast or perform regenerative braking when the motor is stopped. <\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wiring Guide<\/h2>\n\n\n\n<p>Here is a list of the basic connections you will need to make to operate this motor driver:<\/p>\n\n\n\n<ol><li>Terminal block VIN &#8211; Voltage input from power source (usually a battery)<\/li><li>Terminal block GND &#8211; Ground from power source<\/li><li>Terminal blocks OUT1 and OUT2 &#8211; DC motor input. <\/li><li>Header GND\/VCC &#8211; Ground and 5V from microcontroller.<\/li><li>Header EN &#8211; 5V, from microcontroller&#8217;s digital output.<\/li><li>Header ENB &#8211; 0V, from microcontroller&#8217;s digital output.<\/li><li>Header PWM1\/PWM2 &#8211; Digital pins 5\/6 from the microcontroller. (The pinout can change, of course).<\/li><li>Header OCM &#8211; Analog pin 1 from microcontroller(Can also be reconfigured). <\/li><\/ol>\n\n\n\n<p>Here is a wiring example using an Arduino Nano, and 4 AA batteries (which, when fully charged, provide about 5 volts). <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"935\" src=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1-1024x935.jpg\" alt=\"\" class=\"wp-image-253\" srcset=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1-1024x935.jpg 1024w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1-300x274.jpg 300w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1-768x702.jpg 768w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1-1536x1403.jpg 1536w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6915-1.jpg 1872w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-1024x768.jpg\" alt=\"\" class=\"wp-image-254\" srcset=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-1024x768.jpg 1024w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-300x225.jpg 300w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-768x576.jpg 768w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-1536x1152.jpg 1536w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6917-2048x1536.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"623\" src=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-1024x623.jpg\" alt=\"\" class=\"wp-image-255\" srcset=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-1024x623.jpg 1024w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-300x183.jpg 300w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-768x467.jpg 768w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-1536x935.jpg 1536w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-2048x1247.jpg 2048w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/IMG_6918-1400x850.jpg 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Programming the Arduino<\/h2>\n\n\n\n<p>Now that we have everything wired up, we need to figure out how to get the Arduino to send the correct signals to the motor controller. There is a <a href=\"https:\/\/github.com\/adamlm\/tb9051ftg-motor-carrier-arduino\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"TB9051FTG Motor Driver - GitHub\">very helpful library available<\/a> for Arduino which makes it very straightforward to interface with this motor controller. <\/p>\n\n\n\n<p>To use this library, open up your Arduino IDE and select Sketch > Mange Libraries > Library Manager. Install the library called <strong>TB9051FTGMotorCarrier<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"983\" height=\"554\" src=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/image.png\" alt=\"\" class=\"wp-image-257\" srcset=\"https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/image.png 983w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/image-300x169.png 300w, https:\/\/archive.gagvani.com\/wp-content\/uploads\/2021\/12\/image-768x433.png 768w\" sizes=\"(max-width: 983px) 100vw, 983px\" \/><\/figure>\n\n\n\n<p>Next, upload this code to your Arduino:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;TB9051FTGMotorCarrier.h&gt; \/\/ Include the library for interfacing with the motor controller\n\n\/\/ TB9051FTGMotorCarrier pin definitions\nstatic constexpr uint8_t pwm1Pin{5};\nstatic constexpr uint8_t pwm2Pin{6};\nstatic constexpr uint8_t ocmPin{A1};\n\nint enbPin = 7;\nint enPin = 8;\n\nstatic float throttlePercent{0.0f};\n\n\/\/ Instantiate TB9051FTGMotorCarrier with the pins provided\nstatic TB9051FTGMotorCarrier driver{pwm1Pin, pwm2Pin, ocmPin};\n\nvoid setup() {\n  pinMode(enPin, OUTPUT); \n  digitalWrite(enPin, HIGH); \/\/ Set Enable pin to High\n  pinMode(enbPin, OUTPUT);\n  digitalWrite(enbPin, LOW); \/\/ Set ENB pin to Low\n  \n  Serial.begin(9600); \/\/ Instantiate Serial port through USB\n\n  driver.enable(); \/\/ Enable motor driver\n}\n\nvoid loop() {\n  motorRamp();\n}\n\nvoid motorRamp() {\n  \/\/ ramp up to full speed in 50*200 = 10000 millsec\n    for(int i = 0; i &lt; 200; i++) {\n      driver.setOutput(throttlePercent);\n      Serial.print(throttlePercent);\n      Serial.print(&quot; --&gt; &quot;);\n      Serial.println(driver.getCurrent());\n      throttlePercent+= 0.005;\n      delay(50);\n    }\n\n    \/\/ ramp down to 0 speed in 50*200 = 10000 millsec\n    for(int i = 0; i &lt; 200; i++) {\n      driver.setOutput(throttlePercent);\n      Serial.print(throttlePercent);\n      Serial.print(&quot; --&gt; &quot;);\n      Serial.println(driver.getCurrent());\n      throttlePercent-= 0.005;\n      delay(10);\n    }\n\n    \/\/ ramp down to full REVERSE speed in 50*200 = 10000 millsec\n    for(int i = 0; i &lt; 200; i++) {\n      driver.setOutput(throttlePercent);\n      Serial.print(throttlePercent);\n      Serial.print(&quot; --&gt; &quot;);\n      Serial.println(driver.getCurrent());\n      throttlePercent-= 0.005;\n      delay(50);\n    }\n\n    \/\/ ramp up to 0 speed in 50*200 = 10000 millsec\n    for(int i = 0; i &lt; 200; i++) {\n      driver.setOutput(throttlePercent);\n      Serial.print(throttlePercent);\n      Serial.print(&quot; --&gt; &quot;);\n      Serial.println(driver.getCurrent());\n      throttlePercent+= 0.005;\n      delay(50);\n    }\n}\n<\/pre><\/div>\n\n\n<p>Make sure to unplug your Arduino&#8217;s USB cable before connecting it to the motor, or the USB connection will attempt to supply the current demands of the motor, which could be damaging to your computer. <\/p>\n\n\n\n<p>Hope you liked this tutorial! Below is a video of the circuit and code in this tutorial in action:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"TB9051FTG Motor Driver Video\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/t3zhm4y0NJg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>What is the TB9051FTG? The Toshiba TB9051FTG is a brushed DC motor driver. From Pololu&#8217;s website: The TB9051FTG from Toshiba is an H-bridge motor driver IC that can be used for bidirectional control of a single brushed DC motor at 4.5 V to 28 V. It can supply up to about 2.6 A continuously, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[24,25],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/posts\/245"}],"collection":[{"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":6,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions\/260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.gagvani.com\/index.php\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}