Sie sind auf Seite 1von 24

Parallel and Serial Communication

Name of Student-

Keshav Maheshwari (8102163) Bhuvan Gupta (8102323)

Name of Supervisor- Mr Saurabh Chaturvedi

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING JAYPEE INSTITUTE OF INFORMATION TECHNOLOGY, NOIDA

TABLE OF CONTENTS
Chapter No. Topics Certificate from the Supervisor Acknowledgement Abstract Chapter No.1 Introduction Basic knowledge about Parallel and Serial Ports 6 5 Page No. 3 4

Chapter No. 2

Parallel Port Communication 2.1 Basic knowledge of parallel port 2.2 Programming at C Platform 2.3 Problem encountered in C language 2.4 Programming in Matlab Application of Parallel port (IC Tester) Serial Port communication 4.1 Basic knowledge of Serial Communication 4.2 Line Registers 4.3 Programming in C language 4.4 Bascom codes Application of Serial port (Touchpad) Final circuit diagram 23 39 16

Chapter No. 3 Chapter No. 4

Chapter No. 5 Chapter No. 7

References....40

CERTIFICATE

This is to certify that the work titled Parallel and Serial Communication submitted by Keshav Maheshwari and Bhuvan Gupta in minor project of degree of Bachelor of Technology of Jaypee Institute of Information Technology, Noida has been carried out under my supervision. This work has not been submitted partially or wholly to any other University or Institute for the award of this or any other degree or diploma.

Signature of Supervisor. Name of Supervisor: Mr. Saurabh Chaturvedi Designation: Lecturer Department of Electronics and Communications Engineering Jaypee Institute of Information Technology, Noida

ACKNOWLEDGEMENT

First and foremost, we would like to thank God for blessing us with the strength, intelligence, and patience to complete this project. We would like to express my sincere thanks to Mr. Saurabh Chaturvedi and Mr. Sandeep Joshi who have been helping us by giving their valuable suggestions and guiding us right way throughout the project. We are extremely thankful to the HOD of Electronics and Communication Engineering Department, Prof. R. C. Jain for providing the infrastructural facilities to work in, without which this work would have not been possible and Veer Bahadur Singh for providing his desktop.

Signature of Students Name of Student: Keshav Maheshwari , Bhuvan Gupta Date: ..

Abstract
We believe that learning in Electronics Engineering should reflect the current state of field as well as introduce the principles that are shaping computing. As in engineering course and during daily life also, we use parallel and serial ports knowingly and unknowingly. Parallel ports are generally used in printer interfacing and serial ports have greatly revolutionized the communication between devices so we are just studying them and working on their application. The first chapter gives an introduction to the project stating the structure of Parallel and Serial ports. Second chapter discusses about the Matlab and C++ software which we have used to implement our project work. Third and fourth chapter is about Parallel port communication and their application. Chapter fifth and sixth, h o w we are handling Serial port and its application that is touch pad.

CHAPTER

Introduction
Project IC tester - As the name suggest, our I.C tester will test digital integrated chips of 74 series. The basic idea of making ic tester came from digital electronics lab in 4th semester. While using those ics, we generally encountered with the problem of having wrong ics, which we got to know after making whole circuit. So , this project is having real practical application. We are using parallel ports to make ic tester, which we generally find in desktop not on modern laptops. So whats the idea ? Put the IC in, IC holder which will already be connected to our DB-25 i.e. parallel port according to our program. Program will check each and every combination of the I.C and produce the Output in details. Like "Gate 1 is good", "Gate is Bad etc . Project Touchpad -The National Semiconductor Corporation PC 16550D is a programmable communication interface designed to connect to virtually any type of serial interface. The 16550 is a universal asynchronous receiver/transmitter (UART) that is fully compatible with the Intel microprocessors. The 16550 is capable of operating at 0 1.5 M baud rate. Baud rate is the number of bits transferred per second, including start stop data and parity . The 16550 also includes a programmable Baud rate generator and separates FIFO for input and output data to ease the load on the microprocessor. E ach FIFO contain 16 bytes of storage . This is the most common communications interface found in modern microprocessor based equipment including the personal computer and many modems.

CHAPTER

Parallel Port
Parallel ports are the 25 pin cute things that you will find behind your computer panel. Here is a picture below to show you the pin categories. Basically they are split into three categories. The control pins, status and data pins (as shown below).

Snapshot 2.1 : Pins of Parallel Port Now data ports and status ports (pins actually) can be used for input and output data and the status are used by the computer to find out the status of an external device and thus can serve a good input port. Actually speaking mostly all these can be used for input and output but you can't use output to status pins. (If your ports don't work just check your BIOS there will be a option to elect ports as bidirectional so just enable that option).

Programming in Turbo C

Snapshot 2.1: Snapshot is showing output programme in Turbo C

Snapshot 2.2: Snapshot is showing parallel port


8

Problem encountered in C language:


Outportb is not working properly i.e Not working Include<stdio.h> Include<conio.h> Void main() { Outportb(0x378,0xff); } Working Include<stdio.h> Include<conio.h> Void main() { Outportb(0x378,0xff); Outportb(0x378,0xff); }

Very less documentation on i.c driving parallel port. Never able to take input from parallel port. not working Include<stdio.h> Include<conio.h> Void main() { inportb(0x378); inportb(0x378); Working Include<stdio.h> Include<conio.h> Void main() { Outportb(0x378,0xff); Outportb(0x378,0xff);

So decided to switch on the different platform i.e from C platform to MATLAB.

Programming in Matlab
open = daqhwinfo('parallel') DIO1 = digitalio('parallel','LPT1'); DIO2 = digitalio('parallel','LPT1'); outreg = addline(DIO1, 0:7, 0, 'out'); inreg = addline(DIO2, 0:4, 1, 'in'); outreg is the variable in which output value will be put into by MATLAB and sent to ports and inreg is port to which the input value will be saved. now the '0:7' represents 8 pins of dataport and '0:4' represents 5 pins of status port. putvalue(DIO1.Line(2),1) puts the value to line number "2" of the DIO1 configured port and the poutput value is 1. Getvalue(DIO2,line(1:4)) will get the input value

10

CHAPTER

Matlab codes for IC tester


B = zeros(1,4); open = daqhwinfo('parallel') DIO1 = digitalio('parallel','LPT1'); DIO2 = digitalio('parallel','LPT1'); outreg = addline(DIO1, 0:7, 0, 'out'); inreg = addline(DIO2, 0:4, 1, 'in'); function and () { putvalue(dio.Line(1:7), [ 1 1 1 1 1 1 1 1]) B = getvalue(DIO2.Line(1:4)) IF B ~= [1 1 1 1] putvalue(dio.Line(1:7), [ 1 0 1 0 1 0 1 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0 ] putvalue(dio.Line(1:7), [ 0 1 0 1 0 1 0 1]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0] putvalue(dio.Line(1:7), [ 0 0 0 0 0 0 0 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0 ] } OR () % or implementation { putvalue(dio.Line(1:7), [ 1 1 1 1 1 1 1 1]) B = getvalue(DIO2.Line(1:4)) IF B ~= [1 1 1 1] putvalue(dio.Line(1:7), [ 1 0 1 0 1 0 1 0]) B=getvalue(DIO2.Line(1:4))
11

IF B~= [1 1 1 1 ] putvalue(dio.Line(1:7), [ 0 1 0 1 0 1 0 1]) B=getvalue(DIO2.Line(1:4)) IF B~= [1 1 1 1] putvalue(dio.Line(1:7), [ 0 0 0 0 0 0 0 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0 ] } NAND () % nand implementation { putvalue(dio.Line(1:7), [ 1 1 1 1 1 1 1 1]) B = getvalue(DIO2.Line(1:4)) IF B ~= [0 0 0 0] putvalue(dio.Line(1:7), [ 1 0 1 0 1 0 1 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [1 1 1 1 ] putvalue(dio.Line(1:7), [ 0 1 0 1 0 1 0 1]) B=getvalue(DIO2.Line(1:4)) IF B~= [1 1 1 1] putvalue(dio.Line(1:7), [ 0 0 0 0 0 0 0 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [1 1 1 1 ] } NOR () % nor implementation { putvalue(dio.Line(1:7), [ 1 1 1 1 1 1 1 1]) B = getvalue(DIO2.Line(1:4)) IF B ~= [0 0 0 0] putvalue(dio.Line(1:7), [ 1 0 1 0 1 0 1 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0 ] putvalue(dio.Line(1:7), [ 0 1 0 1 0 1 0 1]) B=getvalue(DIO2.Line(1:4)) IF B~= [0 0 0 0] putvalue(dio.Line(1:7), [ 0 0 0 0 0 0 0 0]) B=getvalue(DIO2.Line(1:4)) IF B~= [1 1 1 1 ] }

12

CHAPTER
Serial Port:

Serial communication is a popular means of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer. Serial communication uses a transmitter to send data, one bit at a time, over a single communication line to a receiver. You can use this method when data transfer rates are low or you must transfer data over long distances. Serial communication is popular because most computers have one or more serial ports, so no extra hardware is needed other than a cable to connect the instrument to the computer or two computers together.

Snapshot 4.1 : Serial Port

ASYNCHRONOUS SERIAL DATA Asynchronous serial data are transmitted and received without a clock or timong signal. Figure illustrate two frame of asynchronous serial data. each frame contains a start bit and seven data bits parity and one stop bit. in this figure a frame which conatin ascii chatacter has 10 bits. ,most dial up connection system such as prodigy and America online use 10 bits for asynchronous serial data with even parity. Most internet and bulletinboard service also use 10 bits but they makes byte transfers of non ascii dat much easier to accomplish normally do not use parity.

13

Different line register:

Fig: Line Control Register outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */ we are giving value 00000011 at the address base+3 ie of line control register

14

Fig: outportb(PORT1 + 2 , 0xC7); /* C7=10100111*/


we are giving value 10100111 at the address -Baseaddress+2 ie for FIFO control register

15

Codes in C Language
#include<graphics.h> #include <dos.h> #include <stdio.h> #include <conio.h #define PORT1 0x3F8

/* Defines Serial Ports Base Address */ /* COM1 0x3F8 */ /* COM2 0x2F8 */ /* COM3 0x3E8 */ /* COM4 0x2E8 */ void drawline(int *ch) { if(ch[2]==0 && ch[3]==0) { circle(ch[0],ch[1],5); } if(ch[0]!=ch[2] || ch[1]!=ch[3]) line(ch[2]*100,ch[3]*100,ch[0]*100,ch[1]*100); } } void main(int m) {//clrscr(); int c,*P=NULL; char ch[4]={'0','0','0','0'}; char a; int i=0; int gdriver = DETECT, gmode, errorcode; clrscr(); printf("%x abnd %x",&P,P); initgraph(&gdriver, &gmode, ""); /* read result of initialization */
16

errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s\n", grapherrormsg(errorcode)) printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */ /* PORT 1 - Communication Settings */ outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */ outportb(PORT1 + 0 , 0x0c); /* Set Baud rate - Divisor Latch Low Byte */ /* Default 0x03 = 38,400 BPS */ /* 0x01 = 115,200 BPS */ /* 0x02 = 57,600 BPS */ /* 0x06 = 19,200 BPS */ /* 0x0C = 9,600 BPS */ /* 0x18 = 4,800 BPS */ /* 0x30 = 2,400 BPS */ outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */ outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */ outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */ outportb(PORT1 + 4 , 0x0B); /* Turn o.n DTR, RTS, and OUT2 */ do { c = inportb(PORT1 + 5); if (c & 1) { ch[i] = inportb(PORT1)-48; a=inportb(PORT1); a=inportb(PORT1); i=i++; if(i==2) { i=0; drawline(ch); ch[2]=ch[0]; ch[3]=ch[1]; }
17

delay(50); } }while(!kbhit()); /* ch[0]=10; ch[1]=10; ch[2]=200; ch[3]=200; drawline(ch);getch(); */ }

18

Bascom codes:
$regfile = "m16def.dat" $crystal = 8000000 $baud = 9600 $prog &HFF , &HC4 , &HD9 , &H00 Config Lcd = 16 * 2 Config Config Config Config Porta Portb Portd Portc = = = = Input Output Input Input

Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portl = B.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Config Adc = Single , Prescaler = Auto , Reference = Avcc Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down Dim X As Integer Dim Y As Integer Dim Flag As Integer Start Adc Start Timer1 Cls Lcd "hello8" If Pind = 0 Or Pina = 0 Then Cls Else X = 3 Y = 2 Print X Print Y 'End If End

19

CHAPTER

Application of Serial Port (Touchpad):

Snapshot 5.1 : Assembly Board containg Microcontroller.

20

Snapshot 5.2 : Touchpad Board showing fixed Laser and LDR

Snapshot 5.3: Connection between touchpad board and development board containing microcontroller

21

Block Diagram

TOUCHPAD
CONTAINING LASERS AND LDR
B

Computer Screen CPU


Containing

DEVELOPMENT BOARD
Microcontroller Ports

SERIAL PORT AND UART

22

Working of Touchpad :
Touhpad board is containg 8 lasers and 8 LDR. These 16 items will make criss-cross network as 4 lasers are fixed on 1 side and 4 on adjacent side. Similarly LDR will be fixed in the same pattern. Lasers are getting 5V supply on the ither hand output of LDR is connected to ports A & B of development board. Here our microcontroller and their Bascom Codes will do their work . Now signals from this development board will be sent to serial port od computer. Basially here we are involved in serial commuication. The specific values which will be given to serial port will get stored in UART where different line registers are used by our C language programme.

23

References:
1. http://madan.wordpress.com/parallel-port/

2. Jan Axelson, Programming, Interfacing & Using the Pcs Parallel Port, 4th edition,

USA,2000

3. http://www.robosapiensindia.com/resources/Robosapiens%20ATMEGA %208%20Development%20Board.pdf

4. Barry.B.Brey, Intel. Microprocessors 8086-8088,4th ed,Prentice Hall Inc ,PP 412-419 ,

1997

24

Das könnte Ihnen auch gefallen