1. Blog>
  2. A Standalone Full Bridge DC Motor Driver

A Standalone Full Bridge DC Motor Driver

by: Oct 26,2022 14749 Views 0 Comments Posted in Technology

Bridge DC Motor Driver

By Hesam Moshiri, Anson Bao

Copyright: Attribution, NonCommercial, NoDerives (CC BY-NC-ND)


The Full-Bridge (H-Bridge) is the most popular driver circuit to control brushed DC motors. The main advantage of a full bridge driver is the ability to change the rotation direction of the motor, without manually reversing the supply wires. I’ve already published the Half-bridge and H-bridge driver circuits before; however, I was receiving many requests and comments for a standalone H-Bridge driver to control the DC motors, without using any external board or a controller.

Therefore, I introduced a cheap, compact, and standalone H-Bridge DC motor driver that can be embedded in a variety of mechatronic devices. A cheap ATTiny13 microcontroller controls everything and I used the Arduino IDE to write the microcontroller code. All components, except for the connectors, are SMD.

The motor can be controlled in three modes: Forward, Stop, and Reverse. The user can adjust the rotation speed of the motor separately in the forward or reverse direction, using two panel-mounting potentiometers. The low ON-Resistance of the Mosfets allows you to use this circuit in high currents.

To design the schematic and PCB, I used Altium Designer 22. The fast component search engine (octopart) allowed me to quickly collect the components’ data and generate the BOM as well. To get high-quality fabricated boards, I sent the Gerber files to PCBWay. To test the driver board, I disassembled an electric toy car and used its powerful 775 DC motor (plus the gearbox). 

It’s a cool experience, just build one and have fun!


Specifications

  • Input Voltage (Motor): 8-40VDC
  • Supply Voltage (Controller): 12VDC
  • PWM Frequency: 25KHz
  • Motor Control: Forward-Stop-Reverse
  • Motor Speed: [0 to 100%] Forward, [0 to 100%] Reverse


Download the Gerber or order 10Pcs high-quality boards here

To order a fully assembled PCB board (FREE shipping). Please contact: anson@pcbway.com



A. Circuit Analysis  

Figure 1 shows the schematic diagram of the standalone full bridge DC motor driver device. The circuit consists of three main parts: The h-Bridge driver, the microcontroller, and the supply regulator. 

Figure 1

The schematic diagram of the standalone full bridge DC motor driver (Altium)


A-1. Microcontroller

IC1 is the ATTiny13 microcontroller [1] that controls the H-Bridge part. C1 and C2 are decoupling capacitors that are used to reduce the supply noises. R1 is the pull-up resistor for the RESET Pin. ISP provides the in-circuit programming interface for IC1 and P1 and P2 are 3-Pins XH connectors for the potentiometers. These potentiometers are connected to the ADC pins of the microcontroller to adjust the Forward/Reverse rotation speed of the motor. P3 and P4 are also 3-Pins XH connectors to connect a 3-State, 6-Pins SPDT switch and control the Forward-Stop-Reverse state of the DC motor. Figure 2 shows my used switch. Its part number is KCD4-604-6P. You are free to use any similar switch you like but I loved this switch because of its cute handle :-)

Figure 2

My selected 3-State, 6-Pins SPDT switch, KCD4-604-6P (Forward-Stop-Back)


A-2. Supply Regulator

REG1 is the main component of the supply regulator and that is the 78L05 (SOT-89) [2] regulator chip. P5 is a 2-Pins XH connector for the 12V input. R4 and C6 build a low-pass RC filter to reduce the supply noises as much as possible. D1 is an SMD blue LED to indicate a proper supply connection and R5 limits the current to the LED. C7 and C8 are used to reduce the output noise.


A-3. H-Bridge (Full-Bridge) Driver

Q1...Q4 are powerful D2Pack IRF3205 Mosfets [3] that build the H-Bridge circuit. D4…D7 diodes provide an extra layer of protection against the motor’s reverse inductive current, it’s not mandatory, but it’s better to be implemented. R6, R7, R8, and R10 are Gate pins’ current-limiting resistors. IC2 and IC3 are IR2104 [4] half-bridge driver ICs. C12 and C13 are decoupling capacitors and R9 and R11 are pull-down resistors to prevent any unwanted triggering for the IN pins of the chips. C9 is used to reduce the motor supply noises, especially at cranking (start time).


B. PCB Layout

Figure 3 shows the PCB layout of the device. It’s a two layers PCB board and except for the connectors, all components are SMD. This makes it compact and easier to embed in a variety of enclosures. Figure 4 shows the assembly drawings of the board.

Figure 3

PCB layout of the Standalone Full Bridge DC Motor Driver (Altium)

Figure 4

Assembly drawings of the PCB board


C. Code

To write the code, I used Arduino IDE and the MicroCore Arduino hardware package [5]. You should install this package to be able to compile the code for ATTiny13. For your leisure, I also provided the compiled HEX file [6]. You just need an AVR ISP programmer (such as USBasp or similar) to burn the HEX file into the ATTiny13 chip. The fuse bits must be set on the 9.6MHz internal clock, with no clock division (division = 1). Figure 5 shows the ISP programming pins.

#include <util/delay.h>


// Clock at 9.6MHz
#define F_CPU 9600000


const int PWMPin = 1;
analog_pin_t FVOLPin = A3;
analog_pin_t RVOLPin = A2;
analog_pin_t SwitchPin = A1;
int rawPotF = 0, out = 0, rawPotR = 0;
unsigned char Fcounter = 0, Rcounter = 0;


void setup()
{
  pinMode(PWMPin, OUTPUT);


  // Phase Correct PWM Mode, no Prescaler
  // PWM on Pin 1(PB1), Pin 0(PB0) disabled
  // 9.6MHz / 192 / 2 = 25Khz
  TCCR0A = _BV(COM0B1) | _BV(WGM00);
  TCCR0B = _BV(WGM02) | _BV(CS00);
  // Set TOP and initialize duty cycle to zero(0)
  OCR0A = 192// TOP - DO NOT CHANGE, SETS PWM PULSE RATE
  OCR0B = 192;    // duty cycle for Pin 1(PB1)
}


void loop()
{


  switch (analogRead(SwitchPin))
  {
    case 0 ... 50:
    forward();
      break;
    case 400 ... 620:
      OCR0B = 0;
      break;
    case 980 ... 1024:
    reverse();
      break;
  }
}


void forward()
{
  _delay_ms(10);
  rawPotF = analogRead(FVOLPin) + rawPotF;
  Fcounter ++;
  Rcounter = 0;
  rawPotR = 0;
  if (Fcounter == 20) {
    rawPotF = rawPotF / 20;
    out = map(rawPotF, 0, 1023, 0, 192);
    OCR0B = out;
    Fcounter = 0;
    rawPotF = 0;
  }
}


void reverse()
{
  _delay_ms(10);
  rawPotR = analogRead(RVOLPin) + rawPotR;
  Rcounter ++;
  Fcounter = 0;
  rawPotF = 0;
  if (Rcounter == 20) {
    rawPotR = rawPotR / 20;
    out = map(rawPotR, 0, 1023, 0, 192);
    OCR0B = out;
    Rcounter = 0;
    rawPotR = 0;
  }
}

Figure 5

AVR ISP programming pinout


D. Assembly and Test

Figure 6 shows the assembled PCB board. If you don’t have enough time or experience soldering the SMD components, you can just order an assembled board. For P1 and P2, just use high-quality 5K potentiometers or even multiturn types for more stability and accurate speed adjustment. Figure 7 shows the wiring diagram and required board connections.

Figure 6

Fully assembled PCB board of the standalone full bridge DC motor driver

Figure 7

Wiring diagram and board connections 


E. Bill of Materials

Figure 8 shows the bill of materials for the project. The Octopart website is not just a fast search engine for electronic components, but it also provides a very nice tool to build any kind of BOM for free.

Figure 8

Bill of materials of the Standalone Full Bridge DC Motor Driver


F. References

[1]: ATTiny13 MCU: https://octopart.com/attiny13a-ssur-microchip-77761976?r=sp

[2]: 78L05 SOT89: https://octopart.com/ka78l05aimtf-onsemi-84329328?r=sp

[3]: IRF3205 D2PACK: https://octopart.com/irf3205strlpbf-infineon-65873335?r=sp

[4]: IR2104: https://octopart.com/ir2104spbf-infineon-65872813?r=sp

[5]: MicroCore Arduino Package: https://github.com/MCUdude/MicroCore

[6]: Complied HEX file: https://drive.google.com/file/d/1_FEbxj3XtWoZCNCxfpgcvCwcf9j8cqj-/view?usp=sharing


Join us
Wanna be a dedicated PCBWay writer? We definately look forward to having you with us.
  • Comments(0)
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000
    Back to top