Circuit's Projects :
Return to ProjectsPIC Controlled Relay Driver
Project Summary
This circuit is a relay driver that is based on a PIC16F84A microcontroller. The board includes four relays so this lets us to control four distinct electrical devices. The controlled device may be a heater, a lamp, a computer or a motor. To use this board in the industrial area, the supply part is designed more attentively. To minimise the effects of the ac line noises, a 1:1 line filter transformer is used.
Project Description
The components are listed below.
1 x PIC16F84A Microcontroller
1 × 220V/12V 3.6VA (or 3.2VA) PCB Type Transformer (EI 38/13.6)
1 x Line Filter (2×10mH 1:1 Transformer)
4 × 12V Relay (SPDT Type)
4 x BC141 NPN Transistor
5 × 2 Terminal PCB Terminal Block
4 × 1N4007 Diode
1 × 250V Varistor (20mm Diameter)
1 x PCB Fuse Holder
1 × 400mA Fuse
2 × 100nF/630V Unpolarized Capacitor
1 × 220uF/25V Electrolytic Capacitor
1 × 47uF/16V Electrolytic Capacitor
1 × 10uF/16V Electrolytic Capacitor
2 × 330nF/63V Unpolarized Capacitor
1 × 100nF/63V Unpolarized Capacitor
1 × 4MHz Crystal Oscillator
2 × 22pF Capacitor
1 × 18 Pin 2 Way IC Socket
4 × 820 Ohm 1/4W Resistor
1 × 1K 1/4W Resistor
1 × 4.7K 1/4W Resistor
1 × 7805 Voltage Regulator (TO220)
1 × 7812 Voltage Regulator (TO220)
1 × 1A Bridge Diode
The transformer is a 220V to 12V, 50Hz and 3.6VA PCB type transformer. The model seen in the photo is HRDiemen E3814056. Since it is encapsulated, the transformer is isolated from the external effects.
{mosgoogle}A 250V 400mA glass fuse is used to protect the circuit from damage due to excessive current.
A high power device which is connected to the same line may form unwanted high amplitude signals while turning on and off. To bypass this signal effects, a variable resistor (varistor) which has a 20mm diameter is paralelly connected to the input.
Another protective component on the AC line is the line filter. It minimises the noise of the line too. The connection type determines the common or differential mode filtering.
The last components in the filtering part are the unpolarized 100nF 630V capacitors. When the frequency increases, the capacitive reactance (Xc) of the capacitor decreases so it has a important role in reducing the high frequency noise effects. To increase the performance, one is connected to the input and the other one is connected to the output of the filtering part.
After the filtering part, a 1A bridge diode is connected to make a full wave rectification. A 2200 uF capacitor then stabilizes the rectified signal.
The PIC controller schematic is given in the project file. It contains PIC16F84A microcontroller, NPN transistors, and SPDT type relays. When a relay is energised, it draws about 40mA.
As it is seen on the schematic, the relays are connected to the RB0-RB3 pins of the PIC via BC141 transistors. When the transistor gets cut off, a reverse EMF may occur and the transistor may be defected. To overcome this unwanted situation, 1N4007 diodes are connected between the supply and the transistor collectors.
There are a few number of resistors in the circuit. They are all radially mounted.
Example C and HEX code files are included in the project file. It energises the next relay after every five seconds.
Y. Erol
Project Files
| File Name | File Size |
|---|---|
| Schematic, Layout and PCB files | 399.01 KB |



4 years ago: It was a bit hard for me to find the same transformer but now everything works ok. thanks
4 years ago: can a 110 to 12 volt transformer work on this? Does anybody know?
4 years ago: Hi Rob, Of course you can use 110/12V transformer if you apply 110V AC to the power input.
4 years ago: Thanks I just wanted to make sure. I am looking at this to control pneumatic cylinders. I hope this works.
4 years ago: Hey can this be made to run seven or eight outputs? If so what would it take? Or is there another design that will that I am missing? I am looking at this to control pneumatic cylinders. Any help is appreciated.
4 years ago: Oh and 110 not 220
4 years ago: I'm also wonderign if it can support more circuitry. Let's say double of what has been designed to support...
3 years ago: I was wondering the same thing but no-one answers. Maybe I wasn't clear with what I asked. I would like to see a design for eight output circuits.
3 years ago: I think it's possible! You can use all 12 pins on PIC, but if you need buttons to control all of them individually then 6 buttons 6 relays. I managed to create code in asyambler and use pic16f84a with max232, now I'm able control all of my relays ( right now LED's) through computer, using only 2 pins on pic as buttons! I can control up to 10 relays.
3 years ago: that was a nicely organized PCB with components!
3 years ago: I would like to ask if any interference/distortion caused on the controller by the relays switching on/off fast... thank you
3 years ago: I think it's not very smart to switch a relay on/off very fast, because a relay is still a mechanic device! There was an alternative, but I forgot that components name. :D
3 years ago: nice project...
may be the component you are trying to say is OPTOCOUPLER, isn't it Xcoder..
2 years ago: could someone tell me what is the function of this circuit.
what kind of application or situation that make people/industry use this circuit.
help me please.
may god bless you
2 years ago: hw can I connect it to my copmuter via rs 232 and control the relays from my computer ?
2 years ago: Hi every one. I am sagar, B.Tech 2nd year. Can someone help me to write program in ATMEGA128 micro controller for working of relay driver? We are doing project on intelligent irrigation system
2 years ago: how can i connect and operate relays to ATMEGA128 micro controller ?
1 year ago: You need to be careful with this because the motherboards they are now producing don’t include a serial port or parallel ports
We are now at USB 3 which means that you will have to start looking at USB programmers
PS I also think this is wrong as RS232 / RS434 is still commonly used throughout the industry It also means extra driver files and 32 bit / 64 bit drivers The havoc and the money that this is costing the industry is phenomenal
If you consider just how many cutters routing, printing, embedded programmers there are out there never mind simple networks , modems , temperature sensors which rely on RS232 as a communications medium,” With very tight budgets " Some of these advance embedded device programmers cost some £400 plus That’s a lot of money to throw away all because a PC company cant simply adopt or keep a life long standard such as RS232 / RS 434 which are still IEEE standards Internationally accepted standards
Makes you wonder how they ever got the Motherboards accepted since rs232 / 434 is a recognized IEEE standard you might say that as a whole the completed motherboard perhaps doesn’t comply
Could this mean cases for the monopolies commission and if so how many MNFR:S will be considering court action for loss of business who knows ??
Picture if you will a manufacturing company that utilizes rs232 / rs434 with PC acquisition possibly driving machinery or for updating embedded software to do injection molding or advertising sign companies relying on cutters to create the window display
All of a sudden along comes windows 64 bit, USB3 , No parallel ports , all modems have to be changed All wiring needs to be redone and your company is forced to fold due to having to update machinery
Meaning of course terminate employment
This is what I mean by just no thought what so ever for any other trade and Industry that utilizes RS434 / RS232 to embrace their roles within universal business but there you go How ever you could consider http://www.ftdichip.com which is the USB to serial conversion chip however but for big industrial concerns this wont be the answer
I’m not so sure every peace of software that has been purchased over the last five years has incorporated USB adaptation I know for a fact mine at present doesn’t
Not very helpful if you need to communicate and blow your chips with a serial port or produce embedded solutions
Mark http://www.harrington.force9.co.uk
1 year ago: I would also consider TCP IP Ethernet solutions as opposed to Rs232 / rs434 making of course all software invalid as well Along comes embedded TCPIP stack inside Pic Micro and not to far off I can then further see that this will transform to Fiber optic control doing away with copper core for the most part
Be warned don’t rush into anything or rush out and buy tons of Ethernet cable Routers or Modules such as this because very simply put There wont be any motherboards available to adapt for this knowing exactly how fast they move and simply just don’t let you know in advance Also do not forget Wifi and the dreaded smart phone as lovely as this is Most control will now be handed over to modern day smart phones complete with scanners Sensors and built in OS meaning all embedded control will move to Smart phone era or may be even IPAD2 not that I like this very much either
Also bare in mind that this can now be nearly all controlled via a website even through to embedded machinary changing the classes on the fly and Remote method invocation
The IP controlled toaster and kettle , oven are now fully on the way if not with you already
Heavy investment , very long hours and lots and lots of research
Best of luck
Mark http://www.harrington.force9.co.uk
1 year ago: Now have a LOOK AT THIS LINK
HOW EASY
http://tinymicros.com/mediawiki/images/5/54/USB_Relay_Schematic.pdf
1 year ago: Hi.. Myself Kuldeep.S.Tank.
i am in Third year of electronics and Telecom engineering.
i have to do my mini project this year.
iam interested in your Mobile detector Project.
I Want to Purchase your this Project so please Guide me acccordingly.
My email ID: .(JavaScript must be enabled to view this email address)
I am Awaiting for your reply........
1 year ago: I think your in the wrong area my friend I think you are looking at another link which was in the forum last week re mobile phone detection
1 year ago: give ma circuit diagram
12 months ago: Do use a special formula to use EMI trans filters ? Any help is appreciated.
9 months ago: Hi. I'm working on my thesis right now which needs a PIC relay driver circuit just like yours. I would like to integrate your project to my thesis (with due credit given of course) but in my study I have to switch 220VAC loads with the relays so is it possible to use 220V relays with this circuit?