0% found this document useful (0 votes)
27 views

Sensor Report Fixed

This document provides instructions for an experiment to control a parallel port and LED circuit using a C program. The learning outcomes are to gain experience writing C programs for parallel ports, learn parallel port hardware and software protocols, and understand the function of each parallel port pin. It describes the 25 pins on the parallel port connector and their functions. It also provides a sample C program code to output a value to the parallel port to control an LED, and lists the required components, equipment, and software needed to build the circuit. The document includes circuit diagrams and step-by-step instructions for setting up the hardware and running the program.

Uploaded by

Tan Kee Kian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Sensor Report Fixed

This document provides instructions for an experiment to control a parallel port and LED circuit using a C program. The learning outcomes are to gain experience writing C programs for parallel ports, learn parallel port hardware and software protocols, and understand the function of each parallel port pin. It describes the 25 pins on the parallel port connector and their functions. It also provides a sample C program code to output a value to the parallel port to control an LED, and lists the required components, equipment, and software needed to build the circuit. The document includes circuit diagrams and step-by-step instructions for setting up the hardware and running the program.

Uploaded by

Tan Kee Kian
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Learning Outcomes

1. Gain experience with writing C program to write to parallel port and read data from parallel port. 2. Learn hardware and software protocols of standard parallel port. 3. Analyse the function of each pins on parallel port and implement it with C program.

Background Knowledge
In this experiment, we used parallel port, parallel port connector and code block as our main tools to send our virtual data to the circuit. There are a few basic knowledge that we need to understand in order to carry out the experiment. Parallel Port Connector

Above is the schematic diagram of the PC parallel port connector. These are 25 pins all together. The pins are counted from the top right side until top left side and continue from bottom right side to the bottom left side. The function of each pins can be categorized into 4 group: 1. First Output Port(D0-D7) - Pin2 to pin9 are called data register. The voltage flow through these pins can be controlled using C programming. 2. Input Port(S3-S7) - Pin10,11,12,13, and 15 are called status register. These pin can be connected to the switch as an input device. 3. Second Output Port(C0-C3) - Pin1,14,16 and 17 are called output port however they also known as control register. This is an extra port in case controlling through first port is not sufficient. 4. Ground Pin - Pin18 to Pin 25 are PC ground. Each output pin can have only two values: either 5 volts or 0 volts which is what we call as digital value. The digital state of '1' or ON represent 5 volts while the digital state of '0' or OFF represent 0 volts.

Code Block To write a program with an output and input. We have to include the <conio.h> library. Since this program required to be integrate with the parallel port which is one of the windows function. <windows.h> library is also included in the program. Moreover, the base address of the parallel port need to be identify. The program need an address to send data to just like how the postman need an address to deliver the mail to. By accessing the properties of the parallel port, the base address can be indentify. The following is an example of the essential par t of the program to output the value that we want, (oup32)(0xECD8, 255) "oup32" is a C program user-defined function output. 0xECD8 is the base address of the output port. "255" is the value that we want the output port to have. It is also the value that control the reaction of the LED in the circuit. It is the total decimal equivalent value of the digital value "11111111".

The following table is used as a references to determine output port value that we want the output port to have. Data port Status port Base Base+1 Pin 9 Pin 8 Pin~11 Pin 10 Bit7 27 128 Bit6 26 64 Pin 7 Pin 12 Bit5 25 32 Pin 6 Pin 13 Bit4 24 16 Pin 5 Pin 15 Pin~17 Bit3 23 8 Pin 4 Pin 3 Pin 2

Control port Base+2 Bit designation Bit value Decimal equivalent value

Pin 16 Bit2 22 4

Pin~14 Bit1 21 2

Pin~1 Bit0 20 1

List of Required Components, Equipment and Software


Components :1. Parallel port

2. Parallel port Connector

3. Wires/Jumper 4. LED

5. Bread board

Equipment :1. PC

Software :1. Code blocks

Circuit Diagram

Diagram 1: The parallel port connector circuit diagram

Diagram 2: The LED circuit diagram

Step-by-step Activities
1. The PC was set up and switched on. 2. The PC is ensured to have code blocks software before proceeding with the programming. If there is no code block software in the PC, changed another PC. 3. Repeat step 1 and 2 until code block is found in the computer. 4. The base address of the parallel port is checked by accessing the properties of the parallel port. 5. A series of code was inputted into the software. The code is shown as below,

6. The components were set up as shown in the figure below,

7. Then, the parallel port slot in the PCI slot of the desktop is connected to the parallel port connector with a parallel port cable. 8. The program was compiled and run. 9. The reaction of the LED is recorded. The program code was changed and the change of the reaction of the LED is recorded.

The reaction of the LED 1. (oup32)(0xECD8, 255)

2. (oup32)(0xECD8, 254

3. (oup32)(0xECD8, 72)

Learning Summary
As the conclusion, this experiment helps us to understand more about parallel ports and the ways to manipulate or control it by using C programming. There are 25 pins all together in parallel port and it represents four main function. It has programmable electronic device that has input, output, microprocessor and memory. Through controller, we can send the signal from C programming to/from the parallel port. This signal will operate the parallel port which connected with LED circuit. Depending on the input program, the output can be control as the user desired.

You might also like