Overview

In this tutorial, we’ll create a motor driver circuit using the TB6612FNG motor driver IC. This circuit can be used to control DC motors with PWM capability and direction control.

Creating the Circuit

Open snippets.tscircuit.com and create a new snippet.

First, let’s import our motor driver component (Using the import dialog at the top) and set up the basic structure:

import { useMotorDriver } from "@tsci/imrishabh18.TB6612FNG"

export default () => {
  const MotorDriver = useMotorDriver("M1")

  return (
    <board width="30mm" height="30mm">
      <MotorDriver />
    </board>
  )
}

Adding Pin Headers

We’ll add two 8-pin headers for connecting our control signals and power:

<pinheader
  name="JP1"
  pinCount={8}
  pcbX={-9}
  pcbRotation={90}
  schX={-4}
  footprint="pinrow8"
/>
<pinheader
  name="JP2"
  pinCount={8}
  pcbX={9}
  pcbRotation={90}
  schX={4}
  schRotation={180}
  footprint="pinrow8"
/>

Adding Decoupling Capacitors

Decoupling capacitors are essential for stable operation. We’ll add three 0.1μF capacitors:

<capacitor
  name="C1"
  capacitance="0.1uF"
  pcbX={-7}
  pcbY={8}
  pcbRotation={90}
  schX={-2.5}
  schY={3}
  footprint="0402"
  symbolName="capacitor_vert"
/>
<capacitor
  name="C3"
  capacitance="0.1uF"
  pcbX={-5}
  pcbY={8}
  pcbRotation={90}
  schX={-1}
  schY={3}
  footprint="0402"
  symbolName="capacitor_vert"
/>
<capacitor
  name="C2"
  capacitance="0.1uF"
  pcbX={5}
  pcbY={8}
  pcbRotation={90}
  schX={2.5}
  schY={3}
  footprint="0402"
  symbolName="capacitor_vert"
/>

Connecting Everything Together

Now we’ll add all the traces to connect our components:

// Power connections
<trace from=".JP1 > .pin8" to=".C1 > .neg" />
<trace from=".JP1 > .pin8" to=".C3 > .neg" />
<trace from=".JP1 > .pin8" to=".M1 > .pin24" />
<trace from=".JP1 > .pin7" to="net.VCC" />
<trace from=".JP1 > .pin6" to="net.GND1" />

// Control signals
<trace from=".JP1 > .pin5" to=".M1 > .pin1" />
<trace from=".JP1 > .pin4" to=".M1 > .pin5" />
<trace from=".JP1 > .pin3" to=".M1 > .pin7" />
<trace from=".JP1 > .pin2" to=".M1 > .pin11" />
<trace from=".JP1 > .pin1" to="net.GND2" />

// Motor outputs
<trace from=".JP2 > .pin7" to=".M1 > .pin15" />
<trace from=".JP2 > .pin6" to=".M1 > .pin16" />
<trace from=".JP2 > .pin5" to=".M1 > .pin17" />
<trace from=".JP2 > .pin4" to=".M1 > .pin19" />

Pin Functions

The TB6612FNG motor driver pins are arranged as follows:

  • Power pins:

    • VCC: Logic power supply
    • VM: Motor power supply
    • GND: Ground connections
  • Control pins:

    • PWMA/PWMB: PWM control inputs
    • AIN1/AIN2/BIN1/BIN2: Direction control inputs
    • STBY: Standby control
  • Output pins:

    • A01/A02: Motor A outputs
    • B01/B02: Motor B outputs

Testing Your Circuit

Click “Run” to see your circuit. You can switch between different views:

Schematic view showing component connections

Switch to the PCB view to see the physical layout:

PCB view showing component placement and traces

And check the 3D view to preview the final board:

3D preview of the assembled circuit

Want to see this circuit in action? Check out the live example

Exporting Your Design

You can export your design in various formats:

  • Gerber files for PCB manufacturing
  • KiCad format for further editing
  • STEP files for mechanical design

Click the “Export” button and choose your desired format.

Next Steps

Try modifying the design:

  • Add LED indicators for motor direction
  • Include power supply filtering
  • Add motor protection diodes
  • Experiment with different board layouts

Remember to save your snippet if you want to share it or use it in other projects!