Title: Controlled Systems Via Parallel Port
1Table of contents
- The LPT Hardware.
- Relationship Between (Digital Bit 0 or 1)
Binary Decimal Systems - Outputting to a simple 8-LEDs display.
- Output Circuit .
- Controlling the LED display with Visual Basic.
- Analog Digital Input Output.
- Reading Writing through (LPT).
- Interface circuit Construction description.
- Controlling the interface sections.
- Controlling the control Register.
- References.
The common PC printer port has long
been a convenient interface for the electronic
hobbyist looking to control some external device
with their computer
??? ???? ?????? ??????
Controlled Systems Via Parallel Port
Controlled Systems Via Parallel Port
2Parallel Port Hardware.
- The standard Parallel port (also called Parallel
Printer Port or LPT) has undergone a number of
changes over the years. In the early 80s the IBM
standard printer port (SPP) provided only output
data flow, from the computer to an peripheral
device, usually the printer. It could not receive
data from a peripheral device back into the
computer except for a couple of status lines to
tell the computer that the printer was out of
paper, or off-line etc. - The original IBM-PC's Parallel Printer Port had a
total of 12 digital outputs and 5 digital inputs
accessed via 3 consecutive 8-bit ports in the
processor's I/O space.
3Parallel Port Hardware.
4 Output Pins (Three inverted) Accessed via the
CONTROL Port.
25-way Female D-type Conector.
5 Input Pins (one inverted) Accessed via the
STATUS Port
8 Output Pins Accessed via the DATA Port
Beside the data output port there is a five bit
STATUS input port through which the computer
could get status information from the printer
such as paper out, or busy or printer online etc.
These bits are read by reading the 5 most
significant bits from the LPT1 base I/O address
1, usually 379 hex or 889 Dec
The DATA port contains eight bits of data
that are accessible by writing to the LPT 1 (PC
May contain two or three LPT ports) port base I/O
address, usually 378 Hex or 888 Dec
Finally there is a four bit CONTROL
port that is used to control various functions of
the printer such as initializing, linefeed, etc.
These bits can be controlled by writing to the
least significant 4 bits of the LPT1 base I/O
address 2, usually 380 hex or 890 Dec.
4Parallel Port Hardware.
Its very Significant to know
Corresponding Decimal Values of each DATA Pins
(D0 to D8) to Design nor Develop necessary
software and external devices.
Decimal Values
128 64 32 16 8 4 2 1
The remaining 8 Pins 18 through 25 are
Grounded.
5Parallel Port (LPT) Hardware.
- The bi-directional Printer Port
- Although the original printer port
specification (called SPP for Standard Parallel
Port) did not allow for reading 8-bit data
through the data port, this capability began
appearing with IBMs PS-2 line of computer
systems. Most computer systems today that are
sold with the serial and printer ports integrated
into the motherboard contain bi-directional
parallel ports. - On the other hand, many multi-function I/O
cards that you can buy today to plug into your
computers motherboard may still only contain the
SPP parallel port specification. When choosing a
parallel port or multi-function I/O card, ensure
that the specification for the printer port is
stated as being either EPP for Enhanced Parallel
Port or ECP for Extended Capabilities Port.
Either of these two specifications allow for
bi-directional data flow.
6Outputting to a simple 8-LEDs display.
- Output Circuit
- To begin using Visual Basic to perform I/O tasks
we need to construct a connection to the
computers LPT port. We will use a DB-25 male
connector which is connected via a 25-pin ribbon
cable to a 24- pin DIP. In this first exercise
using the LPT interface we will construct a
simple circuit on the proto-board to see if we
can simply output data using Visual Basic and
have a group of eight LEDs respond to it. - Next Slide shows the circuit. Pins 2 through 9
are connected to the anode of each LED and the
cathode of the LED is connected through a 470 to
1 Kohm resistor to any one of the internally
connected ground pins 18 through 25. The
resistors are used to limit the current from the
LPT port through the LEDs.
7Outputting to a simple 8-LEDs display.
Pins 2 through 9 are connected to the anode of
each LED
and the cathode of the LED is connected through a
470 ohm to 1K resistor to any one of the
internally connected ground pins 18 through 25.
The resistors are used to limit the current from
the LPT port through the LEDs.
8Outputting to a simple 8-LEDs display
- Circuit Operation
- The operation of this circuit is straight
forward. Take note that this circuit requires no
external power supply, the current required to
illuminate the LEDs is delivered from the LPT
port itself. Under software control data values
are written to the data register of the LPT1 port
by writing to I/O address 888. Valid data values
range from 0 to 255(Decimal). When a data value
is written the LEDs will illuminate. An
illuminated LED reflects a digital 1 and a dark
LED reflects a digital 0.
9Outputting to a simple 8-LEDs display
- Controlling the I/O port with Visual Basic
- Unlike its predecessors such as Qbasic,
Turbo-Basic or even the lowly GW-Basic, Visual
Basic does not have the ability to directly
access I/O ports on its own. We can, however add
this capability to Visual Basic by using an OCX
( Object Control Extension). - Theres lots of technical language we
could use to describe an OCX but basically it
adds a control to the Visual Basic toolbox that
can be placed on a form which will allow us to
perform input and output operations from any I/O
port including the LPT port. -
- It is available as a shareware program on the
Internet.
10Outputting to a simple 8-LEDs display
- LPT Output Test Program
- Entering a value into the text box at any
time and then pressing ENTER (or Clicking Display
button ) will cause the entered value to be sent
to the LPT port. The value entered must be valid
for an 8-bit value. This is from 0 to 255. - Any value entered outside this range will
cause an error message to be displayed and the
text box will be cleared.
So, Present Decimal Value 64 (in the Text
box), will turn LED No. 7 (D6 1) On .
11Reading Writing through the Printer Parallel
Port.
Reading Writing through the Printer Parallel
Port.
- we will take the interfacing of the
printer port one step further by building a
circuit that will allow digital and analog input
and output from a single LPT port.
- This project has two
parts - constructing the Input/Output circuit .
- writing the test routine.
12Reading Writing through the Parallel Port
Interface Circuit Description
. It contains the following sections
- Power Supply
- The circuit is powered by a single 5 volt supply
which can be constructed using a 9volt battery
and the 7805 voltage regulator. - An alternate arrangement is to use a 7vDC or
higher wall adapter and connect it into the
circuit as you would the battery. - The 7805 regulator can regulate any supply
voltage from 7 to 25v DC down to the required 5 v
for this circuit.
Building the Interface...
Simple Printer Port Interface Circuit
13A 74ALS574 octal D Latch to provide an 8-bit
digital output port which will be used to light 8
LEDs or any device that you wish to send digital
signals to.
A 74LS245 octal bi-directional latch to provide
an 8-bit digital input port which will be
connected to 8 switches or any devices that you
wish to read digital information from.
An Analog Devices AD558 8-bit digital to analog
converter to provide an analog output ranging
from 0 to 2.55 volts. The AD 558 is unique in
that it has an on-board 8-bit latch that we will
use to hold the data that is delivered to it from
the printer port.
Analog Output 0 to 2.55 Volt
A National Semiconductor ADC0804 8-bit analog to
digital converter. That will read an analog
input from 0 to 5 volts and provide an 8-bit
corresponding output to the printer port.
Initially, the analog input will be connected to
a 100K to 500K(or any Sensor ) potentiometer that
is connected between 5volts and ground to
provide an analog input signal.
Simple Printer Port Interface Circuit
Analog Input 0 to 5 Volts
14Reading Writing through the Parallel Port
- Interface Circuit Description
- Each IC will be controlled by one of the bits of
the CONTROL section of the LPT port ( indicated
by blue circle in previous slide ). These control
bits will be manipulated by Visual Basic to latch
data to be written out of the interface or to
read data from the digital or analog inputs to
the computer. -
- The 8 data lines of the LPT port now form a data
bus, which at times will contain data to be read
by the computer and at other times will carry the
data to be delivered from the computer to the
digital or analog output.
Constructing the Interface Use the circuit
shown to build the complete printer port
interface. The layout of the parts should occupy
3 proto-boards (Proto-boards are arranged to
accept integrated circuit chips and electronic
components and allows the interconnection of the
components to form complete circuits. ), one for
the DIP-24 connector from the LPT port cable, one
to hold all four ICs in a row as illustrated in
the circuit diagram and a final one to contain
the 8-bit DIP switch, the 8 LEDs and the
potentiometer. Take the time to lay out a neat
circuit. This will always make trouble-shooting
easier if it is necessary later. Note The jumper
wire from the ADC0804 pins 3 and 5 to ground is
usually left open. Normally this circuit will
trigger and begin performing free-running A/D
conversions at power-up. If it does not, then
touching this connection to ground momentarily
will trigger the circuit.
15Reading Writing through the Parallel Port
Controlling the Interface Sections In short, we
need to have control in our hardware and our
software to be able to determine what each
section of the interface will do and when it is
allowed to do it. The hardware control is
achieved through the use of four control lines
from the LPT port. These lines are C0, C1, C2 and
C3 which are connected to LPT pins 1, 14, 16 and
17 respectively. Each time we wish to cause a
value to be read or written to a device in our
interface we must change the state of its
control line. This will allow the device to
either latch the data on the data bus if it is an
output device or to place data onto the data bus
if it is an input device.
- Controlling the Interface Sections
- Using multiple devices all connected to a common
data bus raises some design and programming
issues. - Control of the data bus
- One and only one device may place data on the
data bus at a time. If we wish to send digital or
analog signals out of the computer, the computer
will have control of the data bus. If we wish to
read digital or analog information into the
computer, the digital input IC or the analog to
digital converter will have control of the data
bus. It becomes the job of the program to make
sure that only one of the interface sections will
have access to the data bus at a time in order to
read data from or to place data onto the bus. - Selecting Input or Output devices
- Suppose we wish to output a digital value to the
LEDs and so we therefore cause the computer to
place a digital value onto the data bus. We want
the digital output latch, the 74574 to then react
to the data on the bus and deliver it to the
LEDs. We must ensure that the digital to analog
converter, the ADC0804 does not react to the
digital value that is placed on the data bus.
16Reading Writing through the Parallel Port
Controlling the Control Register
- In this project we need to control four bits of
the control register. For most systems with a
single printer port, designated as LPT-1 this
would be at address (or called Base address) 888
(dec) or 378 (hex). - If there was a second printer port LPT-2 its
address would be 632 (dec) or 278 (hex). As we
have seen before, each LPT port has at least 3
sections. Each section has its own register, or
I/O address. - The data register is at the base address of the
LPT port - The Status register is at the base address 1 of
the LPT port - The Control register is at the base address2 of
the LPT port
In order to control the bits of the control
register we must write to the base address 2 of
the LPT port we are connected through. ((Notice))
that control lines C0, C1 and C3 are inverted
logic. This means that when a 1 is written to
that bit by the program, the logic level at the
respective pin at the LPT port is 0. Only C2,
the third bit at pin 16, which controls the
AD558 digital to analog converter is positive
logic. It must be kept high most of the time
until it is brought low to trigger the AD558 to
read the data bus and deliver a corresponding
analog output.
17(No Transcript)
18References
- References
- Electronic Devices Floyd.
- Electronic Circuit Shaum.
- Upper Canada Technologies Online
http//www.uct.co.ca - Electronics Information Online,
http//www.eio.com. - Hyper Physics
- http//hyperphysics.phy-astr.gsu.edu..
- E4All
- http//www.electronic-circuit-diagrams.com
- IC's Conf. Online http//www.ics.trieste.it.
- MS-V Basic 5 Abu El-Ata M. M..