The only electronic website that replies to every comment, and addresses all circuit related issues.

High Current Motor Control using Arduino

In this project, we discuss how to control motor speed using Arduino PWM circuit, and how to implement reverse forward or direction control in a DC motor using Arduino through a couple of push button switches. Any high current motor upto 30 amp can be controlled using this set up


By Ankit Negi

Motor is a very essential component in electrical and electronics as they are used as actuators in many areas.

We need motors for small applications like robotics as well as in areas where heavy motors are used (industries etc.).

Now motors which are used for small applications can be controlled easily as they do not take much current(less than 2amp).

And these motors can be easily controlled by using microcontroller like arduino with motor driver ic’s like L298 or L293D.

But motors which are used for heavy purposes (greater than 10amp), cannot be controlled using these ic’s as they can supply limited current ( max 2amp). So how these motors are controlled than?

The answer is simple: using Relays, which acts as switches i.e. switch large current using small current. In this way two things can be achieved:

1. Running our high current motor itself.

2. Isolating the circuit, thus preventing any shocks.

Now any microcontroller can be used to switch these relay. We will be using arduino UNO here.

COMPONENTS REQUIRED FOR THIS PROJECT:

1. ARDUINO UNO: to give input logics to relay’s primary side.

2. SPDT RELAY -2: two relays are required for rotation in both directions. Contacts must be  rated to handle the high current motor specifications




3.Power Mosfet:  You can use IRF1010 mosfet




4. BATTERY (12v) : to supply power to motor.

5. TWO PUSHBUTTONS: to give inputs to arduino (i.e. when pressed and when not pressed)


6. TWO 10K RESISTORS: for debouncing (explained below)




7. CONNECTING WIRES: for making connections.

SCHEMATIC:


High Current Motor Control using Arduino


Make connections as shown in the figure.

1. Connect normally open terminal of both relay to positive terminal of battery and normally closed terminal to battery’s negative terminal.

2. Connect the motor in between the remaining terminal (out of three) of each relay.

3. Connect one terminal of primary side of relays to the output pins of arduino as specified in the code and other terminal to ground.

4. Connect one terminal of both pushbuttons to 5v pin of arduino and other terminal to input pins as specified in the code.

4. **Don’t forget to connect resistors as they are very important for proper functioning of this circuit, as explained below:

WHY RESISTORS ARE CONNECTED?

You may find that there's nothing at all connected to input pins of Arduino, but that does not mean  these pinouts may be a logical zero when the indicated switch is open

Rather it implies that when switch is open arduino can take any random value between logic 0 and logic 1, which is not good at all (this is called bouncing).

So what we want here is that when nothing is connected to the input pin i.e. pushbutton is open, arduino takes 0 input from the pin.

And to achieve this, the pin is directly connected to ground before the pushbutton via resistor. If it is directly connected to ground without resistor there are good chances that it will burn out as pin will be shorted to ground and huge amount of current will flow. To prevent this, a resistor is connected in between.

This resistor is called pulldown resistor as it is pulling logic on pin to 0. And this process is called debouncing.

CODE:

Burn this code into your arduino.

int x;// initialise variables
int y;
int z;
int w;
void setup() {
  pinMode(6,OUTPUT);//initialise pin 6 as output to RL1
  pinMode(9,OUTPUT);//initialise pin 9 as output to RL2
  pinMode(3,INPUT);//initialise pin 3 as input
  pinMode(4,INPUT);//initialise pin 4 as input
  pinMode(10,OUTPUT);//initialise PWM pin 8 as output to gate of mosfet
  pinMode(A0,INPUT);//initialise pin A0 as input from pot.
   Serial.begin(9600);
 
}

void loop() {
  z=analogRead(A0);// read values from potentiometer in terms of voltage
 w= map(z,0,1023,0,255);// map those values from 0 to 255
  analogWrite(10,w);// write the mapped value to 10thpin as output
delay(1);//on time period of mosfet
  analogWrite(10,w);
delay(1);//off time period of ,mosfet
Serial.println(z);//print value from pot to serial monitor
Serial.println(w);//print mapped value to serial monitor

 x= digitalRead(3);
 y= digitalRead(4);
 if(x==0 && y==0){digitalWrite(6,LOW);//hault motor
 digitalWrite(9,LOW);}
 if(x==1 && y==0){digitalWrite(6,HIGH);// clockwise rotation of motor
 digitalWrite(9,LOW);}
 if(x==0 && y==1){digitalWrite(6,LOW);// anticlockwise rotation of motor
 digitalWrite(9,HIGH);}
 if(x==1 && y==1){digitalWrite(6,LOW);//hault motor
 digitalWrite(9,LOW);
 }

}


Working (understanding code):

• DIRECTION CONTROL:

A. When both pushbuttons are not pressed:

In this condition, arduino takes 0 input from both the pins. As specified in the code in this condition both the output pins give 0 logic (LOW) :

if(x==0 && y==0){digitalWrite(6,LOW);

digitalWrite(9,LOW);}

Since input voltage to primary of both the relays is zero secondary terminal of both remains at normally closed position. Thus there is zero volts at both terminals of motor, causing no rotation.

B. When push button X is pressed but Y is not pressed:

In this condition, arduino takes 0 inputs from pin 4 but input1 from pin3. As specified in the code in this condition pin 6 should be at logic 1(HIGH) whereas pin 9 at logic 0(LOW) :

if(x==1 && y==0){digitalWrite(6,HIGH);

digitalWrite(9,LOW);}

Since input voltage to relay#1 is high, the switch of this relay is thrown to normally open condition whereas input voltage to relay 2 is low, the switch of this relay remains in normally closed condition causing 12v and 0v respectively across motor terminals, causing rotation of motor in one direction.

C. When push button Y is pressed but X is not pressed:

In this condition, arduino takes 1 input from pin 4 but input0 from pin3. As specified in the code in this condition pin 6 should be at logic 0(LOW) whereas pin 9 at logic 1(HIGH) :

if(x==1 && y==0){digitalWrite(6,LOW);

digitalWrite(9,HIGH);}

Since input voltage to relay#2 is high this time, the switch of this relay is thrown to normally open condition whereas input voltage to relay#1 is low, the switch of this relay remains in normally closed condition causing 12v and 0v respectively across motor terminals, causing rotation of motor in another direction.

D. When both pushbuttons are pressed:

In this condition, arduino takes 1 input from both the pins. As specified in the code in this condition both the output pins give 0 logic (LOW):

if(x==0 && y==0){digitalWrite(6,LOW);

digitalWrite(9,LOW);}

Since input voltage to primary of both the relays is zero secondary terminal of both remains at normally closed position. Thus there is zero volt at both terminals of motor, causing no rotation.

• SPEED CONTROL:

Let’s say potentiometer is at such position when it gives 0 volts as input to the A0 pin of arduino. Due to this, arduino maps this value as 0 and thus gives 0 as output PWM on pin#10 i.e.,

analogWrite(10,0);// write the mapped value to 10th pin as output

Hence gate of mosfet gets 0 current due to which it remains off and motor is in the switched OFF position.

However, as the pot is rotated and the value of the pot is varied, voltage on pin A0 also varies, and this value is mapped on pin#10 with a proportionately increasing PWM width, causing more current to flow through the motor and the mosfet drain, which in turn allows the motor to gain more speed proportionately, and the same happens vice versa.

Thus from the above discussion we can see how an Arduino can be used for controlling the speed as well as direction (reverse forward) of a high current DC motor simply by adjusting the specified pot and through couple of push buttons.

Motor Speed control Simulation:



video


Update:

For high current motor, please use 12V/30 amp relays and BJT driver stgaes for operating these high power relays as indicated in the following modified diagram:


High Current Motor Control using Arduino




Please Share this Post:
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble



  • 3 comments:

    1. Dear Ankit , could you please suggest a BLDC motor driving circuit based on micro controller for a 12/24 volt 4o inch ceiling fan.

      Regards:
      Krishna Kaushik

      ReplyDelete
    2. you will have to use high power mosfets to derive motor coils on and off in a sequential manner.Each mosfet will be triggered by microcontroller one by one so that rotor can rotate.
      you can use the same code to triggger it:
      digitalWrite(pin,HIGH)
      delay(how fast coil should energized)
      digitalWrite(another pin,High) but make sure when one pin is high all other must be low
      In this way you can drive the motor.
      I hope this helped

      ReplyDelete

    Please Note: If you find any DEAD link starting with http//:homemadecircuitsandschematics.blogspot.com, please replace it with http://www.homemade-circuits.com/ for making it visible and alive again.