Parallel Port Interface with relay

29,082

Circuit Image

Below are three examples of controlling a relay from the PC's parallel printer port (LPT1 or LPT2). Figure A shows a solid state relay controlled by one of the parallel port data lines (D0-D7) using a 300 ohm resistor and 5 volt power source. The solid state relay will energize when a "0" is written to the data line. Figure B and C show mechanical relays controlled by two transistors. The relay in figure B is energized when a "1" is written to the data line and the relay in figure C is energized by writing a "0" to the line. In each of the three circuits, a common connection is made from the negative side of the power supply to one of the port ground pins (18-25).

There are three possible base addresses for the parallel port. You may need to try all three base addresses to determine the correct address for the port you are using but LPT1 is usually at Hex 0378. The QBasic "OUT" command can be used to send data to the port. OUT, &H0378,0 sets D0-D7 low and OUT, &H378,255 sets D0-D7 high. The parallel port also provides four control lines (C0,C1,C2,C3) that can be set high or low by writing data to the base address+2 so if the base address is Hex 0378 then the address of the control latch would be Hex 037A. Note that three of the control bits are inverted so writing a "0" to the control latch will set C0,C1,C3 high and C2 low.

To implement the described relay control circuit, the following components are required: a parallel port interface, a solid-state relay (SSR) or mechanical relays, transistors (for mechanical relays), resistors (300 ohm for SSR), and a power supply (5 volts).

In Figure A, the solid-state relay is connected to one of the data lines (D0-D7) of the parallel port. The 300-ohm resistor serves to limit the current flowing into the input of the SSR, protecting the parallel port from excessive current draw. When a logic "0" is sent to the data line, the SSR is activated, allowing current to flow through the load connected to its output.

Figures B and C illustrate the use of mechanical relays. In Figure B, a transistor is used to control the relay. When a logic "1" is sent to the data line, it turns on the transistor, which in turn energizes the relay coil, closing the relay contacts. Conversely, in Figure C, the transistor is activated by sending a logic "0" to the data line, thus energizing the relay in this configuration. This dual setup allows for flexible control of different load types depending on the logic state sent from the parallel port.

The common ground connection from the power supply to the parallel port's ground pins (18-25) is essential for ensuring that all components operate within the same reference voltage level, preventing potential floating ground issues that could lead to erratic behavior or damage to the components.

The parallel port's base address is critical for correct operation, with Hex 0378 being the most common for LPT1. The use of the QBasic "OUT" command allows for straightforward manipulation of the data lines and control lines. The control lines (C0-C3) can also be utilized to manage additional functions or to provide feedback from the relays, with the inverted logic of some control bits requiring careful programming to ensure correct operation.

This setup provides a versatile and effective means of controlling relays directly from a PC, suitable for various automation and control applications.Below are three examples of controlling a relay from the PC's parallel printer port (LPT1 or LPT2). Figure A shows a solid state relay controlled by one of the parallel port data lines (D0-D7) using a 300 ohm resistor and 5 volt power source. The solid state relay will energize when a "0" is written to the data line. Figure B and C show mechanical relays controlled by two transistors. The relay in figure B is energized when a "1" is written to the data line and the relay in figure C is energized by writing a "0" to the line.

In each of the three circuits, a common connection is made from the negative side of the power supply to one of the port ground pins (18-25). There are three possible base addresses for the parallel port You may need to try all three base addresses to determine the correct address for the port you are using but LPT1 is usually at Hex 0378. The QBasic "OUT" command can be used to send data to the port. OUT, &H0378,0 sets D0-D7 low and OUT, &H378,255 sets D0-D7 high. The parallel port also provides four control lines (C0,C1,C2,C3) that can be set high or low by writing data to the base address+2 so if the base address is Hex 0378 then the address of the control latch would be Hex 037A.

Note that three of the control bits are inverted so writing a "0" to the control latch will set C0,C1,C3 high and C2 low. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713