0% found this document useful (0 votes)
940 views

Parallel Port Interfacing

The document discusses parallel port interfacing and programming. It defines parallel ports and how they are used to connect printers and other devices capable of receiving multiple bits of data simultaneously. It also discusses the challenges of programming parallel ports in Windows NT-based operating systems and introduces solutions using kernel mode drivers and dynamic link libraries to allow user mode programs to communicate with parallel ports. Examples are provided of programming code to output and read values from parallel ports.

Uploaded by

Kingsprincess
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
940 views

Parallel Port Interfacing

The document discusses parallel port interfacing and programming. It defines parallel ports and how they are used to connect printers and other devices capable of receiving multiple bits of data simultaneously. It also discusses the challenges of programming parallel ports in Windows NT-based operating systems and introduces solutions using kernel mode drivers and dynamic link libraries to allow user mode programs to communicate with parallel ports. Examples are provided of programming code to output and read values from parallel ports.

Uploaded by

Kingsprincess
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

PARALLEL PORT

INTERFACING
GROUP 8
SANDICO, ARWIN

SEVILLA, BRIGETTE MECCA


VALENZUELA, GEORGEN

VICTORIANO, RICHARD

VIZCARRA, JAMES DARWIN

PARALLEL PORT
Refers to processes that occur simultaneously.

Printers and other devices are said to be either


parallel or serial. Parallel means the device is
capable of receiving more than one bit at a time
(that is, it receives several bits in parallel).
Most modern printers are parallel.
  Reference to Address
Printer Port
 Using function Inp32 and Out32 extremely
need to reference to Address Printer Port in
order to verify and send value in each bit of
Printer Port that will be divided into 3 parts:

o DATA
o STATUS
o CONTROL
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.

LPT1 Data=H378
LPT2 Data=H278

STATUS
  2)   is the part that verifies 
the status of printer such as the 
printer is error, out of paper, sending 
signal to work, etc. We can use Status 
Port to control equipment as Input (+5 
Vdc) for reference of Data Port Data 
Port will equal to the position of base 
printer port+1.
     LPT1 Status=H379 (H378+1)
     LPT2 Status=H279 (H278+1)
3)  CONTROL is the part that control 
working of printer such as Strobe, 
Auto linefeed, Select printer, etc. It 
can receive and sent data, 6 bit for 
reference position of Data Port will 
be equal to the position of base 
printer port+1
     LPT1 Status=H37A(H378+2)
     LPT2 Status=H27A(H278+2)
COMPUTER INTERFACING?
the art of connecting computers and
peripherals
THE PROBLEM:
Writing programs to talk with parallel port
was pretty easy in old DOS days and in
Win95/98 too. We can use Inporb and
outportb or _inp() or _Outp functions in our
program without
any problem if we are running the program
on Dos or WIN95/98.

But entering to the new era of


NT clone operating systems like WIN NT4,
WIN2000, WINXP, all this simplicity goes
away.
There is a problem
in writing a program that can talk to parallel
port successfully in NT based operating
systems.
WHY?
WINDOWS NT
vIs a family of Operating Systems produced by
Microsoft
vIt was originally designed to be a powerful high-
level-language-based, processor-independent,
multiprocessing, multiuser operating system
vNT was the first fully 32-bit version of Windows
vWindows 3.1x and Windows 9x, were 16-bit/32-
bit hybrids
vWindows 2000 Windows XP. Windows Vista,
Windows 7 are based on Windows NT
v
vBeing a very secure operating system, Windows NT
assigns some privileges and restrictions to different
types of programs running on it
v
v
vIt classifies all the programs in to two categories ,
User mode and Kernel mode
v
USER MODE
 KERNEL MODE

qPrograms generally qNot restricted to such


written falls in the instructions
user mode category.
q
qRestricted to use
certain instructions
like IN, OUT etc..

THE SOLUTION :
write a kernel mode driver capable of reading
and writing data to parallel port and let the
user
mode program to communicate with it
" DLl "
( Dynamic Link
Library )
qcollection of small programs, which can be called
upon when needed by the executable program
(EXE) that is running
q
qThe DLL lets the executable communicate with a
specific device such as a printer
q
qIs an executable file that cannot  run on its own, it
can only run from inside an executable file, eg. an
engine of a car

START PROGRAMMING
Example 1:

Ø
Prog r amming by
  

using Function Out


and Inp
 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 

Dim PortData  ' variable for data at port 
 

 Const AddressLPT1 =&H378  'Constant for 
position of Printer Port 1(LPT1) and Data Port
 

        Const Statusport1 =AddressLPT1+1  ' 


Constant for position of Status Port(LPT1))
 

       Const Controlport1 =AddressLPT1+2  ' 


Constant for position of Control Port (LPT1))
 

      Const AddressLPT2 =&H278  ' Constant for 


position of Printer Port 2(LPT2) และ Data Portt
 

        Const Statusport2 =AddressLPT2+1  ' 


Constant for position of Status Port(LPT2)
 

       Controlport2 =AddressLPT2+2  ' Constant 
for position of Control Port (LPT2))
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
 So now, we will write code in control, starting to send
value to control Parallel Port. You must put in Textbox
and send value out by clicking at Command Button,
for getting value at port will show label.

Private Sub Command1_Click()


      PortData = Val("&H" & Text1.Text) 'count value in
Textbox to put in variable PortData
     Call Out(AddressLPT1, PortData) ''send to Port
       Label1.Caption = Hex(Inp(AddressLPT1)) ''read
value from I/O Port LPT1 as Hexadenary
End Sub
Sending value of PortAddress at Printer 
Port =&H378 Data that is value that send 
to Printer Port by sending by use 
Hexadenary, but port will transform data 
as binary numeral system that has 8 bit 
such as Hexadenary &H0F at Port =000011112  
of binary numeral system.
E xample 2 :

ØP ro g ra m m in g to g e t in p
T h e re w ill b e th e e x a m p le o f co n n e c tin g sig n a l like
b e lo w

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
Address LPT1=H378 -->Status Port =H378+1=H379,
etc.
       LPT1 Status=H379 (H378+1)

       LPT2 Status=H279 (H278+1)


Option Explicit

Private Declare Function Inp Lib "Dllport.dll"


Alias "Inp32" (ByVal PortAddress As Integer) As
Integer
Private Declare Sub Out Lib "Dllport.dll" Alias
"Out32" (ByVal PortAddress As Integer, ByVal
Value As Integer)

We will find value when there will be signal in

port by using And by permanent value in


Decimal Number
'like bit 0=1 | bit 1=2 | bit 2=4 | bit 3=8 | bit
4=16 | bit 5=32 | bit 6=64 | bit 7=128
'When input is 1, there will be file is about 5
Vdc to which connector, it will show permanent
value as Decimal Number
Private Sub Command1_Click()

Label1.Caption = (Inp(&H379)) And 8 ' 8 ' read value of


error signal at bit’s position at 3
   Label2.Caption = (Inp(&H379)) And 16 ' read value of
Select signal at bit’s position at 4
   Label3.Caption = (Inp(&H379)) And 32 ' read value of
Select Paper Empty at bit’s position at 5
   Label4.Caption = (Inp(&H379)) And 64 ' read value of
ACK signal at bit’s position at 6
   Label5.Caption = (Inp(&H379)) And 128 ' read value of
Busy signal at bit’s position at 7
' For condition that work in the case of having input signal,
sending value out Data Port
   If Label1.Caption = 8 Then Out &H378, 1 ' sending signal
out Data Port bit 0
   If Label2.Caption = 16 Then Out &H378, 2 ' sending
signal out Data Port bit 1
   If Label3.Caption = 32 Then Out &H378, 4 ' sending
signal out Data Port bit 2
   If Label4.Caption = 64 Then Out &H378, 8 ' sending
signal out Data Port bit 3
   If Label5.Caption = 128 Then Out &H378, 16 ' sending
signal out Data Port bit 4

End Sub

The example of program
run:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy