In this project, I will show you to how to operate DC motors as one of the basics within home automation and control applications. The DC Motor drive is implemented on the Arduino UNO and a MOSFET based half bridge driver circuit. This project is all about operating a DC motor in the forward motoring mode and regenerative braking mode. 

Project Video

No Video Available

Step by Step Guide

  • Arduino UNO board (Order code SKU: 2075382): The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins, a 16 MHz ceramic resonator. 
  • DC motor drive: The DC motor drive is the MOSFET based half bridge circuit, with isolated gate circuit, as shown in the circuit diagram image
  • 4x1 keyboard: The 4x1 keyboard has 4 digital keys, one end of each key connected to the common pin. 
  • 16x2 LCD display: 16x2 Character dot Matrix LCD Display Module used to display the input parameters. 
  • DC Motor (Order code SKU: 599104):  Miniature circular DC motor, ideal for models and educational applications. The two flat sides enable easy mounting onto a panel or PCB.
  • Connecting wires.
  • Power supply for Arduino and DC Motor drive. 

During the motoring mode, energy flows from the voltage source to the motor through MOSFET (Tr1) which is in series connection with motor armature terminal.  If the motor is driven by the load which is connected to the motor shaft, and that time motor acts as a generator. In this mode, energy flows from the motor to voltage source. During the regenerative braking mode, the MOSFET (Tr2) is switched on the armature current rises due to the short-circuiting of the motor terminals. If the MOSFET (Tr2) is turned off, diode D1 would be turned on and the energy stored in the armature circuit would be transferred to the voltage source.

Making the Circuit

Take all the required hardware components and make the circuit connection as mentioned in the below table

Arduino Pins 4x2 Keyboard 16x2 LCD Display Stepper Motor Drive
0      
1      
2 G1    
3 G2    
4   Register Select  
5   Enable  
6   D4  
7   D5  
8   D6  
9   D7  
10     SELECT
11     START_STOP
12     DECREMENT
13     INCREMENT

 

  • Connect the respective power supplies to Arduino UNO and the DC motor driver board and make them on. 
  • Download and install the Arduino IDE, Create a new project, copy the two quadrant chopper source code provided as below and upload the code to the Arduino UNO board.
  • Now press the START_STOP key(Pin no.11), LCD display shows “Motoring ON”,  to increase the motor speed, increase the Duty cycle using increment key(Pin no13), to decrease the speed use Decrement key(Pin no13).
  • If you want to change the quadrant press SELECT key (Pin no 10).
  • After completion of your work turn off the power supply provided to Arduino and motor drive, remove the connected wires. 
The power circuit is shown in the figure below. 

 

 

/*
 Using this program we can operate a DC motor in two quadrants (motoring and Breaking modes).
 A Key board is connected to pins 10, 11, 12, 13 key board common point should connect to GND.
 16x2 LCD display is connected to Rs=4, En=5,D4=6,D5=7,D6=8,D7=9.

 */

#include 
const int SELECT=10, START_STOP=11,DECREMENT=12,INCREMENT=13,MX_D=90,MI_D=1;
LiquidCrystal lcd(4,5, 6, 7, 8, 9);                                             // 16X2 LCD pins: Rs=4, En=5,D4=6,D5=7,D6=8,D7=9
int  Dcy =1,Key_delay=50,OUT=4, mode=1;                                              
volatile int i = 0,Temp=0;
void setup()
{
  lcd.begin(16, 2);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(DECREMENT, INPUT_PULLUP);
  pinMode(INCREMENT, INPUT_PULLUP);
  pinMode(START_STOP, INPUT_PULLUP);
  pinMode(SELECT, INPUT_PULLUP);
   
  lcd.print("  Welcome to ");
  lcd.setCursor(0, 1);
  lcd.print("  Element14 ");
  delay(5000);
  lcd.setCursor(0, 0);
  lcd.print("MOTORING     OFF ");                  
  lcd.setCursor(0, 1);
  lcd.print("D_cycle: 1 %   ");
  delay(4000);
}

void motorPwm(int x)                                                           //PWM output function
{  
   for(i=0;i<1000;i++)                                              
   {
   digitalWrite(OUT, 1);
   delayMicroseconds(x);
   digitalWrite(OUT,0);
   delayMicroseconds(200-x); 
   } 
}

void soft_start()
{ 
  delay(500);
  for(Temp=0; TempMI_D)
         Dcy--; 
         
      lcd.setCursor(9, 1);
      lcd.print(Dcy);
          if(Dcy<10)
          lcd.print(" ");
     }
  
   if(digitalRead(SELECT)==LOW)
    {      
    
      lcd.setCursor(0, 0); 
       if(mode==1)
         {
          lcd.print("BRAKING ");
          mode=2;
          OUT=2;
          digitalWrite(3, 0);
          for(i=0;i<100;i++)
          motorPwm(Dcy*2);
         }
        else
        {
          lcd.print("MOTORING");
          mode=1;
          OUT=3;
          digitalWrite(2, 0);
          soft_start();
        }
    }
   
  }
  lcd.setCursor(0xd, 0);
  lcd.print("OFF");
  delay(500);
}

Downloads

No Downloads Available