August 27, 2007

PC Parallel Port Interfacing Technique – Part 2

Introduction

In this tutorial we will flash a LED (Light Emitting Diode) connected to your printer port socket. Reading the first part is recommended to get a general idea of what you are up to.

Connections
To connect a LED to your port first you have to know what it looks like. Shown below is the most common type of connector you can find on a PC.

LPT Pin Out [courtesy:
http://www.wkretak.pl/readarticle.php?article_id=5]



The Light Emitting Diode (LED)
Shown below is a very common Light Emitting Diode (LED) found anywhere from toys to computers.

Green LED and Red LED
Side View LED

In the above image the longer pin is positive and the shorter one is negative (ground). Our topic does not go into the details of how LED's works. For wiki info on LED, see here, http://en.wikipedia.org/wiki/Light-emitting_diode

If you have a LED looking like the one on the left (Green LED) then another way to know the polarity is to look at the side of the case. If flat, its negative. See the image below.

Top View LED

Schematic Representation of LED

It is recommended, that instead of connecting the LED and resistor directly to the port on your PC, use a long wire for easy reach. Connect the positive side of the LED into the 2nd data port as shown below. You should attach the LED with a 330 Ω resistor to limit the current. I have connected it without the resistor, which works, but is not recommended.

How to connect the LED to the parallel port.

After you finish this setup, it is now time to test the light! See if you have really found out the correct address by following the first tutorial then download this ( http://www.beyondlogic.org/pardebug/spp20.zip) to have real-time control over your Port to test the light.

Screenshot of SPP 2.0 from Beyond Logic .org

Open the executable; you should see a blue screen with port addresses, pins and their description. Choose the address where you have connected the port wire. Click on PIN 2 (Data 0) (there should be a cross on it now). Look at the LED, it must glow. If it does not glow, try a different Port address, LPT1, LPT2 etc. If it still does not glow, check your connection, something must be loose.

Programming the Parallel Port in C, C++, VB or Java with Windows XP or above, is not easy since it does not allow you to access the Ports directly. After Windows 98 all hardware control was virtualized.

Dont hesitate, ask me if you have trouble with anything.

Some Useful links:

http://www.epanorama.net/circuits/parallel_output.html : A very detailed look into the Port basics and programming.

http://www.logix4u.net/ : Excellent for explanation on Win NT/XP programming.

http://www.beyondlogic.org/pardebug/spp20.zip: Program to control parallel port pins individually.

http://www.beyondlogic.org/pardebug/pdebug.htm : The Debug program to test your parallel port with LED

No comments: