06/25/091 computer interfacing via the parallel port carlos m. oppus ecce program, admu

20
06/25/09 1 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU .

Upload: rosaline-ross

Post on 23-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 1

Computer Interfacing

Via the

Parallel Port

Carlos M. Oppus

ECCE Program, AdMU .

Page 2: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 2

Objectives

This lecture aims :

1) to give an overview of computer interfacing.

2) to give the basics of interfacing via the parallel port

Page 3: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 3

Introduction Computer Interfacing means

connecting different devices to the computer and being able to control or read the status of these devices.

There are many ways to achieve computer interfacing.

(1) Interfacing by making your own computer interface card.

(2) Interfacing via the existing ports in your computers.

Page 4: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 4

Introduction (cont …)

namely (a) modem (b) internet (c) serial port (d) game port (e) parallel port (f) USB etc.

Page 5: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 5

Parallel Port Computers are equipped with at least

one parallel printer port card. This parallel port can be used as a

general input-output device used for manipulating interfaced hardware.

The printer port is designated as LPT 1, LPT 2 & LPT 3

Page 6: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 6

Printer PortParallel (printer) port as a general-purpose

set of digital input and output port for interfacing devices.

 8-bit digital input/output (I/O) register if an

enhanced parallel port is being used otherwise it is just an output register

4-bit output register

4-bit input register (actually 5 inputs)

Page 7: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 7

Parallel (Printer) Port

Port Configuration I/O Port address

LPT 1 378H to 37AH

LPT 2 278H to 27AH

Page 8: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 8

8 output pins accessed via the DATA Port (pins 1 to 9) 5 input pins (one inverted) accessed via the STATUS Port (pins 10, 11, 12,

13, 15) 4 output pins (three inverted) accessed via the CONTROL Port (pins 1, 14,

16, 17)

The remaining 8 pins are ground (pins 18 to 25)

Parallel (Printer) Port

Page 9: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 9

Parallel (Printer) Portnote: high TTL level = 2.4V to 5V low TTL level = 0V to 0.8V (normally 0V)

An OUT instruction to port address 378H (278H) and 37A (27A) can write the data directly to the connector pins.

An IN instruction to port address 378H (278H) [if an enhanced parallel port is in use] and 379H (279H) can read the data directly from the connector pins.

Page 10: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 10

8-bit I/O if an enhanced parallel port is being used otherwise it is just an output port at address 378H (278H)

BIT TTL level when a 1 is written/read to/from

the port bit

pin position

description

0 high 2 D0 1 high 3 D1 2 high 4 D2 3 high 5 D3 4 high 6 D4 5 high 7 D5 6 high 8 D6 7 high 9 D7

example:  

PASCAL: port[$0378] := 255; // outputs 11111111 to pins 2 to 9

C: outportb(0x378,255); // outputs 11111111 to pins 2 to 9

Page 11: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 11

379H (279H)

4-bit input port at address 379H (279H) BIT TTL level when a

1 is read from the port bit

pin position

description

0 not used n/a n/a 1 not used n/a n/a 2 not used n/a n/a 3 not used n/a n/a 4 high 13 select 5 high 12 P.E. 6 high 10 ackn 7 low 11 busy

Page 12: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 12

PASCAL: data := port[$037A] ; reads port 37AH i.e. reads the TTL levels of

pins 13,12,10 & 11 respectively and places the corresponding values at the higher nibble of variable “data”.

C: data = inportb(0x37A); reads port 37AH i.e. reads the TTL levels of

pins 13,12,10 & 11 respectively and places the corresponding values at the higher nibble of variable “data”.

Example

Page 13: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 13

37AH (27AH)4-bit output port at address 37AH (27AH)

BIT TTL level when a 1 is written to the port bit

pin position

Description

0 low 1 strobe 1 low 14 autofeed 2 high 16 init prt 3 low 17 select inp 4 direction control bit of

data register (378H/278H) if enhanced parallel port (high for input, low for output)

not applicabl

e (n/a)

n/a

5 not used n/a n/a 6 not used n/a n/a 7 not used n/a n/a

Page 14: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 14

PASCAL:

Port[$037A] := 4; outputs 0100 to pins 17,16,14 & 1 respectively

i.e. pin 17 is high, pin 16 is high, pin 14 is high and pin 1 is high.

C:

outportb(x037A,4); outputs 0100 to pins 17,16,14 & 1

respectively i.e. pin 17 is high, pin 16 is high, pin 14 is high and pin 1 is high.

Example

Page 15: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 15

vbOut [port],[number] example:

'set port to 00001011 378H = 888vbOut 888, 11 [variable]=vbInp([port])

example:

‘input from 379H = 889PortNum%=vbInp(889)

For 32bit VB (WIN95IO.DLL), use: Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer) Declare Sub vbOutw Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer) Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer Declare Function vbInpw Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer

Page 16: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 16

Sample Circuits

Page 17: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 17

Sample Circuits

Page 18: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 18

Demonstration

Appliance controller …

Page 19: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 19

Circuit Diagram

Page 20: 06/25/091 Computer Interfacing Via the Parallel Port Carlos M. Oppus ECCE Program, AdMU

06/25/09 20

Sample Program

uses crt;

var ch :char;

begin

clrscr;

repeat

port[$37A] := $0B; gotoxy(20,20); write('off');

ch := readkey;

port[$37A] := $04; gotoxy(20,20); write('on ');

ch := upcase(readkey);

until ch = 'Q';

port[$37A] := $0B;

end