Parallel Port Interfacing

34
PARALLEL PORT INTERFACING

Transcript of Parallel Port Interfacing

Page 1: Parallel Port Interfacing

PARALLEL PORT INTERFACING

Page 2: Parallel Port Interfacing

SANDICO, ARWIN

SEVILLA, BRIGETTE MECCA

VALENZUELA, GEORGEN

VICTORIANO, RICHARD

VIZCARRA, JAMES DARWIN

GROUP 8

Page 3: Parallel Port Interfacing

PARALLEL PORTRefers 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.

Page 4: Parallel Port Interfacing
Page 5: Parallel Port Interfacing
Page 6: Parallel Port Interfacing

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:

oDATAoSTATUSoCONTROL

  Reference to Address Printer Port

Page 7: Parallel Port Interfacing

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

Page 8: Parallel Port Interfacing

  2) STATUS 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)

Page 9: Parallel Port Interfacing

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)

Page 10: Parallel Port Interfacing

the art of connecting computers and peripherals

COMPUTER INTERFACING?

Page 11: Parallel Port Interfacing

THE PROBLEM:Writing programs to talk with parallel port was pretty easy in old DOS days and inWin95/98 too. We can use Inporb and outportb or _inp() or _Outp functions in our program withoutany problem if we are running the program on Dos or WIN95/98.

But entering to the new era ofNT clone operating systems like WIN NT4, WIN2000, WINXP, all this simplicity goes away.

Page 12: Parallel Port Interfacing

There is a problemin writing a program that can talk to parallel port successfully in NT based operating systems.

Page 13: Parallel Port Interfacing

WHY?

Page 14: Parallel Port Interfacing

Is a family of Operating Systems produced by Microsoft

It was originally designed to be a powerful high-level-language-based, processor-

independent, multiprocessing, multiuser operating system

NT was the first fully 32-bit version of Windows

Windows 3.1x and Windows 9x, were 16-bit/32-bit hybrids

Windows 2000 Windows XP. Windows Vista, Windows 7 are based on Windows NT

WINDOWS NT

Page 15: Parallel Port Interfacing

Being a very secure operating system, Windows NT assigns some privileges and restrictions to different types of programs running on it

It classifies all the programs in to two categories , User mode and Kernel mode

Page 16: Parallel Port Interfacing

USER MODEPrograms generally

written falls in the user mode category.

Restricted to use certain instructions like IN, OUT etc..

Not restricted to such instructions

KERNEL MODE

Page 17: Parallel Port Interfacing

write a kernel mode driver capable of reading and writing data to parallel port

and let the usermode program to communicate with it

THE SOLUTION:

Page 18: Parallel Port Interfacing

"DLl"(Dynamic Link

Library)

Page 19: Parallel Port Interfacing

collection of small programs, which can be called upon when needed by the executable program (EXE) that is running

The DLL lets the executable communicate with a specific device such as a printer

Is an executable file that cannot  run on its own, it can only run from inside an executable file, eg. an engine of a car

Page 20: Parallel Port Interfacing

START PROGRAMMING

Page 21: Parallel Port Interfacing

Example 1:

   Programming by using

Function Out and Inp

Page 22: Parallel Port Interfacing

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

Page 23: Parallel Port Interfacing

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))

Page 24: Parallel Port Interfacing

For sending value via Parallel Port, you can do like this; Call Out (PortAddress,Data)

For getting value at Parallel Port

Inp (PortAddress)

Page 25: Parallel Port Interfacing
Page 26: Parallel Port Interfacing

 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 HexadenaryEnd Sub

Sending output signal

Page 27: Parallel Port Interfacing

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.

Page 28: Parallel Port Interfacing
Page 30: Parallel Port Interfacing

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)

There will be the example of connecting signal like below

Page 31: Parallel Port Interfacing

Option Explicit

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

Page 32: Parallel Port Interfacing

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

Page 33: Parallel Port Interfacing

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

Page 34: Parallel Port Interfacing

The example of program run: