Driving Motors with Arduino and TC4428 using MOSFET H-Bridge

The TC4428 is a dual MOSFET driver that provides independent, high-speed, non-inverting gate drive outputs. It is useful for driving MOSFET-based H-bridges as it ensures fast switching and reduces losses. The TC4428 accepts TTL and CMOS logic-level inputs, making it compatible with Arduino and other microcontrollers.

In this guide, we will explore how to interface an Arduino with the TC4428 and use it to control a MOSFET H-bridge built with IRF540N (N-channel MOSFETs) and IRF9540 (P-channel MOSFETs) to drive a DC motor.

Circuit Diagram

TC4428 with Arduino and MOSFET drivers

Understanding the MOSFET H-Bridge Configuration

The H-bridge circuit is constructed using:

  • Two P-channel MOSFETs (Q1 and Q2) - IRF9540

  • Two N-channel MOSFETs (Q3 and Q4) - IRF540N

  • TC4428 MOSFET driver

  • 10kΩ pull-up and pull-down resistors for keeping transistor gates in known states

  • 1N4001 diodes across each transistor for protection against back EMF

The gate connections are as follows:

  • Gates of Q1 (P-MOS) and Q3 (N-MOS) are tied together and controlled by one output of TC4428.

  • Gates of Q2 (P-MOS) and Q4 (N-MOS) are tied together and controlled by the other output of TC4428.

The TC4428 takes two input signals from Arduino (Pin 8 and Pin 9) and converts them into proper gate drive signals for the MOSFETs, ensuring efficient motor control.

For a detailed explanation of how MOSFET H-bridges operate, visit:
H-Bridge with P-Channel and N-Channel MOSFETs

If you prefer using BJT transistors for an H-bridge, check:
Driving DC Motor with BJT-based H-Bridge

For automatic motor cutoff, a current sensor can be used:
Current Sensing in H-Bridge - Quick Guide

Arduino Code to Control the Motor

The following Arduino code demonstrates how to control the motor using the TC4428 and MOSFET H-bridge:

// Driving Motors with Arduino and TC4428 using MOSFET H-Bridge
// https://www.ee-diary.com/2025/03/driving-motors-with-arduino-and-tc4428.html
// Constants for motor direction
#define FORWARD 1
#define REVERSE 2
#define STOP 0

// Define the pins
const int IN1 = 8;  // Input 1 for TC4428 (PWM-capable pin)
const int IN2 = 9; // Input 2 for TC4428 (PWM-capable pin)

void setup() {
  // Set the pins as outputs
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  // Initialize the serial monitor for debugging
  Serial.begin(9600);
}

void loop() {
  // Drive the motor forward at half speed
  Serial.println("Driving Forward");
  driveMotor(FORWARD, 128);  // 128 is half of 255 (50% duty cycle)
  delay(2000);               // Run for 2 seconds

  // Stop the motor
  Serial.println("Stopping Motor");
  driveMotor(STOP, 0);
  delay(1000);               // Stop for 1 second

  // Drive the motor in reverse at full speed
  Serial.println("Driving Reverse");
  driveMotor(REVERSE, 255);  // 255 is full speed (100% duty cycle)
  delay(2000);               // Run for 2 seconds

  // Stop the motor
  Serial.println("Stopping Motor");
  driveMotor(STOP, 0);
  delay(1000);               // Stop for 1 second
}

// Function to control the motor
void driveMotor(int direction, int speed) {
  switch (direction) {
    case FORWARD:
      analogWrite(IN1, speed); // Set IN1 to PWM speed
      digitalWrite(IN2, LOW);  // Set IN2 LOW
      break;

    case REVERSE:
      digitalWrite(IN1, LOW);  // Set IN1 LOW
      analogWrite(IN2, speed); // Set IN2 to PWM speed
      break;

    case STOP:
      digitalWrite(IN1, HIGH);  // Set IN1 LOW
      digitalWrite(IN2, LOW);  // Set IN2 LOW
      break;
  }
}

Explanation of the Code

  1. Pin Definitions:

    • IN1 (Pin 8) and IN2 (Pin 9) control the TC4428 inputs.

  2. Setup Function:

    • Initializes the pins as outputs and starts the serial monitor.

  3. Loop Function:

    • Runs the motor forward at 50% speed for 2 seconds.

    • Stops the motor for 1 second.

    • Runs the motor in reverse at full speed for 2 seconds.

    • Stops the motor again.

  4. driveMotor() Function:

    • Controls the motor direction and speed using analogWrite() for PWM control.

    • FORWARD: IN1 is given a PWM signal, IN2 is set LOW.

    • REVERSE: IN1 is set LOW, IN2 gets a PWM signal.

    • STOP: IN1 and IN2 are set LOW to stop the motor.

Video Demonstration

 The following video demonstrates how TC4428 with Arduino and MOSFET based H-bridge works.
 

Additional Resources

End Note

Using the TC4428 MOSFET driver with an IRF540N & IRF9540 H-Bridge, we can efficiently drive motors with Arduino while ensuring fast switching and protection against back EMF. This method provides precise speed and direction control using PWM signals.

For more details on H-Bridge configurations, current sensing, and alternative designs, check the provided links.

Post a Comment

Previous Post Next Post