Skip to main content

How to design microcontroller interface circuit for Relay and Solenoid Valves

Background Story:

Recently, while helping my friend in building his Automatic Cleaning filter, I designed driver circuit for Solenoid Valves and DC Motor.

You can easily find enormous amount of How-To, tutorials, circuits on google. But they are specific with those applications. Simply they referred other designs and decided to use them in theirs.

Most of them do not discuss about calculation involved for designing driver circuit according to power rating of the solenoids/relay/DC Motor.

Depending upon the power rating of your Relay,Solenoid and DC Motor; selection of driver circuit is done.

This post to address those issues,  
  • How to choose right driving element like Power Transistor, Power MOSFET etc. ?
  • How to calculate sink or source current needed?
  • How to safeguard your microcontroller from notorious back EMF of Relays and Solenoids?
[Note: Principle involved in driving Solenoids and Relays are same, so covering Relays also]   

Solution:

As described above, For Automatic Cleaning Filter, I need to drive Solenoid Valves & DC Motor.
Component
Nos.
Power Rating
Solenoid Valve (8 mBar)
3
+12V / 5Watts.
DC Motor (30 RPM)
1
+12V / 400mA


[NOTE: Remember, When designing such a driver circuit, you need to over-rate it.

Why? – In such loads (Solenoids,DC Motors) starting current A.K.A. "Inrush current" is high for few-millisecs. Your driver circuit should withstand this high inrush current. Otherwise it will fry the circuit.]

Driving Solenoid Valves or relays:

Solenoid/Relay is nothing but electromagnetic switch, available in various sizes and ratings, widely used in many industrial applications.

One can use BJT or MOSFET based driver circuit. I choose BJT for easy-availability and cost of component.

We are using solenoid valves of rating +12V/5W, that is Operating current is around I = 200mA
We can drive the solenoid from MCU GPIO using driver circuit, with proper safety consideration.

I decided to go with TIP122 (NPN) Power Transistors, which is more than enough to drive the Solenoid Valves. Also easily available in your nearest electronics store.
 
Calculations:
When we are driving any load using either BJT/MOSFET we are using it as a switch. 

So For Transistor, we need to calculate the minimum base current required to fully turn ON (“Saturate”) the transistor.

Calculating Base Current and Base Resistor:
Load Current [Solenoid Valve] = ILOAD = 200mA.
And ILOAD = IC.

From the datasheet of the Transistor we will need, β, IC, VBE (MIN).

From the Datasheet of TIP122 we have,
  • β = 1000 (Typ.2500).
  • IC = 5A (Max).
  • VBE (MIN) = 2V to 4V.
We Have Formula for Base Current,



Putting values, 
Base Current = 200mA/1000 = 0.2mA
This is the amount of current sourced from microcontroller GPIO, to turn on the transistor.

·      Base Resistance,
Putting values,
Base resistor = ( 4V - 0.7V) / 0.2mA = 16.5KΩ
(Standard Value = 16KΩ).

Solenoid Valve/Relay Driving Circuit
Safety: Flywheel Diode.
Generic diode 1N4007 is added, to safe guard MCU circuitry from back EMF/ Inductive kick generated by Solenoid Valve.
Indication: We have added LEDs (5mm), to get notified when, Valve turns ON.

Driving DC Motors:

DC Motor which is again an Inductive load. Same principle that we used for solenoid valves applies to the DC Motor.

We do not need to control the speed of a motor, simply turning ON/OFF.

Again, we are going to use BJT based driver circuit. Same TIP122 Power transistor used here to drive DC Motor.

We are using DC Motor of rating +12V/400mA.

Calculating Base Current and Base Resistor:
Load Current [DC Motor] = ILOAD= 400mA.
And ILOADIC.
Using same formula as above, 

Calculating the base current and hence base resistance required to drive transistor.
Base Current = 400mA/1000 = 0.4mA
Base Resistor = (4V - 0.7V) / 0.4mA = 8.2KΩ
(Standard Value = 8.2KΩ).

Few Facts:

  • BJT & MOSFET are widely used devices in driving DC loads.

  • There are two types of BJT - NPN & PNP.
    • In case of PNP, you need to sink the current.
    • In case of NPN, you need to source the current.

  • NPN driver Circuit works like this: 

  • When the microcontroller pin is at Logic 1, current will flow into the base of the transistor, driving the device into saturation: the required current will then flow and turns ON the device. 

  • When the microcontroller pin is at Logic 0, however, no current will flow into the base of the transistor and the load will be turned OFF.  

  • For medium powered loads like Relays, Solenoid Valves BJT is best suited solution.

  • For high-powered loads, one can use MOSFET. I will cover this next time.






Comments

  1. Very nice article. Keep share more article with us.

    Thank you!

    dust collector solenoid valve

    ReplyDelete
  2. Vannuoccongnghiepsaigon.com specializes in providing solenoid valves, gate valves, vanbi, electric butterfly valves ... from world famous brands. More: https://slides.com/vansaigon

    ReplyDelete

Post a Comment

Popular posts from this blog

Best Books For Every Electronics Engineer Out There

I have been asked many times on Quora  that which are the best books or sites to learn the basics of Electronics.   It is said that Electronics is not just an engineering branch, but it's an Art in itself. And There are thousands of books available to master this Art. But question arises, where to find the best one. I have gone through hundreds of reference books while pursuing my masters.And I still use some to develop a product at our HardWare Startup. This experience has provided me to choose the best one. And Am here to share the same List with you. List Comprises books and sites for excelling in Basic electronics, Analog Circuit, Digital Circuit, Electronics Components, Embedded System design. Basic Electronics: The Art of Electronics by Paul Horowitz & Winfield Hill.  Electronic Principles 7th Edition by Albert Paul Malvino. Foundation of Analog & Digital Electronic Circuits by Anant Agarwal. Practical Electronics For Inve...

IFTTT + Twitter + Arduino + ESP8266 = #IOTcoolness

Intro: It’s been really long since my last post. Well, I couldn’t find something worth sharing, or should I say , I wasn’t working on something cool which is worth sharing. Finally, after such a long silence, I have something to share, which seems cool to me. I used Arduino Uno coupled with ESP8266 wifi module to post tweets of sensor values on twitter using IFTTT & Maker Channel. Background story: After reading & watching couple of blog posts & videos about, how hackers from around the world have built really smart and kickass IoT & home automation applications using IFTTT, I couldn’t wait myself to jump start building one. I just can’t stop myself thinking of unlimited possibilities that you can built around it. And thanks to Maker Channel, you need nothing more than an Arduino and Internet Connectivity to build cool IoT IFTTT application. Action Plan: For starters, I decided to build a simple application, which involves Arduino Uno + ESP-01 ...