This article is part of a series of articles on how to Build A Custom PID Line Following Robot From Scratch. This article will cover how to build a motor circuit, but more specifically how to build one with a TB67H420FTG motor driver in dual motor mode. Setting up a motor driver circuit is pretty much the same with any motor driver, just the pins from the microcontroller to the driver will most likely change slightly.
If you need to solder your board, I suggest you start here How to Solder a TB67H420FTG Motor Driver Carrier and if you need to solder wires onto your motor, try this How to Solder Motor Wires. I used a set of motors that draw between 1.5 and 3A so I needed a 12V supply that could handle around 6A of current. I used the U3V70F12 12V Step up regulator because it was cheaper than buying a step down regulator with the same current capabilities. If you need to solder one of those up… guess what… try this How to Solder a U3V70 Series Motor Driver Carrier.
Parts
Here are the parts I used in my circuit, while you certainly don’t need to use the exact parts I did, it would be helpful in troubleshooting problems since, if you use exactly what I do and hook it up exactly the same way, it should work exactly the same. I like to buy quality parts that last so these motors might be on the pricey side for some people, if that’s you it’s no big deal. Just do an Amazon search for 12V DC motors and you can probably pick up a set of two for around $10. If you want to save on the battery, you can use rechargeable AAs, just use whatever you have on hand that’s compatible and if you don’t know leave a comment and I’ll let you know.
Part | Image | Description | Cost Per | Qty | Total Cost |
---|---|---|---|---|---|
Microcontroller | Teensy 3.2 | $20 | 1 | $20 | |
Motors | 25:1 Metal Gearmotor 20Dx41L mm 12V CB with Extended Motor Shaft | $23 | 2 | $46 | |
Motor Driver | TB67H420FTG Dual/Single Motor Driver Carrier | $10 | 1 | $10 | |
5V Regulator | LM7805 Voltage Regulator (only come in packs) | $8 | 1 | $8 | |
12V Regulator | 12V Step-Up Voltage Regulator U3V70F12 | $13 | 1 | $13 | |
Battery | 1000mAh 2S Lithium Polymer | $12 | 1 | $12 | |
Solderless Breadboard | Half Size (Only come in packs) | $7 | 1 | $7 | |
Total | $116 |
Watch the video
Alright, enough with the setup, let’s start building the circuit. If you prefer to watch a video, you can check that out below or continue on and read the article or hey, even both!
The Circuit
I whipped up this Fritzing circuit, the motor driver and voltage regulator may not look legit, that’s because I had to make those parts myself so I did enough to make them look like the parts they represent.
For the Teensy, I am using pins 5 through 10. Pins 5 and 6 go to INA1 and INA2, pins 7 and 8 go to INB1 and INB2. Then pins 9 and 10 are my PWM pins, one goes to each motor to control the motor speed. Pin 9 goes to PWMA and 10 goes to PWMB.
I have motor B hooked up with the correct polarity and I have motor A hooked up backwards, why? If both motors are facing the same direction then if I sent a HIGH/LOW to pins 5/6 and 7/8 then both motors will spin in the same direction. However, if I have on motor on each side of my robot, then one motor is going to spin in the opposite direction because it’s facing the opposite way. By hooking up one motor with backwards polarity I make sure that the same software code of sending HIGH/LOW will move both motors in the same direction with respect to my robot. Otherwise I’d have to remember to use HIGH/LOW for one motor and LOW/HIGH for the other to have them move the robot in one direction which is just confusing.
For power, I have my battery voltage going to both the 12V regulator for my motor power and then to the LM7805 regulator which supplies my Teensy power. Then I have the output of my 12V regulator tied to the VIN and GND pins on the motor driver to supply the motor voltage.
That’s pretty much it, once this is done we’re ready to start programming. I do like to pull the boards off and test with a volt meter to make sure I don’t fry anything. This way I can be sure all of the voltage connections are right.
Alternative considerations
I could have very well used an Arduino Uno or Arduino Nano, or any arduino for that matter. You can use any microcontroller that has at least four digital pins and two PWM pins since that’s really all you need to program this circuit.
Do I need the 12V step up regulator? Not really, I could just connect a 3S battery directly for a 12V motor voltage but I like to regulate my motor voltage, this ensures that my motors will provide the same output no matter how fully charged my battery is. If you don’t use a regulator, your motors will start to move slower and/or provide less torque as the battery discharges so if you skip the regulated motor voltage, be aware of this negative impact.You could use any motors that you wanted here as long as it fits within the voltage restrictions of the regulator which is 10-47 volts. If you have 6V motors you could use them with 12V but there’s not guarantee of how long they would last before they get burned out. Additionally, make sure your motors won’t draw more than 4.5A each during continuous use.
What next?
When you’ve completed this article, check out how to program this circuit in this article How to program a motor circuit with the TB67H420FTG
Can you share the fritzing model for the TB67H420FTG? It would be great help for my project
Sure, I don’t use fritzing outside of creating visual hookup diagrams so this part is only usable in the “Breadboard” view. This link should allow you to download the file.
I didn’t have a file sharing plugin so let me know if it doesn’t work.
Thanks a lot!
No problem, thanks for checking out the site.