Six Weeks

Embed Size (px)

Citation preview

  • 8/10/2019 Six Weeks

    1/38

    Company Profile

    Technology changes drastically within the counts of time and it have become vicissitude of

    life. To survive in the air of cutthroat competition, one needs to be fully cognizant with the

    changing trends of the technology, the needs of the clients and the employers, in brief,

    with almost all the aspects o f the industry. There is great demand for system designing

    engineers working on the embedded systems. This demand is going to rise further in the

    coming years. Other factor favorable for this is the incursion of foreign especiallyAmerican companies in India.

    EEAST is a complete R & D Organization dedicated to provide Electronics and

    Advanced Software Products and Solutions to its Clients. Achieving the needs of our

    customer and converting their ideas to real models is our motto. We are working in the field of

    Embedded Systems, Automation and Advanced System design for the last four years with the

    vision of becoming a center of Excellence to provide Solutions, Services and Training in

    various fields of technologies.

    EEAST has the distinction of being a pioneer among the embedded companies in India,

    engaged in imparting high-end training in all aspects of Embedded Systems Design and

    Project development in various fields of engineering and technology for graduates,

    undergraduates and postgraduates of the appropriate discipline, the training at EEAST is not

    merely passing knowledge but build intelligence among the participants to achieve goals intheir life by thoroughly exposing them to industrial environment and projects. We work

    on overall development of our employees and trainees.

    EEAST is an organization providing advanced projects, complete electronic solutions in

    development systems like microprocessor, micro - controllers, wireless communications,

    optical fiber communications, real time operating systems, digital signal processing,

    Embedded Systems and Micro - Sensors including software solution, solutions in C, C++,

    Java, .Net, Visual, C++ Visual basic, embedded C and Embedded LINUX. We have been

    roviding projects and solutions professionally to various industries, academically to

    innumerable number of students. In our endeavor for excellence and manpower

    developments in this field, we are providing on these technologies specially customized for

    individual needs.

  • 8/10/2019 Six Weeks

    2/38

    Introduction

    Microcontroller are widely used in Embedded System products. An Embedded product uses

    the microprocessor(or microcontroller) to do one task & one task only. A printer is an example

    of Embedded system since the processor inside it perform one task only namely getting the

    data and printing it. Contrast this with Pentium based PC. A PC can be used for any no. ofapplications such as word processor, print server, bank teller terminal, video game player,

    network server or internet terminal. Software for variety of applications can be loaded and run.

    Of course the reason a PC can perform multiple task is that it has RAM memory and an

    operating system that loads the application software into RAM & lets the CPU run it. In and

    Embedded system there is only one application software that is typically burn into ROM. An

    x86PC Contain or its connected to various Embedded Products such as keyboard, printer,

    modem, Disc controller, Sound card, CD-Rom Driver, Mouse & so on. Each one of these

    peripherals as a microcontroller inside it that performs only one task. For example inside every

    mouse there is microcontroller to perform the task of finding the mouse position and sending it

    to PC.

    Although microcontroller are preferred choice for many Embedded systems, There are timesthat a microcontroller is inadequate for the task. For this reason in recent years many

    manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD & Cyrix

    have targeted their microprocessors for the high end of Embedded market. While INTEL,

    AMD, Cyrix push their x86 processors for both the embedded and desktop pc market,

    Motorolla is determined to keep the 68000 families alive by targeting it mainly for high end of

    embedded system.

    One of the most critical needs of the embedded system is to decrease power consumptions and

    space. This can be achieved by integrating more functions into the CPU chips. All the

    embedded processors based on the x86 and 680x0 have low power consumptions in additions

    to some forms of I/O, Com port & ROM all on a single chip. In higher performance Embedded

    system the trend is to integrate more & more function on the CPU chip & let the designerdecide which feature he/she wants to use.

  • 8/10/2019 Six Weeks

    3/38

    MICROPROCESSOR (MPU)

    A microprocessor is a general-purpose digital computer central processing

    unit (CPU). Although popularly known as a computer on a chip is in nosense a complete digital computer. The block diagram of a microprocessor

    CPU is shown, which contains an arithmetic and logical unit (ALU), a

    program counter(PC), a stackpointer (SP),some working registers, a clock

    timing circuit, and interrupt circuits.

    BLOCK DIAGRAM OF A MICROPROCESSOR

    ARITHMETICAND

    LOGICAL UNIT

    ACCUMULATOR

    WORKING REGISTERS

    PROGRAMCOUNTER

    STACKPOINTER

    CLOCKCIRCUIT

    INTERRUPTCIRCUITS

  • 8/10/2019 Six Weeks

    4/38

    MICROCONTROLLERS (MCU)

    Figure shows the block diagram of a typical microcontroller, which is a true

    computer on a chip. The design incorporates all of the features found in

    micro-processor CPU: ALU, PC, SP, and registers. It also added the other

    features needed to make a complete computer: ROM, RAM, parallel I/O,serial I/O, counters, and clock circuit.

    BLOCK DIAGRAM OF A MICROCONTROLLER

    TIMER / COUNTER

    INTERNALROM

    ALU I/OPORT

    I/O

    PORT

    Interrupt

    Circuits

    CLOCK

    CIRCUIT

    ACCUMULATOR

    REGISTERS

    INTERNALRAM

    ALU

    PROGRAM COUNTER

  • 8/10/2019 Six Weeks

    5/38

    MICROCONTROLLER ARCHITECTURE

    VARIOUS MICROCONTROLLERS

    First microcontroller is 8031

    FEATURES

    (i) It is Intels product. Neither a microprocessor nor a microcontroller.

    (ii) It is a 8-bit controller.

    (iii) Internally no ROM is provided i.e. code is outside the chip.

    Second microcontroller is 8051

    FEATURES

    (i) It is a first complete 8-bit microcontroller.

    (ii) It is a name of a family. In which the instruction set, pin configuration,

    architecture are same, only memory storage capacity is different.

    (iii) Internally PROM (programmable read only memory) is provided so it

    called one time programmable (OTP).

    Third microcontroller is AT89C51

    FEATURES

    (i) It is a similar to 8051 microcontroller i.e. having same instruction set,

    pin configuration, architecture.

    (ii) It is a also 8-bit microcontroller. Its cost is only Rs10 more than 8051.

    (iii) It uses EPROM (erasable programmable read only memory) or

    FLASH memory.

    (iv) it is Multiple time programmable (MTP)i.e. 1000 times. So it is better

    than 8051.

    ATMEL 89C51

    It is a low-power, high-performance CMOS 8-bit microcomputer with 4K 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 pin out. The on-chip Flash allows the 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 AT89C51 is a

    powerful microcomputer, which provides a highly flexible and cost-effective solution to many

    embedded control applications

  • 8/10/2019 Six Weeks

    6/38

    THE 8051 MICROCONTROLLER

    The 8051 provides the following standard features: 4Kbytes of ROM, 128 bytes ofRAM,

    32 I/O lines, two16-bit timer/counters, a five vector two-level interrupt architecture, a full

    duplex serial port, on-chip oscillator and clock circuitry. In addition, the 8051 is designed

    with static logic for operation down tozero frequencyandsupportstwosoftwareselectable

    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 hardware reset.

    The 8051 Microcontrollers Architectureconsists of thesespecific features

    Eight-bit CPU with registers A (the accumulator) & B.

    Sixteen-bit program counter (PC) and data pointer (DPTR).

    Eight-bit program status word (PSW).

    Eight-bit stack pointer (SP).

    Internal ROM or EPROM (8751) of 0(8031) to 4K (8051).

    Internal RAM of 128 bytes.

    1. Four register banks, each containing eight registers.2. Sixteen bytes, which may be addressed at the bit level.3. Eight bytes of general-purpose data memory.

    Thirty two I/O pins arranged as four-bit ports P0 P3.

    Two 16-bit Timer/Counters T0 and T1.

    Full duplex serial data receiver/transmitter (SBUF).

    Control registers TCON, TMOD, SCON, PCON, IP and IE.

    Two external and three internal interrupt sources.Oscillator and clock circuits

  • 8/10/2019 Six Weeks

    7/38

    PIN DESCRIPTION

    VCC -- Supply voltage.

    GND --Ground.

    Port 0 -- Port 0 is an 8-bit open drain bi-directional I/O port. As anoutputport each pin can sink eight TTL inputs. When 1s are written to port 0

    pins, the pins can be used as high impedance inputs. Port0 may also be

    configured to be the multiplexed low order Address / data bus during

    accesses to external program and data memory. In this mode P0 has

    internal pull ups. Port 0 also receives the code bytes during ROM

    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 . ThePort1 output buffers can sink/source four TTL inputs. When 1s are written

    to Port1pins theyarepulled 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 (IIL) because of the internal pull-ups. Port 1 also receives

    the low-order address bytes during ROM programming and verification.

  • 8/10/2019 Six Weeks

    8/38

    Port 2 -- Port 2 is an 8-bit bi-directional I/O port with internal pull-ups . ThePort2 output buffers can sink/source four TTL inputs. When 1s are written

    to Port2 pins they are pulledhigh by theinternal pull-ups and can beused

    as inputs. As inputs, Port 2 pins that are externallybeing pulled low will

    source current (IIL) because of the internal pull-ups. Port2 emits the high-

    order address byte during fetches from external program memory and

    during accesses to external data memory that use 16-bit addresses

    (MOVX @ DPTR). In this application it uses strong internal pull-ups when

    emitting 1s. During accesses to external data memory that use 8-bit

    addresses(MOVX @ RI), Port 2 emits the contents of the P2 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.ThePort3 output buffers can sink/source four TTL inputs.When 1s are written

    to Port3pins they are pulled high by the internal pull-ups andcan be used

    as inputs. As inputs, Port 3 pins that are externally being pulled low will

    source current (IIL) because of the pull-ups. Port 3 also receives some

    control signals for ROM programming and verification. Port 3 also serves

    the functions of various special features of the 8051.

    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/10/2019 Six Weeks

    9/38

    RST -- Reset input. A high on this pin for two machine cycles while theoscillator is running resets the device.

    ALE/PROG -- Address Latch Enable output pulse for latching the low

    byte of the address during accesses to external memory. This pin isalso the program pulse input (PROG) during ROM programming. In

    normal operation ALE is emitted at a constant rate of 1/6 the oscillator

    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 is the read strobe to external programmemory. When the 8051 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 inorder 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. EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage (VPP)

    during Flash programming, for parts that require12-volt VPP.

    XTAL1Input to the inverting oscillator amplifier and input to theinternal clock operating circuit.

    XTAL2-- Output from the inverting oscillator amplifier.

  • 8/10/2019 Six Weeks

    10/38

    Memory Organization

    There are two types of memory in microprocessor devices.

    Program Memory

    Data MemoryEach memory type has different addressing mechanism, different control signals and different

    function. The Program Memory (ROM or EPROM) is extremely large, read only and non-

    volatile. This has a 16-bit address bus, whose elements are accessed by program counter or

    instructions that generates 16-bit address.

    The Data Memory is a read/write memory space, which is smaller and hence quicker than

    program memory. It goes into random state when the electric power is applied. On chip data

    RAM is used for variables, which are determined or may change while program is running.

    Memory Mapping

    Up to 64KB of

    External

    ROM/PROM

    Up to

    60KB of

    External

    ROM/

    PROM

    4KB of

    Internal

    ROM/EPROM

    Up to 64KB of

    External

    RAM

    SFRs and

    128 bytes

    RAM

    Program Memory Data Memory

  • 8/10/2019 Six Weeks

    11/38

    VARIOUS REGISTERS

    THE PROGRAM STATUS WORD(PSW)

    SF REGISTER

    Bit Description

    7 6 5 4 3 2 1 0 Bit No.

    Bit description

    BIT SYMBOL FUNCTION

    7 CY Carry flag used in arithmetics, jump, rotate, and rotat

    and Boolean instructions.

    6 AC Auxiliary Carry flag; used for BCD arithmetic.

    5 FO User Flag 0

    4 RS1 Register Bank Select Bit 1

    3 RS0 Register Bank Select Bit 0

    RS1 RS0

    0 0 Select Register bank 0

    0 1 Select Register bank 1

    1 0 Select Register bank 2

    1 1 Select Register bank 3

    2 OV Overflow flag, used in arithmetic instruction.

    1 ___ Reserved for future use

    0 P Parity Flag; shows parity of register A

    CY AC FO RS1 RS0 OV ___ P

  • 8/10/2019 Six Weeks

    12/38

    SPECIAL FUNCTION REGISTERS

    The 8051 operations that do not use the internal 128-byte Ram addresses

    from 00h to 7Fh are done by a group of specific internal register, each

    called a special function register (SFR).

    WHAT IS INTERNETWORK?

    NAME FUNCTION INTERNALRAM ADD.

    A ACCUMULATOR 0E0B ARITHMETIC 0F0

    DPH ADDRESSING EXTERNAL MEMORY 83

    DPL ADDRESSING EXTERNAL MEMORY 82

    IE INTERRUPT ENABLE CONTROL 0A8

    IP INTERRUPT PRIORITY 0B8

    P0 INPUT/OUTPUT PORT LATCH 80

    P1 INPUT/OUTPUT PORT LATCH 90

    P2 INPUT/OUTPUT PORT LATCH 0A0

    P3 INPUT/OUTPUT PORT LATCH 0B0

    PCON POWER CONTROL 87

    PSW PROGRAM STATUS WORD 0D0

    SCON SERIAL PORT CONTROL 98

    SBUF SERIAL PORT DATA BUFFER 99

    SP STACK POINTER 81

    TMOD TIMER/COUNTER MODE CONTROL 89

    TCON TIMER/COUNTER MODE CONTROL 88

    TL0 TIMER 0 LOW BYTE 8A

    TH0 TIMER 0 HIGH BYTE 8C

    TL1 TIMER 1 LOW BYTE 8B

    TH1 TIMER 0 HIGH BYTE 8D

  • 8/10/2019 Six Weeks

    13/38

    TIMER MODE CONTROL REGISTER(TMOD)

    SFR

    [ TIMER1 ] [ TIMER0 ]

    Bits

    7 6 5 4 3 2 1 0 Bit No.

    BIT DESCRIPTION

    The various bits of TMOD register are explained below:

    BIT SYMBOL FUNCTION

    7/3 GATE OR gate enable bit which controls RUN/STOP of Timer I/O.

    6/2 C/T Set to 1 by program to make timer I/O act as a counter by

    counting pulses from external input pin3.5(T1) or 3.4(T0).

    5/1 M1 Timer/Counter operating mode select bit1. Set /Cleared byprogram to select mode.

    4/0 M0 Timer/Counter operating mode select bit0. Set/Cleared by

    program to select mode.

    TMOD is not bit addressable.

    GATE C/T M1 M0 GATE C/T M1 M0

  • 8/10/2019 Six Weeks

    14/38

    TIMER CONTROL (TCON)

    Bits7 6 5 4 3 2 1 0 Bit No.

    BIT DESCRIPTION

    The various bits of TCON registers are explained below:

    BIT SYMBOL FUNCTION

    7 TF1 Timer 1 overflow flag.

    6 TR1 Timer 1 RUN control bit.

    5 TF0 Timer 0 overflow flag.

    4 TR0 Timer 0 RUN control bit.

    3 IE1 External interrupt 1 edge flag.

    2 IT1 External interrupt 1 single type control bit.

    1 IE0 External interrupt 0 edge flag.

    0 IT0 External interrupt 1 single type control bit.

    TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

  • 8/10/2019 Six Weeks

    15/38

    ADDRESSING MODES

    The various addressing mode are immediate, register, direct and indirect.Data is stored at a source address and moved (copied) to a destinationaddress. The ways by which these addresses are specified are called the

    addressing modes. The 8051 mnemonics are written with the (data)destination address named first, followed by the source address.

    1. Immediate Addressing Mode

    source ofdata only

    2. Register Addressing Mode

    Source ordestination of data

    3. Direct Addressing Mode

    Source or destinationdata

    4. IndirectAddressing Mode

    Address ofdata

    Source or destinationdata

    Instruction using # Next bytes are data

    Instruction using R0 to R7

    Register R0 to R7 in current bank

    Instruction using a RAM address

    Address in RAM

    Instruction using @ R0 or @R1

    Register R0 or R1 in current bank

    Address in RAM

  • 8/10/2019 Six Weeks

    16/38

    Keil Software

    Keil software is used for the software implementation of the developed system. Vision2

    Integrated Development Environment is an IDE that encapsulates a project manager, make

    facility, tool configuration, editor and a powerful debugger. Vision2 is used to write and

    compile the programs using the tools. It can transfer the assembly language as well as, C codeinto the hex file. Keil software consists of a Linker Control File, Map File, Project Target,

    Source File Group, Toolset. Linker Control File

    i) Linker control fileIt is a text file that Vision passes to the linker when linking. The control file includes all

    directives and names of object files and library files to include in the output file.

    ii) Map FileThe Map File is a listing file generated by the linker.

    iii) Project Target:In a project, a target is an executable program that is generated. A project may generate a

    target that runs on an 8051. Targets may be created for builds with no optimization and for

    builds with full optimization.

    iv) Source File Group:In a project, a group is a number of source files that compose the project target. Although you

    may individually specify the toolset options for a file, a group lets you apply the same options

    to a group of source files. The options for a group may be different from the options for the

    target.

    v) Toolset:A toolset include an assembler, compiler, linker, HEX converter, debugger, and the otherassociated tools for a particular device family like the 8051. All of the tools or programs in a

    toolset are dedicated to generating target code for a specific family of chips [27].

    To evaluate the software for correct operation the file was programmed into the

    microcontroller on the relevant development board. Programming of the microcontroller was

    achieved using the VPL-SPROG programmer. It is a handy serial programmer. This permits

    hexadecimal files to be loaded into the microcontroller. Initially the microcontroller was

    programmed by removing it from the socket on the board and inserting it into the multi-pin

    socket on the programmer.

    Section 4.2 describes the programming model and instruction set and section 4.3 describes the

    algorithm.

  • 8/10/2019 Six Weeks

    17/38

    Power Supply

    The power supply supplies the required energy for both the microcontroller and the associated

    circuits. It is the most essential part of the circuit because to run its constituent ICs circuit has

    to be provided with power. These ICs can run on DC power. Hence the required D.C supply

    has to be generated. The main parts of a power supply unit and their function are as follows:

    Power supply schematic

    DESCRIPTIONPower supply is the main requirement of every project. The various parts of a power supply

    are explained below:

    Transformer:The function of the transformer is to step down the voltage level from

    the available A.C.220V to the desired voltage. The 9-0-9 rating of the transformer upon

    the requirements of the ICs in the circuit is used. The secondary has a center tapping

    which forms the neutral terminal.

    Bridge rectifier: The function of the rectifier is to convert the alternating voltage

    signal into a unidirectional one. This function is provided by semiconductor diodes

    connected in bridge configuration. Diodes 1N4007 are used as rectifier.

    Ripple Rejection:The output voltage of the rectifier is unidirectional but pulsating. A

    capacitor of 1000f is used for ripple rejection.

    Regulation:To obtain a constant voltage specific ICs are used as voltage regulator.

    Voltage regulator LM7805 is used. These ICs have three terminals an input, an output

    and a ground terminal.

    D2

    C1

    1000uf

    1N4007 +5V

    V

    LM7805

    1 2

    3

    VIN VOUT

    G

    N

    D

    J1

    1

    2

    3

    D3

    gnd

    D4

    D1

  • 8/10/2019 Six Weeks

    18/38

    LCD Display

    Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs.

    This is due to the declining prices of LCD, the ability to display numbers, characters and

    graphics, incorporation of a refreshing controller into the LCD, their by relieving the CPU

    of the task of refreshing the LCD and also the ease of programming for characters and

    graphics. HD 44780 based LCDs are most commonly used.

    LCD pin description

    The LCD discuss in this section has the most common connector used for the Hitatchi

    44780 based LCD is 14 pins in a row and modes of operation and how to program and

    interface with microcontroller is describes in this section.

    Vcc

    1615141312111098

    654321

    7

    1615141312111098

    65432

    1

    7

    D7

    E

    Vcc

    D4

    ContrastRS

    Gnd

    R/W

    Gnd

    D0

    D3

    D6D5

    3

    2

    D2D1

    LCD Pin Description Diagram

    VCC, VSS, VEE

    The voltage VCC and VSS provided by +5V and ground respectively while VEE is

    used for controlling LCD contrast. Variable voltage between Ground and Vcc is used to

    specify the contrast (or "darkness") of the characters on the LCD screen.

    RS (register select)

    There are two important registers inside the LCD. The RS pin is used for their selection as

    follows. If RS=0, the instruction command code register is selected, then allowing to user

    to send a command such as clear display, cursor at home etc.. If RS=1, the data register is

    selected, allowing the user to send data to be displayed on the LCD.

    R/W (read/write)

  • 8/10/2019 Six Weeks

    19/38

    The R/W (read/write) input allowing the user to write information from it. R/W=1, when it

    read and R/W=0, when it writing.

    EN (enable)

    The enable pin is used by the LCD to latch information presented to its data pins. Whendata is supplied to data pins, a high power, a high-to-low pulse must be applied to this pin

    in order to for the LCD to latch in the data presented at the data pins.

    D0-D7 (data lines)

    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 displays the letters and numbers, we send ASCII codes for

    the letters A-Z, a-z, and numbers 0-9 to these pins while making RS =1. There are also

    command codes that can be sent to clear the display or force the cursor to the homeposition or blink the cursor.

    We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the

    information. The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if

    R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking care of internal

    operations and will not accept any information. When D7 =0, the LCD is ready to receive

    new information.

    14.7 Interfacing of micro controller with LCD display

    In most applications, the "R/W" line is grounded. This simplifies the application

    because when data is read back, the microcontroller I/O pins have to be alternated between

    input and output modes. In this case, "R/W" to ground and just wait the maximum amount

    of time for each instruction (4.1 msecs for clearing the display or moving the cursor/display

    to the "home position", 160 usecs for all other commands) and also the application

    software is simpler, it also frees up a microcontroller pin for other uses. Different LCD

    execute instructions at different rates and to avoid problems later on (such as if the LCD is

    changed to a slower unit). Before sending commands or data to the LCD module, the

    Module must be initialized. Once the initialization is complete, the LCD can be written to

    with data or instructions as required. Each character to display is written like the control

    bytes, except that the "RS" line is set. During initialization, by setting the "S/C" bit during

    the "Move Cursor/Shift Display" command, after each character is sent to the LCD, the

  • 8/10/2019 Six Weeks

    20/38

    cursor built into the LCD will increment to the next position (either right or left). Normally,

    the "S/C" bit is set (equal to "1")

    Interfacing of Microcontroller with LCD

  • 8/10/2019 Six Weeks

    21/38

    ANALOG TO DIGITAL CONVERTER

    The ADC (0808) data acquisition component is a monolithic CMOS device with 8-bit

    analog to digital converter, 8-channel multiplexer and microprocessor compatible control logic.

    The Pin diagram for the ADC 0809 is shown in figure 3.5

    Some of the specifications of ADC (0808) are, Resolution of 8 bits, 100 s Conversion

    time, Radiometric Conversion, Monotonic Over the entire A/D Conversion Range, No

    Missing Codes, Clock range 50 to 800 kHz. It is Easy Interface to all Microprocessors,

    Microcontroller and Operates ratio metrically or with 5 VDC or analog span adjusted

    voltage reference. The 8bit A /D converter uses successive approximation as the

    conversion technique. The converter features a high impedance chopper stabilized

    comparator, a 256R voltage divider with analog switch tree and a successive approximationregister. The 8-channel multiplexer can directly access any of 8-single-ended analog

    signals. The device eliminates the need for external zero and full-scale adjustments. Easy

    interfacing to microprocessor, microcontroller is provided by the latched and decoded

    multiplexer address inputs and latched TTL Tri-State outputs. Incorporating the most

    desirable aspects of several A/D conversion techniques has optimized the design of the

    ADC 0808. The ADC 0808 offers high speed, high accuracy, minimal temperature

    OUTPUT ENABLE 9

    7

    8

    5

    6

    4

    3

    2

    26

    27

    28

    13

    12

    11

    10

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    1IN3

    START

    IN4

    IN5

    IN6

    IN7

    EOC

    2-5

    CLOCK

    VCC

    VREF(+)

    GND VREF(+)

    IN2

    IN1

    IN0

    ADD A

    ADD B

    ADD C

    ALE

    2-1 MSB

    2-2

    2-3

    2-4

    2-8 LSB

  • 8/10/2019 Six Weeks

    22/38

    dependence, excellent long term accuracy and repeatability, and consume minimum power.

    These features make this device ideally suited to applications from process and machine

    control to consumer and automotive applications. The 8-channel multiplexer can be

    controlled by a microcontroller through a 3-bit address decoder with address load to select

    any one of eight single-ended analog switches connected directly to the comparator.

    Channel 0 of the multiplexer has been selected permanently by grounding the address pins

    of multiplexer in the electronics hardware i.e. Pin no. 23, Pin no. 24 and Pin no. 25. The

    comparison and the converting methods used eliminate the possibility of missing codes,

    nonmonotonicity, and the need for zero or full-scale adjustment. Also featured are latched

    3-state outputs from the SAR and latched inputs to the multiplexer address decoder. The

    single 5V supply and low power requirements make the ADC 0808 especially useful for a

    wide variety of applications. Ratio metric conversion is made possible by access to the

    reference voltage input terminals. The ADC 0809 are characterized for operation from 40

    0 C to 85 0 C. The ADC 0809/0808 contains a network with 256-300W resistors in series.

    Analog switch taps are made at the junction of each resistor and at each end of the network.

    In operation, a reference of 5V is applied across the network of 256 resistors. An analog

    input VIN is first compared to the center point of the ladder via the appropriate switch. If

    VIN is larger than VREF / 2, the internal logic changes the switch points and now

    compares VIN and VREF. This process, known as successive approximation, continues

    until the best match of VIN and VREF is made. N defines a specific tap of the resistor

    network. When the conversion is complete, the logic loads a binary word corresponding to

    this tap into the output latch and an end of conversion (EOC) logic level appears. The

    output latch holds this data valid until a new conversion is completed and new data is

    loaded into the latches. The data transfer occurs in about 100ns so that valid data is present

    virtually all the time in the latches. The data outputs are activated when the output enable is

    high, and in TRI-STATE when output enable is low. The enable delay time is

    approximately 100ns.each conversion requires 40 clock periods. The device may be

    operated in the free running mode by connecting the start conversion line to the end of

    conversion line. However, to ensure start-up under all possible conditions, an external start

    conversion pulse is required during power up conditions. The EOC line (pin 7) will be in

    the low state for a maximum of 40 clock periods to indicate busy. A START pulse that

    occurs while the A/D is BUSY will reset the SAR and start a new conversion with the EOC

    signal remaining in the low state until the end of this new conversion. When the conversion

  • 8/10/2019 Six Weeks

    23/38

    is complete, the EOC line will go to the high voltage state. An additional 4 clock periods

    must be allowed to elapse after EOC goes high, before a new conversion cycle is requested.

    Start conversion pulses that occurs during this last 4 clock period interval may be ignored.

    This is a problem only for high conversion rates and keeping the number of conversions

    per second less than fCLOCK/44 automatically guarantees proper operation. For example,

    for an 800 KHz clock approximately 18,000 conversions per second are allowed. The

    reference applied across the 256 networks determines the analog input range. A reference

    voltage of 5V is applied to the pin number 12 of the ADC 0808. Since the conversion

    completes with in 256 steps. By using VREF = 5V, each step have voltage of 20mv as 5 /

    256 = 20mv.The pin numbers 1, 2, 3, 4, 5, 26, 27, 28 of the ADC 0808 describes the 8

    multiplexer channels. Any channel can be selected by using three address bits ADDA (pin

    25), ADDB (pin 24), ADDC (pin 23). In the hardware channel (INO) pin number 26 is

    selected permanently by grounding ADDA, ADDB, ADDC.

    The 8-bit digital output we are getting at the pin numbers 21, 20, 19, 18, 8, 15, 14, 17 of

    ADC 0808 are connected to port 2 of the 8051 microcontroller. Pin10 of ADC 0809 is for

    CLK input. Since ADC 0808 have clock between 50 KHz to 800 KHz. A reference of 5V

    is provided at pin12 of ADC 0809. Pin number 16 is grounded and pin 22 is (ALE). ADC

    (0808) is low cost IC, cost only RS. 125/- and easily available.

    Block diagram of Analog to Digital Converter 0808

    13.3 555 TIMER:

  • 8/10/2019 Six Weeks

    24/38

    The 555 Timer is used to provide frequency to ADC. The 555 timer IC was first introduced

    around 1971 by the signetics corporation as the SE555/NE555 and was called The IC Time

    Machine and was also the very first and only commercial timer IC available. It provided

    circuit designers with the relatively cheep, stable and user friendly IC for both monostable and

    astable applications. The 555 timer use on both analog and digital electronics techniques to

    perform its function, but if we consider its o/p only it can be thought of as a digital device. The

    o/p of 555 timer can be in one of the two states at any time, which mean it is a digital O/p.

    LOW is also known as space for logic 0.

    HIGH is also known as mark for logic 1.

    13.3.1 Pin Description of 555 TIMER:

    Power supply:

    Pin 8 is used to connect the positive power supply (Vs) to the 555. This can be any voltage

    between 3V and 15V DC, but is commonly 5V DC when working with digital ICs. Pin 1 is the

    0V connection to the power supply.

    Trigger and Reset Inputs:

    Pin 2 is called the trigger input as it is this input that sets the output to the high state. Pin 4 is

    called the reset input as it is this input that resets the o/p to the low state. Both pins may be

    connected to push buttons to control the operation of the 555.Sometimes the reset input is not

    used in a circuit, in which case it is connected directly to Vs to that unwanted resetting cant

    occur.

    Threshold and discharge:

  • 8/10/2019 Six Weeks

    25/38

    Pins 6 and7 (and sometimes the Trigger i/p, pin2) are used to set up the timing aspect of the

    555 IC. They are normally connected to a combination of resistors and a capacitor.

    Offset:

    Pin 5 can be used to alter the timing aspect of the 555 IC in applications such as frequency

    modulation.

    Output:

    Pin 3 is the digital output of the 555.It can be connected directly to the inputs of other digital

    ICs, or it can control other devices with the help of a few extra components.

    U?

    LM555

    2 5

    3 7 6

    4

    TR

    CV

    Q

    DIS

    THR

    R

    40

    +

    11

    -

    - +

    DIODE BRIDGE

    1

    2

    3

    4

    13

    A

    1 1Friday, May 18, 2007

    Title

    Size Document Number Rev

    Date: Sheet of

    LM 35

    0

    R?R

    LCD

    T?

    TRANSFORMER

    1 5

    4 8

    SW1

    +

    Y?

    CRYSTAL

    -

    1 2VS+ VOUT

    0-12V

    220V

    AC

    0

    SW2

    U?

    ADC0809

    26

    27

    28

    1 2 3 4 5 12

    16

    10

    9 7

    17

    14

    15

    8 18

    19

    20

    21

    25

    24

    23

    6 22

    IN0

    IN1

    IN2

    IN3

    IN4

    IN5

    IN6

    IN7

    REF+

    REF-

    CLK

    OE

    EOC

    D0

    D1

    D2

    D3

    D4

    D5

    D6

    D7

    A0

    A1

    A2

    START

    ALE

    C?

    Output 5V DC

    J?

    CON16

    1 2 3 4 5 6 7 8 9 10

    11

    12

    13

    14

    15

    16

    7805

    C?CAP NP

    SW3

    1 3VIN VOUT

    VCCU?

    AT89C52

    91819 29

    30

    31

    12345678

    2122232425262728

    1011121314151617

    3938373635343332

    RSTXTAL2XTAL1 PSEN

    ALE/PROG

    EA/VPP

    P1.0/T2P1.1/T2-EX

    P1.2P1.3P1.4P1.5P1.6P1.7

    P2.0/A8P2.1/A9

    P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

    P3.0/RXDP3.1/TXD

    P3.2/INTOP3.3/INT1

    P3.4/TOP3.5/T1

    P3.6/WRP3.7/RD

    P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

    Buzzer

    20

  • 8/10/2019 Six Weeks

    26/38

    Interfacing of MCU with LED:-

    A light-emitting diode(LED) is a semiconductor diode that emits incoherent narrow-

    spectrum light when electrically biased in the forward direction of the p-n junction. This effect

    is a form of electroluminescence.

    An LED is usually a small area source, often with extra optics added to the chip that shapes its

    radiation pattern. The color of the emitted light depends on the composition and condition ofthe semiconducting material used, and can be infrared, visible, or near-ultraviolet. An LED can

    be used as a regular household light source

    .

    D3

    LED

    C?CAP NP

    D7

    LED

    D4

    LED

    D5

    LED

    D8

    LED

    U?

    AT89C52

    91819 29

    30

    31

    12345678

    2122

    232425262728

    1011121314151617

    3938

    373635343332

    RSTXTAL2XTAL1 PSEN

    ALE/PROG

    EA/VPP

    P1.0/T2P1.1/T2-EXP1.2P1.3P1.4P1.5P1.6P1.7

    P2.0/A8P2.1/A9

    P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

    P3.0/RXDP3.1/TXD

    P3.2/INTOP3.3/INT1

    P3.4/TOP3.5/T1

    P3.6/WRP3.7/RD

    P0.0/AD0P0.1/AD1

    P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

    D1

    LED

    R1R

    40

    D2

    LED

    Y?

    CRYSTAL

    VCC

    D6

    LED

    20

    Device interfacing with MCU

  • 8/10/2019 Six Weeks

    27/38

    Figure no 2.15: Electromagnetic Solenoid Valve

    The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an electromagnet. When

    the coil is energised, by passing current through it, the core becomes temporarily magnetised. The magnetised

    core attracts the iron armature. The armature is pivoted which causes it to operate one or more sets of contacts.

    When the coil is de-energised the armature and contacts are released. The coil can be energised from a low power

    source such as a transistor while the contacts can switch high powers such as the mains supply. The relay can also

    be situated remotely from the control source. Relays can generate a very high voltage across the coil whenswitched off. This can damage other components in the circuit. To prevent this a diode is connected across the

    coil.

    As there are always some chances of high voltage spikes back from the switching circuit i.e. heater so an

    optocoupler/isolator MCT2e is used. It provides and electrical isolation between the microcontroller and the

    heater. MCT2e is a 6-pin IC with a combination of optical transmitter LED and an optical receiver as

    phototransistor. Microcontroller is connected to pin no 2 of MCT2e through a 470-ohm resistor. Pin no.1 is given

    +5V supply and pin no.4 is grounded.

    To handle the current drawn by the heater a power transistor BC-369 is used as a current driver. Pin no.5 of

    optocoupler is connected to the base of transistor. It takes all its output to Vccand activates the heater through

    relay circuit. The electromagnetic relay consists of a multi-turn coil, wound on an iron core, to form an

    electromagnet. When the coil is energized, by passing current through it, the core becomes temporarily

    magnetized. The magnetized core attracts the iron armature. The armature is pivoted which causes it to operate

    one or more sets of contacts. When the coil is de-energised the armature and contacts are released. Relays can

    generate a very high voltage across the coil when switched off. This can damage other components in the circuit.

    To prevent this a diode is connected across the coil. Relay has five points. Out of the 2 operating points one is

    permanently connected to the ground and the other point is connected to the collector side of the power transistor.

  • 8/10/2019 Six Weeks

    28/38

    When Vcc reaches the collector side i.e. signal is given to the operating points the coil gets magnetized and attracts

    the iron armature. The iron plate moves from normally connected (NC) position to normally open (NO) position.

    Thus the heater gets the phase signal and is ON. To remove the base leakage voltage when no signal is present a

    470-ohm resistance is used.

    R4

    NO

    MCT2E

    1 6

    2

    5

    4VCC

    RELAY

    35

    412

    BC-369VCC

    D11

    From P3.0 ofmicrocontroller

    J4

    HEATER

    12

    NCphase

    R2

  • 8/10/2019 Six Weeks

    29/38

    Controlling the Seven Segment Display

    The diagram below illustrates an arrangement showing

    how a seven segment display can be interfaced along withswitch inputs.

    Note the RA0 and RA1 port bits are connected toboth the A1, A0 Switches, the transistor drivers to select the displaydigits.

    To drive the display, the RA0 and RA1 bits are configured as

    outputs.To input from the two switches,the RA0 and RA1 bitsare configured as inputs. The two 10K resistors preventdamage to the port when configured as outputs and a switchis closed.

    30

  • 8/10/2019 Six Weeks

    30/38

    USER INTERFACE

    The user interface is the aggregate of means by which people (the users)

    Interact with a particular machine, device, computer program or other

    complex tool (the system). The user interface provides means of: * Input,

    allowing the users to control the system* & Output, allowing the system

    to inform the users (also referred to as feedback). A good user interface

    makes it easy for users to do what they want to do.

    The junction between a user and a computer program. An interface is aset ofcommandsormenus through which a user communicates with aprogram. A command-driven interface is one in which you entercommands.A menu-driven interface is one in which you select commandchoices from various menus displayed on the screen. The userinterface

    is one of the most important parts of any program because it determineshow easily you can make the program do what we want to. It is widelyaccepted that the user interface can make a critical difference in theperceived utility of a system regardless of the system's performance.

    D.C. MOTOR

    Working Principle:

    The principle upon which the d.c. motor works is very simple . If a

    current carrying conductor is placed in a magnetic field, mechanical

    force is experienced on the conductor, the direction of which is given

    by the Fleming's left hand rule and hence the conductor moves in the

    direction of force. The magnitude of the mechanical force experienced

    on the conductor is given by:

    F = B Ic Lc newtons

    where B is the field strength in teslas ,

  • 8/10/2019 Six Weeks

    31/38

    Ic is the current flowing through the conductor in amperes

    and Lc is the length of the conductor in metres.

    When the motor is connected to the d.c. supply mains a direct

    current passes through the brushes and the

    commutator to the armature winding ; while it passes through the

    commutator it is converetd into a.c. so that the group of conductors

    under successive field poles carry currrent in the opposite direction.

    Also the direction of the currrent in the individual conductors reverse

    as they pass away from the influence of one pole to that of the next.

    The split phase arrangement of the motor creates two fluxes B1and B2 which

    induces voltage around them in the rotor and under the influence of these induced

    voltages current flows in the rotor. The current i1 produced by flux B1 reacts with flux

    B2 and develops force F1.The quantities are going to be expressed as :

    B1=B1max . sin(wt)

    B2=B2max . sin(wt + )

    It may be assumed with negligible error thet the paths in which the

    rotor current flow has negligible self-inductance and hence the rotor

    currents are in phase with their respective voltages.

    i1(db1/dt)=.B1max.cos wt

  • 8/10/2019 Six Weeks

    32/38

    i2(db2/dt)=K. B2 max.cos (wt +X)

    Since the two forces (f1and f2 ) developed are in opposition

    .Therefore the net force F acting on the movable element is given as:

    F=F2-F1(B2.i1-i2.b1)

    F=K B1 max.B2 max sin r)

    EMF Equation:

    Back EMF, Eb=Flux *ZNP/60A

    where

    Z= total number of armature cunductors

    N= Speed in r.p.m

    P= total number of poles

    A= Total number of parallel paths.

    V= Eb + IaRa

    .Ia= (V - Eb)/Ra

    where

    V = Terminal voltage

    Ia= Armature current

  • 8/10/2019 Six Weeks

    33/38

    Ra= Armature resistance

    Eb= back e.m.f.

    Types of D.C. motor:

    (i) Permanent magnet motors: It consists of an armature and one or

    several permanent magnets encircling the armature . Field coils are

    usually notrequired. However some of these motors do have coils

    wound on the poles .

    If they exist , these coils are intended only for recharging the magnets

    in the event that they loose their strength.

    (ii) Seperately excited D.C. motors: These motors have field coils

    similar to those of a shunt wound machine, but the armature and field

    coils are fed from diferent supply sources and may have different

    voltage ratings.

    (iii) Series wound D.C. motor: As the name indicates, the field coils,

  • 8/10/2019 Six Weeks

    34/38

    consisting of few turns of a thick wire are connected in series with the

    armature. The cross-sectional area of the wire used for the field has to

    be fairly large to carry the armature current ,but owing to the higher

    current , the number of turns of wire in them need not be large.

    (iv) Shunt wound D.C. motor: These motors are so named because

    they basically operate with field coils connected in parallel with the

    armature.

    The field winding consists of a large number of turns of comparatively

    fine wire so as to provide large resistance. The field current is much

    less than the armature current, sometimes as low as 5%.

    (v) Compound wound D.C. motor : A compound wound D.C.

    motor has both shunt and series field coils. The shunt field is normally

    stronger of the two. Compound wound motors are of two types:.

    (a) Cumalative compound wound motor.

    (b) Differential compound wound motor.

  • 8/10/2019 Six Weeks

    35/38

  • 8/10/2019 Six Weeks

    36/38

    Stepper Motor

    Motion Control, in electronic terms, means to accurately control the movement of an object based on either speed,

    distance, load, inertia or a combination of all these factors. There are numerous types of motion control systems,

    including; Stepper Motor, Linear Step Motor, DC Brush, Brushless, Servo, Brushless Servo and more.

    A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical

    movements. Stepper motor is a form of ac. motor .The shaft or spindle of a stepper motor rotates in discrete step

    increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has

    several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to

    the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of

    the input pulses and the length of rotation is directly related to the number of input pulses applied [39].

    For every input pulse, the motor shaft turns through a specified number of degrees, called a step. Its

    working principle is one step rotation for one input pulse. The range of step size may vary from 0.72 degree to 90

    degree. In position control application, if the number of input pulses sent to the motor is known, the actual

    position of the driven job can be obtained.

    A stepper motor differs from a conventional motor (CM) as under:

    a. Input to SM is in the form of electric pulses whereas input to a CM is invariably from a constant voltage

    source.

    b. A CM has a free running shaft whereas shaft of SM moves through angular steps.

    c. In control system applications, no feedback loop is required when SM is used but a feedback loop is

    required when CM is used.

    d. A SM is a digital electromechanical device whereas a CM is an analog electromechanical device [40].

    3.12.1Open Loop Operation

    One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop

    system. Open loop control means no feedback information about position is needed. This type of control

    eliminates the need for expensive sensing and feedback devices such as optical encoders. Control position is

    known simply by keeping track of the input step pulses [39].

    Every stepper motor has a permanent magnet rotor (shaft) surrounded by a stator. The most common

    stepper motor has four stator windings that are paired with a center-tapped common. This type of stepper motor is

    commonly referred to as a four- phase stepper motor. The center tap allows a change of current direction in each

    of two coils when a winding is grounded, thereby resulting in a polarity change of the stator. Notice 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. This repeatable

  • 8/10/2019 Six Weeks

    37/38

    Fig 3.20: Rotor Alignment

    fixed movement is possible as a result of basic magnetic theory where poles of the Same polarity repel and

    opposite poles attract. 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. The stepper motor used here has a total of 5 leads: 4 leads representing the

    four stator windings and 1 common for the center tapped leads. As the sequence of power is applied to each stator

    winding, the rotor will rotate. There are several widely used sequences where each has a different degree of

    precision. Table shows the normal 4-step sequence. For clockwise go for step 1 to 4 & for counter clockwise go

    for step 4 to 1.

    Winding D

    Winding B

    1

    2

    3

    4 5 6

    Winding DWinding C

    Winding A

    Fig 3.21: Stator Windings Configuration

    Step Winding A Winding B Winding C Winding D

    1 0 1 1 1

    2 1 0 1 1

  • 8/10/2019 Six Weeks

    38/38

    3 1 1 0 1

    4 1 1 1 0

    Table 3.6: Input Sequence to the Windings

    3.12.2 Step Angle & Steps per Revolution

    Movement associated with a single step, depends on the internal construction of the motor, in particular the

    number of teeth on the stator and the rotor. The step angle is the minimum degree of rotation associated with a

    single step.

    Step per revolution is the total number of steps needed to rotate one complete rotation or 360 degrees (e.g., 180

    steps * 2 degree = 360) [31].

    Since the stepper motor is not ordinary motor and has four separate coils, which have to be energized

    one by one in a stepwise fashion. We term them as coil A, B, C and D. At a particular instant the coil A should get

    supply and then after some delay the coil B should get a supply and then coil C and then coil D and so on the

    cycle continues. The more the delay is introduced between the energizing of the coils the lesser is the speed of the

    stepper motor and vice versa.