Main Project Repor

Embed Size (px)

Citation preview

  • 8/2/2019 Main Project Repor

    1/59

    CHAPTER 1

    INTRODUCTION

    While travelling in air, there is a finite possibility of colliding with the objects thatappear in the surroundings. By using a Ultra sonic sensor and Direction sensor, we can detect

    an objects accuarte position and get it displayed on the LCD screen so that one can prevent

    collisions with that object by detecting it before hand and take necessary measures. Hence we

    propose our model Indication of Object position based on Radar principle.

    1.1 Requirements of the Project

    Power Supply.

    Micro Controller.

    LCD.

    Buzzer.

    RF Transmitter and Receiver.

    RF Encoder and Decoder.

    Ultra Sonic sensor.

    Direction sensor.

    Stepper motor.

    MAX232 and Rs232.

    1.2 Why we are using 89s52 microcontroller

    The AT89s52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K

    bytes of Flash programmable and erasable read only memory (PEROM). The device is

    manufactured using Atmels high-density nonvolatile memory technology and is compatible

    with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the

    1

  • 8/2/2019 Main Project Repor

    2/59

    program memory to be reprogrammed in-system or by a conventional nonvolatile memory

    programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel

    AT89s52 is a powerful microcomputer which provides a highly-flexible and cost-effective

    solution to many embedded control applications.

    1.3 Organization of Report

    In chapter 2 the overall system block diagram of Indication of Object position

    based on Radar principle is explained.

    In chapter 3 the AT89S52 microcontroller, its internal structure and all its

    components are explained.

    In chapter 4 describes the power supply block diagram, LCD, Ultrasonic sensor,

    Direction sensor, Stepper motor and RF transmitter and receiver is also explained.

    The software code written in embedded C for the system is given with the helpof flow chart in chapter 5.

    Results obtained and conclusions are presented in chapter 6.

    The maximum ratings and DC characteristics of the LM7805 voltage regulator are

    presented in appendix A . Finally the references are given.

    2

  • 8/2/2019 Main Project Repor

    3/59

    CHAPTER 2

    BLOCK DIAGRAM EXPLAINATION

    This chapter deals with Indication of object position based on radar principle in which

    all the components are embedded together and the circuit diagram are presented.

    2.1Block Diagram

    Indication of object position based on radar principle consists of microcontroller, LCD,

    power Supply, Max 232, Ultrasonic sensor, Direction Sensor, RF transmitters and

    Receivers, RF Encoders and Decoders and stepper motor.

    3

    89s52

    Micro

    Controller

    Ultrasonic

    Directio

    n

    NRF

    Driver

    Power

  • 8/2/2019 Main Project Repor

    4/59

    Receiver:

    Fig. 2.1 Block Diagram of Indication of object position based on radar principle

    Block Diagram Description

    The brief Function of each block is given below

    Micro controller

    The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with

    8Kbytes of in-system programmable Flash memory. The device is manufactured using Atmels

    high-density non-volatile memory technology and is compatible with the industry-standard

    80C51 instruction set and pin-out. The on-chip Flash allows the program memory to be

    reprogrammed in-system or by a conventional non-volatile memory programmer. By

    combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the

    4

    Stepper Motor

    Max23289s52

    RF

    ReceiverPC

    (VB)

    LCD

  • 8/2/2019 Main Project Repor

    5/59

    Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-

    effective solution to many embedded control applications

    LCD

    LCD is a Liquid Crystal Display. It is used to display the outputs. LCDs can add a lot to

    our application in terms of providing a useful interface for the user, debugging an application

    or just giving it a "professional" look.

    Power supply

    In this power supply circuit we have to create a +5V DC which is given to the micro

    controller. The below components are used to create the power supply.

    Fig. 2.2 Block Diagram of Power Supply

    Direction sensor

    A magnetometer is a scientific instrument used to measure the strength and/or direction

    of the magnetic field in the vicinity of the instrument. Magnetism varies from place to place

    and differences in Earth's magnetic field (the magnetosphere) can be caused by the differing

    nature of rocks and the interaction between charged particles from the Sun and the

    magnetosphere. Magnetometers are a frequent component instrument on spacecraft that

    explore planets.

    Ultrasonic sensors

    Ultrasonic sensors (also known as transceivers when they both send and receive) work

    on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the

    echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency

    sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the

    5

    230V AC

    Supply

    Step down

    transformer

    Bridge

    rectifierFilter Regulator

    http://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Earth's_magnetic_fieldhttp://en.wikipedia.org/wiki/Magnetospherehttp://en.wikipedia.org/wiki/Sunhttp://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Earth's_magnetic_fieldhttp://en.wikipedia.org/wiki/Magnetospherehttp://en.wikipedia.org/wiki/Sun
  • 8/2/2019 Main Project Repor

    6/59

    time interval between sending the signal and receiving the echo to determine the distance to an

    object.

    RF transmitters and Receivers

    The STT-433 is ideal for remote control applications where low cost and longer range is

    required. The transmitter operates from a1.5-12V supply, making it ideal for battery-powered

    applications. The transmitter employs a SAW-stabilized oscillator, ensuring accurate frequency

    control for best range performance.

    The data is received by the RF receiver from the antenna pin and this data is available

    on the data pins. Two Data pins are provided in the receiver module. Thus, this data can be

    used for further applications.

    RF Encoders and Decoders

    The microcontroller sends the data to the transmitter, the transmitter is not able to

    accept this data as this will be not in the radio frequency range. Thus, we need an intermediate

    device which can accept the input from the microcontroller, process it in the range of radio

    frequency range and then send it to the transmitter. Thus, an encoder is used.

    . The data transmitted into the air is received by the receiver. The received data is taken

    from the data line of the receiver and is fed to the decoder .The output of decoder is given to

    microcontroller and then data is processed according to the applications.

    Max 232

    A line driver required to convert RS232 voltage levels to TTL levels, and vice versa. It

    includes a capacitive voltage generator to supply TIA/EIA-232-F voltage levels from a single

    5-V supply. Each receiver converts TIA/EIA-232-F inputs to 5-V TTL/CMOS levels. These

    receivers have a typical threshold of 1.3 V, a typical hysteresis of 0.5 V, and can accept 30-V

    inputs. Each driver converts TTL/CMOS input levels into TIA/EIA-232-F levels.

    Stepper Motor

    6

  • 8/2/2019 Main Project Repor

    7/59

    A stepper motor is a widely used device that translates electrical pulses into mechanical

    movement. The stepper motor is used for position control in applications such as disk drives,

    dot matrix printers and robotics.

    CHAPTER 3

    MICRO CONTROLLER (AT 89s52)

    This chapter introduces features of the AT89S52 microcontroller, architecture,

    pin diagram, oscillator characteristics, addressing modes.

    Born of parallel developments in computer architecture and integrated circuit

    fabrications, the microprocessor or computer on chip first becomes a commercial reality in

    1971. With the introduction of the 4 bit 4004 by a small, unknown company by the name

    of Intel corporation other, well established, semiconductor firms soon followed Intels

    pioneering technology, so that by the late 1970s we could choose from a half dozen or so

    microprocessor types.

    The 1970s also saw the growth of the number of the personal computer users from

    a handful of hobbyists and hackers to millions of business, industrial, governmental,

    defense, and educational and private users now enjoying the advantages of inexpensive

    computing.

    3.1 Features

    Compatible with MCS-51 Products

    8K Bytes of In-System Programmable (ISP) Flash Memory

    Endurance: 1000 Write/Erase Cycles

    4.0V to 5.5V Operating Range

    7

  • 8/2/2019 Main Project Repor

    8/59

    Fully Static Operation: 0 Hz to 33 MHz

    Three-level Program Memory Lock

    256 x 8-bit Internal RAM

    32 Programmable I/O Lines

    Three 16-bit Timer/Counters

    Full Duplex UART Serial Channel

    Low-power Idle and Power-down Modes

    Interrupt Recovery from Power-down Mode

    Watchdog Timer

    Dual Data Pointer

    3.2 Architecture of AT89S52

    The Architecture of AT89S52 provides the following standard features: 8K bytes

    of Flash, 256 bytes of RAM, 32 I/O lines, watchdog timer, two data pointers, three 16-bit

    timer/counters, full duplex serial port, on-chip oscillator, and clock circuitry as shown in

    8

  • 8/2/2019 Main Project Repor

    9/59

    9

  • 8/2/2019 Main Project Repor

    10/59

    Fig. 3.1 Architecture of Microcontroller AT89S52

    In addition, the AT89S52 is designed with static logic for operation down to zero

    frequency and supports two software selectable power saving modes. The idle mode stops

    the CPU while allowing the RAM timer/counters, serial port, and interrupt system to

    continue functioning. The power-down mode saves the RAM contents but freezes the

    oscillator, disabling all other chip functions until the next interrupt or hardware reset.

    3.3 Pin Diagram of AT89S52

    The 40 pin Dual- In- Line package of AT89S52 microcontroller is shown in

    Fig.3.2.

    10

  • 8/2/2019 Main Project Repor

    11/59

    Fig. 3.2 Pin diagram of Microcontroller AT89S52

    3.3.1 Pin Description of AT89S52

    Vcc

    Supply voltage.

    GND

    Ground.

    Port 0

    11

  • 8/2/2019 Main Project Repor

    12/59

    Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can

    sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high

    impedance inputs. Port 0 can also be configured to be the multiplexed low order

    address/data bus during access to external program and data memory. In this mode, P0 has

    internal pull-ups. Port 0 also receives the code bytes during Flash programming and

    outputs the code bytes during program verification. External pull-ups are required during

    program verification.

    Port 1

    Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output

    buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled

    high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are

    externally being pulled low will source current because of the internal pull-ups addition, P1.0

    and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the

    timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following Table 3.1.

    Port 1 also receives the low-order address bytes during Flash programming and verification.

    Table 3.1 Port 1 Pin Details

    Port Pin Alternate Functions

    P1.0 T2 (external count input to

    Timer/Counter 2),

    clock-out

    P1.1 T2EX (Timer/Counter 2 capture/reload

    trigger

    and direction control)

    12

  • 8/2/2019 Main Project Repor

    13/59

    P1.5 MOSI (used for In-System

    Programming)

    P1.6 MISO (used for In-System

    Programming)

    P1.7 SCK (used for In-System

    Programming)

    Port 2

    Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output

    buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are

    pulled high by the internal pull-ups and can be used as inputs.

    Port 2 emits the high-order address byte during fetches from external program

    memory and during access to external data memory that uses 16-bit addresses (MOVX

    @DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s

    During access to external data memory that uses 8-bit addresses (MOVX @ RI),

    Port 2 emits the contents of the Special Function Register. Port 2 also receives the high-

    order address bits and some control signals during Flash programming and verification.

    Port 3

    Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output

    buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are

    pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that

    are externally being pulled low will source current because of the pull-ups. Port 3 also

    serves the functions of various special features of the AT89C52, as shown in the following

    Table 3.2. Port 3 also receives some control signals for Flash programming and

    verification.

    Table 3.2 Alternative function of Port 3 Pins

    13

  • 8/2/2019 Main Project Repor

    14/59

    RST

    Reset input. A high on this pin for two machine cycles while the oscillator is running

    resets the device. This pin drives high for 96 oscillator periods after the watchdog times out.

    The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the

    default state of bit DISRTO, the RESET HIGH out feature is enabled.

    ALE/PROG

    Address Latch Enable (ALE) is an output pulse for latching the low byte of the address

    during access to external memory. This pin is also the program pulse input (PROG) during

    Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator

    14

    Port Pin Alternate Functions

    P3.0 RXD (serial input port)

    P3.1 TXD (serial output port)

    P3.2 INT0 (external interrupt 0)

    P3.3 INT1 (external interrupt 1)

    P3.4 T0 (timer 0 external input)

    P3.5 T1 (timer 1 external input)

    P3.6 WR (external data memory write strobe)

    P3.7 RD (external data memory read strobe)

  • 8/2/2019 Main Project Repor

    15/59

    frequency and may be used for external timing or clocking purposes. Note, however, that one

    ALE pulse is skipped during each access to external data Memory. If desired, ALE operation

    can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only

    during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the

    ALE-disable bit has no effect if the microcontroller is in external execution mode.

    PSEN

    Program Store Enable (PSEN) is the read strobe to external program memory.

    When the AT89C52 is executing code from external program memory, PSEN is activated

    twice each machine cycle, except that two PSEN activations are skipped during each

    access to external data memory.

    EA/VPP

    External Access Enable. EA must be strapped to GND in order to enable the device

    to fetch code from external program memory locations starting at 0000H up to FFFFH.

    Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. A

    should be strapped to VCC for internal program executions. This pin also receives the 12-

    volt Programming enables voltage (VPP) during Flash programming.

    XTAL1

    Input to the inverting oscillator amplifier and input to the internal clock operating

    circuit.

    XTAL2

    Output from the inverting oscillator amplifier.

    3.3.2 Oscillator Characteristics

    15

  • 8/2/2019 Main Project Repor

    16/59

    XTAL1 and XTAL2 are the input and output, respectively, of an inverting

    amplifier that can be configured for use as an on-chip oscillator, as shown in Figure3.3.

    Either a quartz crystal or ceramic resonator may be used. To drive the device from an

    external clock source, XTAL2 should be left unconnected while XTAL1 is driven. Fig 3.3

    shows the oscillator connections.

    Fig. 3.3 Oscillator Connection

    3.4 Addressing Modes

    An addressing mode refers to the address of a given memory location. In

    summary, the addressing modes are as follows, with an example of each:

    Immediate Addressing MOV A, #20 H

    Direct Addressing MOV A, 30 H

    Indirect Addressing MOV A, @R0

    Immediate Addressing

    16

  • 8/2/2019 Main Project Repor

    17/59

    Immediate addressing is so named because the value to be stored in memory

    immediately follows the operation code in memory. That is to say, the instruction itself

    dictates what value will be stored in memory.

    MOV A, #20H

    This instruction uses immediate addressing because the accumulator will be

    loaded with the value that immediately follows, in this case 20(hexadecimal). Immediate

    addressing is very fast since the value to be loaded is included in the instruction. However,

    since the value to be loaded is fixed at compile time it is not very flexible.

    Direct Addressing

    Direct addressing is so named because the value to be stored in memory is

    obtained by directly retrieving it from another memory location.

    MOV A, 30H

    This instruction will read the data out of internal RAM address 30(hexadecimal)

    and store it in the accumulator. Direct addressing is generally fast since, although the value

    to be loaded isnt included in the instruction, it is quickly accessible since it is stored in the

    8051s internal RAM. It is also much more flexible than immediate addressing since the

    value to be loaded is whatever is found at the given address which may be variable. Also

    it is important to note that when using direct addressing any instruction that refers to an

    address between 00h and 7FH is referring to the SFR control registers that control the

    89S52 microcontroller itself.

    Indirect Addressing

    Indirect addressing is a very powerful addressing mode, which in many cases

    provides an exceptional level of flexibility. Indirect addressing is also the only way to

    17

  • 8/2/2019 Main Project Repor

    18/59

    access the extra 128 bytes of internal RAM found on the 8052. Indirect addressing appears

    as below.

    MOV A, @R0

    This instruction causes the 89S52 to analyze Special Function Register Memory.

    Special Function Registers (SFR) is areas of memory that control specific functionality of

    the 89S52 processor.

    3.5 Modes of Operation

    Idle Mode

    In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain

    active. The mode is invoked by software. The content of the on-chip RAM and all the special

    functions registers remain unchanged during this mode. The idle mode can be terminated by

    any enabled interrupt or by a hardware reset. Note that when idle mode is terminated by a

    hardware reset, the device normally resumes program execution from where it left off, up to

    two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits

    access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate

    the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the

    instruction following the one that invokes idle mode should not write to a port pin or to

    external memory.

    Power down Mode

    In the power-down mode, the oscillator is stopped, and the instruction that invokes

    power-down is the last instruction executed. The on-chip RAM and Special Function Registers

    retain their values until the power-down mode is terminated. Exit from power-down mode can

    be initiated either by a hardware reset or by an enabled external interrupt. Reset redefines theSFRs but does not change the on-chip RAM. The reset should not be activated before VCC is

    restored to its normal operating level and must be held active long enough to allow the

    oscillator to restart and stabilize.

    18

  • 8/2/2019 Main Project Repor

    19/59

    3.6 Watchdog Timer(WDT)

    (One-time Enabled with Reset-out)

    The WDT is intended as a recovery method in situations where the CPU may be

    subjected to software upsets. The WDT consists of a 13-bit counter and the Watchdog Timer

    Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the

    WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location

    0A6H). When the WDT is enabled, it will increment every machine cycle while the oscillator

    is running. The WDT timeout period is dependent on the external clock frequency. There is no

    way to disable the WDT except through reset (either hardware reset or WDT overflow reset).

    When WDT overflows, it will drive an output RESET HIGH pulse at the RST pin.

    3.7 Timers and Counters

    Timer 0 and Timer 1

    The Timer or Counter function is selected by control bits C/T in the Special

    Function Register TMOD. These two Timer/Counters have four operating modes, which are

    selected by bit-pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both

    Timers/Counters. Mode 3 is different. The four operating modes are described as follows

    Mode 0

    Putting either Timer into Mode 0 makes it look like an 8048 Timer, which is an 8-bit

    Counter with a divide-by-32 prescaler. In mode 0, the Timer register is configured as a 13-bit

    register. As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TF1. The

    counted input is enabled to the Timer when TR1 = 1 and either GATE = 0 or INT1 = 1.

    (Setting GATE = 1 allows the Timer to be controlled by external input INT1, to facilitate pulse

    width measurements). TR1 is a control bit in the Special Function Register TCON (Figure 4).

    GATE is in TMOD. The 13-bit register consists of all 8 bits of TH1 and the lower 5 bits of

    TL1. The upper 3 bits of TL1 are indeterminate and should be ignored. Setting the run flag

    19

  • 8/2/2019 Main Project Repor

    20/59

    (TR1) does not clear the registers. Mode 0 operation is the same for the Timer 0 as for Timer 1.

    There are two different GATE bits, one for Timer 1 (TMOD.7) and one for Timer0 (TMOD.3).

    Mode 1

    Mode 1 is the same as Mode 0, except that the Timer register is being run with all 16

    bits.

    Mode 2

    Mode 2 configures the Timer register as an 8-bit Counter (TL1) with automatic reload

    Overflow from TL1 not only sets TF1, but also reloads TL1 with the contents of TH1, which is

    preset by software. The reload leaves TH1 unchanged. Mode 2 operation is the same for

    Timer/Counter 0.

    Mode 3

    Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1 = 0.

    Timer 0 in Mode 3 establishes TL0 and TH0 as two separate counters. The logic for Mode 3 on

    Timer 0 is shown in Figure 3.4. TL0 uses the Timer 0 control bits: C/T, GATE, TR0, INT0,

    and TF0. TH0 is locked into a timer function (counting machine cycles) and takes over the use

    of TR1 and TF1 from Timer 1. Thus, TH0 now controls the Timer 1 interrupt. Mode 3 is

    provided for applications requiring an extra 8-bit timer on the counter. With Timer 0 in Mode

    3, an 89s52 can look like it has five timer/Counters. When Timer 0 is in Mode 3, Timer 1 can

    be turned on and off by switching it out of and into its own Mode 3, or can still be used by the

    serial port as a baud rate generator, or in fact, in any application not requiring an interrupt.

    20

  • 8/2/2019 Main Project Repor

    21/59

    Fig. 3.4 TMOD register

    Fig. 3.5 TCON register

    Timer 2

    Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.

    The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has three operating

    modes shown in table 3: capture, auto-reload (up or down counting), and baud rate generator.

    21

  • 8/2/2019 Main Project Repor

    22/59

    The modes are selected by bits in T2CON, as shown in Table 3.6 Timer 2 consists of two 8-bit

    registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine

    cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the

    oscillator frequency.

    Table. 3.6 Timer 2 operating modes

    In the counter function, the register is incremented in response to a 1-to-0 transition at

    its corresponding external input pin, T2.

    Capture mode

    In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 =

    0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit

    can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation,

    but a 1- to-0 transition at external input T2EX also causes the current value in TH2 and TL2 to

    be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX

    causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt. The

    capture mode is illustrated in Figure

    22

  • 8/2/2019 Main Project Repor

    23/59

    Fig. 3.6 Timer in capture mode

    Auto-reload (Up or Down Counter)

    Timer 2 can be programmed to count up or down when configured in its 16-bit auto-

    reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the

    SFR T2MOD. Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up.

    When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

    Fig. 3.7 Timer 2 in auto reload mode

    Figure 3.7 shows Timer 2 automatically counting up when DCEN=0. In this mode, two

    options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH

    and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be

    reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture

    23

  • 8/2/2019 Main Project Repor

    24/59

    ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be

    triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This transition

    also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled.

    Rate Generator

    Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in

    T2CON. Note that the baud rates for transmit and receive can be different if Timer 2 is used for

    the receiver or transmitter and Timer 1 is used for the other function.

    The baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate according

    to the following equation.

    The Timer can be configured for either timer or counter operation. In most applications,

    it is configured for timer operation The timer operation is different for Timer 2 when it is used

    as a baud rate generator.

    Normally, as a timer it increments every machine cycle (at 1/12 the oscillator

    frequency).As a baud rate generator, however, it increments every state time (at 1/2 the

    oscillator frequency).

    The baud rate formula is given below.

    where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit

    unsigned integer.

    3.8 Interrupts

    24

  • 8/2/2019 Main Project Repor

    25/59

    The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0

    and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These

    interrupts are all shown in Figure3.8.

    Each of these interrupt sources can be individually enabled or disabled by setting or

    clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which

    disables all interrupts at once. In the AT89S51, bit position IE.5 is also unimplemented. User

    software should not write 1s to these bit positions, since they may be used in future AT89

    products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register

    T2CON.

    Fig. 3.8 Interrupt sources

    Neither of these flags is cleared by hardware when the service routine is vectored to. In

    fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the

    interrupt, and that bit will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0

    and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled

    by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled

    in the same cycle in which the timer overflows.

    CHAPTER 4

    25

  • 8/2/2019 Main Project Repor

    26/59

    HARDWARE IMPLEMENTATION

    4.1 POWER SUPPLY

    The input to the circuit is applied from the regulated power supply. The a.c. input i.e.,

    230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier.

    The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c

    voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components

    present even after rectification. Now, this voltage is given to a voltage regulator to obtain a

    pure constant dc voltage.

    Fig. 4.1 Power Supply

    Transformer

    Usually, DC voltages are required to operate various electronic equipment and these

    voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input

    available at the mains supply i.e., 230V is to be brought down to the required voltage level.

    This is done by a transformer. Thus, a step down transformer is employed to decrease the

    voltage to a required level.

    26

    RegulatorFilterBridge

    Rectifier

    Step down

    transformer

    230V AC

    50HzD.C

    Output

  • 8/2/2019 Main Project Repor

    27/59

    Rectifier

    The output from the transformer is fed to the rectifier. It converts A.C. into pulsating

    D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier

    is used because of its merits like good stability and full wave rectification.

    Filter

    Capacitive filter is used in this project. It removes the ripples from the output of

    rectifier and smoothens the D.C. Output received from this filter is constant until the mains

    voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage

    received at this point changes. Therefore a regulator is applied at the output stage.

    Voltage regulator

    As the name itself implies, it regulates the input applied to it. A voltage regulator is an

    electrical regulator designed to automatically maintain a constant voltage level. In this project,

    power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and

    7812 voltage regulators are to be used. The first number 78 represents positive supply and the

    numbers 05, 12 represent the required output voltage levels.

    The Soil Moisture sensor is a high performance and accurate soil moisture sensor. It measures

    soil moisture from 0 to 200 centibar (cb). The Soil Moisture sensor includes the

    WATERMARK soil moisture sensor, Fouriers adaptor and BNC/alligator cable.

    4.2 LCD

    In 1968, RCA Laboratories developed the first liquid crystal display (LCD). Since then,

    LCDs have been implemented on almost all types of digital devices, from watches to

    computer to projection TVs .LCDs operate as a light valve, blocking light or allowing it to

    pass through. An image in an LCD is formed by applying an electric field to alter the chemical

    properties of each LCC (Liquid Crystal Cell) in the display in order to change a pixels light

    27

  • 8/2/2019 Main Project Repor

    28/59

    absorption properties. These LCCs modify the image produced by the backlight into the

    screen output requested by the controller. Through the end output may be in color, the LCCs

    are monochrome, and the color is added later through a filtering process. Modern laptop

    computer displays can produce 65,536 simultaneous colors at resolution of 800 X 600.

    To understand the operation of an LCD, it is easiest to trace the path of a light ray from

    the backlight to the user. The light source is usually located directly behind the LCD, and can

    use either LED or conventional fluorescent technology. From this source, the light ray will

    pass through a light polarizer to uniformly polarize the light so it can be acted upon by the

    liquid crystal (LC) matrix. The light beam will then pass through the LC matrix, which will

    determine whether this pixel should be on or off. If the pixel is on, the liquid crystal cell

    is electrically activated, and the molecules in the liquid will align in a single direction. This

    will allow the light to pass through unchanged. If the pixel is off, the electric field is

    removed from the liquid, and the molecules with in scatter. This dramatically reduces the light

    that will pass through the display at that pixel.

    Fig. 4.2 General Purpose Alphanumeric LCD

    Interfacing LCD To The Microcontroller

    This is the first interfacing example for the parallel port. We will star with something

    simple. This example does not use the Bi-directional feature found on newer ports, thus it

    should work with most, if no all Parallel Ports. It however does not show the use of the status

    port as an input. So what are we interfacing? A 16 Character X 2 Line LCD Module to the

    28

  • 8/2/2019 Main Project Repor

    29/59

    Parallel Port. These LCD Modules are very common these days, and are quite simple to work

    with, as all the logic required running them is on board.

    Features

    Interface with either 4-bit or 8-bit microprocessor.

    Display data RAM

    Character generator ROM

    160 different 5 and 7 dot-matrix character patterns.

    Character generator RAM

    8 different user programmed 5 and 7 dot-matrix patterns.

    Display data RAM and character generator RAM may be

    accessed by the microprocessor.

    Numerous instructions

    Clear Display, Cursor Home, Display ON/OFF, Cursor

    ON/OFF, Blink Character, Cursor Shift, Display Shift.

    Built-in reset circuit is triggered at power ON.

    Pin Configuration

    Fig. 4.3 Pin Configuration of 2x16 Character LCD Display

    29

  • 8/2/2019 Main Project Repor

    30/59

    Vcc and Vss are supply pins and VEE (Pin no.3) is used for controlling LCD contrast.

    Pin No.4 is Rs pin for selecting the register, there are two very important registers are there in

    side the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction

    command code register is selected, allowing the user to send data to be displayed on the LCD.

    R/W is a read or writes Pin, which allows the user to write information to the LCD or read

    information from it. R/W=1 when reading R/W=0 when writing. The LCD to latch information

    presented to its data pins uses the enable (E) pin. The 8-bit data pins, D0-D7, are used to send

    information to the LCD or read the contents of the LCDs internal registers. To display letters

    and numbers, we must send ASCII codes for the letters A-Z, and number 0 -9 to these pins

    while making RS=1.

    Table 4.1 Pin Configurations of LCD Display

    30

  • 8/2/2019 Main Project Repor

    31/59

    Lcd Interfacing With The Microcontroller

    Fig. 4.4 Lcd Interfacing With The Microcontroller

    4.3 DIRECTION SENSOR

    A magnetometer is a scientific instrument used to measure the strength and/or

    direction of the magnetic field in the vicinity of the instrument. Magnetism varies from place to

    place and differences in Earth's magnetic field can be caused by the differing nature of rocks

    and the interaction between charged particles from the Sun and the magnetosphere.

    Magnetometers are a frequent component instrument on spacecraft that explore planets.

    Fig. 4.5 Magnetometer

    31

    Vcc

    Gn

    d

    PRESET

    (CONTRAST

    CONTROL)

    VccFOR

    BACKLIGHT

    PURPOSE

    P2.0

    P2.

    1

    P2.

    2

    AT89s52

    P0.0

    4 (RS)1

    5 (R/W)

    2

    6(EN)

    3

    LCD

    Gnd

    http://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Earth's_magnetic_fieldhttp://en.wikipedia.org/wiki/Sunhttp://en.wikipedia.org/wiki/Sunhttp://en.wikipedia.org/wiki/Magnetic_fieldhttp://en.wikipedia.org/wiki/Earth's_magnetic_fieldhttp://en.wikipedia.org/wiki/Sun
  • 8/2/2019 Main Project Repor

    32/59

    Magnetometers can be divided into two basic types:

    Scalar magnetometers measure the total strength of the magnetic field to which they are

    subjected, and

    Vector magnetometers have the capability to measure the component of the magnetic

    field in a particular direction, relative to the spatial orientation of the device.

    The use of three orthogonal vector magnetometers allows the magnetic field strength,

    inclination and declination to be uniquely defined. Examples of vector magnetometers are

    fluxgates, superconducting quantum interference devices (SQUIDs), and the atomicSERF

    magnetometer. Some scalar magnetometers are discussed below.

    A magnetograph is a special magnetometer that continuously records data.

    Uses

    Magnetometers are used in ground-based electromagnetic geophysical surveys(such as

    magnetotellurics and magnetic surveys) to assist with detecting mineralization and

    corresponding geological structures. Airborne geophysical surveys use magnetometers that can

    detect magnetic field variations caused by mineralization, using airplanes like the Shrike

    Commander. Magnetometers are also used to detect archaeological sites, shipwrecks and other

    buried or submerged objects, and in metal detectors to detect metal objects, such as guns in

    security screening. Magnetic anomaly detectorsdetect submarines for military purposes.

    They are used in directional drilling for oil or gas to detect the azimuth of the drilling

    tools near the drill bit. They are most often paired up with accelerometersin drilling tools so

    that both the inclination and azimuth of the drill bit can be found.

    Magnetometers are very sensitive, and can give an indication of possible auroral

    activity before one can see the light from the aurora. A grid of magnetometers around the

    world constantly measures the effect of the solar wind on the Earth's magnetic field, which is

    published on the K-index.

    32

    http://en.wikipedia.org/wiki/Spatial_orientationhttp://en.wikipedia.org/wiki/Superconducting_quantum_interference_devicehttp://en.wikipedia.org/wiki/SERFhttp://en.wikipedia.org/wiki/SERFhttp://en.wikipedia.org/wiki/Geophysical_surveyhttp://en.wikipedia.org/wiki/Geophysical_surveyhttp://en.wikipedia.org/wiki/Magnetotelluricshttp://en.wikipedia.org/wiki/Magnetic_survey_(archaeology)http://en.wikipedia.org/wiki/Shrike_Commanderhttp://en.wikipedia.org/wiki/Shrike_Commanderhttp://en.wikipedia.org/wiki/Archaeological_sitehttp://en.wikipedia.org/wiki/Shipwreckhttp://en.wikipedia.org/wiki/Metal_detectorhttp://en.wikipedia.org/wiki/Magnetic_anomaly_detectorhttp://en.wikipedia.org/wiki/Magnetic_anomaly_detectorhttp://en.wikipedia.org/wiki/Submarinehttp://en.wikipedia.org/wiki/Directional_drillinghttp://en.wikipedia.org/wiki/Azimuthhttp://en.wikipedia.org/wiki/Accelerometershttp://en.wikipedia.org/wiki/Accelerometershttp://en.wikipedia.org/wiki/Inclinationhttp://en.wikipedia.org/wiki/Lighthttp://en.wikipedia.org/wiki/Lighthttp://en.wikipedia.org/wiki/Auroral_lighthttp://en.wikipedia.org/wiki/Auroral_lighthttp://en.wikipedia.org/wiki/K-indexhttp://en.wikipedia.org/wiki/K-indexhttp://en.wikipedia.org/wiki/Spatial_orientationhttp://en.wikipedia.org/wiki/Superconducting_quantum_interference_devicehttp://en.wikipedia.org/wiki/SERFhttp://en.wikipedia.org/wiki/Geophysical_surveyhttp://en.wikipedia.org/wiki/Magnetotelluricshttp://en.wikipedia.org/wiki/Magnetic_survey_(archaeology)http://en.wikipedia.org/wiki/Shrike_Commanderhttp://en.wikipedia.org/wiki/Shrike_Commanderhttp://en.wikipedia.org/wiki/Archaeological_sitehttp://en.wikipedia.org/wiki/Shipwreckhttp://en.wikipedia.org/wiki/Metal_detectorhttp://en.wikipedia.org/wiki/Magnetic_anomaly_detectorhttp://en.wikipedia.org/wiki/Submarinehttp://en.wikipedia.org/wiki/Directional_drillinghttp://en.wikipedia.org/wiki/Azimuthhttp://en.wikipedia.org/wiki/Accelerometershttp://en.wikipedia.org/wiki/Inclinationhttp://en.wikipedia.org/wiki/Lighthttp://en.wikipedia.org/wiki/Auroral_lighthttp://en.wikipedia.org/wiki/K-index
  • 8/2/2019 Main Project Repor

    33/59

    A three-axis fluxgate magnetometer was part of the Mariner 2 and Mariner 10

    missions. A dual technique magnetometer is part of the Cassini-Huygens mission to explore

    Saturn. This system is composed of a vector helium and fluxgate magnetometers.[5]

    Magnetometers are also a component instrument on the Mercury MESSENGERmission. A

    magnetometer can also be used by satellites like GOES to measure both the magnitude and

    direction of a planet's or moon's magnetic field.

    4.4 ULTRASONIC SENSOR

    Ultrasonic sensors (also known as transceivers when they both send and receive) work

    on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the

    echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency

    sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the

    time interval between sending the signal and receiving the echo to determine the distance to an

    object.

    This technology can be used for measuring: wind speed and direction (anemometer),

    fullness of a tank and speed through air or water. For measuring speed or direction a device

    uses multiple detectors and calculates the speed from the relative distances to particulates in the

    air or water. To measure the amount of liquid in a tank, the sensor measures the distance to thesurface of the fluid. Further applications include: humidifiers, sonar, medical ultrasonography,

    burglar alarms and non-destructive testing.

    Systems typically use a transducer which generates sound waves in the ultrasonic

    range, above 18,000 hertz, by turning electrical energy into sound, then upon receiving the

    echo turn the sound waves into electrical energy which can be measured and displayed.

    The technology is limited by the shapes of surfaces and the density or consistency of

    the material. For example foam on the surface of a fluid in a tank could distort a reading.

    33

    http://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Mariner_2http://en.wikipedia.org/wiki/Mariner_10http://en.wikipedia.org/wiki/Mariner_10http://en.wikipedia.org/wiki/Cassini-Huygenshttp://en.wikipedia.org/wiki/Magnetometer#Vector_heliumhttp://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Magnetic_field_sensors#cite_note-4http://en.wikipedia.org/wiki/Magnetic_field_sensors#cite_note-4http://en.wikipedia.org/wiki/MESSENGERhttp://en.wikipedia.org/wiki/GOEShttp://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Direction_(geometry,_geography)http://en.wikipedia.org/wiki/Humidifierhttp://en.wikipedia.org/wiki/Sonarhttp://en.wikipedia.org/wiki/Medical_ultrasonographyhttp://en.wikipedia.org/wiki/Non-destructive_testinghttp://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Mariner_2http://en.wikipedia.org/wiki/Mariner_10http://en.wikipedia.org/wiki/Cassini-Huygenshttp://en.wikipedia.org/wiki/Magnetometer#Vector_heliumhttp://en.wikipedia.org/wiki/Magnetometer#Fluxgate_magnetometerhttp://en.wikipedia.org/wiki/Magnetic_field_sensors#cite_note-4http://en.wikipedia.org/wiki/MESSENGERhttp://en.wikipedia.org/wiki/GOEShttp://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Direction_(geometry,_geography)http://en.wikipedia.org/wiki/Humidifierhttp://en.wikipedia.org/wiki/Sonarhttp://en.wikipedia.org/wiki/Medical_ultrasonographyhttp://en.wikipedia.org/wiki/Non-destructive_testing
  • 8/2/2019 Main Project Repor

    34/59

    Transducers

    Fig. 4.6 Ultrasonic Transducer

    An ultrasonic transducer is a device that converts energy into ultrasound, or sound

    waves above the normal range of human hearing. While technically a dog whistle is an

    ultrasonic transducer that converts mechanical energy in the form of air pressure into ultrasonic

    sound waves, the term is more apt to be used to refer topiezoelectric transducers that convert

    electrical energy into sound. Piezoelectric crystals have the property of changing size when a

    voltage is applied, thus applying an alternating current (AC) across them causes them to

    oscillate at very high frequencies, thus producing very high frequency sound waves.

    The location at which a transducer focuses the sound can be determined by the active

    transducer area and shape, the ultrasound frequency, and the sound velocity of the propagation

    medium.

    Detectors

    Since piezoelectric crystals generate a voltage when force is applied to them, the same

    crystal can be used as an ultrasonic detector. Some systems use separate transmitter and

    receiver components while others combine both in a single piezoelectric transceiver.

    Alternative methods for creating and detecting ultrasound include magnetostriction and

    capacitive actuation.

    34

    http://en.wikipedia.org/wiki/Ultrasoundhttp://en.wikipedia.org/wiki/Dog_whistlehttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Alternating_currenthttp://en.wikipedia.org/wiki/Magnetostrictionhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Actuatorhttp://en.wikipedia.org/wiki/Ultrasoundhttp://en.wikipedia.org/wiki/Dog_whistlehttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Alternating_currenthttp://en.wikipedia.org/wiki/Magnetostrictionhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Actuator
  • 8/2/2019 Main Project Repor

    35/59

    4.5 RF TRANSMITTER AND RECEIVER

    RF Transmitter STT-433MHz

    Fig. 4.7 STT-433 MHZ Transmitter

    About the transmitter

    The STT-433 is ideal for remote control applications where low cost and longer rangeis required.

    The transmitter operates from a1.5-12V supply, making it ideal for battery-powered

    applications.

    The transmitter employs a SAW-stabilized oscillator, ensuring accurate frequency

    control for best range performance.

    The manufacturing-friendly SIP style package and low-cost make the STT-433 suitable

    for high volume applications.

    Features

    433.92 MHz Frequency

    Low Cost

    1.5-12V operation

    35

  • 8/2/2019 Main Project Repor

    36/59

    Small size

    Pin Description

    Fig. 4.8 Pin diagram of STT-433MHz

    GND

    Transmitter ground. Connect to ground plane

    DATA

    Digital data input. This input is CMOS compatible and should be driven with CMOS level

    inputs.

    VCC

    Operating voltage for the transmitter. VCC should be bypassed with a .01uF ceramic

    capacitor and filtered with a 4.7uF tantalum capacitor. Noise on the power supply will degrade

    transmitternoise performance.

    ANTs

    50 ohm antenna output. The antenna port impedance affects output power and harmonic

    emissions. Antenna can be single core wire of approximately 17cm length or PCB trace

    antenna

    36

  • 8/2/2019 Main Project Repor

    37/59

    Application

    Fig. 4.9 Basic Application circuit of STT-433MHz

    The typical connection shown in the above figure cannot work exactly at all times

    because there will be no proper synchronization between the transmitter and the

    microcontroller unit. i.e., whatever the microcontroller sends the data to the transmitter, the

    transmitter is not able to accept this data as this will be not in the radio frequency range. Thus,

    we need an intermediate device which can accept the input from the microcontroller, process itin the range of radio frequency range and then send it to the transmitter. Thus, an encoder is

    used.

    RF Receiver STR-433 MHz

    Fig. 4.10 RF Receiver STR-433MHz

    37

  • 8/2/2019 Main Project Repor

    38/59

    The data is received by the RF receiver from the antenna pin and this data is available

    on the data pins. Two Data pins are provided in the receiver module. Thus, this data can be

    used for further applications.

    Pin description

    in ame Descript Fig. 4.11 Pin diagram of STR-433MHz

    ANT

    Antenna input.

    GND

    Receiver Ground. Connect to ground plane.

    VCC (5V)

    VCC pins are electrically connected and provide operating voltage for the receiver.

    VCC can be applied to either or both. VCC should be bypassed with a .1F ceramic capacitor.

    Noise on the power supply will degrade receiver sensitivity.

    DATA

    Digital data output.

    This output is capable of driving one TTL or CMOS load. It is a CMOS compatible output.

    38

  • 8/2/2019 Main Project Repor

    39/59

    Applications

    Fig. 4.12 Basic Application circuit of STR-433MHz

    Similarly, as the transmitter requires an encoder, the receiver module requires a decoder.

    4.6 RF ENCODER AND DECODER

    Encoder HT640

    Fig. 4.13 Pin diagram of Encoder HT640

    39

  • 8/2/2019 Main Project Repor

    40/59

    Pin Description

    The Encoder Working

    The 318 (3 power of 18) series of encoders begins a three-word transmission cycle

    upon receipt of a transmission enable (TE for the HT600/HT640/HT680 or D12~D17 for the

    HT6187/HT6207/HT6247, active high). This cycle will repeat itself as long as the transmission

    enable (TE or D12~D17) is held high. Once the transmission enable falls low, the encoder

    output completes its final cycle and then stops as shown below.

    40

  • 8/2/2019 Main Project Repor

    41/59

    Basic Application Circuit Of HT640 Encoder

    Fig. 4.14 Basic Application Circuit of HT640 Encoder

    Transmission Circuit

    41

  • 8/2/2019 Main Project Repor

    42/59

    Fig. 4.15 Basic Transmission Circuit

    The data sent from the microcontroller is encoded and sent to RF transmitter. The data

    is transmitted on the antenna pin. Thus, this data should be received on the destination i.e, on

    RF receiver.

    Decoder HT648L

    Fig. 4.16 Decoder HT648L

    Pin Description

    42

  • 8/2/2019 Main Project Repor

    43/59

    Features

    Operating voltage: 2.4V~12V.

    Low power and high noise immunity CMOS technology.

    Low standby current.

    Capable of decoding 18 bits of information.

    Pairs with HOLTEKs 318 series of encoders.

    8~18 address pins.

    0~8 data pins.

    THE DECODER WORKING

    The 3^18 decoders are a series of CMOS LSIs for remote control system applications.

    They are paired with the 3^18 series of encoders.

    For proper operation, a pair of encoder/decoder pair with the same number of address

    and data format should be selected.

    The 3^18 series of decoders receives serial address and data from that series of

    encoders that are transmitted by a carrier using an RF medium.

    A signal on the DIN pin then activates the oscillator which in turns decodes the

    incoming address and data.

    It then compares the serial input data twice continuously with its local address.

    If no errors or unmatched codes are encountered, the input data codes are decoded and

    then transferred to the output pins.

    The VT pin also goes high to indicate a valid transmission. That will last until the

    address code is incorrect or no signal has been received.

    The 3^18 decoders are capable of decoding 18 bits of information that consists of N

    bits of address and 18N bits of data.

    43

  • 8/2/2019 Main Project Repor

    44/59

    Basic Application Circuit Of HT648L Decoder

    Fig. 4.17 Basic Application Circuit of HT648L Decoder

    Reception Circuit

    Fig. 4.18 Basic Reception Circuit

    44

  • 8/2/2019 Main Project Repor

    45/59

    The data transmitted into the air is received by the receiver. The received data is taken

    from the data line of the receiver and is fed to the decoder .The output of decoder is given to

    microcontroller and then data is processed according to the applications.

    4.7 STEPPER MOTOR

    Fig. 4.19 Stepper motor

    A stepper motor is a widely used device that translates electrical pulses into mechanical

    movement. The stepper motor is used for position control in applications such as disk drives,

    dot matrix printers and robotics.

    Stepper motors commonly have a permanent magnet rotor surrounded by a stator. The

    most common stepper motors have four stator windings that are paired with a center-tapped

    common. This type of stepper motor is commonly referred to as a four-phase or unipolar

    stepper motor. The center tap allows a change of current direction in each of the two coils

    when a winding is grounded, thereby resulting in a polarity change of the stator.

    The direction of the rotation is dictated by the stator poles. The stator poles are determined by

    the current sent through the wire coils. As the direction of the current is changed, the polarity is

    also changed causing the reverse motion of the rotor.

    45

  • 8/2/2019 Main Project Repor

    46/59

    It should be noted that while a conventional motor shaft runs freely, the stepper motor

    shaft moves in a fixed repeatable increment, which allows one to move it to a precise position.

    Thus, the stepper motor moves one step when the direction of current flow in the field coil(s)

    changes, reversing the magnetic field of the stator poles. The difference between unipolar and

    bipolar motors lies in the may that this reversal is achieved.

    Fig. 4.20 Stepper motor operation

    Advantages

    1. The rotation angle of the motor is proportional to the input pulse.

    2. The motor has full torque at standstill (if the windings are energized)

    3. Precise positioning and repeatability of movement since good stepper motors have an

    accuracy of 3 5% of a step and this error is non cumulative from one step to the next.

    4. Excellent response to starting/ stopping/reversing.

    5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor

    is simply dependant on the life of the bearing.

    6. The motors response to digital input pulses provides open-loop control, making the motor

    simpler and less costly to control.

    7. It is possible to achieve very low speed synchronous rotation with a load that is directly

    coupled to the shaft.

    46

  • 8/2/2019 Main Project Repor

    47/59

    8. A wide range of rotational speeds can be realized as the speed is proportional to the

    frequency of the input pulses.

    Disadvantages

    1. Resonances can occur if not properly controlled.

    2. Not easy to operate at extremely high speeds.

    4.8 Buzzer

    A buzzer or beeper is a signalling device, usually electronic, typically used in

    automobiles, household appliances such as a microwave oven, or game shows. It most

    commonly consists of a number of switches or sensors connected to a control unit that

    determines if and which button was pushed or a preset time has lapsed, and usually illuminatesa light on the appropriate button or control panel, and sounds a warning in the form of a

    continuous or intermittent buzzing or beeping sound. Initially this device was based on an

    electromechanical system which was identical to an electric bell without the metal gong

    (which makes the ringing noise). Often these units were anchored to a wall or ceiling and used

    the ceiling or wall as a sounding board.

    Another implementation with some AC-connected devices was to implement a circuit

    to make the AC current into a noise loud enough to drive a loudspeaker and hook this circuitup to a cheap 8-ohm speaker. Now-a-days, it is more popular to use a ceramic-based piezo-

    electric sounder like a Sonalert which makes a high-pitched tone. Usually these were hooked

    up to driver circuits which varied the pitch of the sound or pulsed the sound on and off

    V C C

    Q ?

    B C 5

    D ?

    4 0 0 7

    +

    1 2 V

    -

    B u z

    Fig. 4.21 Buzzer Circuit

    47

    C PORT

  • 8/2/2019 Main Project Repor

    48/59

    The circuit is designed to control the buzzer. The buzzer ON and OFF is

    controlled by the pair of switching transistors (BC 547). The buzzer is connected in the Q2

    transistor collector terminal. When high pulse signal is given to base of the Q1 transistors, the

    transistor is conducting and close the collector and emitter terminal so zero signals is given to

    base of the Q2 transistor. Hence Q2 transistor and buzzer is turned OFF state.

    When low pulse is given to base of transistor Q1, the transistor is turned OFF.

    Now 12V is given to base of Q2 transistor so the transistor is conducting and buzzer is

    energized and produces the sound signal.

    Applications

    Annunciate panels

    Electronic metronomes

    Game shows

    Microwave ovens and other household appliances

    4.9 RELAY CIRCUIT

    This is a regular general-purpose NPN type transistor. For control the 12V DCvoltage

    electromechanical relay.BC547 is used in the relay circuit.This device is designed for use asgeneral purpose amplifiers and switches requiring collector currents to 300 mA. Sourced from

    Process . Relay circuit acts as a switch in this purpiose .It also save the power .

    48

  • 8/2/2019 Main Project Repor

    49/59

    Fig. 4.23 Relay Circuit

    4.10MAX232 AND RS232

    A line driver required to convert RS232 voltage levels to TTL levels, and vice versa. It

    includes a capacitive voltage generator to supply TIA/EIA-232-F voltage levels from a single

    5-V supply. Each receiver converts TIA/EIA-232-F inputs to 5-V TTL/CMOS levels. These

    receivers have a typical threshold of 1.3 V, a typical hysteresis of 0.5 V, and can accept 30-V

    inputs. Each driver converts TTL/CMOS input levels into TIA/EIA-232-F levels.

    Pin Diagram

    Fig. 4.24 MAX 232 pin configuration

    49

  • 8/2/2019 Main Project Repor

    50/59

    Connection with Microcontroller and DB9

    Fig. 4.25Connections with Microcontroller and DB9

    8051 has two pins that are used specifically for transferring and receiving data serially. These

    two pins are called TxD and RxD and are part of the port 3 group (P3.0 and P3.1).These pins

    are TTL compatible; therefore, they require a line driver to make them RS232 compatible. To

    allow data transfer between the PC and an 8051 system without any error, we must make sure

    that the baud rate of 8051 system matches the baud rate of the PCs COM port.

    How the RS-232 serial interface works

    Most computers have one or two serial RS-232 interface as standard equipment.

    Characteristics

    An RS-232 interface has the following characteristics:

    50

  • 8/2/2019 Main Project Repor

    51/59

    Uses a 9 pins connector "DB-9" (older PCs use 25 pins "DB-25").

    Allows bidirectional full-duplex communication (the PC can send and receive data at

    the same time).

    Can communicate at a maximum speed of roughly 10KBytes/s.

    DB-9 connector

    You probably already saw this connector on the back of your PC.

    Fig. 4.26 DB-9 connector

    It has 9 pins, but the 3 important ones are:

    pin 2: RxD (receive data).

    pin 3: TxD (transmit data).

    pin 5: GND (ground).

    Using just 3 wires, you can send and receive data.

    CHAPTER 5

    SOFTWARE IMPLEMENTATION

    5.1 FLOWCHART

    51

  • 8/2/2019 Main Project Repor

    52/59

    Fig. 5.1 Flow chart for the Transmitter Section

    52

  • 8/2/2019 Main Project Repor

    53/59

    Fig.5.2 Flow chart for the Receiver Section

    5.2 code dumped in a micro controller

    53

  • 8/2/2019 Main Project Repor

    54/59

    54

  • 8/2/2019 Main Project Repor

    55/59

    APPENDIX AIC7805

    The specifications and absolute maximum ratings of IC7805 voltage regulator are

    presented in this chapter.

    A.1 Electrical Characteristics:

    A.2 Maximum Ratings

    55

  • 8/2/2019 Main Project Repor

    56/59

    APPENDIX B

    Microcontroller(AT89S52)

    The specifications and absolute maximum ratings of AT89S52 microcontroller are

    presented in this chapter

    B.1 DC Characteristics

    56

  • 8/2/2019 Main Project Repor

    57/59

    B.2 Absolute Maximum Rating

    B.3 AC Characteristics

    57

  • 8/2/2019 Main Project Repor

    58/59

    REFERENCES

    58

  • 8/2/2019 Main Project Repor

    59/59

    Books

    The 8051 Microcontroller architecture, programming and applications -Kenneth

    J.Ayala,second edition.

    The 8051 Microcontroller and Embedded systems Muhammad Ali mazidi, Janice

    Gillispoe mazidi,3rd edition.

    C and the 8051 programing And MultitaskingSchultz.

    URLs

    www.atmel.com ATMEGA8952 Microcontroller

    www.senet.com.au/~cpeacock RS 232

    www.maxim-ic.com Max 220-249

    www.mysunrise.ch/users/pfleury/avr-circuits.html LCD

    http://www.atmel.com/http://www.senet.com.au/~cpeacockhttp://www.senet.com.au/~cpeacockhttp://www.maxim-ic.com/http://www.maxim-ic.com/http://www.mysunrise.ch/users/pfleury/avr-circuits.htmlhttp://www.atmel.com/http://www.senet.com.au/~cpeacockhttp://www.maxim-ic.com/http://www.mysunrise.ch/users/pfleury/avr-circuits.html