Interfacing Relays Using The Parallel Port: Contents
Interfacing Relays Using The Parallel Port: Contents
a single PC. Our project aims at the same and could be used to control the printer power, loads & other household electrical appliances. The circuit comprises decoder, inverter, latch & relay driver sections. To control these equipments we are using PCs Parallel port. The program of controlling is written in C language. It is compiled using Turbo C compiler. The project though a bit expensive, is very efficient in control of real world peripherals. Contents: 1. INTRODUCTION 2. PARTS LIST 3. BLOCK DIAGRAM 4. COMPONENT DESCRIPTION o Parallel Port o 1C ULN 2803 o Relay o 12V power supply o DB-25 Male Connector o Light Bulb o Zero PCB o Ribbon Wire 5. CIRCUIT DESCRIPTION AND WORKING 6. SOFTWARE PROGRAM 7. CONCLUSION INTRODUCTION: The PC parallel port is an expensive yet a powerful platform for implementing projects dealing with the control of real-world peripherals. This port can be used to control the printer as also household and other electrical appliances. The computer program through the interface circuit controls the relays, which, in
Parallel Port Basics The parallel port has 12 outputs including 8 data lines and 4 control lines. The circuit described here can be used to control up to 255 electrical appliances using only eight data lines from the parallel port. Besides, the software program allows the users to know the current status of the loads. A parallel port is a socket found in personal computers for interfacing with various peripherals such as printers, scanners and even some webcams. On many computers, particularly laptops, the parallel port is omitted for cost savings, and is considered to be a legacy port. However, in laptops, access to the parallel port is still commonly available through docking stations. Here's a picture of a DB-25 parallel printer port on the back of a laptop. When a PC sends data to a printer or other device using a parallel port, it sends 8 bit of data (1 byte) at a time. These 8 bits are transmitted parallel to each other, as opposed to the same eight bits being transmitted serially through a serial port. The pin assignments on a parallel port are as follows:
Pin No. Pin Name Description 1 Strobe Usually remains high but is pulled low whenever the computer sends a byte of data. This drop in voltage tells the printer that data is being sent. The eight data ports. We will be using these in our project Sends the acknowledge signal from the printer to the computer. If the printer is busy, it will set this pin to high. Then, it will pull to let the computer know it is ready to receive more data. The printer lets the computer know if it is out of paper with this pin. Device indicates it is ready by pulling high.
2-9 10
D0 - D7 nAck
11
Busy
12 13
14
Autofeed
The computer sends an auto feed signal to the printer through Pin 14. If the printer has any problems, it drops the voltage to less than 0.5 volts on Pin 15 to let the computer know that there is an error. This pin is pulled low by the computer whenever a a new print job is ready for the printer. Pin 17 is used by the computer to remotely take the printer offline. These are mostly used for competing circuits
15
Error
16 17 18-25
Circuit Diagram 1
Circuit Diagram 2 Circuit Description 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. Note - For 12 V power supply I have used the power supply of my computer system. Power supply of a PC has got 4 terminals, of which 2 are GND and the other 2 are +5V and +12V. I have used one GND and +12V terminal to give power supply to ULN2803 IC. 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. Working of ULN2803 IC IC ULN 2803 Pinout & Working Introduction IC ULN2803 consists of octal high voltage, high current darlington transistor arrays. The eight NPN Darlington connected transistors in this family of arrays are ideally suited for interfacing between low logic level digital circuitry (such as TTL, CMOS or PMOS/NMOS) and the higher current/voltage requirements of lamps, relays, printer hammers or other similar loads for a broad range of computer, industrial, and consumer applications. Features Eight Darlingtons with Common Emitter. Opencollector outputs. Free wheeling clamp diodes for transient suppression. Output Current to 500 mA. Output Voltage to 50 V. Inputs pinned opposite outputs to simplify board layout.
Pinout
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. Working The ULN 2803 IC consists of eight NPN Darlington connected transistors (often called a Darlington pair). Darlington pair consists of two bipolar transistors such that the current amplified by the first is amplified further by the second to get a high current gain or hFE. The figure shown below is one of the eight Darlington pairs of ULN 2803 IC.
Now 2 cases arise:Case 1: When IN is 0 volts. Q1 and Q2 both will not conduct as there is no base current provided to them. Thus, nothing will appear at the output (OUT). Case 2: When IN is 5 volts. Input current will increase and both transistors Q1 and Q2 will begin to conduct. Now, input current of Q2 is combination of input current and emitter current of Q1, so Q2 will conduct more than Q1 resulting in higher current gain which is very much required to meet the higher current requirements of devices like motors, relays etc. Output current flows through Q2 providing a path (sink) to ground for the external circuit that the output is applied to. Thus, when a 5V input is applied to any of the input pins (1 to 8), output voltage at corresponding output pin (11 to 18) drops down to zero providing GND for the external circuit. Thus, the external circuit gets grounded at one end while it is provided +Vcc at its other end. So, the circuit gets completed and starts operating.
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# for developing this software. First you need to download OutPort.dll. This library allows access to ports while using windows, Then copy the dll into windows32 folder. For this you will need two classes PortAccess.cs Form1.cs
PortAccess.Output(address, 0); }
private void button_Address_Click_1(object sender, EventArgs e)//Sets the parallel port address for the program to run { if (this.textBox_port_address.Text == "378") address = 888; else address = 632; } /* The pins 2-9 (Data Pins) can be used as Output or Input, but the mode they are in is common for all the 8 pins. So you cannot use one of the Data pins for Input and other for Output at the same time. You will have to select the mode you want.*/ private void button_on_Click(object sender, EventArgs e) { //sets all ports to output a high PortAccess.Output(888, 255); } private void button_off_Click(object sender, EventArgs e) { //sets all ports to output a low PortAccess.Output(888, 0); } private void button_reset_Click(object sender, EventArgs e) { Reset_ports(); } } } APPEARENCE OF THE FORM
RESET
CONCLUSION:
This project can be effectively and conveniently utilized for the control of different appliances. As this project could be extended to control about 255 devices, this could be used for computerization of an office, home, or a firm. Though it is quiet costlier, the circuit is simple and the working mechanism could be easily understood. An added advantage of this project is that we are able to know the status of the device to be controlled. The program to control the appliances is written in C language which is more user friendly and easy to understand than other programming languages. Disadvantages / Improvements:If at all a new device has to be added to the hardware the software doesnt support this to achieve which the source code has to be changed manually. The status of all the devices that are switched are maintained in a database which may not coincide with actual status of the devices as we are not reading the status directly from the HARDWARE.