Vous êtes sur la page 1sur 5

Parallel Port

Interfacing is controlling objects electronically. This requires three hardware components such as a computer, an interface a buffer in this case, and a peripheral in this case 4 LEDs and a buzzer. A parallel port cable is used to connect the peripheral to the computer for interfacing which allows binary information to flow back and forth between the computer and the peripherals. The parallel port has 25 pins as shown in the above diagram. Pins 2-8 are used to output information from the computer. Pins 15, 13-10 are used to input information to the computer. Pins 18-25 are ground pins which complete the electrical circuits. The chart below displays the information mentioned in an orderly manner. Pin # 1 2 3 4 5 Function Printer D0 - Output D1 - Output D2 - Output D3 - Output Pin # 6 7 8 9 10 Function D4 - Output D5 - Output D6 - Output D7 - Output I0 - Input Pin # 11 12 13 14 15 Function I1 - Input I2 - Input I3 - Input Printer I4 - Input Pin # 16 17 18 19 20 Functio n Printer Printer Ground Ground Ground Pin Function # 21 Ground 22 Ground 23 Ground 24 Ground 25 Ground

Commands such as parallelget() to read the parallel port, and parallelput() to write to the parallel port, are used via computer programing software to perform the written tasks. The software controls this flow of information to and from the parallel port.

Page | 1


The buffer 74LS245 is the interface that was used. The task of the buffer chip is to protect the computer from potential electrical damage. Damage could easily occur as a result of an interface drawing too much current from the parallel port, or sending too much current or incorrect voltage back into the parallel port. This is why a buffer chip is connected between the computer and an interface. When the buffer chip is correctly implanted sends and receives information to and from the computer and acts as an input output signal. The buffer chip is an electronic chip that has 20 pins as shown in the diagram above. The 20th pin is the +5V power pin, and pin 10 is the ground pin. Pin 1 is the direction pin and when it is +5V, it gives access to information to moves from A to B. When pin 1 is 0V the information moves from B to A. Pin 19 is the enable pin which, when it is +5V, prevents information from moving from A to B or B to A, unless pin 19 is 0V then it allows the information to flow from A to B or B to A depending on the wiring of pin 1. Pins 2-9 (A1-A8), also referred to as data outputs, and pins 18-11 (B1- B8) are the data pins.

Page | 2


The diagram above shows the wiring and the path in which they are connected. The buffer chip on the left is wired as an input buffer, which receives data on the Bus A side and send the data on the Bus B, where pin 1 is set high +5V and the buffer chip on the right is wired as an output buffer, which receive the data on the Bus B side and send the data on the Bus A side, where pin 1 is low 0V (ground). The buffer chips consists of two sides, side A (pins 2 9) and side B (pins 18 11, backwards). The correspondence between the pins from side A of the left buffer and the parallel port pins is 5-S3, 6-S4, 7-S5, and 8-S6. The remaining pins 2, 3, 4, and 9 are not used. These pins are connected to a (high/low) of the four switches. The correspondence between pins from the side B of the left buffer and the parallel port pins is 15-S3, 14-S4, 13-S5, and 12-S6. Again the remaining pins 18, 17, 16, and 11 are not used. The correspondence between the pins from side A of the right buffer and the parallel port pins is 2-D0, 3-D1, 4-D2, 5D3, 6-D4. Pins 7, 8, and 9 are not used. The correspondence between pins from the side B of the left buffer and the parallel port pins is 18-D0, 17-D1, 16-D2, 15-D3, and 14-D4. Pins 13, 12, 11 are not used. The buzzer is connected to pin 6 and the four LEDs are connected to pins 2-5. Pins 19 of both buffers are grounded to 0V.

Page | 3

The Turing programming language is used to read the input status of the parallel port, and to write the parallel port as integers. However, a specific pin needs to be isolated to determine the status of the input of the parallel port. The following table shows the calculations required to isolate input pins for the purpose of decision making.

Pin # 10 11 12 13 15

input S6

Calculation (input div 64) mod 2

Value for 5V input 1

S5 S4 S3

(input div 32) mod 2 (input div 16) mod 2 (input div 8) mod 2

1 1 1

The div in the calculation is used to push the pin to the most right position of the byte of information. The mod deletes anything to the left of the most right position of a byte of information which would then leave that bit status at the most right position by itself. The Turing commands which control the peripherals though the interface are: if then elseend if forend for loop end loop parallelget(0 parallelput()

Here is how the isolation of the pin works: Example: isolating pin S6 (determine the value of pin S6)

Page | 4

Weight Pins Data

128 S7 1

64 S6 1

32 S5 0

16 S4 0

8 S3 0

4 x x

2 x x

1 x x

Byte: 128 + 64 + 0 + 0 + 0 + 0 + 0 + 0 Byte: 192 input := parallelget() input := 192 input div 64 = 3 as shown below Data 0 0 0 0 0 (input div 64) mod 2 = 3 mod 2 = 1 R 1 as shown below Data 0 0 0 0 So now we have S6=(input div 64) mod 2 = 1 The same applies for S5, S4, and S3 0 0 1 1

Here is how parallelput() command woks: The procedure parallelput(18) would send the eight bit binary number as shown below. This means that a high output (logic 1) would be sent to pin 3 and pin 6 of the parallel port (D1 and D4), so if you connected an LED to pin 3 or pin 6 it would light up.

0 D7

0 D6

0 D5

1 D4

0 D3

0 D2

1 D1

0 D0

Parallelget() works as follows: var input: int input := parallelget().

Page | 5