Lpu Report

download Lpu Report

of 45

Transcript of Lpu Report

  • 7/27/2019 Lpu Report

    1/45

    Embedded Systems

    A Training/project report submitted in partial fulfillment of the requirements forthe award of the degree of

    Bachelor of Technology

    By

    Kumar Satyam (11003378)

    Lovely Professional University JalandharDelhi G. T

    Road (NH-1),

    Phagwara, Punjab, 144402, India

    2013

  • 7/27/2019 Lpu Report

    2/45

  • 7/27/2019 Lpu Report

    3/45

    II

    OBJECTIVE OF TRAINING

    A microcontroller can lift up many of our everyday life work, making work more facile and

    require of less human physical effort. So where the microcontroller is the brain of the machine

    we somehow need to control it. Would not it much more convenient if we were to sitcomfortably in our chairs and let the press of a button do our job? Such a luxury is provided by

    the communication between the machine and our switch over the RF. In this project such a work

    is shown by controlling motors to run in a direction we want through wireless control and using

    8051 microcontroller. So where, where the motors should run would be decided by us (whether

    left or right, forward or backward) the microcontroller would be the one to actually process our

    data and move the motors in that direction. RF module is used for the wireless communication

    here. Therefore with projects like such and with increasing its dimension we can achieve a lot

    more than just rolling motors.

  • 7/27/2019 Lpu Report

    4/45

    III

    ACKNOWLEDGEMNET

    First,I would like to express my best regards to our project guide Mr.Chirajeet kumar,

    whose valuable guidance, encouragement, and provision of necessary facilities made this work

    possible.

    Many thanks are owed to my group mates for their useful discussion and timely suggestions.

    Their technical support and encouragement helped me to finalize our project.

    Our special thanks to Mr. Abhishekwho helped me a lot through the problems we came across.

    We would also like to express our gratitude towards the Cetpa Infotech Pvt. Ltd. for

    providing me with the best facilities and proper environment to work on my project.

    Finally I offer my great thanks and regards to my family for their support which helped

    us through the difficulty and hardships of life to earn this achievement.

  • 7/27/2019 Lpu Report

    5/45

    IV

    TABLE OF CONTENTS

    Title Pgae no

    DECLARATION..

    OBJECTIVE.

    ACKNOWLEDGEMENT

    LIST OF TABLES

    LIST OF FIGURES..

    CHAPTER 1 INTORDUCTION

    1.1Embedded Systems.

    1.2Microcontroller families

    CHAPTER 2 COMPANY PROFILE

    2.1 Introduction

    CHAPTER 3 IDENTIFICATION OF TRAINING

    3.1 work done in company.

    3.2 Assembly Language and Instruction set of 8051

    3.2.1 Introduction

    3.2.2 Addressing Modes..

    3.2.3 Instruction types.

  • 7/27/2019 Lpu Report

    6/45

    3.3 Interrupts.

    3.4 Serial Communication.

    CHAPTER 4 IMPLEMENTATION DETAIL

    4.1

    LED Interfacing..

    4.27 SEGMENT Interfacing..

    4.3LCD interfacing.

    4.4DC MOTORInterfacing..

    4.5Project(RF controlled robo car)

    V

    4.5.1 Introduction.

    4.5.2 Rf Module

    4.5.3 HT12E.

    4.5.4 HT12D.

    4.5.5L293D

    4.5.6 DC geared motor..

    4.5.7 Design Details..

    4.5.7.1 Receiver Design

    4.5.7.2 TransmitterDesign

    4.5.7.3 Source code .

    CHAPTER 5 RESULT AND DISCUSSION

    5.1Introduction

    5.2Discussion.. .

    5.2.1 Conclusion ...

    5.2.2 Future Scope

    REFERENCES.

  • 7/27/2019 Lpu Report

    7/45

    VI

    LIST OF TABLES

  • 7/27/2019 Lpu Report

    8/45

    VII

    LIST OF FIGURES

  • 7/27/2019 Lpu Report

    9/45

    VIII

    CHAPTER 1

    INTRODUCTION

    1.1EMBEDDED SYSTEMSAn embedded system is a special-purpose system in which the computer is completely

    encapsulated by the device it controls. Unlike a general-purpose computer, such as a personal

    computer, an embedded system performs pre-defined tasks, usually with very specific

    requirements. Since the system is dedicated to a specific task, design engineers can optimize

    it, reducing the size and cost of the product. Embedded systems are often mass-produced, so

    the cost savings may be multiplied by millions of items.

  • 7/27/2019 Lpu Report

    10/45

    Handheld computers or PDAs are generally considered embedded devices because of the

    nature of their hardware design, even though they are more expandable in software terms.

    This line of definition continues to blur as devices expand.

    Physically, embedded systems range from portable devices such as digital watches and MP3

    players, to large stationary installations like traffic lights, factory controllers. Complexity

    varies from low, with a single microcontrollerchip, to very high with multiple

    units, peripherals and networks mounted inside a large chassis or enclosure.

    Embedded systems contain processing cores that are eithermicrocontrollers ordigital signal

    processors (DSP). The key characteristic, however, is being dedicated to handle a particular

    task. Since the embedded system is dedicated to specific tasks, design engineers can optimize

    it to reduce the size and cost of the product and increase the reliability and performance.

    Some embedded systems are mass-produced, benefiting from economies of scale.

    Robotics and automation are a part of embedded systems itself. Robot development and

    automation needs study of embedded systems.

    1

    Examples of Embedded System are

    I. automatic teller machines (ATMs)

    II. avionics, such as inertial guidance systems, flight control hardware/software and

    other integrated systems in aircraft and missiles

    III. cellular telephones and telephone switches

    IV.

    computer equipment such as routers and printersV. engine controllers and antilock brake controllers for automobiles

    Characteristics of Embedded Systems

    1. Embedded systems are designed to do some specific task, rather than be a general-

    purpose computer for multiple tasks. Some also have real-time performance constraints

    http://en.wikipedia.org/wiki/Digital_watchhttp://en.wikipedia.org/wiki/Digital_audio_playerhttp://en.wikipedia.org/wiki/Digital_audio_playerhttp://en.wikipedia.org/wiki/Traffic_lighthttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Peripheralhttp://en.wikipedia.org/wiki/Chassishttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Economies_of_scalehttp://en.wikipedia.org/wiki/Economies_of_scalehttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Digital_signal_processorhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Chassishttp://en.wikipedia.org/wiki/Peripheralhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Traffic_lighthttp://en.wikipedia.org/wiki/Digital_audio_playerhttp://en.wikipedia.org/wiki/Digital_audio_playerhttp://en.wikipedia.org/wiki/Digital_watch
  • 7/27/2019 Lpu Report

    11/45

    that must be met, for reasons such as safety and usability; others may have low or no

    performance requirements, allowing the system hardware to be simplified to reduce costs.

    2. The program instructions written for embedded systems are referred to as firmware, and

    are stored in read-only memory orFlash memory chips. They run with limited computer

    hardware resources: little memory, small or non-existent keyboard or screen.

    3. Many embedded systems consist of small, computerized parts within a larger device that

    serves a more general purpose. For example- a line follower autonomous robot which

    follows a specific path and moves accordingly to the path.

    4. The embedded systems are special purpose computer systems designed to perform only

    the specific purposes. For Example- a system designed to display numbers cannot be used

    to operate motors.

    Table 1.1: Microcontrollers v/s Microprocessors

    Microcontrollers Microprocessors

    1. A Microcontroller (sometimes

    abbreviated C, uC orMCU) is a small

    computer on a single integrated

    circuit containing a processor core,

    memory, and

    programmable input/outputperipherals.

    1. A Microprocessor is an IC which

    has only the CPU inside them i.e. only

    the processing powers such as Intels

    Pentium 1,2,3,4, core 2 duo, i3, i5 etc.

    2. Microcontrollers are designed to

    perform specific tasks. Specific means

    applications where the relationship of

    input and output is defined. Depending

    on the input, some processing needs to

    be done and output is delivered. For

    example, keyboards, mouse, washing

    machine, digicam, pen drive, remote,

    microwave, cars, bikes, telephone,

    mobiles, watches, etc.

    2. Microprocessor find applications

    where tasks are unspecific like

    developing software, games, websites,

    photo editing, creating documents etc.

    http://en.wikipedia.org/wiki/Firmwarehttp://en.wikipedia.org/wiki/Flash_memoryhttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Flash_memoryhttp://en.wikipedia.org/wiki/Firmware
  • 7/27/2019 Lpu Report

    12/45

    3. Since the applications are very

    specific, they need small resources like

    RAM, ROM, I/O ports etc. and hence

    can be embedded on a single chip.

    3. In such cases the relationship

    between input and output is not

    defined. They need high amount of

    resources like RAM, ROM, I/O ports

    etc. So needs external RAM, ROM and

    Memory.

    4. The microcontrollers operate from a

    few MHz to 30 to 50 MHz

    4. The microprocessor operates above

    1GHz as they perform complex tasks.

    5.The microcontroller is designed for

    embedded applications.

    Microcontrollers are used in

    automatically controlled products and

    devices, such as automobile engine

    control systems.

    5.The microprocessors are used

    in personal computers or other general

    purpose applications such as for laptops

    and heavy applications where

    complexity is more and memory

    requirements are high.

    1.2 MICROCONTROLLER FAMILIES

    8051-These microcontrollers are old but still trendy and most of the companies fabricate these

    microcontrollers. The older types of 8051 have 12 clocks per instruction that make it sluggish

    whereas the recent 8051 have 6 clocks per instruction. The 8051 microcontroller does not have

    an in built memory bus and A/D converters. In 1980, Intel fabricated the single chipmicrocontroller 8051 with Harvard architecture.

    PIC-Programmable Interface Controller is usually referred as PIC. They are slightly older than

    8051 microcontrollers but excel cause of their small low pin count devices. They perform well

    http://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Personal_computerhttp://www.engineersgarage.com/8051-microcontrollerhttp://www.engineersgarage.com/articles/pic-microcontroller-tutorialhttp://www.engineersgarage.com/articles/pic-microcontroller-tutorialhttp://www.engineersgarage.com/8051-microcontrollerhttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Microprocessor
  • 7/27/2019 Lpu Report

    13/45

    and are affordable. The Microchip technology fabricated the single chip microcontroller PIC

    with Harvard architecture. The programming part is very tedious and hence it is not

    recommended for beginners.

    AVR(Advanced Version RISC) - In 1996, Atmel fabricated this single chip microcontroller with

    a modified Harvard Architecture. This chip is loaded with C- compiler, Free IDE and many more

    features. This microcontroller is a bit difficult for the starters to handle.

    CHAPTER 2

    COMPANY PROFILE

    2.1 INTRODUCTION

    CETPA InfoTech Pvt. Ltd. is an ISO 9001:2008 Certified Company deals in the field of

    Software Development, Embedded Products Development, Placement Consultancy and

    Engineers Training Programs. CETPA is the mission, which is working for the promotion of

    latest technologies in India and abroad. To achieve our goal, we have made collaboration with a

    http://www.engineersgarage.com/articles/avr-microcontrollerhttp://www.engineersgarage.com/articles/avr-microcontrollerhttp://www.engineersgarage.com/articles/what-is-compiler-tutorialhttp://www.engineersgarage.com/articles/what-is-compiler-tutorialhttp://www.engineersgarage.com/articles/avr-microcontroller
  • 7/27/2019 Lpu Report

    14/45

    number of institutions and firms. CETPA deals in three different domains, first is education,

    second is development and third is consultancy.

    CETPA Education:

    CETPA Education mainly deals in Engineers Training Programs in latest technologies for

    Engineering students, corporate and other professionals. Some of the technologies offered for

    training are .NET, VHDL, Embedded System, Advance Embedded System, CATIA, MATLAB,

    J2EE, Verilog HDL, Linux, AutoCAD, PCB & Circuit Designing, and Personality &

    Entrepreneurship Development.

    CETPA Consultancy:

    CETPA Consultancy helps to provide jobs for different field s students and professionals.

    CETPA consultancy was started to provide jobs to CETPA Certified students, who are made

    technologically strong by CETPA, are well placed by CETPA Consultancy. Hence the fresher

    trained by us are well absorbed in companies.

    CETPA Development:

    CETPA development deals in software as well as embedded production development. In

    software domains, CETPA offers customized software products, web development, web

    hosting, search engine optimization and other related products. In embedded domain, CETPA

    has developed a number of solutions like moving message displays, token display systems for

    private as well government organizations.

    Table 2.1: CETPA Corporate Training Clients

  • 7/27/2019 Lpu Report

    15/45

  • 7/27/2019 Lpu Report

    16/45

    CHAPTER 3

    IDENTIFICATION OF TRAINING

    3.1 WORK DONE IN COMPANY

    ARCHITECTURE OF 8051

    The most commonly used microcontroller is 8051 families AT89C51 microcontroller which is

    produced by Atmel. It is widely used in most of the application for having an advantage of

    simple programming and low cost.

    AT89C51

    AT89C51 is an 8-bit, 40 pin microcontroller that belongs to Atmel's8051 family.ATMEL

    89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes

    of RAM. It can be erased and program to a maximum of 1000 times.

    In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit

    bi-directional ports, i.e., they can be used as both input and output ports. Except P 0 which needs

    external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins,

    they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit

    addressable and so their bits can also be accessed individually.

    FIG. 3.1:

    BLOCK DIAGRAM OF 8051

    http://www.engineersgarage.com/8051-microcontrollerhttp://www.engineersgarage.com/8051-microcontrollerhttp://www.engineersgarage.com/8051-microcontrollerhttp://www.engineersgarage.com/8051-microcontroller
  • 7/27/2019 Lpu Report

    17/45

    Address bus-For a device (memory or I/O) to be recognized by the CPU, it must beassigned an

    address. The address assigned to a given device must be unique. The CPU puts the address on

    the address bus, and the decoding circuitry finds the device.

    Data bus-The CPU either gets data from the deviceor sends data to it.

    Control bus-Provides read or write signals to the device to indicate if the CPU is asking for

    information or sending it information .

    FIG.3.2: PIN DIAGRAM OF 89C51

    Memory and Registers

    The 8051 microcontroller has a total of 256 bytes of RAM in which 128 is visible or user

    accessible and extra 128 is for special function registers.

    The user accessible RAM is used for temporary data storage. The user accessible RAM is from

    the address range 00 to 7Fh.

    From the user accessible RAM, 32 bytes of RAM is used for registers and rest for Stack

    operations. The 32 Bytes of RAM is divided into four register Banks i.e. Bank0, Bank 1, Bank 2,

    Bank3. Each of these banks have 8 Registers i.e. R0 to R7 each.

    RAM locations from 0 to 7 are set aside for bank 0 of R0 R7 where R0 is RAM location 0, Rl

    is RAM location 1, and R2 is location 2, and so on, until memory location 7, which belongs to

  • 7/27/2019 Lpu Report

    18/45

    R7 of bank 0. The second bank of registers R0 R7 starts at RAM location 08 and goes to

    location 0FH. The third bank of R0 R7 starts at memory location 10H and goes to location

    17H. Finally, RAM locations 18H to 1FH are set aside for the fourth bank of R0R7.

    FIG.

    3.3: BANKS OF 89C51

    Generally for normal operations, Register bank Bank0 is set by default. But we can switch to

    other banks by using PSW Commands.

    FIG. 3.4: BANK ADDRESS OF 89C51

    SFRs (Special Function Register) - These Registers are in extra 128 bytes of the memory. This

    part of memory is not user accessible and these registers are used for special purposes. These

    registers range from 80h to FFh. There are a total of only 21 SFRs in this range and all other

    addresses from 80h to FFh are invalid and there use can cause errors and not valuable results.

    Some of the SFRs are TCON, SBUF, ACC, B, SCON, TMOD SP, P0, PSW, TL0, and TL1.

    These all the registers have some specific function that has to be performed after they are

    programmed.

    (i) Byte Addressable SFR with byte address

    SPStack printer81H

    DPTRData pointer 2 bytes

    DPLLow byte82H

    DPHHigh byte83H

  • 7/27/2019 Lpu Report

    19/45

    TMODTimer mode control89H

    TH0Timer 0 Higher order bytes8CH

    TL0Timer 0 Low order bytes8AH

    TH1Timer 1 High bytes = 80H

    TL1Timer 1 Low order byte = 86H

    SBUFSerial data buffer = 99H

    PCONPower control87H.

    DPTR- Data Pointer in 8051

    16 bit register; it is divided into two parts DPH and DPL.

    DPH for Higher order 8 bits, DPL for lower order 8 bits.

    DPTR, DPH, DPL these all are SFRs in 8051.

    3.2ASSEMBLY LANGUAGE AND INSTRUCTION SET OF 80513.2.1 Introduction

    Assembly language is instructional language which contains instruction in the form of

    Mnemonics.

    How to Program an 8051 microcontroller

    [Label:] mnemonic [operands] [; comment]

    Mnemonics -Assembly level instructions are called mnemonic like MOV R5

    Operands -On which the operation is performed.

    Example:

    Loop: MOVR1, #25H; transfer 25H into R1

    Label mnemonics operand comments

    3.3.2 Addressing Modes

    Table 3.2

  • 7/27/2019 Lpu Report

    20/45

    Addressing modes Instructions

    Register MOV A, B

    Direct MOV 30H,A

    Indirect MOV A,@R0

    Immediate MOV A,#80H

    Relative SJMP +127/-128 of PC

    Absolute AJMP within 2K

    Long LJMP FAR

    Indexed MOVC A,@A+PC

    Register Addressing Mode-The register addressing instruction involves information transfer

    between registers

    Example:

    MOV R0, A

    Direct Addressing Mode- This mode allows you to specify the operand by giving its actual

    memory address (typically specified in hexadecimal format) or by giving its abbreviated name

    (e.g. P3).Used for SFR accesses

    Example:

    MOV A, P3; Transfer the contents of Port 3 to the accumulator

    Indirect Addressing Mode-In the Indirect Addressing mode, a register is used to hold the

    effective address of the operand. This register, which holds the address, is called the pointer

    register and is said to point to the operand. Only registers R0, R1 and DPTR can be used as

    pointer registers. R0 and R1 registers can hold an 8-bit address whereas DPTR can hold a 16-bit

    address. DPTR is useful in accessing operands which are in the external memory.

    Examples:

    MOV @R0, A; Store the content of accumulator into the memory location pointed to by the

    contents of register R0. R0 could have an 8-bit address, such as 60H.

    Immediate Addressing Mode-In the Immediate Constant Addressing mode, the source operand

    is an 8- or 16-bit constant value. This constant is specified in the instruction itself (rather than in

  • 7/27/2019 Lpu Report

    21/45

  • 7/27/2019 Lpu Report

    22/45

    Arithmetic Instructions of 8051 are shown as follows-

    [@ RI] implies contents of memory location pointed to by R0 or R1.

    Rn refers to registers R0-R7 of the currently selected register bank.

    Table 3.3: Arithmetic Instruction set of 8051

    Logical Instructions-Logical instructions perform standard Boolean operations such as AND,

    OR, XOR, NOT (compliment). Other logical operations are clear accumulator, rotate

    accumulator left and right, and swap nibbles in accumulator.

    Examples:

    ANL A, #02H; Mask bit 1

    ORL TCON, A; TCON=TCON OR A

    Table 3.4: logical Instruction set

  • 7/27/2019 Lpu Report

    23/45

    Data Transfer Instructions- Data transfer instructions can be used to transfer data between an

    internal RAM location and an SFR location without going through the accumulator.

    It is also possible to transfer data between the internal and external RAM by using indirect

    addressing. The upper 128 bytes of data RAM are accessed only by indirect addressing and the

    SFRs are accessed only by direct addressing.

    Table 3.5: Instructions for Data Transfer-

  • 7/27/2019 Lpu Report

    24/45

    Program Branching Instructions- Program branching instructions are used to control the flow

    of program execution. Some instructions provide decision making capabilities before

    transferring control to other parts of the program e.g. conditional and unconditional branches. the

    following table contains all the branching instructions.

    Table 3.6: Branching Instruction

    3.4 INTERUPTS

    An interrupt is an external or internal event that interrupts the microcontroller to inform it that a

    device needs its service.

    The advantage of interrupts is that the microcontroller can serve many devices.

    Each device can get the attention of the microcontroller based on the assigned priority.

    The microcontroller can also ignore (mask) a device request for service.

    Hardware and Software interrupt

    The interrupts in a controller can be either hardware or software. If the interrupts are generated

    by the controllers inbuilt devices, like timer interrupts; or by the interfaced devices, they are

    called the hardware interrupts. If the interrupts are generated by a piece of code, they are termed

    as software interrupts.

    The 8051 controller has six hardware interrupts of which five are available to the programmer.

  • 7/27/2019 Lpu Report

    25/45

    1. RESET Interrupt - This is also known as Power on Reset (POR). When the RESET interrupt

    is received, the controller restarts executing code from 0000H location. This is an interrupt which

    is not available to or, better to say, need not be available to the programmer.

    2. Timer interrupts - Each Timer is associated with a Timer interrupt. A timer interrupt notifiesthe microcontroller that the corresponding Timer has finished counting. Therefore these are two

    interrupts for the timers.

    3. External interrupts - There are two external interrupts EX0 and EX1 to serve external

    devices. Both these interrupts are active low. In AT89C51, P3.2 (INT0) and P3.3 (INT1) pins are

    available for external interrupts 0 and 1 respectively. An external interrupt notifies the

    microcontroller that an external device needs its service.

    4. Serial interrupt - This interrupt is used forserial communication. When enabled, it notifies

    the controller whether a byte has been received or transmitted.

    Fig. 3.5: Interrupts of 8051

    The interrupts must be enabled by software in order for the microcontroller to respond to them.

    Interrupt Enable Register- There is a register called IE (interrupt enable) that is responsible for

    enabling(unmasking) and disabling (masking) theinterrupts.

    EA -------- ET2 ES ET1 EX1 ET0 EX0

    Fig. 3.6: Interrupt enable register

    To enable any of the interrupts, first the EA bit must be set to 1. After that the bits

    corresponding to the desired interrupts are enabled.

    http://www.engineersgarage.com/at89c51-or-89c51-microcontrollerhttp://www.engineersgarage.com/microcontroller/8051projects/interface-serialport-RS232-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/interface-serialport-RS232-AT89C51http://www.engineersgarage.com/at89c51-or-89c51-microcontroller
  • 7/27/2019 Lpu Report

    26/45

    ET0, ET1 and ET2 bits are used to enable the Timer Interrupts 0, 1 and 2, respectively. In

    AT89C51, there are only two timers, so ET2 is not used.

    EX0 and EX1 are used to enable the external interrupts 0 and 1. ES is used for serial

    interrupt.

    EA bit acts as a lock bit. If any of the interrupt bits are enabled but EA bit is not set, the interrupt

    will not function. By default all the interrupts are in disabled mode.

    3.5 SERIAL PORT COMMUNICATION

    The 8051 microcontroller transmits data serially as well as parallel communication is also done.

    For serial communication, the microcontroller comes with serial communication pin TXD and

    RXD. Normally TXD is used for transmitting serial data which is in SBUF register, RXD is used

    for receiving the serial data. SCON register is used for controlling the operation.

    The two registers used for controlling the communication are SCON and SBUF.

    Serial Communication Parallel Communication

    Fig. 3.7 : Serial Communication

    Serial data communication uses two methods-

    Synchronous method transfers a block of data at a time

    Asynchronous method transfers a single byte at a time

    It is possible to write software to use either of these methods, but the programs can be tediousand long.

    There are special IC chips made by many manufacturers for serial communications

    UART (universal asynchronous Receiver transmitter)

    USART (universal synchronous-asynchronous Receiver-transmitter)

  • 7/27/2019 Lpu Report

    27/45

    The rate of data transfer in serial data communication is stated in bps (bits per second).

    Another widely used terminology for bps is baud rate.

    SCON

    Fig. 3.8: scon register

    RI (Receive Interrupt Flag)-Set by hardware on receiving. Must be cleared by software

    TI (Transmit Interrupt Flag) -Set by hardware on transmitted, must clear by hardware

    Operating modes

    Mode 0- 8-bit shift register, f/12

    1Mbit with 12 MHz Oscillator Frequency

    Mode 1- 8-bit UART, variable baud rate

    Mode 2 -9-bit UART, f/64 or f/32

    187.5K and 375K with 12MHz Oscillator Frequency

    Mode 3- 9-bit UART, variable baud rate.

    SBUF

    These are two separate data buffers for transmit and receive.

    The register SBUF is used to hold both the transmitter and receiver serial port data.

    To transmit the data, load SBUF register with data.

    MOV SBUF, source

    When transmission is complete the TI bit will be set in the SCONregister.

    When a data frame is received the RI bit in SCON is set high.

    The received data may then be loaded from SBUF

    MOV destination, SBUF

    Data reception is double buffered.

  • 7/27/2019 Lpu Report

    28/45

    3.6 CERTIFICATE

    CHAPTER 4

    IMPLEMENTATION DETAIL

    4.1 LED INTERFACING

    Interfacing an LED with 8051 is easy. The I/O pins are used as output pins. When any of the bit

    is set to 1, the LED glows if LED n side is connected to ground and p side with bit. And if p side

    is connected to power and n side to bit, then on bit low, the LED glows.

    Code-

    ORG 0000h

    loop:

    CLR P2.0

    CALL DELAY

  • 7/27/2019 Lpu Report

    29/45

    SETB P2.0

    CALL DELAY

    JMP loop

    delay:

    mov R7,#100

    L1_delay: djnz r7, L1_delay

    Ret

    Fig. 4.1: LED Interfacing4.2 SEVEN SEGMENT INTERFACING

    A seven segment consists of eight LEDs which are aligned in a manner so as to display digits

    from 0 to 9 when proper combination of LED is switched on. Seven segment uses seven LEDs

    to display digits from 0 to 9 and the eighth LED is used for the dot. A typical seven segment

    looks like as shown in the figure below.

    http://engineersgarage.com/content/seven-segment-displayhttp://engineersgarage.com/content/ledhttp://engineersgarage.com/content/ledhttp://engineersgarage.com/content/seven-segment-display
  • 7/27/2019 Lpu Report

    30/45

    Fig. 4.2: 7 SEGMENTCode-

    ORG 000H

    START: MOV A, #00001001B

    MOV B, A

    MOV R0, #0AH

    LABEL: MOV A, B

    INC A

    MOV B,A

    MOVC A,@A+PC

    MOV P1, A

    ACALL DELAY

    DEC R0

    MOV A, R0

    JZ START

    SJMP LABEL

    DB 3FH

    DB 06H

    DB 5BH

    DB 4FH

  • 7/27/2019 Lpu Report

    31/45

    DB 66H

    DB 6DH

    DB 7DH

    DB 07H

    DB 7FH

    DB 6FH

    DELAY: MOV R4,#05H

    WAIT1: MOV R3,#00H

    WAIT2: MOV R2,#00H

    WAIT3: DJNZ R2,WAIT3

    DJNZ R3,WAIT2

    DJNZ R4,WAIT1

    RET

    END

    Fig.4.3: 7-SEGMENT INTERFACING

    4.3 LCD INTERFACING

  • 7/27/2019 Lpu Report

    32/45

    A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD

    each character is displayed in 5x7 pixel matrix. This LCD has two registers.

    1. Command/Instruction Register - stores the command instructions given to the LCD. A

    command is an instruction given to LCD to do a predefined task like initializing, clearing the

    screen, setting the cursor position, controlling display etc.

    2.Data Register - stores the data to be displayed on the LCD. The data is the ASCII value of the

    character to be displayed on the LCD.

    Code-

    Fig.4.4: HEX CODE FOR LCD

    http://engineersgarage.com/content/lcdhttp://engineersgarage.com/content/lcd
  • 7/27/2019 Lpu Report

    33/45

    Fig. 4.5: LCD INTERFACING

    4.4 INTERFACING MOTOR WITH 8051

    Interfacing DC motor to 8051 forms an essential part in designing embedded robotic projects. A

    well designed 8051-DC motor system has essentially two parts. Firstly an 8051 with the

    required software to control the motor and secondly a suitable driver circuit.

    L293D-L293 is a dedicated quadruple half H bridge motor driver IC available in 16 pin package.

    The L293 is designed to provide bidirectional drive currents of up to 1 A at voltages

    from 4.5 V to 36 V.

  • 7/27/2019 Lpu Report

    34/45

    Fig. 4.6: MOTOR INTERFACING

    Code-

    ORG 00H // initial starting address

    MAIN: MOV P1,#00000001B // motor runs clockwise

    ACALL DELAY // calls the 1S DELAY

    MOV P1,#00000010B // motor runs anti clockwise

    ACALL DELAY // calls the 1S DELAY

    SJMP MAIN // jumps to label MAIN for repaeting the cycle

    DELAY: MOV R4,#0FH

    WAIT1: MOV R3,#00H

    WAIT2: MOV R2,#00H

    WAIT3: DJNZ R2,WAIT3

    DJNZ R3,WAIT2

    DJNZ R4,WAIT1RET

    END

  • 7/27/2019 Lpu Report

    35/45

    2.3PROJECT (RF CONTROLLED ROBO CAR)

    2.3.1 INTRODUCTIONThere are many ways to communicate data that is wireless or wired. Now we are going to

    transfer the data wireless using RF. And we are going to control the robot with this project. This

    project describes a design of effective data communication without wires and air as

    communication medium using RF. The source information is generated by a key pad and this

    will be sent to destination through RF communication. The receiving system will check the data

    and control the robot as per as our concern.

    2.3.2 RF MODULERadio Frequency (RF) communication has a ton of applications. It can be used in robots, home

    automation, special effects, or in any application that needs the wireless transfer of data. The data

    transfer speed varies based on the receiver and transmitter. In the real world, with all the

    electrical interference, we get around 240 bytes per second. However, since half of the 240 bytes

    per second is used for encoding, we really can only do 120 bytes of data a second. In reality the

    range is closer to 250 feet.

    2.3.3 HT12EHT12E is a 2

    12series encoder IC (Integrated Circuit) for remote control applications. It is

    commonly used for radio frequency (RF) applications. By using the paired HT12E encoder

    and HT12D decoder we can easily transmit and receive 12 bits of parallel data serially. HT12E

    simply converts 12 bit parallel data in to serial output which can be transmitted through a RF

    transmitter. These 12 bit parallel data is divided in to 8 address bits and 4 data bits. By using

    these address pins we can provide 8 bit security code for data transmission and multiple receivers

    may be addressed using the same transmitter.

    2.3.4 HT12D

    http://www.electrosome.com/ht12e-encoder-ic-remote-control-systems/http://www.electrosome.com/ht12d-decoder-ic-remote-control-systems/http://www.electrosome.com/ht12d-decoder-ic-remote-control-systems/http://www.electrosome.com/ht12e-encoder-ic-remote-control-systems/
  • 7/27/2019 Lpu Report

    36/45

    This IC is paired with HT12E. For proper operation a pair of encoder/decoder with the same

    number of address and data format should be selected. The Decoder receive the serial address

    and data from its corresponding decoder, transmitted by a carrier using an RF transmission

    medium and gives output to the output pins after processing the data.

    4.5.5 L293D

    L293D is a dualH-bridgemotor driver integrated circuit (IC). Motor drivers act as current

    amplifiers since they take a low-current control signal and provide a higher-current signal. This

    higher current signal is used to drive the motors.

    L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation, two DC

    motors can be driven simultaneously, both in forward and reverse direction. The motor

    operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic

    00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and

    anticlockwise directions, respectively.

    Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating.

    When an enable input is high, the associated driver gets enabled. As a result, the outputs become

    active and work inphase with their inputs. Similarly, when the enable input is low, that driver is

    disabled, and their outputs are off and in the high-impedance state.

    4.5.6 DC Geared motor

    A geared DC Motor has a gear assembly attached to the motor. The speed of motor is counted in

    terms of rotations of the shaft per minute and is termed as RPM.

    http://www.engineersgarage.com/electronic-circuits/h-bridge-motor-controlhttp://www.engineersgarage.com/electronic-circuits/h-bridge-motor-controlhttp://www.engineersgarage.com/electronic-circuits/h-bridge-motor-controlhttp://www.engineersgarage.com/electronic-circuits/h-bridge-motor-control
  • 7/27/2019 Lpu Report

    37/45

    Fig 4.7. DC geared motor

    4.5.7 DESIGN DETAIL

    The RF module, as the name suggests, operates at Radio Frequency. The corresponding

    frequency range varies between 30 kHz & 300 GHz. In this RF system, the digital data is

    represented as variations in the amplitude of carrier wave. This kind of modulation is known as

    Amplitude Shift Keying (ASK). Transmission through RF is better than IR (infrared) because of

    many reasons. Firstly, signals through RF can travel through larger distances making it suitable

    for long range applications. Also, while IR mostly operates in line-of-sight mode, RF signals can

    travel even when there is an obstruction between transmitter & receiver. Next, RF transmission is

    more strong and reliable than IR transmission. RF communication uses a specific frequency

    unlike IR signals which are affected by other IR emitting sources.

    FIG.4.8: PIN DIAGRAM OF RF MODULE

  • 7/27/2019 Lpu Report

    38/45

    4.5.7.1 Transmitter design

    RF transmitters are an essential part of modern communications. Designed and assembled from

    core RF components, RF transmitters have many different forms and applications. We often

    think of RF transmitters in wireless communications.

    The system allows one way communication between two nodes, namely, transmission and

    reception. The RF module has been used in conjunction with a set of four channel

    encoder/decoder ICs. Here HT12E & HT12D have been used as encoder and decoder

    respectively. The encoder converts the parallel inputs (from the remote switches) into serial set

    of signals. These signals are serially transferred through RF to the reception point. The decoder is

    used after the RF receiver to decode the serial format and retrieve the original signals as outputs.

    Encoder IC (HT12E) receives parallel data in the form of address bits and control bits. The

    control signals from remote switches along with 8 address bits constitute a set of 12 parallel

    signals. The encoder HT12E encodes these parallel signals into serial bits. Transmission is

    enabled by providing ground to pin14 which is active low. The control signals are given at

    pins 10-13 of HT12E. The serial data is fed to the RF transmitter through pin17 of HT12E.

    Operating parameters, cost, and design considerations impact RF transmitter performance and,

    subsequently, the RF signal quality. Consequently, ensuring the RF transmitter meets

    specification is essential in quality RF communications. Across various implementations of RF

    transmitters there are standard tests that are essential to ensuring proper operation. RF power

    measurements take many forms, depending on the RF transmitter design and application. The RF

    output may be a simple continuous wave (CW) signal, a pulse, and an analog modulated signal.

    Among the types of RF power measurements, the steady state RF power of a CW tone is perhaps

    the simplest. Peak power, such as the overshoot of an RF pulse, is the maximum value over some

    period of time. The power measurement can be averaged across a time period, such as across a

    series of RF pulses, yielding the average power.

    Here, we have used four switches S1, S2, S3 and S4 to give 4-bit parallel data (D0-D3). Since the

    switches are in active low state (i.e. low signal is sent when the switch is pressed), we need to

    add external pull-up resistors as shown, so as to provide a high signal by default. A resistance as

    high as 1Mohm is required in between OSC1 and OSC2 pins. The Transmitter Enable (TE, pin

    http://www.ni.com/rf/http://www.ni.com/rf/
  • 7/27/2019 Lpu Report

    39/45

    14) pin is an active low pin. Thus, it is permanently grounded, so as to enable the

    transistoralways. The output serial data DOUT is fed to the RF Transmitter Module directly.

    The most important thing lies in the address pins (A0-A7, pin1-8). Suppose you have two

    wireless devices (A and B) in your house, both have different remote controls (AA and BB) and

    both implement the same type of RF module (say 433 MHz). AA is the remote control of A and

    BB is of B. Now, you obviously wouldnt want AA to control B (which is the most probable case

    since both the devices use same kind of RF module, having same frequency!). This is where

    address pins come into play. There are 8 address pins, thus giving you an opportunity to have 8!

    (8 factorial) different and independent ways to connect to a device, so that there is no

    interference. The address pins MUST have the same address in both transmitter and

    receiver, or else the data wont be transferred.

  • 7/27/2019 Lpu Report

    40/45

    FIG.4.9: TRANSMITTER CIRCUIT

    4.5.7.2 Receiver design

    When no signal is received at data pin of HT12D, it remains in standby mode and consumes very

    less current (less than 1A) for a voltage of 5V. When signal is received by receiver, it is given

    to DIN pin (pin14) of HT12D. On reception of signal, oscillator of HT12D gets activated. IC

    HT12D then decodes the serial data and checks the address bits three times. If these bits match

    with the local address pins (pins 1-8) of HT12D, then it puts the data bits on its data pins

    (pins 10-13) and makes the VT pin high.

    The corresponding output is thus generated at the data pins of decoder IC. A signal is sent by

    lowering any or all the pins 10-13 of HT12E and corresponding signal is received at receivers

    end (at HT12D). Address bits are configured by using the by using the first 8 pins of both

    encoder and decoder ICs. To send a particular signal, address bits must be same at encoder and

    decoder ICs. By configuring the address bits properly, a single RF transmitter can also be used to

    control different RF receivers of same frequency.

    So now that all the connections are made, I choose an antenna for signal transmission. Usually, a

    20-30 cm wire serves best. It is sufficient to give a range of 80 meters in open region. To

    improve the efficiency, I use a coiled wire (take a wire and make it into a coil). It increases the

    signal strength.

  • 7/27/2019 Lpu Report

    41/45

    FIG.4.10: RECEIVER CIRCUIT

    4.5.7.3 SOURCE CODE

    #include

    sbit a=P1^3;

    sbit b=P1^2;

    sbit c=P1^1;

    sbit d=P1^0;

    sbit w=P2^0;

    sbit x=P2^1;

  • 7/27/2019 Lpu Report

    42/45

    sbit y=P2^2;

    sbit z=P2^3;

    void back(void);

    void left(void);

    void right(void);

    void fwd(void);

    void main(void)

    {

    P1=0xFF;

    P2=0x00;

    if(a==0&&b==1&&c==1&&d==1)

    {back();}

    else if(a==1&&b==0&&c==1&&d==1)

    {left();}

    else if(a==1&&b==1&&c==0&&d==1)

    {right();}

    else if(a==1&&b==1&&c==1&&d==0)

    {fwd();}

    else

    {w=0;x=0;y=0;z=0;}

    }

    void back()

    {w=0;x=1;y=0;z=1;}

    void left()

    {w=1;x=0;y=1;z=0;}

    void right()

    {w=1;x=0;y=0;z=1;}

    void fwd()

    {w=0;x=1;y=1;z=0;}

  • 7/27/2019 Lpu Report

    43/45

    FIG. 4.11: FINALE PROJECT

    CHAPTER 5

    RESULT AND DISCUSSION

    5.1RESULT

  • 7/27/2019 Lpu Report

    44/45

    I got the training of embedded systems by CETPA infotech pvt. ltd. , which helped me to

    understand the embedded world and I enhanced my skills in this field. As I learned about

    8051 family ICs so I am now able to understand the architecture, instruction set and

    other functionality of 89C51 ICs, which is common 8051 family IC.

    The classes on microcontroller 8051 was intended for practical

    knowledge of the subject rather than theoretical as it was told that there is a huge gap

    between theoretically knowing a subject and practically implementing it.

    5.2DISCUSSION

    5.2.1 CONCLUSIONSo by doing the training of embedded systems I made myself aware of importance of embedded

    system in our daily life.

    And, by doing project of Rf controlled robo car I made myself

    aware of working of Rf module and interface it with the 89c51 microcontroller.

    5.2.2 FUTURE SCOPEThe future scope of this project can be replace the button remote with

    ACCELEROMETER which sends output by getting input by varying the position of

    that . so we dont need to press buttons to control the robo car, rather we only have to

    change the position of remote and the car will move accordingly.

    The fm bug or spy cam can be fitted onto it so we can receive audio or video of other

    places by sending this robo with remote control.

    REFRENCES

    1. CETPA INFOTECH PVT. LTD.

    2. ENGINEERSGARAGE.COM

  • 7/27/2019 Lpu Report

    45/45

    3. WIKIPEDIA.ORG

    4. ATMEL.COM

    5. DATASHEETS.COM

    6. CIRCUITSTODAY.COM

    7. PDFs FROM VARIOUS SITES

    8. GOOGLE.COM

    9. The 8051 microcontroller and Embedded Systems by M.A.Mazid

    10.www.8051projects.info

    http://www.8051projects.info/http://www.8051projects.info/http://www.8051projects.info/http://www.8051projects.info/