![]() |
| 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 2 Thai Page Clcik Here Actually, getting data named "Input" from Printer Port; printer will send its signal to interface with computer in order to show status of printer, verifying for sending data to printer such as Printer Error, out of paper, ready to work, etc. All will connect via Printer Status Port that are port for getting input signal that are read only which differ from sending signal out to Printer Port that we will send via Data Port, 8 bit, but getting data like this will be used just 5 bit.
Actually, Status Port has 8 bit, but the first 3 bit will not be used, 2 reserved bit and IRQ signal will not be good for getting data have 5 bit, from bit 3 - bit7, but they can be used.
There will be the example of connecting signal like below,
Function we use for getting data via Printer Status Port from DLL file (Dllport.Dll) needs reference Address Printer Status Port that will be Address from Printer Data Port that is added one position such as
LPT1 Status=H379 (H378+1) The example of using getting data function Private Declare Function Inp32 Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Dim StatusValue As Integer StatusValue= Inp32 (&H379) However, programming by using several form of function, you must change Private to Public, then declare function in module file like the following; Public Declare Function Inp Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Start programming First of all, you create New Project by choosing Standard EXE. VB program will create the blank form, after that clicking at Project ---> Add Module in order to create a module file, typed .BAS to declare API Function of Dll in module of visual basic, also for convenience in using with other programming, but if you will use just a form, you must not create module file. You can declare in that form.
We will create Form, getting value from Printer Status Port in Visual Basic by clicking Control from Control Dialog, Label for showing Label 1- Label 5 and a Command Button to put in Form. Option Explicit 'Programming for Command button control, named Command1 in Click event. Click Private Sub Command1_Click()
Label1.Caption = (Inp(&H379)) And 8 ' 8 ' read value of error signal at bits position at 3 The example of program run
You can copy Source Code below, and then Paste in Notepad, then Save As the type as Form1.FRM, you will get form of this program.
The result In addition, why we must And Decimal Number, from experiment at computer we use when we push the button to read value, value we read will be changed. This is the reason emphasizing on And by permanent value in Decimal Number
| |||
| Copyright (c) 2000-2008 thaiio.com all rights reserved. Contact webmaster :webmaster@thaiio.com |