Introduction
In this article I will first tell you about how to build the Relay interface circuit for the Parallel Port and then how to control the circuit using software. With this very basic prototype you will be able to learn a lot how the parallel port works, how a relay works and the use of ULN2803 IC. So, I'll start with the circuit first.
Circuit Diagram
Circuit DescriptionComponents Used:-
- One 12V Relay
- IC ULN2803
- 12V power supply
- DB-25 Male Connector
- Light Bulb
- Zero PCB
- Ribbon Wire
- Connect the data pins(2 to 9) of the parallel port to pins 1 to 8 of ULN2803 IC.
- Connect GND pin 25 of the parallel port to pin 9 of ULN2803 IC.
- Connect one side of Relay coil to pin 10 and other side to pin 18 of ULN2803 IC.
- Connect a bulb between common terminal of relay and neutral AC wire.
- Connect the live AC wire to normally open terminal of relay.
- Connect +ve terminal of power supply to pin 10 and -ve terminal to pin 9.
- Your circuit is now complete.
How the circuit works?
The circuit consists of two main parts - ULN2803 IC and a 5 pin Relay. Working of both of them is explained below:-
Working of Relay
A relay is an electrically operated switch. It allows one circuit to switch a second circuit which is completely separated from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.
In the above figure, when controlling switch is closed, current flows through the coil and thus, magnetic field is produced. The resulting magnetic field attracts an armature that is mechanically linked to a set of contacts. The movement makes a connection with a fixed contact and circuit gets completed. When the current to the coil is switched off, the armature is returned by a force approximately half as strong as the magnetic force to its relaxed position and the connection is broken.
The relay's switch connections are usually labeled COM, N/C and N/O:
- COM = Common, always connect to this, it is the moving part of the switch.
- N/C = Normally Closed, COM is connected to this when the relay coil is off.
- N/O = Normally Open, COM is connected to this when the relay coil is on.
- Connect to COM and N/O if you want the switched circuit to be on when the relay coil is on.
- Connect to COM and N/C if you want the switched circuit to be on when the relay coil is off.
For working of ULN2803 click here.
Circuit Working
Working of this circuit is very simple. When data at pin 2 is '1', i.e., when 5V is coming out of pin 2 then, pin 1 of ULN2803 IC receives 5V input and thus its pin 18 provides GND to one end of relay coil. The other end of relay coil is given +Vcc (12V), so the coil gets energized and the COM gets connected to the N/O contact and the AC mains circuit gets completed and the bulb glows.
Now, bulb will glow as long as data at pin 2 is high. When data at pin 2 becomes low, then the GND provided by pin 18 of ULN2803 IC vanishes and coil gets de-energized and thus COM is connected back to N/C contact. Thus, external AC mains circuit is broken and bulb stops glowing.
Software
To control any port we need a kernel mode driver software. Softwares generally run in USER mode. But to control the Parallel Port we need a software running in kernel mode. I have used C#.Net for developing this software.
- Download and install Microsoft .NET Framework Version 2.0.
- Now download and install My Parallel Port Control Setup.
- Download C#.net source code.
38 comments:
Thanks for sharing,
Can i use it without ULN IC?
Thanks
You can use it without ULN but you will need a few transistors to replace ULN. Also the circuit will become more complex. So, its better to use ULN instead.
Hi,, me doing electronic engineering,me in 4th Semester,, me want to do this Project,, If i Cant Get ULN 2803,, Could i Use another one
ULN 2003 can also be used instead of ULN 2803. The only difference b/w the two is that ULN2003 has got 7 input/output pins and ULN2803 has 8 input/output pins.
Which relay i need to use, there is many ? Like 12V 6A, 12V 1A...
Which ?
sir mainay is web say circuit diagram tally kar kay circuit banaya http://www.electronic-circuits-diagrams.com/computersimages/computersckt1.shtml but yeh work nahi kar raha jub may apnay ghar kay pass electronic shop per gia to usnay kaha yeh circuit diagram kharab hai app com ko load per lagai or n/o ko ac voltage day then it will work ...so sir can you pls help me out abh to ciruit chal hi nahi raha mujhay lagata hai IC ur gai hai kue kay mainay ziada voltage bhi diya that 12v...pls sir help me.
@Saqib
Circuit diagram is OK.
Either ur ckt connections are wrong or ur IC is not working.
Also, ur ckt will work only if ur ckt's GROUND is connected to the parallel port's GROUND.
hi how to make a 8 leds conected with parallel port to make them on off in odd and even numbers by using terbo c
Turbo C programs for parallel port will not work on 2000, XP, vista and windows 7. We need DOS or windows 98 to run C program for parallel port.
Hi,
I am building a project for my sister. I am trying to interface eight 6V bulbs(In a house model) and control it with parallel port. All I need is to replace the relays with my 6V bulb. Right???
Your explaination and video was very helpful but I got to visit this site http://www.zen22142.zen.co.uk/Circuits/Interface/pc_int.htm
Here the diagram shows pin 10 isnt connected to neither VCC or Gnd...
Could you explain.
Siddharth
vish.sid73@gmail.com
@Siddharth
Replace the relays with 6V bulbs. It would work fine.
For ULN2803 either we can connect +ve supply to pin 10 or we can provide output supply via a diode directly to its output pins.
But its better to connect it to pin 10 as we would not need any external diode in this case.
Hi, Thanks for your prompt reply.
I will be using ULN2803 for the project. But I yesterday I made this schematic using NPN transistors only.
http://demo.festinindia.com/schemesvg.png
Would you mind checking it. I built this schematic taking refrence from this http://demo.festinindia.com/ref.png
I have replaced the IN4148 btwn parllel port grnd and data line with a zener.
What are your suggestions..
NOte: In my schematic please see the placing of zener diode is correct. I think It should not be between transistor and data line but it should be btwn ground of parallel port and data line.
I will be uploading my new schematic using ULN2803 before implementing.
@Siddharth
Instead of using such complex circuit use ULN2803. Circuit will take less space and also can be made in less time. Also no external diodes are required for ULN2803.
Hi,
Sure. I totally agree with you. I was just asking to make sure my circuit was fine.
Here, my new ULN2803 schematic. Please confirm me so that i can move ahead with the implementation part. http://demo.festinindia.com/project.svg
I added a zener to your design. I took refernce from http://demo.festinindia.com/ref1.PNG
Do I need any more addition or substration. Or this design is good to move forward. i hope it dont short my PC.:-)
@Siddharth
Add a 220 ohm resistor (or above) between each of the output pin of the ULN2803 and the LED. Rest of the circuit in my opnion is OK.
Hello,
Great tutorial..This tutorial only use one relay..if i want to control a lot of appliances..how should i do that?
thanks
@jaspreet
Thanks for your review.
I am using 6V bulbs..Do I still need to add 220 ohm resistor btwn output pins and Bulb.
@Anonymous
We can connect 8 relays to ULN2803.
Connect coil of each relay between PIN 10 and PINs 11 to 18 of ULN2803.
@Siddharth
For 6V Bulb we can omit the resistor but for LED we need it.
Thanks for sharing such a nice tutorial.
What will happen if "Pin 10" is not connected to +V in case of driving an unipolar stepper motor ?
Please reply.
Thanks.
@mahesh
We can remove +V from Pin 10 of ULN2803. The circuit will work fine.
But this may damage the ULN2803 if high reverse voltages are introduced at its output pins.
Thanks a lot Jaspreet.
Keep it up.
Sir Jaspreet i need circuit diagram for controlling home lights and fan from remote control. This circuit has also ability to control tuning speed of fan from fast to slow or slow to fast. please help me out.
bro ur work is really awesome can u tell the specs of inductor to be used
sir pls provide me circuit that control electrical appliances from GSM based mobile sms.
im edmer what relay do you use? and what transistor can i use for may relay 12v 220vac
@edmer
I'm using a 12V relay with IC ULN2803.
Instead of ULN2803 we can use NPN Transistor: BC547A or 2N2222A.
Hi, im doing a project regarding this, is it ok if there are multiple high inputs to the ic?? for ex. is it ok if i keep input pin 1,3, and 5 of the ic on? will it result into any damage
Hey Jaspreet, thanks a lot man. This is just amazing.
I just wanted to ask:
1. Any other IC's I can use apart from the one you did?
2. Can I use the same code in Windows 7? Or can I use C?
Thanks a lot man.
Sorry I should have included this above.
Earlier you said that, NPN Transistors: BC547A or 2N2222A can also be used.
How does that work?
One Transistor for every Relay?
A little more detail please?
My gmail id:
aradhyaalamuru@gmail.com
Thanks a lot man.
@Ardy
Q. Any other IC apart from ULN2803 that can be used?
A. ULN2003 can be used. The ULN2803 & ULN2003 are identical except ULN2003 has 7 channels and ULN2803 has 8 channels.
Q. Can I use the same code in Windows 7?
A. Yes, we can use the above code in Windows 7.
Q. BC547A or 2N2222A can also be used. How does that work?
A. We need to connect one Parallel Port output pin to the transistor and further connect the transistor to the Relay. So for 8 data pins of Parallel Port we need 8 transistors & 8 relays.
Sweet. Thanks man. That was a very swift reply. Appreciate it a lot.
Can I get your email id? I have a couple of other related questions.
Thanks man.
Hi Jaspreet, im doing a project regarding this, is it ok if there are multiple high inputs to the ic?? for ex. is it ok if i keep input pin 1,3, and 5 of the ic on? will it result into any damage??
Pls reply need ur help
@Ardy
Please ask your questions here via comments only, so that everybody else can see and have their doubts cleared.
@Aditya Medhe
ULN2803 IC provides 8 simultaneous channels. We can keep any number of inputs to the IC High or Low, at any time. It would not result in any damage.
Okay, which IC can I use to convert BCD from the parallel port of the computer to control relays in a mux?
Thanks.
Thanks a lot! I created my circuit today and am happy to see it running!
@Ardy
Use IC 74LS154 & IC 74LS05.
Post a Comment