51_KHAIRULAZRIBINISMAIL2007

download 51_KHAIRULAZRIBINISMAIL2007

of 54

Transcript of 51_KHAIRULAZRIBINISMAIL2007

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    1/54

    PSZ 19 :16 (Pind. 1/97)

    UNIVERSITI TEKNOLOGI MALAYSIA

    BORANG PENGESAHAN STATUS TESIS***

    JUDUL: ELECTRONIC BOOK SHELF

    SESI PENGAJIAN : 2007/2008

    Saya KHAIRUL AZRI BIN ISMAIL____________ (HURUF BESAR)

    mengaku membenarkan tesis (PSM/Sarjana/Doktor Falsafah)* ini disimpan di

    Perpustakaan Universiti Teknologi Malaysia dengan syarat-syarat kegunaannya sepertiberikut:

    1. Tesis adalah hak milik Universiti Teknologi Malaysia.2. Perpustakaan Universiti Teknologi Malaysia dibenarkan membuat salinan untuk

    tujuan pengajian sahaja.3. Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran

    antara institusi pengajian tinggi.

    4. * * Sila tandakan ( )

    Disahkan oleh

    ________ ___________ ______ __________

    (TANDATANGAN PENULIS) (TANDATANGAN PENYELIA)

    Alamat Tetap:11, TAMAN BUNGA RAYA, PM. DR. SULAIMAN BIN MOHD. NOR

    JALAN TEMENGGONG AHMAD, Nama Penyelia

    84OOO MUAR, JOHOR.

    Tarikh : 10 NOV 2007 Tarikh : 10 NOV 2007

    (Mengandungi maklumat yang berdarjah

    keselamatan atau kepentingan Malaysia seperti

    yang termaktub di dalam AKTA RAHSIA

    (Mengandungi maklumat terhad yang telah

    ditentukan oleh or anisasi / badan di mana

    SULIT

    TIDAK

    CATATAN : * Potong yang tidak berkenaan** Jika tesis ini SULIT atau TERHAD, sila lampirkan surat daripada pihak

    berkuasa/organisasi berkenaan dengan menyatakan sekali sebab dan tempoh

    tesis ini perlu dikelaskan sebagai SULIT atau TERHAD.

    *** Tesis dimaksudkan sebagai tesis bagi Ijazah Doktor Falsafah dan Sarjana

    secara penyelidikan, atau disertai bagi pengajian secara kerja kursus ataupenyelidikan, atau Laporan Projek Sarjana Muda (PSM).

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    2/54

    I hereby declare that I have read this thesis and in my opinion

    this thesis is sufficient in terms of scope and quality for the award of the Degree of

    Electrical Engineering (Computer)

    Signature :

    Name of Supervisor : PM. Dr. Sulaiman bin Mohd. Nor.

    Date : 10 Nov 2007

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    3/54

    ELECTRONIC BOOK SHELF

    KHAIRUL AZRI BIN ISMAIL

    A thesis submitted in fulfillment of the requirements for the award of the Degree of

    Bachelor of Electrical Engineering (Computer)

    Faculty of Electrical Engineering

    Universiti Teknologi Malaysia

    NOV 2007

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    4/54

    ii

    DECLARATION

    I declare that this thesis entitled Electronic Book Shelf is the result of my own research

    except as cited in the references. The thesis has not been accepted for any degree and is

    not concurrently submitted in candidature of any other degree.

    Signature : ............... ...................

    Name : Khairul Azri bin Ismail

    Date : 10th

    Nov 2007

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    5/54

    iii

    Especially to my beloved parents, whose love, patience and sacrifice have given

    me the world. To my precious siblings, Izza, Iwan, Dyna, Nurul and my fellow friends;

    thank you so much for your love and support.

    Things happen. People change. Life goes on. My work is dedicated to all who

    inspire me and recently demonstrated how not to give up even when the going gets worst.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    6/54

    iv

    ACKNOWLEDGEMENT

    First of all, I would like to take this opportunity to present my full appreciation to

    those who contribute direct or indirectly to complete this thesis. Special thanks to Dr.

    Sulaiman bin Mohd. Noh, my supervisor for his guide, advice and commitment. He is not

    just being my supervisor, but also being a good friend of mine.

    It is impossible to list all those names who have contributed to complete this

    thesis, but I really appreciate all your kindness and support to me.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    7/54

    v

    ABSTRACT

    Nowadays, reading as a hobby is very important for everyone. No matter who

    they are, how old are they or where they come from everybody need to read to gain

    knowledge. When we want to read we must have the reading material such as books,

    journals, newspapers etc. When there are so many types of reading materials put in a

    place we must categorize them, so that the other user can easily find the books whenever

    they need them. Libraries are the best example for this case or scenario. The usage of

    book shelf is very practical to locate the books properly. Some other places that are using

    the book shelf are offices and maybe houses.

    User has to manually locate the books they have taken at the book shelf. User may

    accidentally locate the books at the wrong shelf. Meaning that, the user may not put the

    books they have read in the right category.

    So, in this project, the problem to put the books at the right place is being solved.

    Electronic Book Shelf is the best and practical way to locate the books automatically.

    The circuit and some sort of sensors will detect whether the user have wrong placed the

    books or not.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    8/54

    vi

    TABLE OF CONTENTS

    CHAPTER

    1

    2

    TITLE

    DECLARATION

    DEDICATION

    ACKNOWLEDGEMENT

    ABSTRACT

    TABLES OF CONTENTS

    LIST OF TABLES

    LIST OF FIGURES

    INTRODUCTION

    1.1 Problem Statement1.2 Solution Electronic Book Shelf1.3 Project Objective1.4 Scope of Project1.5 Thesis Structure1.6 Summary

    HARDWARE

    2.1 Electronic Book Shelf Hardware2.2 ATMEL AT89S51 Microcontroller

    2.3 Stepper Motor

    2.4 Infrared Sensor

    2.5 Proximity Sensor

    2.6 Voltage Regulator

    2.7 Transformer

    PAGE

    ii

    iii

    iv

    v

    vi

    viii

    ix

    1

    1

    2

    2

    3

    3

    4

    5

    5

    5

    14

    18

    20

    22

    23

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    9/54

    vii

    3

    4

    SOFTWARE

    3.1 Introduction

    3.2 Simulator Board

    3.3 Writing the Program

    3.4 Flow Chart for Electronic Book Shelf

    3.5 Schematic to PCB Design Integration

    RESULTS & CONCLUSION

    4.1 Main Conclusion

    4.2 Problems and Limitation

    4.3 Future Improvement

    REFFERENCE

    APPENDIX A

    APPENDIX B

    24

    24

    25

    26

    26

    28

    32

    32

    33

    34

    35

    36

    40

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    10/54

    viii

    LIST OF TABLES

    TABLE TITLE PAGE

    2.1 Pin Description for AT89S51 Microcontroller 9

    2.2 Other features for AT89S51 Microcontroller 122.3 Type of motor and its function 15

    2.4 Motor Sequence 17

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    11/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    12/54

    1

    CHAPTER 1

    INTRODUCTION

    Book Shelf is design to locate some sort of books in one place. Other user can

    easily find the books when they need them as the book are arranged in an appropriate

    order. The usage of book shelf is well known as they are always being used at the

    place like libraries, offices and houses.

    But to make it smarter, the book shelf is not only designed to locate the

    books, but can detect the right and wrong books that are placed by the users using

    some sort of sensors. This smart book shelf consist of hardware (circuit and sensors)

    and depend on microcontroller based (PIC) to control the system.

    1.1 Problem Statement

    Certain places such as libraries and offices have a lot of books and

    documentation for their record, collection and research. So, the usage of book shelf is

    the best way to locate and store those books. At the library for example, user might

    put the books that they have read at the book shelf, but not in the right place. This

    means that, the books are not located at the right category. The other problems are:

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    13/54

    2

    i. User have forgotten where the book he or she taken from.

    ii. User doesnt know whether they have putted the books they have read in the

    right or wrong place.

    iii. In a place like libraries, there are too many categories of books. Sometimes,

    there are books that can include in several possibilities of categories. So, the

    library user may accidentally put the books in the wrong place of category.

    So, in this final project, I decided to propose a project to overcome the

    problem. This project will detect the books that are wrong putted by the user and

    categories the books in order. The project is Electronic Book Shelf.

    1.2 Solution Electronic Book Shelf

    Electronic Book Shelf is a system contains a circuit and some sort of sensors

    which being control by microcontroller based.

    1.3 Project Objectives

    To design a circuit of a book shelf that can detect the books and its category.

    The books that are not in its category will move away a little bit from its current

    location.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    14/54

    3

    1.4 Scope Of Project

    The project is dividing by two parts, which are hardware and software. So,

    the scopes of this project are:

    Hardware - The circuit will detect the books using two sensors.

    - Only suitable for books that has been modified for the

    detection according to its category.

    - Using motor circuit to move the casing that contain

    circuit and sensors and also to move away the books

    that are wrong putted by the user.

    Software - Sensor will detect the metal bar that stick to the books.

    - If the sensor doesnt detect the metal bar, the circuit

    will give instruction to push away the books a little bit.

    - The circuit and sensors will detect the books according

    to the instruction from the PIC coding using ATMEL

    type of IC.

    1.5 Thesis Structure

    In this thesis, different parts of the project were written in separate chapters.

    Chapter 1 briefly explanation about introduction of book shelf, problem

    solving by this project and hardware as well as software combination that are use to

    build this project. Objective of this project, work scopes and thesis structure also be

    present in this chapter.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    15/54

    4

    Chapter 2 explains all the hardware. This chapter is divided into four parts.

    The first part will discuss about the microcontroller. The second part discusses the

    stepper motor. The third part discusses the keypad. The last part is focused on 7-

    segment display and power source.

    Chapter 3 discusses more on writing program. After finished writing

    program, this chapter also explains about how to use simulator software and show

    how to burn program into microcontroller. The last part in this chapter will discuss

    about the portel software to make schematic diagram.

    In chapter 4, the project is concluded by the results achieved, the problems

    encountered during the whole project. Future suggestions are given to enhance the

    project.

    1.6 Summary

    Nowadays, academic is very important for individual to make themselves a

    better person. Book and other reading material is becoming a close friend to people.

    Place like library always full of people who want to gain their knowledge. So, the

    library system should be more advance from time to time. The system in library

    should make all the process related easier to the user. One of them is the Electronic

    Book Shelf.

    The Electronic Book Shelf can detect the wrong putted books by the users.

    To detect the books, the system use some sort of sensors that have been

    programming to an IC. The sensors will detect the books and follow the instruction

    from the circuit. All the decision depends on the instruction given by the IC. The

    books that are wrong putted by the user will be push away by the circuit a little bit.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    16/54

    5

    CHAPTER 2

    HARDWARE

    2.1 Electronic Book Shelf Hardware

    The Electronic Book Shelf Hardware consists of microcontroller, motor and

    sensors in the circuit. The motor and sensors in the circuit are controlled by

    microcontroller IC which has been given the program.

    2.2 ATMEL AT89S51 Microcontroller

    Figure 2.1: ATMEL AT89S51 Microcontroller

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    17/54

    6

    The Figure 2.1 above show the picture of ATMEL AT89S51 Microcontroller

    using for Electronic Book Shelf. There are other types of microcontrollers from

    various companies such as PIC16F628A, PIC16F84A, PIC16F88, PIC16FL877A,

    AT91CAP, AT91SAM and many more but for this project, only one microcontroller

    type AT89S51 is chosen as controller. There are several reasons why this

    microcontroller was chosen. The reasons are:

    i) Cheaper

    Microcontroller AT89S51 was produced by Atmel. This

    microcontroller was cheaper compare the other microcontroller produced

    another company. The documentation is provided by Atmel on its website.

    The manual for this microcontroller is also available from on its website. The

    manual provide details such as the pin-out configurations, suitable application

    circuits, detailed code diagrams and much more essential information.

    ii) Suitable for all conditions

    This microcontroller is usable in all type of condition. The

    microcontroller is always stable and does not easily affected by the weather

    or any other harsh condition. Have plenty of Input/Output ports. This

    microcontroller has plenty of I/O ports. There are altogether five I/O ports

    which provided about 40 I/O pins for the various type of application.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    18/54

    7

    iii) Easy to program

    It is easy to program this microcontroller. There is also free software

    that can be used to program and loading the program inside the

    microcontroller. The program loading process can be easily done via serial

    communication using

    AT89S51 microcontroller has 4 ports that could be used as input, output or

    both. There are port 0, port 1, port 2 and port 3. If the ports are used as input or

    output, programmer must assigned port in order to use that port as input or output.

    Figure 2.2 below show the pin configuration for AT89S51.

    Figure 2.2: Pin Configuration for AT89S51 Microcontroller

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    19/54

    8

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

    with 4Kbytes of n-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 pinout. 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 Atmel AT89S51 is a powerful

    microcontroller which provides a highly-flexible and cost-effective solution to many

    embedded control applications.

    The AT89S51 provides the following standard features: 4K bytes of Flash,

    128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit

    timer/counters, a five vector two-level interrupt architecture, a full duplex serial port,

    on-chip oscillator, and clock circuitry. In addition, the AT89S51 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 external interrupt or hardware reset. The Table 2.1

    below show the pin description for AT89S51.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    20/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    21/54

    10

    the internal pull-ups. Port 1 also receives the low-order address bytes during Flash

    programming and verification.

    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 inter-nal pull-ups and can be used as inputs. As inputs,

    Port 2 pins that are externally being pulled low will source current (IIL) because of

    the internal pull-ups. Port 2 emits the high-order address byte during fetches from

    external program memory and during accesses 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 accesses to external data memory that uses 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 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 inter-nal pull-ups and can 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 receives some control signals for Flash programming and

    verification.

    Pin number 9 is reset input (RST). A high on this pin for two machine cycles

    while the oscillator is running resets the device. This pin drives High for 98 oscillator

    periods after the Watchdog times out. The DIS-RTO 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.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    22/54

    11

    Pin number 19 is XTAL1. This pin is an input to the inverting oscillator

    amplifier and input to the internal clock operating circuit. Otherwise, pin number 18

    is XTAL2. This pin is an output from the inverting oscillator amplifier.

    Pin number 29 is Program Store Enable (PSEN). This pin is the read strobe to

    external program memory. When the AT89S51 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 exter-nal data memory.

    Pin number 30 is Address Latch Enable (ALE). ALE is an output pulse for

    latching the low byte of the address during accesses to external memory. This pin is

    also the program pulse input (PROG) during Flash programming.

    Pin number 31 is External Access Enable (EA). 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. EA should be strapped to VCC for internal

    program executions. This pin also receives the 12-volt programming enable voltage

    (VPP) during Flash programming.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    23/54

    12

    Table 2.2: Other features for AT89S51 Microcontroller

    On-Chip Memory

    On-Chip Code Memory 4096 Flash

    On-Chip Internal RAM 128

    On-Chip XRAM -

    On-Chip EEPROM -

    Processor Information

    Max MHz 33

    Clock/Instruction 12

    Max MIPS 2.75

    Voltage 4V to 5.5V

    Packages DIP40, PLCC44, TQFP44

    I/O Information

    I/O Lines 32

    Other I/O Busses -

    UARTs 1

    Other Features

    Timers 2

    DPTRs 2

    Field Updatability ISP

    Interrupts 6 interrupts, 2 priority levels

    PWM Channels None

    PCA Channels None

    Watchdog Yes

    JTAG No

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    24/54

    13

    Figure 2.3: Block Diagram for AT89S51 Microcontroller

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    25/54

    14

    2.3 Stepper Motor

    Figure 2.4: Stepper Motor

    The Figure 2.4 above show the picture of stepper motor using for Electronic

    Book Shelf.

    For this project, 2 stepper motors are being used in each shelf. The first

    stepper motor is used to move the casing that contains the circuit and sensors. Then,

    the second stepper motor is used as the driving force for the arm robot to push away

    the books that have been wrong putted by the user.

    There is various type of motor. Some of them are linear, brushed, brushless

    and piezo (ultrasonic) motor. The Table 2.3 below shows the type of motor and its

    function.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    26/54

    15

    Table 2.3: Type of motor and its function

    There are many types of motor but for this project, stepper motor is chosen as

    motor to move the casing and the arm robot. There are several reasons why this type

    of motor was chosen. The reasons are:

    i) Position error is noncumulative. A high accuracy of motion ispossible, even under open-loop control.

    ii) Large savings in sensor (measurement system) and controllercosts are possible when the open-loop mode is used.

    iii) Because of the incremental nature of command and motion,stepper motors are easily adaptable to digital controlapplications.

    iv) No serious stability problems exist, even under open-loopcontrol.

    v) Torque capacity and power requirements can be optimized andthe response can be controlled by electronic switching.

    Stepper motor is a motor, which move in assigned angle. Movement from one

    of these positions to another is only by stepping it through a series of intermediate

    positions. A typical stepper motor might have 200 such positions in a single,

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    27/54

    16

    complete rotation of the drive shaft. Competitive mice can certainly be built with

    steppers, they are very easy to control and there is no messing around with motor

    control feedback loops and tacky arithmetic. The steeper motor is also is easy to

    control in term in steering.

    Stepper motors do as their name suggests it step a little bit at a time. Stepper

    motors different from DC motors in their torque-speed relationship. DC motors

    generally are not very good at producing high torque at low speeds, without the aid

    of a gearing mechanism. Stepper motors, on the other hand, work in the opposite

    manner. They produce the highest torque at low speeds.

    Stepper motors also have another characteristic, holding torque, which is not

    present in DC motors. Holding torque allows a stepper motor to hold its position

    firmly when not turning. This can be useful for applications where the motor may be

    starting and stopping, while the force acting against the motor remains present. This

    eliminates the need for a mechanical brake mechanism.

    Steppers do not simply respond to a clock signal, they have several windings,

    which need to be energized in the correct sequence before the motor's shaft will

    rotate. Reversing the order of the sequence will cause the motor to rotate the other

    way. If the control signals are not sent in the correct order, the motor will not turn

    properly. It may simply buzz and not move, or it may actually turn, but in a rough or

    jerky manner. A circuit, which is responsible for converting step and direction

    signals into winding energy patterns, is called a translator.

    Most stepper motor control systems include a driver in addition to the

    translator, to handle the current drawn by the motor's windings. To make a stepper

    driver, two independent pulse trains have to be generated. The widths are not too

    critical but it would be good if the processor can be interrupted when each pulse is

    generated. On each interrupt, the timer value required to set the time to the next

    pulse. The very low overhead stuff should leave plenty of processor time for tricky

    stuff like mapping and not running into the walls. It is possible to drive steppers

    together and make steering corrections by missing steps on one or the other motor.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    28/54

    17

    Stepper motors are quite sensitive about getting smooth pulse trains. Once

    messed up at speed, it likely to just stop turning rather than slowing down. The result

    is that the robot will suddenly swings around one wheel to examine the way to run.

    Steering is best done by slightly slowing down the pulse train for one wheel. A

    microcontroller with a pair of spare timers can dome this easily. A number of

    controllers have flexible output compare functions or programmable counter arrays.

    The Figure 2.5 below show the block diagram for stepper motor.

    Figure 2.5: Block Diagram for Stepper Motor

    Table 2.4: Motor Sequence

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    29/54

    18

    The stepper motors have higher torque, higher efficiency, lower noise and

    vibration than standard stepper motors of the same size. The higher torque is

    achieved by higher efficiency magnetic materials. The rotor inertia is also higher

    making them better able to handle high inertia loads. They are ideal in robotics

    applications where a standard motor of the same size has insufficient torque. Table

    2.4 above shows the stepper motor sequence.

    2.4 Infrared Sensor

    Figure 2.6: Infrared Sensor

    The Figure 2.6 above show the picture of infrared sensor using for Electronic

    Book Shelf. In this project, the infrared sensor is used to detect any incoming object

    that coming into the book shelf.

    There are many types of infrared sensor but in this project passive infrared

    sensor is the best choice for Electronic Book Shelf. A passive Infrared sensor (PIR

    sensor) is an electronic devicewhich measures infrared light radiating from objects

    in its field of view. PIRs are often used in the construction of PIR-based motion

    http://en.wikipedia.org/wiki/Electronic_devicehttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Motion_detectorhttp://en.wikipedia.org/wiki/Motion_detectorhttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Electronic_device
  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    30/54

    19

    detectors. Apparent motion is detected when an infrared source with one

    temperature, such as a human, passes in front of an infrared source with another

    temperature, such as a wall.

    All objects emit what is known as black body radiation. This energy is

    invisible to the human eye but can be detected by electronic devices designed for

    such a purpose. The term 'passive' in this instance means the PIR does not emit

    energy of any type but merely accepts incoming infrared radiation.

    Infrared radiation enters through the front of the sensor, known as the sensor

    face. At the core of a PIR is a solid state sensor or set of sensors, made from

    approximately 1/4 inchessquare of natural or artificialpyroelectric materials, usually

    in the form of a thin film, out of gallium nitride (GaN), caesium nitrate (CsNO3),

    polyvinyl fluorides, derivatives of phenylpyrazine, and cobaltphthalocyanine. (See

    pyroelectric crystals.) Lithium tantalate (LiTaO3) is a crystal exhibiting both

    piezoelectricand pyroelectric properties.

    The sensor is often manufactured as part of an integrated circuit and may

    consist of one (1), two (2) or four (4) 'pixels' of equal areas of the pyroelectric

    material. Pairs of the sensor pixels may be wired as opposite inputs to a differential

    amplifier. In such a configuration, the PIR measurements cancel each other so that

    the average temperature of the field of view is removed from the electrical signal; an

    increase of IR energy across the entire sensor is self-cancelling and will not trigger

    the device. This allows the device to resist false indications of change in the event of

    being exposed to flashes of light or field-wide illumination. (Continuous bright light

    could still saturate the sensor materials and render the sensor unable to register

    http://en.wikipedia.org/wiki/Motion_detectorhttp://en.wikipedia.org/wiki/Temperaturehttp://en.wikipedia.org/wiki/Humanhttp://en.wikipedia.org/wiki/Wallhttp://en.wikipedia.org/wiki/Black_body_radiationhttp://en.wikipedia.org/wiki/Eyehttp://en.wikipedia.org/wiki/Electronic_devicehttp://en.wikipedia.org/wiki/Solid_statehttp://en.wikipedia.org/wiki/Sensorhttp://en.wikipedia.org/wiki/Inchhttp://en.wikipedia.org/wiki/Pyroelectricityhttp://en.wikipedia.org/wiki/Thin_filmhttp://en.wikipedia.org/wiki/Gallium_nitridehttp://en.wikipedia.org/w/index.php?title=Caesium_nitrate&action=edithttp://en.wikipedia.org/wiki/Polyvinyl_fluoridehttp://en.wikipedia.org/w/index.php?title=Phenylpyrazine&action=edithttp://en.wikipedia.org/wiki/Cobalthttp://en.wikipedia.org/wiki/Phthalocyaninehttp://en.wikipedia.org/wiki/Pyroelectric_crystalhttp://en.wikipedia.org/wiki/Lithium_tantalatehttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Piezoelectrichttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Differential_amplifierhttp://en.wikipedia.org/wiki/Differential_amplifierhttp://en.wikipedia.org/wiki/Differential_amplifierhttp://en.wikipedia.org/wiki/Differential_amplifierhttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Piezoelectrichttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Lithium_tantalatehttp://en.wikipedia.org/wiki/Pyroelectric_crystalhttp://en.wikipedia.org/wiki/Phthalocyaninehttp://en.wikipedia.org/wiki/Cobalthttp://en.wikipedia.org/w/index.php?title=Phenylpyrazine&action=edithttp://en.wikipedia.org/wiki/Polyvinyl_fluoridehttp://en.wikipedia.org/w/index.php?title=Caesium_nitrate&action=edithttp://en.wikipedia.org/wiki/Gallium_nitridehttp://en.wikipedia.org/wiki/Thin_filmhttp://en.wikipedia.org/wiki/Pyroelectricityhttp://en.wikipedia.org/wiki/Inchhttp://en.wikipedia.org/wiki/Sensorhttp://en.wikipedia.org/wiki/Solid_statehttp://en.wikipedia.org/wiki/Electronic_devicehttp://en.wikipedia.org/wiki/Eyehttp://en.wikipedia.org/wiki/Black_body_radiationhttp://en.wikipedia.org/wiki/Wallhttp://en.wikipedia.org/wiki/Humanhttp://en.wikipedia.org/wiki/Temperaturehttp://en.wikipedia.org/wiki/Motion_detector
  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    31/54

    20

    further information.) At the same time, this differential arrangement minimizes

    common-mode interference; this allows the device to resist triggering due to nearby

    electric fields. However, a differential pair of sensors cannot measure temperature in

    that configuration and therefore this configuration is specialized for motion detectors.

    2.5 Proximity Sensor

    Figure 2.7: Proximity Sensor

    Figure 2.7 above show the picture of proximity sensor using for Electronic

    Book Shelf. The proximity sensor in this project is used to detect the metal bar that

    stick to the modified books. Different height of metal bar is stick to the books in

    different categories. The proximity sensor is installed according to the height of the

    metal bar. Each shelf has different height of proximity sensor.

    Proximity sensors are sensors able to detect the presence of nearby objects

    without any physical contact. A proximity sensor often emits an electromagnetic or

    http://en.wikipedia.org/wiki/Common-mode_interferencehttp://en.wikipedia.org/wiki/Sensorhttp://en.wikipedia.org/wiki/Sensorhttp://en.wikipedia.org/wiki/Common-mode_interference
  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    32/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    33/54

    22

    The active face of an inductive proximity switch is the surface where a high-

    frequency electro-magnetic field emerges. A standard target is a mild steel, 1mm

    thick, square form with side lengths equal to the diameter of the active face or 3X the

    nominal switching distance, whichever is greater.

    Figure 2.9: Inductive Proximity Sensor Circuit

    2.6 Voltage Regulator

    Figure 2.10: Voltage Regulator

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    34/54

    23

    Most digital logic circuits and processors need a 5 volt power supply. To use

    these parts we need to build a regulated 5 volt source. Figure 2.10 is shows the

    voltage regulator. Usually you start with an unregulated power supply ranging from 9

    volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and

    the Microcontroller Beginner Kit.). To make a 5 volt power supply, a LM7805

    voltage regulator IC (Integrated Circuit) is used.

    2.7 Transformer

    Figure 2.11: Transformer 9V

    All circuit must have their own power source. The 9 volt transformer are

    using as power source for Electronic Book Shelf. Each shelf has one transformer.

    This project is used a transformer, not a battery. This make the circuit can be run 24

    hours a day without worrying about the source power. In this project, most critical

    part is movement of the stepper motor. Without enough voltage, the movement of

    stepper motor will become weak and the sensors cannot detect the books.

    The Figure 2.11 above shows the type of transformer 9V AC 500mA that is

    use in this project. This type of transformer can receive input voltage of 120VAC

    60Hz. The output voltage given is across the entire secondary. Center tapped leads

    provide 1/2 that voltage from the center to either lead wire.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    35/54

    24

    CHAPTER 3

    SOFTWARE

    3.1 Introduction

    These projects divide into two main parts. The first part is hardware

    construction and the second part is writing programming. The hardware construction

    has been discussed in chapter 1 and 2. The second part will be discussed in this

    chapter. The ATMEL AT89S51 microcontroller is using assembles language for

    writing programming. Assembles language are more complicated compare with C

    language but assembles language are easy to programming because it can be set

    direct to the microcontroller port.

    This chapter will discuss about step to write a program which is start from

    writing program, assembling the program file, doing simulation and download the

    program into microcontroller.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    36/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    37/54

    26

    3.3 Writing the Program

    Normally for writing programming, two type of software can be used. The

    first software is notepad. Notepad is the most powerful software that window have.

    Some file like assemble code, html page and many more file can be written by using

    only notepad. The second software that many programmer uses to write program are

    MPLAB IDE Programming Software. This software is easier to use because it can

    indicate the source code that use are correct or wrong. If correct all font for source

    code will be blue color. If wrong, the font color will turn into black color. In this

    project, I use notepad to write the coding of the program.

    3.4 Flow Chart for Electronic Book Shelf

    Before doing any programming, the programmer should sketch the basic flow

    of programming. From the basic, then the more complex flow is added in order to

    make programming more advances.

    The program of the first motor stepper needs to do first because it is very

    important compared with second motor stepper and sensors. If the motor stepper

    cannot move the casing that contains the circuit and sensors, the sensors cannot

    detect any incoming object. This is because to know whether user have put the books

    at the right shelf or not is by moving the infrared sensor and the proximity sensor

    towards and back inside the book shelf. At the end of this program, motor stepper

    will move the arm to push away a little bit the books that have been wrong putted by

    the user.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    38/54

    27

    First, the program to move the first motor stepper has generated. So the motor

    stepper can move the casing that contains the circuit and sensors towards and back.

    After that, the infrared sensor added into program. The infrared sensor has the ability

    to detect any incoming object, not necessarily books. Then, the proximity sensor

    added to the program. The proximity sensor should detect the metal bar that stick to

    the modified books. If the proximity can detect, that means user has put the books in

    the right shelf. So, the first motor stepper will move the casing that contains the

    circuit and sensors to detect other books. The red LED at the circuit turn on. But if

    the proximity sensor cannot detect the metal bar that means user has put the books in

    the wrong shelf. The program will give the instruction to move the second motor

    stepper. The stepper motor than move the arm to push away a little bit the books that

    have been wrong putted by the user.

    The flow chart Figure 3.4 at next page shows the program flow chart for

    Electronic Book Shelf system.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    39/54

    28

    Figure 3.2: Program Flow Chart for Electronic Book Shelf

    3.5 Schematic to PCB Design Integration

    The schematic and the PCB is the way to move design information back and

    forth between the two different views of the design. This process, known as design

    synchronization, is an integral part of the design process, and may need to be carried

    out many times through the course of the design cycle. To performing design

    synchronization can be done at any time by selecting Design Update PCB from the

    Schematic Editor Menu, or Design Update Schematic from the PCB Editor menus.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    40/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    41/54

    30

    have a schematic capture. Then create an empty sheet with a sheet size to suit

    documentation standard. Typically use A4 for team project. Locate the components

    with standard components are stored in libraries, access most major parts by part

    number. Some parts are generic (e.g.: resistors, capacitors). ITEE electronics

    workshop has edited libraries http://www.itee.uq.edu.au/~etsg/Electronics workshop

    > Protel99 libraries

    Figure 3.3: Introduction PROTEL 99

    Placing the parts with orient the parts correctly (spacebar rotates, X flips

    horizontally, Y flips vertically). Place all components first and follow the diagram.

    Wire up the schematic and make sure to end wires right on component ends. Add

    nodes to wires that are meant to join. Net labels identify key nets such as power and

    ground. Electrical rule check use for each pin in a library component is defined as

    input, output, I/O, power, etc. ERC checks that component connections are sensible

    such as unconnected inputs; outputs connected together, no power.

    For create a PCB file, use the PCB wizard to create your empty board and use

    the custom board option and set to suit. To transfer the design, make sure that the

    appropriate footprint libraries are loaded. Use the Update PCB dialog to load parts

    and nets from schematic. Set the layers separate physically and electrically different

    parts. Use top and bottom layer and use mechanical layers for holes and cut outs.

    http://www.itee.uq.edu.au/~etsg/http://www.itee.uq.edu.au/~etsg/
  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    42/54

    31

    Routing design rules with instruction (PROTEL 99 = Design > Rules > Routing)

    such as Clearance constraint is 10 mil, routing via style with preferred is 50 mil dia /

    20 mil hole and minimum = 30 mil dia / 12 mil hole. Width constraint is preferred

    for12 mil and minimum is 10 mil. Use thicker tracks for less resistance and

    inductance

    Figure 3.4 below show the screen shot of schematic diagram from Portel 99

    SE Window.

    Figure 3.4: Screen Shot of Schematic Diagram from Portel 99 SE Window

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    43/54

    32

    CHAPTER 4

    RESULTS & CONCLUSION

    4.1 Main Conclusion

    This project has achieved the objective that has target before and but cannot

    assume as fully successful. This is because the proximity sensor cant detect the

    wrong placed books. But when the user put the books in the right shelf, the proximity

    sensor can sense the metal bar that stick to the modified books and the LED at the

    circuit ON. This project also can detect the incoming books repeatedly as the

    sensors move towards and back as long as the power supply is ON. This project is

    the prototype based on hardware and software that used basic components at

    inexpensive prices. The brain of the circuit is microcontroller base. The components

    and their major functions are, a PIC controller (AT89S51) is used efficiently as the

    main controller and a serial port cable forms an interface between PIC controller and

    computer.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    44/54

    33

    4.2 Problems and Limitation

    While doing this project, there are various problems that have been faced. If

    the problems are not critical, it need to be replaced with new one if it damaged or not

    suitable. Below are some problems and limitations that have faced while doing

    Electronic Book Shelf:

    :

    i) This project is limited to hard cover books. It is because the metal bar

    has to stick properly to the cover of the books.

    ii) While doing the testing, some chip are damaged because short circuit.

    The chip is comparator chip LM7805. After the circuit has been

    modified to minimize the short circuit, the new microchips are

    replaced with the damage chip and the circuits works properly.

    iii) There many problems that has been faced while doing the soldering

    the circuit. Normally for the first time after soldering, the circuits do

    not work properly. Troubleshoot should be done until the circuit gives

    the correct output. For this step, much time has been spending to

    troubleshoot. Each pinpoint must be troubleshooting using the

    multimeter to check the continuity of the circuit.

    iv) After running robot for long times, the comparator chip LM7805 and

    stepper motor are hot. To prevent the chip from damage, heat sink is

    place on the top of the chip. The fan is place at each motor stepper.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    45/54

    34

    4.3 Future Improvement

    Although this project has been done successfully but for developments with

    new technology for the future, this Electronic Book Shelf can be modified to make it

    more efficient. The recommendations for this project are:

    i) Add on sensors that are more sensitivity in sensoring. For example, in

    this project, the inductive proximity sensor can only sense the metal

    bar that stick to the modified books up to 10mm only. This may cause

    some books not to be detected whether it is right or wrong placed by

    the user.

    ii) Use railway and softer belt to move the casing that contains the circuit

    and sensors to reduce the noise.

    iii) Time of execution can be shortened if the circuit or PIC coding can be

    modified.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    46/54

    35

    REFERENCE

    1) The C Programming Language, By Brian W. Kernighan and Dennis M.

    Ritchie, Published by Prentice-Hall in 1988.

    2) Training Manual for On Site Programming, BES Research & Development

    Group, FKE, UTM.

    3) Training Manual for Hardware Installation, BES Research Group, FKE,

    UTM.

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    47/54

    36

    APPENDIX A

    CODING

    0000 7B09 MOV R3, #09H

    0002 75A0FF MOV P2, #0FFH

    0005 7B90FF MOV P1, #0FFH

    0008 9000F2 FOR: ACALL DPTR, #TABLE1

    000B 11B1 ACALL MOTOR

    000D 7590FF MOV P1, #0FFH

    0010 7520DA MOV 20H, #10

    0013 11E6 ACALL DELAY

    0015 30B202 JNB P3.2, REV

    0018 0108 AJMP FOR

    001A 9000F6 REV: MOV DPTR, #TABLE2

    001D 11B1 ACALL MOTOR

    001F 7590FF MOV P1, #0FFH

    0022 75200A MOV 20H, #10

    0025 11E6 ACALL DELAY

    0027 30B302 JNB P3.3, FOR1

    002A 011A AJMP REV

    002C 11D8 FOR1: ACALL STOP5

    002E 9000F2 FOR2: MOV DPTR, #TABLE1

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    48/54

    37

    0031 11B1 ACALL MOTOR

    0033 7590FF MOV P1, #0FFH

    0036 75200A MOV 20H, #10

    0039 11E6 ACALL DELAY

    003B 30B11E JNB P3.1, STOP1

    003E 30B202 JNB P3.2, REV2

    0041 012E AJMP FOR2

    0043 9000F6 REV2: MOV DPTR, #TABLE2

    0046 11B1 ACALL MOTOR

    0048 7590FF MOV P1, #0FFH

    004B 75200A MOV 20H, #10

    004E 11E6 ACALL DELAY

    0050 30B122 JNB P3.1, STOP2

    0053 30B302 JNB P3.3, FOR3

    0056 0143 AJMP REV2

    0058 11CD FOR3: ACALL STOP8

    005A 012E AJMP FOR2

    005C 7A32 STOP1: MOV R2, #50

    005E 7590FF STA: MOV P1, #0FFH

    0061 75200A MOV 20H, #10

    0064 11E6 ACALL DELAY

    0066 30E006 JNB P3.0, SEN1

    0069 DAF3 DJNZ R2, STA

    006B 11D8 ACALL STOP5

    006D 012E AJMP FOR2

    006F 118E SEN1: ACALL SENSOR

    0071 11D8 ACALL STOP5

    0073 012E AJMP FOR2

    0075 7A32 STOP2: MOV R2, #50

    0077 75900FF STB: MOV P1, #0FFH

    007A 75200A MOV 20H, #10

    007D 11E6 ACALL DELAY

    007F 30B006 JNB P3.0, SEN2

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    49/54

    38

    0082 DAF3 DJNZ R2, STB

    0084 11D8 ACALL STOP5

    0086 0143 AJMP REV2

    0088 118E SEN2: ACALL SENSOR

    008A 11D8 ACALL STOP5

    008C 0143 AJMP REV2

    008E 7919 SENSOR: MOV R1, #25

    0090 9000F2 MT3: MOV DPTR, #TABLE1

    0093 11BF ACALL MOTOR2

    0095 D9F9 DJNZ R1, MT3

    0097 7590FF MOV P1, #0FFH

    009A 752064 MOV 20H, #100

    009D 11E6 ACALL DELAY

    009F 7919 MOV R1, #25

    00A1 9000F6 MT4: MOV DPTR, #TABLE2

    00A4 11BF ACALL MOTOR2

    00A6 D9F9 DJNZ R1, MT4

    00A8 750FF MOV P2, #0FFH

    00AB 75200A MOV 20H, #10

    00AE 11E6 ACALL DELAY

    00B0 22 RET

    00B1 7C04 MOTOR: MOV R4, #04

    00B3 E4 MT1: CLR A

    00B4 93 MOVC A, @A+DPTR

    00B5 F590 MOV P1, A

    00B7 A3 INC DPTR

    00B8 8B20 MOV 20H, R3

    00BA 11E6 ACALL DELAY

    00BC DCF5 DJNZ R4, MT1

    00BE 22 RET

    00BF 7C04 MOTOR2: MOV R4, #04

    00C1 E4 MT2: CLR A

    00C2 93 MOVC A, @A+DPTR

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    50/54

    39

    00C3 F5A0 MOV P2, A

    00C5 A3 INC DPTR

    00C6 8B20 MOV 20H, R3

    00C8 11E6 ACALL DELAY

    00CA DCF5 DJNZ R4, MT2

    00CC 22 RET

    00CD C2B4 STOP8: CLR P3.4

    00CF 7960 MOV R1, #96

    00D1 11D8 STO1: ACALL STOP5

    00D3 D9FC DJNZ R1, STO1

    00D5 D2B4 SETB P3.4

    00D7 22 RET

    00D8 C2B4 STOP5: CLR P3.4

    00DA 7C11 MOV R4, #17

    00DC 752064 ST1 MOV 20H, #100

    00DF 11E6 ACALL DELAY

    00E1 DCF9 DJNZ R4, ST1

    00E3 D2B4 SETB P3.4

    00E5 22 RET

    00E6 7E06 DELAY: MOV R6, #06 ; 3MS

    00E8 7FF9 DEL: MOV R7, #249

    00EA DFFE DJNZ R7, $

    00EC DEFA DJNZ R6, DEL

    00EE D520F5 DJNZ 20H, DELAY

    00F1 22 RET

    00F2 05 TABLE1: DB 00000101B ; 0101

    00F3 06 DB 00000110B ; 0110

    00F4 0A DB 00001010B ; 1010

    00F5 09 DB 00001001B ; 1001

    00F6 09 TABLE2: DB 00001001B

    00F7 0A DB 00001010B

    00F8 06 DB 00000110B

    00F9 05 DB 00000101B

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    51/54

    40

    APPENDIX B

    DATASHEET

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    52/54

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    53/54

    42

  • 8/13/2019 51_KHAIRULAZRIBINISMAIL2007

    54/54

    43