+ All Categories
Home > Documents > Report of Infrared

Report of Infrared

Date post: 10-Apr-2018
Category:
Upload: jagadish-hosamane
View: 222 times
Download: 0 times
Share this document with a friend

of 51

Transcript
  • 8/8/2019 Report of Infrared

    1/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    DEPARTMENT OF TECHNICAL EDUCATION

    SRI JAYACHAMARAJENDRA (GOVT.) POLYTECHNIC

    (An Autonomous Institution)Sheshadri Road, K.R.Circle, Bangalore-560001

    DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

    CERTIFICATECertified that the project work entitled C Program to File Transmission

    Through IR-Compone nt Connect to RS-232 is a bonafied work carried out

    successfully by Jagadish.T.S (A04CS19), in Partial fulfillment for the award

    of

    DIPLOMA IN COMPUTER SCIENCE & ENGINEERINGPrescribed by the

    ACADEMIC COUNCIL, S.J.(Govt.) POLYTECHNIC

    (Approve d by the Board of Technical Education.)during the year 2006-2007

    Project Guide Head Of the Department Principal

    (Smt. Thulasi .M.B) (Smt.Gayathri.V) (Sri.S.R.Murthy)Sr. Grade Lecturer

    Date:

    Place: Bangalore.

  • 8/8/2019 Report of Infrared

    2/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    The satisfaction & happiness that accompanies the successful completion ofany task would be incomplete without mention of the people who made it possible,whose constant guidance & encouragement crown all efforts with success.

    First of all we have great pleasure in expressing our heartful gratitude to ouresteem Principal, Sri S.R.Murthy and also to our Head of the Department, Smt.

    V.Gayathri, to carry out the project successfully and for their untiring zeal, whichconstantly inspired me during the completion of this project.

    We express our deep sense of gratitude to our guide Smt. M.B.Thulase for herguidance throughout the project. We would also like to express our sincere thanks toSmt. Usharani madam, Mr. Mahadevaiah Sir, Smt. Kavitha madam for their supportand timely co-operation throughout this project.

    We once again thank one and all whose guidance and contributions proved tobe extremely helpful in completion of this project. Special thanks to all the staff of thelaboratories for helping during the long hours of stay at the labs.

    Last but not least, thanks are due to our friends and parents.

  • 8/8/2019 Report of Infrared

    3/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    CONTENTS

    SYNOPSIS

    INTRODUCTION

    ABOUT COMMUNICATION SYSTEM.

    ABOUT INFRARED TECNOLOGY

    NETWORKING GOALS

    ABOUT HARDWARE

    ABOUT SOFTWARE

    CODE

    OUTPUT

    FEATURES

    ADVANTAGES

    CONCLUSION

  • 8/8/2019 Report of Infrared

    4/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    SYNOPSIS

    This project would be the first step in achieving the WIRELESSNETWORKING (opto networking) which is revolutionizing the field of Computernetworking and the application like wireless mouse and keyboard work on the aboveprinciple.

    This project will be capable of transferring files from one system to another bymeans of simple optical linking. The optical linking is provided by an hardwaremodule which will be present in both the PCs. The module is a combination of IRLED and IR DETECTOR.

    Each of the two modules are interfaced to the PCs with an RS 232 standard,

    trough the serial port. These modules from the front end and the back end of the two

    communication entities (system). Each module consists of a level shifter (MAX 232IC), which is a carrier wave generator for the INTENSITY MODULATION of the IRlight generated by the transceiver and IR detector.

    This project is expected to work satisfactorily for a distance of up to 40 feetand the coverage area can be improved with additional LEDs.

    Besides the hardware modules, a C - program involving file manipulatingfunctions would be written to make the system more user friendly.

  • 8/8/2019 Report of Infrared

    5/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    INTRODUCTION

    There is always a need to transfer or share information from one computer toother. This is done in two ways.

    Firstly, the data is transferred to a portable storage medium like floppies , CDsetc and then copied to a target system.

    Secondly, both the system are linked through a cable and data is transferredeither in serial or parallel mode.

    The prototype model developed in this project the data from one pc to other pcwithout any cable connection between them.

    The term Communication refers to sending, receiving and processing ofinformation by electronic means. Communication started with Wire Te legraphy in the1840s, developing with telephony some decades later and radio at the beginning of

    this century. Communication subsequently became even more widely used and

    refined through the invention and use of transistors, integrated circuits and othersemiconductor devices. Thus a communication System has tree basic components.

    1. TransmitterA transmitter is equipment, which converts a physical message into an

    electrical message

    2. ReceiverA receiver on the other hand is equipment, which converts the

    electrical signal back to the physical signal.

    3. ChannelThe electrical signal from transmitter is conveyed to file receiver throughthe channel.

    This project basically deals with communication between Computers i.e.transferring data between two computers using infrared beam.

  • 8/8/2019 Report of Infrared

    6/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    About communication System:

    In modem age communication systems, computers are used broadly. The

    technology development in the software field has given a boost in the communicationto implement complex and diversely featured communication systems. With theinformation technology jump the communication and computer industries are mergedtogether and resulting advanced technologies, which comprise services of both

    computers and communication systems.

    The most advanced communication technology is computer networkingcomputer network is the interconnection of autonomous computers. Autonomouscomputers are the computers, which have their own hardware and software and dontdepend on any other unit for processing works.

    On the basis of area covered, computer networks are distinguished in threecategories.

    1. Local Area Network[LAN]2. Metropolitan Area Network[MAN]

    3. Wide Area Network[WAN]

    LOCAL AREA NETWORKS:

    Local area networks are privately owned networks with in a single campus ofup to a few kilometers in size. They are widely used to connect personal computersand work attains in company offices and factories to share resources and exchange

    information.

    They are the simplest form of networks, which often use a transmissiontechnology consisting of a single cable to which all the machines are attached.Traditional speed of LANs is 10-100Mbps.

    METROPOLITAN AREA NETWORKS:

    A metropolitan area network is basically a bigger version of LAN andnormally used a similar technology.

    It might cover a group of nearby corporate offices or a city and might be

    either private or public.It can support both data and voice. A MAN just has one or twocables and does not contain switches, which shunt packets.

  • 8/8/2019 Report of Infrared

    7/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    WIDE AREA NETWORKS:

    A Wide area network spans a large geographical area of a Country or

    Continents. It contains a collection of machines intended for running application

    programs. The most WAN consist of two distinct components: transmission lines and

    switching elements. Switching elements are specialized computers used to connecttwo or more transmission lines. The INTERNET comes under this category.Depending on the transmission media the computer networks are categorized in two

    ways. They are as follows:

    1. Solid transmission lines computer networks.2. Wireless computer networks.

    The computer networks, in which the transmission media used is cables, wiresor optical fibers, comes in the category of solid transmission line computer network.The attenuation using solid transmission line is more than that of wireless

    transmission. The systems become expensive due to large number of repeaters forlarge distances.

    The alternative, wireless communication, is cheaper and more efficient as themedia is cost free. The new tech communication systems are adopting this technology

    due to its very advantages. The bandwidth available is infinite and thus giving roomfor a lot of channels to frequency multiplexed. Less number of repeaters are required

    than that of wire communication thus reducing the maintenance cost. Wireless LANsare easy to install as compared to wired networks. On contrary, they require complex

    electronics circuitry and antennas. They have the capacity of 1-2 Mbps, which ismuch slower than wired LAN. The error rates are often much higher.

  • 8/8/2019 Report of Infrared

    8/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    DATA TRANSMISSION TECHNIQUES

    All communication system are divided into two categories on basis of methodof transmission data bits. They are

    1.

    Parallel Transmission2. Serial Transmission

    Parallel Transmission:

    In parallel data transmission each bit of message has its own path and the totalmessage is transmitted at the same time.

    This means that an n-bit message must be transmitted through n separateconductor paths.

    Parallel transmission is faster but requires many wires. It is used for short

    distances and where speed is important, if a system has n parallel transmission linesthen it will more than n times faster than that of serial transfer.

    For example in computers, parallel data transfer scheme is used for fastprocessing. The deciding feature of speed of any microprocessor is number of datalines in it and the clock frequency. The data lines are actually parallel conductorspaths, which makes the parallel communication channel in computer architecture.

    Serial Transmission:

    In serial data transmission each bit in message is sent in sequence one at a time.This method requires use of one pair of conductors or one conductor and a common

    ground.

    Serial transmission is slower but is less expensive since if requires only one pair ofconductors.

    For example, all Public Telephone Networks are used for serial transmission of dataas the transmission path length is very from few meters to many kilometers. All

    computer networks use serial transmission technique as it requires less out systemspace and is cheap.

    Although this makes the speed slower but the advantages out weights thedisadvantages. In account of load offered by any network, serial transmission is

    capable of handling the load with bearable failures and sufficient efficiency.

  • 8/8/2019 Report of Infrared

    9/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    RS232 SPECIFICATIONS

    RS 232 is a complete standard. This means that the standard sets out to

    ensure compatibility between the host and peripheral systems by specifying1) Common voltage and signal levels,

    2) Common pin wiring configurations, and3) A minimal amount of control information between the host and peripheral systems.

    Unlike many standards which simply specify the electrical characteristics of a

    given interface, RS-232 specifies electrical, functional, and mechanical characteristicsin order to meet the above three criteria.

    NETWORKING GOALS.

    1. RESOURCE SHARING:

    Computer network provides shared access to resources (program or data) to

    everyone on the network.

    2. HIGHLY RELIALIBILITY:

    A second goal is to provide high reliability by having alternative source ofsupply. For example, files could be stored on two or more machines on thenetwork. Even if one machine fails due to hardware problem, the files can beretrieved from other machines and work can progress.

    3. COMMUNICATION MEDIUM:A computer network provides a powerful communication medium among

    widely separated people.

    ABOUT INFRARED TECNOLOGY:

    Infrared data communication is a mode of communication that plays animportant role in wireless data communication.

    The infrared data association [IRDA] was established in1993 to create andmaintain international standards for the hardware & software used in infrared

    communication links.

    Infrared is simply an invisible light .It has all the properties of visible lightexcept that our eyes cant see it.

    In infrared data communication, a focused ray of light in the infraredfrequency is modulated with information and sent from a transmitter to a receiver.

    The communication between the devices requires each has a transceiver (acombination of a transmitter and a receiver) in order to communicate however adevices may also require further specialized software allowing communication to be

    synchronized. One of the examples of this is the design support that is in Microsoft

    windows as operating system.Infrared uses either directed (line-of-sight) or diffuse technology.

  • 8/8/2019 Report of Infrared

    10/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

  • 8/8/2019 Report of Infrared

    11/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    VOLTAGE LEVEL CONVERTER(MAX 232):

    For converting the voltage level of serial output of computer (TTL/CMOS

    levels) of 9v to interfacing circuit compatible levels 0/5v we have used the ICMAX232 which is a bi-directional voltage converter. The internal description is

    shown in Figure 3

    A MAX232 is a lever converter driver chip basically called a charge pump.

    The chip requires four capacitors to help it build up 10 volts that it can communicatewith a PC serial port on the outbound side. On the other side of the chip, you musthave a micro-processor or some sort of serial input usually from some find of logiccircuit. The chip is typically powered by a 5v dc regulated supply.

  • 8/8/2019 Report of Infrared

    12/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    MODULATOR AND TRANSMITTER (555 timer):

    The modulator used in the circuit is astable multivibrator using 555 timer. The

    duty cycle is set to 25% and it generates square waves of 38 kHz, which modulatesthe signal to be transmitted. The NE555 silicon monolithic timing circuit is a highly

    stable controller capable of producing accurate time delays, or oscillation. In the timedelays, mode of operation, one external resistor and capacitor precisely control thetime.

    The block diagram and pin diagram of 555timer is shown in figure.

  • 8/8/2019 Report of Infrared

    13/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    9-PIN D Connector:

  • 8/8/2019 Report of Infrared

    14/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    RECEIVER (IR RXR MODULE):

    To receiver the infrared signals we have used IR RXR Module, which sensesthe infrared signals and generates corresponding voltages.

    COMPONENT DESCRIPTION

    The component as an interfacing circuit facilitating the convert the electricalsignals in to infrared radiation with modulating unit. Detailed description of the

    interfacing unit is presented below based on the interfacing, circuit diagram shown inFigure 2.

    The interfacing unit consists of following main parts:

    1. 9 pin D connector.

    2. Voltage level converter[IC MAX232]3. Modulator and transmitter [555 timer in Astable Mode]4. Receiver [Infrared RXR Module]

  • 8/8/2019 Report of Infrared

    15/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    WORKING OF HARDWARE :

    Transmitter:

    Data singles transmitted through pin 3 of 9 pin D connector of RS 232 COM

    1 port are sent to pin 8 of MAX 232 and it converts these EIA( Electronics IndustryAssociation) RS232 compatible levels of 9 volts to 0/5 TTL levels as given in table 1.The output pin of MAX 232 TC (pin no. 9) drives the BC 547 npn transistor andpowers the base of transistor. Now, depending on the input at pin 8 of IC MAX232,the transistor goes in active region or in cutoff. Let us take this one by one.

    1. With input at pin 8 is +9v:The output at pin 9 of MAX232 will be 0v and thus the transistor T1 will be in

    cutoff. This supply voltage (+5v) will thus appear on collector of transistor T1 andthe 555 timer will reset as collector is connected to pin 4 of 555 timer (reset pin). Thisoutput thus goes to logic 1 at pin 3 of 555 timer and IR LEDs will glow.

    2. With input at pin 8 is -9v:The output in this case on pin 9 of MAX232 will be +5 volts thus driving the

    transistor T1 in active region. The voltage at pin 4 of 555 timer will goes to zero and

    output at pin 3 of 555 timer goes low thus the LEDs will not glow. The electricalpulses send by the COM port are now converted into corresponding modulated pulsesof IR light.

    The a stable multivibrator is set to generate square wave of 38 kHz as the IRmodule used in the circuit is tuned to 38 kHz. The range of 38kHz is widely used inpractical purposes as most Television remote controls operates on this frequency thus

    providing extra tool for testing.

    Receiver:

    A visible LED 1 at pin 7 of Max 232 IC indicates that the signals are beingreceived. Pin is a lso connected to pin2 (receiving pin) of 9-pin(or pin 3 of 25 pin) D

    connector used for the serial port in the PC so that the data may be read. The optical

    signals received by the IR Module are in fact converted to the electrical pulses andboth PCs think that there is a null modem cable connected between them in some

    PCs the serial port is terminated it to a 9 pin D connector and in some others in to a25 pin D connector.

    The module used works in active low and thus when receives TR radiationgives output low. With low logic at base of transistor T2 the emitter of it will be at

    low voltage level voltage and then the received low voltage signal is converted into+9 voltage level by IC232.

    When there is no IR radiation on the module it gives high output. With highlogic at base of transistor T2 the emitter of it will be at high voltage level and then thereceived high voltage signal is converted into -9 voltage level by IC232.

  • 8/8/2019 Report of Infrared

    16/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

  • 8/8/2019 Report of Infrared

    17/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    File transfer using com port

    This program written in Turbo C uses the pcs serial port, also known as com

    port or RS-232, to transfer files between two computers. The hard ware used is quitesimple and economical, as only 3-core cable with 9-pin D connectors on e ither side is

    required to connect the infrared module which consists of some electroniccomponents and the MAX232 IC and 555 IC .

    COM port communication basics

    Data communication equipment (DCE) and data terminal equipment (DTE)use serial cables for communication. Examples of data communication equipment anddata terminal equipment are modems & computers (or terminals), respectively.

    To connect the two computers (DTES) together, we can use the null-modem

    configuration. The Wiring diagram for the null modem configuration is shown in

    Fig 1. The signal details on the 9-pinD connector are given in Table 1.

    In null modem configuration, only three wires are required (TD, RD, andSG) to connect the ports. Thus it is more cost effective for long cable runs.

    In this wiring configuration a computer thinks that it is talking to a modemrather than another computer. Any data transmitted from one computer must bereceived by the other, so TD pin of first PC is connected to RD pin of the other PC.The second PC also must have a similar set up. Thus its TD pin is connected to RD

    pin if the former computer. Signal ground (SG) pins of both the PCs must be

    connected together, so that the ground forms the common reference for the RS-232Csignals from to each computer.

    The data terminal ready (DTR) signal is looped back to data set ready (DSR)

    and carrier detect (CD) on both the computers. Hence when DTR is active, DSR andCD immediately become act ive. The computer now thinks the configuration to which

    it is connected is that of a virtual modem in ready state. When the computer has tosend data , it makes requesttosend (RTS) high .As this signal is looped back to thecomputers own clearance -to-send (CTS) signal pin, the computer immediately getsa reply that its okay to send .Weve not used the ring indicator (pin 9) as it is notrequired in this configuration.

    Programming for communication

    There are two methods for writing the program, namely, polling method andinterrupt method.

    Polling method In this method, the UART is repeatedly checked for any new datain its receive buffer.

    Interrupt method- An interrupt handler is used to remove the data from the UARTwhen an interrupt is generated.

  • 8/8/2019 Report of Infrared

    18/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    The port base address and IRs for com ports are as follows:

    Name Address IR Int (Hex)COM1 3F8 4 0CCOM2 2F8 3 0B

    COM3 3E8 4 0CCOM4 2E8 3 0B

    We use inport ( ) and outport ( ) instructions to read and write to the registersused for serial communication. Var ious registers with their addresses (related to theirport base addresses) are shown in table II .Though there are only eight addresses , weare able to control twelve registers by using divisor latch enable bit (DLAB) , i.e.,

    bit 7 of the line control register. Bit functions of the line control register are shown inTableIII.

    UART settingsAs the computer works with data in parallel form, we need the serial

    transmission converted back to parallel format so that data could be used .This can bedone using universal asynchronous receiver transmitter (UART) chip.

    In order to use the UART, we first need to make certain register settings. Thesequential steps for polling method are given below:

    1. Stop interrupts generation on the UART, so that the UART doesnt interrupt the

    initialization.2. Now the interrupt vector is set.

    3.

    The next step is to set the speed at which the communication takes place. This isdone by setting bit 7 (DLAB) of the LCR (refer TableIII) to logic 1, so as to have

    an access to divisor latch high and low bytes. Some common baud rates and thecorresponding hex values we used to set the high & low bytes are shown in tableiv .(Baud rates are based on the assumption that the UART utilizes a 1.832 MHzcrystal , which is divided by 16 inside the UART to obtain basic baud rate of

    115,200 bits/sec.)

    4. Then we set the divisor latch -low byte in the registers as per the address shown inTableII.

    5. The next step is to reset /turn off the divisor latch access bit (DLAB) and set the

    word length and parity in the LCR .Here weve selected the word length as 8 bits,

    no parity, and one stop bit. This is done by moving 0x03 to the line controlregister .As this will also turn off the LAB, we can access the interrupt enable

    register and receiver and transmitter buffers.

    6. Now the FIFO buffers are turned on and cleared.7. DTR, RTS, and OUT 2 are made high in modem control register.

  • 8/8/2019 Report of Infrared

    19/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Running the program

    The following steps need to be taken before running the program:

    1. Connect both the computers via their com ports.

    2.

    Use the correct com port address at the respective computers. One easy way todetermine this is using a loop back plug with connections as shown in figure.2 .It

    has the same configuration as that of a null-modem, but only one computer is used

    in this configuration with its TD pin 3 shorted to RD pin 2 .In this configuration,the computer receives what it sends.

    3. It is better to run this program in DOS mode .So, if required, shut down windowsand restart in DOS mode before execution.

    COMPUTER A COMPUTER B

    PIN SIG. SIG. PIN

    3 TD RD 2

    2 RD TD 3

    5 SG SG 5

    4 DTR DTR 4

    6 DSR DSR 6

    1 CD CD 1

    7 RTS RTS 7

    8 CTS CTS 8

    9 RI RI 9

    Wiring for the null -modem configuration

  • 8/8/2019 Report of Infrared

    20/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    TABLEI

    D-Type 9-Pin Connector Details

    D-Type 9-Pin No. Abbreviation Full Name

    Pin3 TD Transmit data

    Pin2 RD Receive dataPin7 RTS Request to send

    Pin8 CTS Clear to send

    Pin6 DSR Dataset ready

    Pin5 SG Signal ground

    Pin1 CD Carrier detect

    Pin 4 DTR Data terminal ready

    Pin9 RI Ring indicator

    TDThis pin is used to send the data.RDThis pin is used to receive data.

    RTS - Used in modem communication, this pin tells that the UARTIs ready to send data.

    CTS- It indicates that the modem is ready to exchange data.

    DSR- It tells the UART that the modem is ready to establish a link.SG- Signal ground.

    CD - This pin is high when the modem detects a carrier from theModem at the other end of the phone.

    DTR- It tells the modem that the UART is ready to link.RI- This pin is high when the modem receives a ring from the public

    Switched telephone network (PSTN).

    TABLE II

    Registers With Their Addresses

    Base address DLAB* Read/Write Abbreviation Register name

    +0 =0 Write ---- Transmitter holding buffer

    +0 =0 Read ---- Receive buffer

    +0 =1 Read/ Write ---- Device latch- low byte

    +1 =0 Read/ Write IER Interrupt enable register

    +1 =1 Read/ Write ---- Device latch-high byte+2 --- Read IIR Interrupt Identificat ion register

    +2 --- Write FCR FIFO control register

    +3 --- Read/Write LCR Line control register

    +4 --- Read/ Write MCR Modem control register

    +5 --- Read LSR Line status register

    +6 --- Read MSR Modem status register

    +7 --- Read/ Write ---- Scratch register

    *DLAB- Divisor latch access bit

  • 8/8/2019 Report of Infrared

    21/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

  • 8/8/2019 Report of Infrared

    22/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    /* This is a program to transfer the file,receive the text file and chat between the twocomputers, using the infra red module connectedto the RS-232 port on the each computer */

    #include#include#include#include //for toupper#include //for clock#include#include //forgetch,putch,textcolor...#include //for bioscom#include //for file functions#include //fordelay,inport,outport...

    #define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00)//baud 1200, 7 data bits, no parity, 1 stop bit#define DEL 25 //Delay time#define COM 0x03f8 //Specifies to com address

    int ralgn(void); //device alignment forreceivingint initial(); //Initialisationint f_rcv(); //file receive functionint salgn(void); //device alignment forsendingint splash(void);int f_snd(); //file sending functionvoid welcome();

    void chatwindow(); //draws the chat window void chatting(); //chatting functionvoid dsply(char *, int);char gra='Y';int flag=0;union REGS inregs,outregs; //The union REGS isused to// pass information to and from inbuilt functionint 86FILE *fp;

    int status;

  • 8/8/2019 Report of Infrared

    23/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    char temp='\n',t2;int t1=10;

    /*main funtion*/

    void main(void){

    char ch,chr,chs;clrscr();if(flag==0){

    flag++;welcome(); // calls the welcome

    function}clrscr();textbackground(0);textcolor(4);gotoxy(30,6);cprintf("INFRARED COMMUNICATION");gotoxy(34,9);textcolor(10);cprintf("R");

    textcolor(7);cprintf("eceive mode");textcolor(14);gotoxy(35,12);cprintf("S");textcolor(7);cprintf("end mode");textcolor(9);gotoxy(36,15);

    cprintf("C");textcolor(7);cprintf("hatting");gotoxy(38,18);textcolor(6);cprintf("E");textcolor(7);cprintf("xit");ch=getch();switch(toupper(ch))

  • 8/8/2019 Report of Infrared

    24/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    {case 'R':R:clrscr(); //Enters to the

    receive menu

    textcolor(4);gotoxy(30,6);cprintf("INFRARED

    COMMUNICATION");textcolor(138);gotoxy(33,9);cprintf("RECEIVE MODE");textcolor(9);gotoxy(33,12);cprintf("A");textcolor(7);cprintf("lign device");textcolor(11);gotoxy(33,15);cprintf("F");textcolor(7);cprintf("ile receive");textcolor(6);gotoxy(36,18);

    cprintf("Q");textcolor(7);cprintf("uit");chr=getch();switch(toupper(chr)){case 'A':ralgn();

    break;case 'F':f_rcv();

    break;case 'Q':main();default:clrscr();

    printf("Wrong keypressed");

    delay(2000);goto R;

    }break;

  • 8/8/2019 Report of Infrared

    25/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    case 'S':S:clrscr(); //Enters in to thesend menu

    textcolor(4);gotoxy(30,6);

    cprintf("INFRAREDCOMMUNICATION");textcolor(142);gotoxy(36,9);cprintf("SEND MODE");textcolor(9);gotoxy(34,12);cprintf("A");textcolor(7);cprintf("lign device");textcolor(11);gotoxy(34,15);cprintf("T");textcolor(7);cprintf("ransfer file");textcolor(6);gotoxy(38,18);cprintf("Q");textcolor(7);

    cprintf("uit");chs=getch();switch(toupper(chs)){case 'A':salgn();

    break;case 'T':f_snd();

    break;case 'Q':main();

    default:clrscr();printf("Wrong keypressed");

    delay(2000);goto S;

    }break;

    case 'C':clrscr(); //Enters into thechatting

    textbackground(0);

    chatwindow();

  • 8/8/2019 Report of Infrared

    26/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    chatting();main();break;

    case 'E':clrscr(); //Exits from main

    menu textcolor(143);gotoxy(35,13);splash();delay(2000);exit(1);break;

    default:clrscr();printf("Wrong key pressed");main();return;

    }}

    // function for recive(for device alingment)

    int ralgn(void){

    char st = ' ';

    clrscr();gotoxy(30,2);textcolor(10);cprintf("RECIVE MODE");textcolor(9);cprintf("ALIGN DEVICE");printf("\n");initial();loop:

    if (!kbhit()){if(st==0x04){

    clrscr();textcolor(140);gotoxy(30,12);cprintf("Aligned properly");gotoxy(48,24);printf("press any key to quit");

    getch();

  • 8/8/2019 Report of Infrared

    27/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    main();}

    status=inp(0x3fd);if((status && 0x01)==0x00)

    goto loop;else if(!kbhit()){

    st=inp(COM);printf("%c",st);goto loop;

    }else

    main();}main();return 0;

    }

    // function for file receive

    int f_rcv(){

    int flag=0,bytecount=0,count;

    float ot=0.00,nt=0.00;char ch,st[5500],fnm[30];clrscr();initial();ot=clock()/18.2;gotoxy(2,2);printf("FILE NAME?:");fp=fopen(gets(fnm),"wb");gotoxy(26,10);

    printf("(Ready for)RECEIVING DATA");gotoxy(47,24);textcolor(138);cprintf("Don't Press any KEY data may loss");loop:nt=clock()/18.2;status=inp(0x3FD);

    if((status & 0x01)==0x00)

    {

  • 8/8/2019 Report of Infrared

    28/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    /*check for no data reception for five/*seconds after start of reception if no

    data is/* received continue other process*/

    if((bytecount>0)&&(nt-ot)>5.0){clrscr();for(count=0;count

  • 8/8/2019 Report of Infrared

    29/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    {clrscr();for(count=0;count

  • 8/8/2019 Report of Infrared

    30/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    if(!kbhit()){

    outport(COM,0x0D);outport(COM,0x0A);

    if(flag==strlen(st)){printf("/n");flag=0;outport(COM,0X0D);delay(5);outport(COM,0X0A);delay(5);

    }else{

    outport(COM,st[flag]);printf("%c",st[flag]);flag++;delay(DEL);

    }}if(kbhit()){

    delay(1);outport(COM,0X04);main();

    }}while(!kbhit());

    return 0;}

    /*function for file transfer*/

    int f_snd(){

    int flag=0,count=0,fl;char ch,st[55000],fnm[20];clrscr();initial();gotoxy(2,2);printf("FILE NAME ? : ");

    gets(fnm);

  • 8/8/2019 Report of Infrared

    31/51

  • 8/8/2019 Report of Infrared

    32/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    delay(DEL);}

    }while(!kbhit());

    return 0;}

    /*initialisation funtion*/

    int initial(){

    inregs.h.ah=0;//The 0 is used to initialize the specifiedserial //communications port to a desired baudrate, parity, //word length and number of stopbits.

    inregs.h.al=0x63;//sets the baud rate to 600, none parity, onestop bit //and word length is 8bits

    inregs.x.dx=0;//DX=communication port number (0=COM1,1=COM2,etc )

    int86(0x14,&inregs,&outregs);

    return 0;}

    /*function for splash screen*/

    int splash(void){

    int d=DETECT,m,j,i;struct palettetype pal;

    initgraph(&d,&m,"c:\\tc\\bgi");setcolor(15);settextstyle(1,0,4);setbkcolor(9);for(i=0;i

  • 8/8/2019 Report of Infrared

    33/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    }sleep(2); //suspends the execution for 2

    secondscleardevice();

    for(i=0;i

  • 8/8/2019 Report of Infrared

    34/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    clrscr();textcolor(3);window(1,1,80,25);for(i=0;i

  • 8/8/2019 Report of Infrared

    35/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    void chatting(){

    char msg[80],msg_in[80];

    int status,out,in,count=0,count_in=0,i,extra;bioscom(0, SETTINGS, COM); //init. port//alternative to outportb(),particularly for

    RS 232

    communication.window(3,23,80,23); //message entry

    windowwhile (1){

    status = bioscom(3, 0, COM);if (status & 0x100){

    if ((out = bioscom(2, 0, COM) &0x7F) != 0)

    // input message byte.msg_in[count_in++]=out;

    if(out==13){

    dsply(msg_in,10);count_in=0;gotoxy(count+1,1);

    }}if (kbhit()) //character entered{

    gotoxy(count+1,1);if ((in = getche()) == 27)

    { textbackground(0);window(1,1,80,25);

    break;}if(in==0){

    in= getch();//special function key pressed, ignore

    continue;

  • 8/8/2019 Report of Infrared

    36/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    }if(in==8 && count>0){

    count-=2;

    cprintf(" \b"); //BackSpace}else

    msg[count]=in;if(count==70){

    in=13;msg[70]=13;

    }count++;if(in==13 ) //Enter: Send{

    i=0;dsply(msg,14);for(i=0;i

  • 8/8/2019 Report of Infrared

    37/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    textcolor(col);gotoxy(1,line);putch('\n');putch(175);

    while(str[i]!=13){putch(str[i]);i++;

    }line=wherey(); //store present linewindow(3,23,80,23); //message enter windowtextbackground(3);textcolor(1);

    }

    // Function to show the welcome screen

    void welcome(){

    int i,j;clrscr();textcolor(4);gotoxy(24,5);

    cprintf("Welcome to PC to PC Communication");gotoxy(28,6);cprintf("Using infrared device");textcolor(2);gotoxy(25,7);cprintf("By Adarsha, Jagadish & Suman ");sleep(1);window(10,9,70,23);textbackground(1);

    clrscr();textcolor(3);window(1,1,80,25);for(i=0;i

  • 8/8/2019 Report of Infrared

    38/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    {gotoxy(10,3+j);

    putch(186); //gotoxy(70,3+j);

    putch(186); //}gotoxy(10,3); putch(201); //gotoxy(70,3); putch(187); //gotoxy(10,23); putch(200); //gotoxy(70,23);

    putch(188); //sleep(1);gotoxy(15,10);window(12,11,68,22);cprintf("To start wireless communication

    between the""two computers, connect infrared device

    module to ""serial port COM1 of each computer.");

    gotoxy(3,12);cprintf("Press any key to start....");window(1,1,80,25);getch();

    }

  • 8/8/2019 Report of Infrared

    39/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    OUTPUT:

    Welcome window of pc to pc communication software

  • 8/8/2019 Report of Infrared

    40/51

  • 8/8/2019 Report of Infrared

    41/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Window after the device has been aligned.

  • 8/8/2019 Report of Infrared

    42/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Choosing the send mode

    Send mode window

    Type the path of the file to be sent

  • 8/8/2019 Report of Infrared

    43/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Contents of the file to be sent

  • 8/8/2019 Report of Infrared

    44/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Choosing the receive mode on the other terminal

    Receive mode window

  • 8/8/2019 Report of Infrared

    45/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    Set the path of the file to be received

    Window after receiving the file

  • 8/8/2019 Report of Infrared

    46/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    CHATTING

    Choose the chatting mode from the main menu to chat with the person on othercomputer

    Window used for chatting

  • 8/8/2019 Report of Infrared

    47/51

  • 8/8/2019 Report of Infrared

    48/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    FEATURES:

    Maximum transmission rate of 2400 bps .

    Half duplex operation. Efficient convers ion of RS232TTL by a single chip

    Simple interface through standard 9-pin cable. IR modulating frequency is 36 KHZ

  • 8/8/2019 Report of Infrared

    49/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    ADVANTAGES:

    The advantage of this project over traditional wired networks is

    1. This system provides the users to access the information any where in theorganization.

    2. Installing this system is fast & easy & can eliminate the need to pull cable through

    walls and ceilings.3. This system is suited for the organization requiring frequent moves and changes.

    If the distance and the speed of the data transfer are increased in this project, it canbe used for many applications like

    1. Sending data from computer to printer.

    2. It can be used in fax machine overhead projectors etc.

    The distance can be increased by

    1. Increasing the modulating frequency.

    2. By providing repeater circuit.3. Using additional IR LEDs.

    Using higher version ports can increase the speed of data transfer.

    It is very much applicable to use in sensitive areas like gas stations, oil refineries

    etc... Where other forms of wireless communication may be dangerous as they might

    produce electrical sparks and may cause disasters.Infrared wireless communication module is very much safer and cheaper compared

    to other systems.

    It is highly compatible with all types of PCs and it works with all versions ofwindows, as it is DOS based.

    The software has a user-friendly text interface written in C.

    CONCLUSION:

    This is one of the efficient communicating methods compared to other methodbecause it is very easy to communicate and also there is no need to have network of

    card for communication. Moreover it is very cheaper than compared to other formsof wireless communication method.

  • 8/8/2019 Report of Infrared

    50/51

    C Program for file transfer through infra red media

    Dept. of Computer Science & Engineering S.J.P

    BIBLOGRAPHY

    INTRODUCTION TO DIGITAL AND ANALOG COMMUNICATION-SIMON HAYKIN

    http://www.anglefire.com/electronic

    http://www.electronicsforu.com

    http://www.ee.ed.ac.uk/~kap/Haed/555

    http://www.docu-track.com

    ELECTRONICS FOR YOU, MAGAZINE, APRIL 2002 ISSUE

    http://www.anglefire.com/electronichttp://www.anglefire.com/electronichttp://www.electronicsforu.com/http://www.electronicsforu.com/http://www.ee.ed.ac.uk/~kap/Haed/555http://www.docu-track.com/http://www.docu-track.com/http://www.docu-track.com/http://www.ee.ed.ac.uk/~kap/Haed/555http://www.electronicsforu.com/http://www.anglefire.com/electronic
  • 8/8/2019 Report of Infrared

    51/51

    C Program for file transfer through infra red media


Recommended