Tutorial navigation bar (Parallel port and Joystick port)

Tutorial (parallel port and Joystick port
  • ISA BUS.


    This is the Tutorial Section. In it we will describe the hardware of some parts of a modern PC. If we take a look at the standard Input/Output PC connectors we can find: the parallel port, to which the printer is connected, two COM ports (the RS_232 ports), and the joystick port. We will start by describing the parallel and the joystick ports. But first, we will show you how can we use the power source of the PC to connect other devices.


    When the box of your computer is open you can see the different parts of the PC: the motherboard, the disk units, the video board and the power source. The power source consists of an aluminum box with wires of different colors getting out of it.

    Using the power source.

    Colors of wires

    The parallel, the joystick and the serial ports have no pin connected to the PC source. So, all the devices you connect to this port must use an extern source. However, you have got another option: the power source of the PC could be used to give power to other devices

    The source of the computer has got five outputs. These outputs consist of ,many wires connected to GND, 5V, -5 V, 12V and -12 V. These are the voltages that the computer works with. If you take these wires out of the computer box you can use them to power up some devices.

    The most used voltages are 5V, 12V and GND. To identify these outputs most dealers of PC power sources use the colors shown in the table 1.1.


    Description of the port.

    The Parallel port is a standard designed to connect a printer to a computer. It is used for the CPU to send data to a printer. This interface drives some input and output signals. The purpose of these signals is to let the computer know the state of the printer and control it. Eight data bits carry all the information sent with each clock pulse.

    The hardware of this port consists of 8 output data bits, 5 input control bits and 5 output control bits. The control signals are listed below:


    STROBE/: Tells the printer when the eight data bits are ready to be read. Turns to a low logic level when the data are ready.

    INIT/: Reset the printer.

    SLCT IN/: Selects the printer when it turns to a low logic level.

    AUTO FD/: Tells the printer to print an empty line followed by a carriage return.

    D0-D7: Data bits.


    ACK/: Tells the CPU that the data has been correctly received.

    BUSY: The printer sets this line when its buffer is full. The computer will stop sending more data.

    SLCT: Tells the computer that a printer is present.

    ERROR/: An error has occurred. The CPU stop sending more data.

    PE: The printer is out of paper.

    All these signals are connected to a 25 PIN connector. All the bits have TTL logic levels.

    Addressing the port.

    Table 2.1

    Data Bits Table
    D0data 02
    D1data 13
    D2data 24
    D3data 35
    D4data 46
    D5data 57
    D6data 68
    D7data 79

    In the MS-DOS operative system three parallel ports, called LPT1, LPT2 and LPT3, are supported. So we can find three addresses dedicated to these ports in the memory map of the PC. Let's study the addresses dedicated to LPT1 first. Each parallel port uses three addresses of the I/O map. For LPT1 these addresses are 378H, 379H and 37AH.

    378H PORT: In this address the CPU writes the data to be sent to the printer. It is an OUTPUT port. The eight data bits (D0-D7) are latched to appear in the output connector. In the table 2.1 we can see which pins of the connector are used.

    379H PORT: This is an INPUT port. These signals are used by the CPU to know the state of the printer. The location of the bits is listed in table 2.2.

    37AH PORT: In this port the computer writes the signals that control the printer. Therefore, it is an OUTPUT port, see table 2.3.

    Table 2.2

    Status Bits Table
    D0not used 
    D1not used 
    D2not used 

    Table 2.3

    Control Bits Table


    D1AUTO FD14
    D3SLCT IN/17
    D4Habilitation IRQ7 
    D5not used 
    D6not used 
    D7not used 

    The computer has three LPTn ports. The addresses of the control and data signals for each LPTn port are listed below. Each port works in the same way that LPT1 does.

    Table 2.4

    Adresses of LPTn

    As you can see, the parallel port is able to control the IRQ7 interruption channel. This is a very powerful capability of this port. In a further tutorial we will show you how to use this signal.

    Programming the port.

    The programs below are examples about the way you can program the parallel port. They are all compiled with the Borland C++ 3.1 compiler.

    #include <stdio.h>
    #include <dos.h>
    #include <conio.h>

    /*This program set the parallel port outputs*/

    void main (void)


    The first program shows you how to send a byte to the parallel port output addresses. It's as easy as you can see. The outportb(); function sends a byte to a specified I/O port. The first function parameter is the address of the port to write a byte. The second parameter is the value of the byte to send. Both parameters can be defined as variables. In this case the first parameter must be an unsigned int, and the second an unsigned char.

    #include <stdio.h>
    #include <dos.h>
    #include <conio.h>

    /*This function read parallel port inputs*/

    int Read_Input()

    {int Byte;

    return Byte;}

    void main (void)

    {int PP_Input;

    PP_Input = Read_Input;

    The second example shows you how to read a byte from the parallel port input address. The main function is only used to show the value of the byte in the screen. The inportb(); function read a byte from the specified I/O address of the computer. The parameter must be an unsigned int.

    [ Home page ] [ Tutorial ] [ Links ] [ Versión en español ]

    Questions, comments, suggestions ?

    Please e-mail us at: pckits@apdo.com