A Beginner's Guide To Parallel Port Programming with Visual Basic

For robotics enthusiasts or electronic students looking for ways to control signaling inputs to their electronic circuits, the PC's parallel port is a very versatile tool to use. With its 8 data lines, 5 status lines, and 4 control lines, there are a myriad of possibilities to what you could do with it.
I first used the parallel port back when I was a student. I needed a lot of processing power to control the signaling needed for my circuit and the available EEPROM and Microprocessor unit couldn't hack it. Besides getting the required components shipped to my locality was more expensive than actually getting a new pc. So I opted to go the Parallel Port route. It was already available and developing and debugging the program was easier than going the EEPROM Microprocessor way.
Besides, it was only a prototype model and I only wanted to show how it my design would work. (Implementing it and presenting it in a real live end user model would have been too expensive and I was just a student with no money)
Anyway I planned to use Visual Basic to program as I was a bit familiar with it. But researching around it, Visual Basic has a single, big drawback for my needs. It can't directly access the pc's hardware components. Thankfully, after a little "google" time, I've discovered somebody already found a simple solution to get around this. My eternal gratitude goes to these generous geeks for making a student's life easier.
Anyway, this solution is for people who have a basic knowledge in Visual Basic programming. Here goes...

PROGRAMMING

1. The first thing you need is to download my zip package, parportpack.zip. It contains the following.
a. inpout32.dll - this dll enables visual basic to access the parallel port. Works with WIN 98/NT/2000/XP.
b. inpout32.bas - you need to add this module in your visual basic project.
c. parmon.exe - a very useful program that shows the status of your parallel port. Great for testing your programs.

That's all the basic stuff you need in order to start playing around with your parallel port.
2. After unzipping the package, here's what you need to do.
a. Put inpout32.dll into your Windows System Directory. (\windows\system32)
b. Add inpout32.bas into your Visual Basic project.
c. To write to the port, type
Out Address, Value
For basic signalling, the Data Lines are good enough. The Data Lines's address is &h378. The value is whatever number you want the 8 pins of the data lines you want to have.
d. To test your program, run parmon.exe while running your program in order to see if it works.


INTERFACING

The parallel port's output current is very, very small(2.5 mA). So you cannot directly use it's pins as signaling outputs. For simple signaling purposes, I use a 2N3904 NPN transistor configured for switching.

The Parallel Port's output current is strong enough to switch the transistor on. Thus powering the LED or the relay if you connect one.

That's all you need to know in order to start playing around for the parallel port. With this, you can now use the parallel port to do some signaling to whatever circuit you need.

REFERENCE

For more detailed information as well as credits for the contents of parportpack.zip go to these sites.
EPANORAMA.NET
Geek Hideout
LOGIX4U.NET
Parallel Port Central


If you have questions or corrections or suggestions, feel free to comment.
Cheers.

0 reactions on "A Beginner's Guide To Parallel Port Programming with Visual Basic"