1. Date: 28/11/2013
Al-Azhar University-Gaza
Faculty of Engineering & Information Technology
Mechatronices engineering
Microprocessors & Interfacing
(ITCE 3306)
LAB NO.5
Status port
Prepared By:
Ronza sameer Abu jayyab
No. 20111511
Submitted To:
Eng. Mahmoud I. Hasanain
First semester
2013/2014
2. Introduction:
We make interfacing with status parallel port to connect our device with PC and
control it by our code design.
Objective:
After this lab we can answer how i can deal with status port and at which
control circuit I can use it.
We will deal with status port with new IC called 74LS157.
Also we are known how we can use 74LS157 IC and how we can input
data for it and for status port to communicate us with computer and tell
it to do a specific test/task.
Background:
Status port:
The PC Parallel Port is commonly used to create an interface between a
computer and an external piece of hardware. Found on the back of a PC,
the parallel port is a D-Type 25 Pin Female Connector. The parallel port is
capable of receiving 9 bits of data or transmitting 12 bits of data, at any
given time.
Figure 1: Parallel Port Connection Pins
Within these lines there are three groups of pins known as the Data Port, Status
Port, and Control Port. The Data Port is composed of 8 lines Data 0 – Data 7 (Pins
2 – 9) that allow data to be transmitted or received to/from an external device.
3. Figure 2: Data port
The Status Port is a read only port composed of 5 input lines (Pins 10, 11, 12, 13, &
15), an IRQ status register, and two reserved lines.
Figure 3: status port
the Control Port is composed of 8 lines that are used to control the sending and
receiving data. Most importantly is the nStrobe line, which indicates that data is
ready to be sent/received.
Figure 4:control port
When writing/reading from the PC Parallel Port it is important to ensure the proper
address is being used. Normally the PC Parallel Port is given one of three commonly
4. used base addresses. However, depending on what external devices are active it is
easy to confuse the correct address.
Figure 5: port address
One of the effective way of reading data from an external device is know as Nibble
Mode. Nibble Mode requires the use of a Quad 2 line to 1 line multiplexer.
Although Nibble Mode reads the same amount of information as a bidirectional
connection or the previous method, it is slower and requires the use of an external
IC.
The eight data lines of the external device are connected to the A & B input lines of
the multiplexer. The outputs of the multiplexer are connected to lines on the
Control and Status Ports, as shown below:
Figure 6: Pin Connections for Nibble Mode
Once again, Nibble Mode requires the use of the proper C code to ensure the data is
properly transferred.
This time the LS Nibble read first, followed by the MS nibble. Finally, the LS Nibble is
shifted.
5. 74LS157 multiplexer:
General purpose of multiplexer:
1. A device to select from a number of input and put that
selected input on an output line.
2. Input are usually called data lines.
3. There must be enough select to unambiguously identify
the unique data line. These select are usually called
address lines.
Experiments:
Control circuit:
Figure 7: Diagram of the Control circuit
Experiment no.1 :
Light leds by status port.
Figure 8: experiment no.1.
6. Control code:
Private Sub Form_Load()
sp.address = 889
End Sub
Private Sub Form_Load()
NTport1.address = 888
End Sub
Private Sub Form_Load()
cp.address = 390
End Sub
Private Sub Timer1_Timer()
cp.Value = 1
sp.address = 889
S3 = (sp.Value And 8) / 8
NTport1.address = 888
If S3 = 1 Then
NTport1.Value = 1
Else: NTport1.Value = 0
Comment:
The circuit shown at Figure_8 _used to interface a set of 1 LED and
one switch connected to the PC using the parallel printer port.
7. Experiment no.2:
Scrolling with one status pin:
Control code:
Dim i As Integer
Private Sub Timer1_Timer()
cp.address = &H37A
cp.Value = 1
sp.address = 889
S3 = (sp.Value And 8) / 8
dp.address = 888
If S3 = 1 Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
dp.Value = 2 ^ i
i=i+1
If i> 7 Then i= 0
End If
End Sub
Comment:
1. The above visual basic code creates a wave on the LED (scrolling) connected
to the output port 378h according to the status ,the switches connected to the
input port 379h.
2. At timer 1 : initialize the data ,status ,control ports addresses .
At Timer 2: scrolling the LEDs.
8. Experiment no.3:
Scrolling with more one status pin:
Figure 9: experiment no.3.
Control code:
Dim i, x1, S345, S7, result As Integer
Private Sub Timer1_Timer()
Control.Value = 1
x1 = Status.Value
S345 = (x1 And &H38) / 2 ^ 3
S7 = ((Not x1) And 2 ^ 7) / 2 ^ 4
result = S345 + S7
End Sub
Private Sub Timer1_Timer()
If S345 = 40 Then
Timer2.Enabled = True
Timer3.Enabled = False
Timer2.Interval = 100
End If
If S345 = 56 Then
Timer2.Enabled = False
Timer3.Enabled = True
Timer2.Interval = 50
End If
Private Sub Timer2_Timer()
dp.Value = 2 ^ i
i=i+1
If i> 7 Then i = 0
End If
End Sub
Private Sub Timer3_Timer()
9. dp.Value = 2 ^ i
i=i-1
If i< 0 Then i = 7
End If
End Sub
Comment:
In the previous code we just use s3 and make for it shifting by
divide it in 2^3.
In this code if we want to use more than one status pin (s3,s4 &
s5).
Instead of define every status pin alone we'll define one variable
for all these pins and do shifting for this variable .
Also in this code we'll define three timer, the first one for define
the status pin, the second one to do scrolling from right to left,
and the last one for do scrolling from left to right.
Conclusion:
At this report we clarified a simple model for using status port ,and showed the
communication between it and the PC with external device.
Reference:
1. 74LS157 IC:
http://www.google.ps/url?sa=t&rct=j&q=&esrc=s&source=web&cd=14&ved=0CIUB
EBYwDQ&url=http%3A%2F%2Fwww.niu.edu%2F~mfortner%2Flabelec%2Flect%2FLe
1_103.pdf&ei=wCCWUv2LEcSB4gTUzoD4DA&usg=AFQjCNHLPaJW7HhVB1JVzOu3oTXYnCPkQ&bvm=bv.57155469,d.bGQ
2. Status port:
http://coecsl.ece.illinois.edu/ge423/sensorprojects/Parallel%20Port%20Interfacing.
doc