![]() |
| Home | Parallel Port | Serial Port | Serial Info | Parallel Info | USB | .NET | Webboard | I/O Today | API | Project | Directory |
| Hardware Interfacing and TCP/IP interfacing in VB programming. | |||||||
Interfacing Parallel Port with Visual Basic Part 1 Thai Page Click Here
We can program by using Visual Basic in order to control hardware via Parallel Port with both output and input. Visual Basic can’t directly interface with hardware because it must be used DLL (Dynamic Link Library) to help in order to interface with port. From researching the relevant websites and books about the ability of Visual Basic in direct interfacing with port, it hasn’t been found. Even when Win32 API (Application Program Interface) which is the book about API function, it about create Dll (Dynamic Link Library) file to help, so I consider that function that interface with port from other language to program DII such as VC++,C++,Pascal, etc. In this article I program by using Visual C++, If you want to know about programming DII file, you can learn from this MS VC++ creating DLL file to interface with Computer Port Interfacing VB Program with hardware via Parallel Port in the 2 ways
1. 1. Interfacing via Printer Port
I will present the first one, interfacing via Printer Port in order to make understanding and can do by yourself. First of all, you must download File DLL at Application topic, named I/O Port Dll File Click Here , after that copy fill DllPort.Dll and paste at Directory Windows\System on your computer.
Reference to Address Printer Port
1. Data is the part that send data, 8 bit to Printer (also computer) that we will control signal in each bit in order to connect with printer for reference position of Data Port that will equal to base printer port position.
Start programming
Output Port
Public Declare Sub Out Lib "DllPort.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Input Port
Public Declare Function Inp Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
If you program just a form, you must use module by changing from Public to Private in the following;
Output Port - Private Declare Function
Private Declare Sub Out Lib "DllPort.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Input Port - Private Declare Function
Private Declare Function Inp Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Programming by using Function Out and Inp
Dim PortData ' variable for data at port
So now, we will create form of sending and getting from Parallel Port in program Visual Basic, clicking Control from Control Dialog, is a TextBox, a Label and a Command Button to put in form in the following;
For sending value via Parallel Port, you can do like this;
Call Out (PortAddress,Data)
For getting value at Parallel Port
Inp (PortAddress)
Sending output signal
Private Sub Command1_Click() The table of Hexadenary that control bit that is out via port
Bit No.
Hex
Binary
1
&H01
00000001
On the picture, I use 3 of LED8, 3 row and switch that this experiment I use with Card I/O Parallel Port IC 8255 that has 9 port of Port I/O or 72 bit that has TTL 0-5 volt. For switch, it has been tested for input signal that I separate into another web page.
Programming to get input signal from Printer Port
| |||||||
| Copyright (c) 2000-2008 thaiio.com all rights reserved. Contact webmaster :webmaster@thaiio.com |