115
i DESIGN AND CONSTRUCTION OF A MICROCONTROLLER-BASED MAINS SWITCH CONTROL SYSTEM BY GWAGWA O. TUBUKARE NAU/ECE/2008366010P A THESIS PRESENTED TO THE DEPARTMENT OF ELECTRONICS AND COMPUTER ENGINEERING NNAMDI AZIKIWE UNIVESITY, AWKA IN PARTIAL FULFILMENT FOR THE AWARD OF MASTER OF ENGINEERING DEGREE (M. ENG) IN ELECTRONICS AND COMPUTER ENGINEERING SEPTEMBER, 2010

10180

Embed Size (px)

DESCRIPTION

project thesis

Citation preview

  • i

    DESIGN AND CONSTRUCTION OF A MICROCONTROLLER-BASED MAINS SWITCH

    CONTROL SYSTEM

    BY

    GWAGWA O. TUBUKARE NAU/ECE/2008366010P

    A THESIS PRESENTED TO THE DEPARTMENT OF ELECTRONICS AND COMPUTER ENGINEERING

    NNAMDI AZIKIWE UNIVESITY, AWKA IN PARTIAL FULFILMENT FOR THE AWARD OF MASTER OF ENGINEERING DEGREE (M. ENG)

    IN ELECTRONICS AND COMPUTER ENGINEERING

    SEPTEMBER, 2010

  • ii

  • iii

    CERTIFICATION

    The thesis a microcontroller- based mains switch control system

    presented by GWAGWA O. TUBUKARE has been read and certified to

    have met requirement of the Department of Electronics and Computer

    Engineering in the Faculty of Engineering, in project presentation to acquire

    a Masters Degree in Engineering.

    GWAGWA O. TUBUKARE ..

    NAU/ECE/2008366010P Signature Date

  • iv

    APPROVAL

    This thesis titled a microcontroller- based mains switch control

    system has been approved for the department of Electronics and Computer

    Engineering:

    BY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Engr. Prof. H.C. Inyiama Date Supervisor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Engr. Dr. V. E. Idigo Date HOD - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Prof. C.C. Osuagwu Date External Examiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Prof. O.D.Onukwuli Date Dean of Faculty of Engineering - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Prof. N.O. Anike Date Dean School of Postgraduate

  • v

    DEDICATION

    To the Lord God Almighty who is the owner of my life and for His divine

    providence, love and care.

  • vi

    ACKNOWLEDGEMENT

    My sincere gratitude goes to my supervisor, Engr. Prof. H. C. Inyiama, who

    has been so supportive to me throughout the period of this program. Also to

    my head of department, Engr. (Dr) V. E. Idigo, for his quick response. My

    regards to Engr. Dr. (Mrs.) C. C. Okezie, Engr prof. G.N. Onoh, Engr. (Dr)

    Eric Okafor, Engr. C. U. Mezi, Engr. A.C. O. Azubogu, Engr. K Akpado,

    Engr. C.O. Ohaneme, Engr. A.N. Isizoh, Mr. T.L. Alumona, Mrs. S.U.

    Nnebe, Mr. S.P.C. Ndum, Engr. T.C. Okafor, Engr. O.O. Eze, Engr. H.

    Ejiofor, Mr. U.P. Ajakor, Mr. C. Ogu,Mr. J.U. Oguejiofor, Mr. T. Onyeyili,

    Engr. V.N. Okorogu, Mr. O.O. Nnaeto and staff of the Department of

    Electronics and Computer Engineering. Greetings to all my friends, and

    fellow classmates who supported me by their encouragement. May God

    bless you all.

    Special thanks to the members of my family, especially to my wife Mrs.

    Gwagwa Mary and my children, Ufuoma Priscilla Gwagwa, Oghenekevwe

    Joy Gwagwa, Ovie Gideon Gwagwa and Oghenetega Goodness Gwagwa

    for their good courage and patience. May the LORD bless with you all.

  • vii

    ABSTRACT

    Many people tend to enjoy use of facilities without control even when there

    are bills to settle to guarantee continuity. This project was born out of the

    desire to prevent damages and time wastage on control of industrial

    equipment. It is designed to control all the facilities (for example electrical

    appliances) not only in the hospitality industry but also in organizations such

    as schools, for security, safety and elimination of problems associated with

    manual switching. The system is a microcontroller-based mains switch

    control project which automatically controls AC loads connected to it

    through a serial port interface. The switch control system can range from

    simply controlling of light without leaving a seat, to being able to switch on

    and off industrial electrical devices through a computer interface, so the

    system produced will enable the switches to be controlled from one source

    (computer system) by simply issuing a command through the interface on

    the computer screen to save the time of going from one switch to another to

    put on or off the industrial equipments since the switches can be controlled

    from a remote system.

  • viii

    TABLE OF CONTENTS

    Title Page ... i

    Unizik Logo.ii

    Certification............ iii

    Approval ... iv

    Dedication . v

    Acknowledgement .vi

    Abstract . . ..vii Table of content viii

    Chapter One: Introduction

    1. 1 Background 1

    1.2 Objective .3

    1.3 Significance of the Project...4 1.4The scope of the Project5

    1.5 Block diagram Overview of the Project .. 6

    Chapter Two: Literature Review

    2.1 Introduction........ 8

    2.2 Overview of Lighting Controller... 11

  • ix

    2.3 Methods of Control. 13

    2.4 Types of Systems. 15

    2.5 Manual Switching System... 17

    2.6 History of Automation. 19

    Chapter Three: Methodology and System Analysis

    3.1 Introduction .21

    3.1.1 Methodology .22

    3.1.2 Prototyping22

    3.1.3 Classification of system Prototypes. .23

    3.1.4 Steps involved in Prototyping.. .24

    3.1.5 Advantages of Prototyping25

    3.1.6 Disadvantages of Prototyping....26

    3.2 Analysis of the Existing System26

    3.2.1Three Features of Existing Switch28

    3.3The Problem of the Existing Switch 28

    3.4 Overview of the Proposed Solution.29

    3.4.1 High level model of the proposed Solution. .30

  • x

    Chapter Four: System Design

    4.0 Introduction 32

    4.1 The Design Objective .34

    4.2 Design Process34

    4.3 Control Center .36

    4.3.1 The hardware Module...36

    4.3.2 Switching Circuit..37

    4.3.3 Control Module.38

    4.3.4 Transmitting Module.39

    4.3.4 Receiving Module ....41

    4.4 Relay Section..42

    4.4,1 Relay driver Unit43

    4.5 Power supply Section (Circuit) 45

    4.5.1 Electrical Components Used..47

    4.6 Functions...48

    4.7 Max 232 serial Interface.....50

    4.7.1 Serial Connection to the PC51

    4.8 Microcontroller Section..54

    4.8.1 Mathematical Specification.57

    4.9 System software Algorithm.......57

    4.10 Justification and choice of Programming Language60

    4.11 Data Dictionary.60

  • xi

    Chapter Five: System Implementation and Testing

    5.0 Introduction.62

    5.1 Hardware Requirements..63

    5.2 The control Subsystem63

    5.3 Installation Process.66

    5.4 How to open the Software...66

    5.5 Hardware Guide..67

    5.6 System Testing67

    5.6.1 Pre-implementation Testing.68

    5.6.2 Post-implementation Testing69

    5.7 Program Documentation (Operation)..70

    5.8 Maintenance Details..71

    5.9 Performance Evaluation72

    5.10 Project Costing....72

    Chapter Six: Summary and Conclusion

    6.0 Summary.74

    6.1 Problems Encountered75

    6.2 Contribution to the Body of Knowledge.75

    6.3 Recommendations...76

    6.4 Conclusion..77

    References...................................................................................78

    Appendices

    Appendix i: Source Code.. 81

  • xii

    Appendix ii: Sample Output of the Visual Basic Code101

    Appendix iii: Evidence of Completion102

    Appendix iv: Operational Guide Manual.103

    List of Figures

    Figure 1.1 Block Diagram overview of the Digital Control System. 6

    Figure 3.1 High-Level Model of the Proposed System 31

    Figure 4.1 Project block diagram...33

    Figure 4.2 The Design Loop..35

    Figure 4.3 Diagram of the Hardware Module...37

    Figure 4.4 The Data Circuit Diagram38

    Figure 4.5 Circuit Diagram of Relay......43

    Figure 4.6 Relay Driver Circuit Diagram..44

    Figure 4.7 Block Diagram of a Regulated Power Supply System45

    Figure 4.8 Block Diagram of the Power Supply Circuits.47

    Figure 4.9 Schematic MAX-232 diagram.........51

    Figure 4.10 Serial Connection to the PC......52

    Figure 4.11 RS-232 Connections using the MAX232 53

    Figure 4.11 Shows the Pin- out of the 8952 Microcontroller 54

    Figure 4.12 Circuit Diagram of Quartz Crystal Oscillator..56

    Figure 4.13 The Overall program Flow Chart.....59

    Figure 5.1: The AT89C52 Implementing the Control Subsystem ......65

    Figure 5.2 Overall Circuit Diagram.73

    List of Table

    Table 5.1 Showing the Operational Status of the System 70

  • 1

    CHAPTER ONE: INTRODUCTION

    1.1 BACKGROUND

    Man has been in a continuous quest to improve his well being through

    reactions to problems and challenges posed by his environment. For the past

    decades, computer and computer communication had gained so much

    attention and grown tremendously, that portable and affordable computers

    have become ubiquitous. Statistics have shown that most people spend most

    of their time on computers, connected together by a network (locally or

    globally). Since much time is spent on computer systems, it becomes

    necessary to design a device for controlling switches from computer.

    Switches are so essential that one cannot avoid using them on a daily basis

    for putting on or turning off electrical devices, and as a result of these, many

    devices have been designed by man to help him conquer these problems and

    challenges posed by physical contact with electricity [1]. The switch control

    system can range from simply controlling of light without leaving a seat, to

    being able to switch on industrial electrical devices through a computer.

    There has to be an interface between industrial electrical devices and a

    controller, the personal computer (PC) in this case. Interface is required so

  • 2

    that the PC can communicate with other devices. The interface used in this

    work is the computer port interface [2]. The microcontroller-based mains

    switch control system is made up of several devices connected together;

    keypads that transmit commands to the device, the controller that is

    programmed to put on or off the appliances automatically via a computer

    system [9].

    It has been observed that the manual switching of the industrial equipment

    in the industrial sector has many problems associated with it, which

    includes:

    Life of the switch operator might be at risk.

    Damage of the industrial equipment.

    Dissatisfaction of customers due to damaged equipment.

    Time wastage.

    As a result of the outlined problems associated with manual switching, the

    design of a device that will be able to control switches via a computer

    system is intended. The system is aimed at solving the associated problems.

  • 3

    1.2 OBJECTIVES

    This research work is aimed at constructing effective software and

    hardware for microcontroller-based mains switch control system.

    Specifically the objectives are to produce a device that:

    Saves the time of going from one switch to another to put on or

    off the industrial equipments since the switches can be

    controlled from a remote place (computer system).

    Has program control switch, which will help to reduce the use of

    manual switches, if not eliminating it completely.

    To create a system that ensure integrity of the complete

    microcontroller system during all forms of environmental stress

    (shock, transient noise) etc.

    Removes friction with the use of the program control switch.

  • 4

    1.3 SIGNIFICANCE OF THE PROJECT

    The significance of this research work is that the system is designed to show

    that it can be useful in the industrial sector, large or small organization such

    as schools, hotels and business centers and governments. The system

    produced will enable the switches to be controlled from one source

    (computer system) by simply issuing a command through the interface on

    the computer screen. This work can also create job opportunities.

    Time: This work will be able to save the time it takes to manually go

    from one device point to another to ensure that proper measures are

    taken.

    Safety: This will prevent human physical contact with the manual

    switches, which we know has taken many lives due to power

    instability.

    Cost: The system reduces the cost of buying switches, which will

    easily wear out due to frequent use.

    Home device: This system can equally reduce stress at home

    especially when everybody at home is off to work. So it can be used

  • 5

    when the system in which it is installed is on line by making it a

    web- based.

    This work can be used for academic purpose.

    Generation of fund: When an organization makes greater profit, they

    tend to pay larger tax to the government.

    1.4 THE SCOPE OF THE PROJECT

    This project is limited to the control of electrical devices from a standalone

    computer system. This prototype is achieved through the serial port and

    expected to control up to three devices, which will be demonstrated with

    three bulbs via three relays. This is achieved through an interface with a

    microcontroller, an integrated circuit that contains the entire central

    processing unit of a computer on a single chip. It can interpret and execute

    program instructions as well as handle arithmetic operations [1]. Their

    development in the late 1970s enabled computer engineers to develop

    microcomputers. Microprocessors led to "intelligent" terminals, such as

    bank ATMs and point-of-sale devices, and to automatic control of much

    industrial instrumentation and hospital equipment, programmable

    microwave ovens, and electronic games. Many automobiles use

  • 6

    microprocessor-controlled ignition and fuel systems. In essence, the

    microprocessor contains the core elements of a computer system, its

    computation and control engine.

    1.5 BLOCK DIAGRAM OVERVIEW OF THE PROJECT

    Figure1.1: Block diagram overview of the centralized

    digital control system

    BRIEF STUDY AND

    BACKGROUND

    MICROPROCESSOR SWITCH

    CONTROL SYSTEM

    SUMMARY, ACHIEVEMENTS

    RECOMMENDATION,

    SUGGESTION AND CONCLUSION

    SYSTEM IMPLEMENTATION

    AND TESTING

    REVIEW ON

    MICROPROCESSOR-BASED

    SWITCH CONTROL SYSTEM

    SYSTEM DESIGN

    RESEARCH METHODOLOGY

    AND ANALYSIS

  • 7

    To ensure clarity as well as understanding of this project work, this report is

    presented in six chapters. Chapter one deals on the introduction with some

    basic definitions necessary for proper understanding of the project topic.

    Chapter two embodies the review of related works while chapter three

    describes the methodology and system analysis. Chapter four showcases the

    system design a description of the performance analysis. Chapter five

    discussed the system implementation. The last chapter chapter six

    summarizes the research work and states conclusion. References and

    appendices follow immediately after chapter six.

  • 8

    CHAPTER TWO: LITERATURE REVIEW

    2.1 INTRODUUCTION

    A control system is a device or set of devices used to manage, command,

    direct or regulate the behaviour of other devices or system. The term control

    system may be applied to the essentially manual controls that allow an

    operator to, for example close and open a hydraulic press, where the logic

    requires that it cannot be moved unless safety guards are in place.

    There are two common classes of control systems with many variations and

    combinations: logic or sequential controls and feedback or linear controls.

    There is also fuzzy logic, which attempts to combine some of the design

    simplicity of logic (the study of the principles of valid inference and

    demonstration) with the utility of linear control. Some devices or systems

    are not controllable. An automatic sequential control may trigger a series of

    mechanical actuators (mechanical device form ring or controlling a

    mechanism or system) in the correct sequence to perform a task. In the case

    of linear feedback systems, a control loop, including sensors (a device that

    measures a physical quantity and converts it into a signal which can be read

  • 9

    by an observer or by an instrument), control algorithms and actuators, is

    arranged in such a fashion as to try to regulate a variable at a reference value

    or set point. An example of this may be to increase the fuel supply to a

    furnace when a measured temperature drops. As Wikipedia cited, PID

    controllers (proportional- integral- derivative controller) is a generic control

    loop feedback mechanism widely used in industrial control system, attempts

    to correct the error between a measured process variable and a desired

    setpoint by calculating and then outputting a corrective action that can adjust

    the process accordingly to keep the error minimal. Open loop control

    systems do not directly make use of feedback, but run only in pre-arranged

    ways. Pure logic control systems were historically implemented by

    electricians with network relays and designed with a notation called Ladder

    logic [3].

    Today, most of such systems are constructed with programmable logic

    devices. ON OFF control, for example a switch control is a simple

    negative- feedback, when light goes below a setpoint (SP), the light is

    switched OFF but when it goes above a setpoint, the light is switched ON,

    logic controllers may respond to switches, light sensor and pressure switches

  • 10

    and cause the machinery to perform some operation. They are used to

    sequence mechanical operations in many applications. Some techniques are

    used in control system like the Derivative action which is a part concerned

    with the rate of change of the error with time. This action makes control

    system behave much more intelligently. The microcontroller- based switch

    control system uses specialized equipment to control the switching of

    electrical devices. Through the interface on the computer, one can switch

    on/off electrical appliances from remote places. Sayers et al. (1991) noted

    that technological advances in Digital Signal processor (DSPS), networking,

    microprocessors, and programmable logic devices (PLDS) have empowered

    designers with entirely new techniques and methodologies that were

    economically unthinkable two decades ago. These advances, along with

    increased performance demands, have fueled the push of digital technology

    deeper into the controlled devices. The justification often quoted for this

    push to digital control includes reproductively, increased stability, increased

    resolution and decreased infrastructure costs (networks replace control

    wiring) [4].

  • 11

    2.2 OVERVIEW OF LIGHTING CONTROLLER

    A switch is a device that opens or closes a circuit. Switch is a device that

    causes the operation of a circuit between discrete specified levels. The

    technology of the automation evolves from a manually switching of devices

    on or off. This automation can be illustrated with a control system that

    uses a computer system to control the state (on/off) of appliances.

    Advanced English Dictionary, defines control to mean the authority, or

    the power to influence or guide something. It can also be defined as the

    levers, switches and other instruments for operating a machine or other

    devices. Lighting Controller here can be defined as responsible for directing

    or controlling the light automatically whether remotely or locally in contrast

    with the manual control where people need to go to the located switch to

    turn on or off the light. This reflects the evolution from Energy Management

    Systems in which a central computer was used to control the lamps in a

    building. A lighting automation technology can enable the person by

    assisting in daily routines and enabling the individual to achieve tasks, they

    might not have previously been able to achieve. Tasks can range in levels of

    complexity from simple tasks such as turning on or off lights through to

  • 12

    fully automating the majority of electrical systems within the building.

    Referring to Bill Gates (2000), We will be able to control our entertainment

    systems in simple but elegant ways, use any TV in the house to monitor

    inexpensive outdoor surveillance cameras and connect to the Internet from

    multiple locations [23]. Some of these tasks will not require a PC, but in the

    end it will make sense to have a computer to quietly orchestrate the

    operations of the systems in a house.

    Most of the todays lighting automation technologies requires computer to

    operate them. Even the stand alone designs need computer to be initialized.

    The existence of computer technology had driven the lighting automation

    technology into the right path. The capability of the lighting automation

    technology has transformed the environment to be an intelligent

    environment or smart environment (Heimer, 1995) [23].

  • 13

    2.3 METHODS OF CONTROL

    There are many options available for controlling the lighting system. In

    order to operate all the mechanical and electrical devices, it requires either a

    very large or a very complex remote control keypad. There are several

    options of the lighting control method that can be identified and these are:

    Computer

    Control systems can be completely computerized. This capability

    allows us to perform complete control and monitoring functions from

    any personal computer.

    Hand Held Remote Control

    Similar to a standard universal remote control that we use for the

    television, DVD player, VCR, or any other electronic equipment, a

    Hand-Held Remote Control is used to provide portable, in home,

    control of any function available in the home automation system.

  • 14

    Timed Events

    Employing a computer-controlled system typically includes software

    that can be programmed to initiate activities. This capability provides

    the ability to trigger, or initiate, pre-defined events at pre-scheduled

    times or under predefined conditions. For example, the system can be

    programmed to turn off all room lights, turn on fan, and turn on gate

    lamps.

    Keypad

    A keypad is the least costly method to control light fixtures, lighting

    scenes, audio/video (AV) equipment, or other devices. These are wall

    plates, similar to a regular wall switch plate with 2 to 8 buttons on

    them. Simply press a button to initiate the desired action. A single

    button press may activate only one light fixture, many fixtures

    located anywhere in the home, or lighting with AV events

    simultaneously. Each plate has an engraved description as to what

    each button will activate. Buttons can be illuminated for locating

    them in the dark.

  • 15

    Liquid Crystal Display

    A LCD Touch Screen controls everything a keypad does plus it can

    display an array of additional information. The display may include

    such things as video camera shots, email, weather, and stock quotes.

    These can be presented on a greyscale screen or on full colour

    screens. In addition, the information is presented in real-time.

    Essential for Heat, ventilation and air conditioner (HVAC) and

    monitoring, LCD screens provide enhanced control of the lighting,

    AV systems, security, and the capability to control the entire home

    from any room.

    2.4 TYPES OF SYSTEMS

    There are several types of systems, or commonly called system protocols,

    that perform light control to suit occupant needs and budget. All of these

    various types of control systems should have the capability for interfacing

    with other systems in the building.

  • 16

    Power Line Carrier (PLC)

    This technology or protocol has existed for over 20 years and used

    for existing homes and expanding existing systems. A command

    signal is transmitted over our existing 230 volt home wiring.

    Wireless Protocols

    Wireless technology, sometimes referred to as RF, or radio

    frequency, control systems, have existed for over 10 years. RF

    components are used in the construction of wireless devices. However,

    RF is more commonly used for existing homes and for expanding existing

    hardwired systems. A command signal is transmitted by radio waves to the

    controller. Systems using this technology have been experiencing

    increasing reliability and dependability.

    Hardwired Systems

    This technology has existed for over 40 years. Hardwired systems

    create a communications network within the home that is impervious

    to the problems that are sometimes suffered by the other protocols

    described above. This technology is most always used in new

    construction due to the extremely reliable communication by a data

  • 17

    path over wire placed in the walls before they are covered. This is

    known as pre-wiring the home for control. This system can also be

    used during major home remodels and controlling other sections of

    the home not being remodeled with one of the wireless methods

    described above.

    2.5 MANUAL SWITCHING SYSTEM.

    The operation of manual switching system is by controlling the switching

    by hands. One can switch something off: to turn off electric bulb or

    industrial equipment or appliance with a switch or one can switch on: to turn

    on electricity with a switch. A switch is a device for completing or breaking

    a circuit [1]. In a Multi- throw switch, there are two possible transient

    behaviour as you move from one position to another. In some switch

    designs, the new contact is made before the old contact is broken. This is

    known as make-before- break and ensures that the moving contact never

    sees an open circuit. The alternative is break-before-make, where the old

    contact is broken before the new one is made. This ensures that the two

    contacts are never shorted to each other.

  • 18

    The two types of designs are in common use for different applications.

    According to Leo Martins, placing parenthesis around all position rather

    than the resting position can modify the on-off notation; for example, on

    (on) - off- (on) switch can be switched on by moving the actuator in either

    direction away from the center but returns to the control off position when

    the actuator is released [24].

    Push-to-make switch makes contact when the button is pressed and breaks

    when the button is released. A push to break switch breaks contact when

    the button is pressed and makes contact when it is released. An example of

    push-to-break switch is a button used to release a door hold open by an

    electromagnetic system. According to Chris Kotoroski, the word toggle is a

    reference to the kind of mechanism or joint consisting of two arms, which

    are almost in line with each other, connected with an elbow- like pivot.

    Toggle switch is a generic class of electrical switch that uses a mechanical

    lever, handle or rocking mechanism to activate it [7].

  • 19

    2.6 HISTORY OF AUTOMATION.

    The first industrial robot, used in 1965 was controlled by a computer and

    worked in an automobile assembly plant. Since 1980s, the use of computer

    machines has greatly stimulated development. Stephanie (2002), IBM in

    1981, introduced its personal computer (PC) for use in home, offices and

    schools [25]. Prior to the time there had been several MS-DOS compatible

    personal computers that ran DOS programs. As smaller computers became

    more powerful, they could be linked or networked to share memory space,

    software and information and also communicate with others. Organizations

    have come a long way in using technology over the past years. From the

    early 1980 through the mid- 1990s, Organizations for the most part used PC

    based automated system to boost efficiency and cut cost. Many roles for

    human industrial processes presently lie beyond the scope of automation.

    Automated control systems have reduced the need for a client to use his

    hand in controlling electrical appliances in a hotel. In general, automation

    has been responsible for the shift in the world economy to industries in the

    19th century and from industrial to services in the 20th century [3].

  • 20

    James Watt (1787), a Scottish engineer constructed a device called a flyball

    governor to regulate the speed of a steam engine [22]. The use of the flyball

    governor marked the first industrial application of automation. These days,

    technology and automation have advanced to the stage of controlling some

    of the electrical appliances (equipment) at home, office, industries, hotels etc

    through a personal computer (PC). This led to the design of this project

    microcontroller- based mains switch control system.

  • 21

    CHAPTER THREE: METHODOLOGY AND SYSTEM ANALYSIS

    3.1 INTRODUCTION:

    System Analysis means the procedural study of the operation of a system

    with an attempt to discover its problem areas i.e. to know why the system is

    not functioning properly and what can be done to restructure the system.

    This chapter is concerned with investigation and analysis of the existing

    system with a view to understanding how it works including the problems

    and limitations. The characteristic attributes of a problem situation where

    system analysis is required are complexity of the issue and uncertainty of the

    outcome of any course of action that might reasonably be taken. System

    analysis usually has some combination of the following: Identification and

    re- Identification of objectives, constrains, and alternative course of action;

    examination of the probable consequences of the alternative in terms of

    costs, benefits and risk; presentation of the results in a comparative

    framework so that the decision maker can make an informed choice from

    among the alternatives.

    This chapter also deals with the methodology, considering the advantages of

    each and the justification of the need for the proposed system.

  • 22

    3.1.1 METHODOLOGY

    Internationally Software Engineering has accepted standards for

    transforming ideas in software. They include:

    The structured system Analysis and Design methodology

    (SSADM)

    Prototyping

    Experts system methodology

    Usability engineering methodologies, etc.

    The methodology applied in the system is prototyping and is discussed

    below.

    3.1.2 PROTOTYPING

    The prototyping methodology is applied in the development of this

    project. Prototyping is the process of building a model of a system. It

    is a model of a system, built to show off certain features or to get a

    working model before refining other parts of the design or just to

    evaluate the feasibility of the system development. A system

    prototype is a working system built to test ideas and assumptions

  • 23

    about the proposed system. Prototyping is an iterative process that is

    part of the analysis phase of the system development life cycle. It

    helps the analyst develop an initial set of system requirements.

    In electronics, prototyping means building an actual circuit to a design

    to verify that it works, and to provide a physical platform for

    debugging it, if it does not work. Prototyping sometimes converts

    intangible specifications into a tangible but limited working model of

    the desired information system.

    3.1.3 CLASSIFICATION OF SYSTEM PROTOTYPES

    System prototypes could be classified into:

    I. Evolutionary prototype: This design is adapted for permanent use

    after the ideas are clarified and must be built using the program tools

    that will be used for the final system.

    II. The throwaway prototype: This design is to be discarded after

    utilization; basically it is to test ideas and is especially useful for

    comparing alternative designs for part of a system.

  • 24

    3.1.4 STEP INVOLVED IN PROTOTYPING

    I. Identify the users known information requirements and features

    needed in the system.

    II. Develop a working prototype.

    III. Use the prototype, noting need enhancements and changes; this

    expands the list of known system requirements.

    IV. Revise the prototype based on information gained through user

    experience.

    V. Repeat these steps as needed to achieve a satisfactory system.

    When both user and analyst decide that sufficient information has been

    collected for the prototyping process, they determine how to meet the

    requirements they have identified using one of the following

    alternatives.

    a. The prototype is redeveloped

    b. The prototype is implemented as the completed system.

  • 25

    c. The project is abandoned; in this case the prototype has been

    provided to meet the desired objectives within existing

    technology or economic or operational guidelines

    d. Another prototype series is begun: The information gained

    through the current experience may suggest an entirely different

    approach or contrasting features.

    3.1.5 ADVANTAGES OF PROTOTYPING

    I. Requires user involvement.

    II. It helps to refine the potential risks associated with the delivery of the

    system being developed.

    III. Prototyping facilitates system implementation since users know what

    to expect and exposed developers to potential future system

    enhancements.

    IV. User can point to features they like or dislike and so indicate

    shortcomings in an existing and working system more easily, and then

    they can describe them in a theoretical or proposed system.

  • 26

    3.1.6 DISADVANTAGES OF PROTOTYPING.

    I. The process of developing a prototype can cause systems to be left

    unfinished or implemented before they are ready.

    II. Prototyping can sometimes lead to incomplete documentation and

    insufficient analysis.

    III. The process of developing a prototype may require greater

    involvement and commitment by key users who are already busy with

    their regular work.

    IV. If sophisticated software prototypes are employed, the time saving

    benefit of prototyping can be lost.

    V. In prototyping, structure of system can be damaged since many

    changes could be made and it is not suitable for large applications.

    Our prototype in this project is constructed using a microprocessor to

    control electrical appliances.

    3.2 ANALYSIS OF THE EXISTING SYSTEM

    The present procedure involves a manual control of the power switch

    by the industrial electrician. The power control switch is operated

    with hand by pushing the switch lever to on position if its intended to

  • 27

    be turned on or off position if its intended to be turned off. Basically,

    during the analysis of this procedure, it is discovered that the

    operators is at high risk of been electrocuted. Manually, switches have

    been existing for many years in every home, industry, company,

    schools and colleges.

    These switches are in different standards such as:

    1. ON- OFF e.g. toggle switches it is used to switch the power

    supply of a circuit. When used with mains electricity, this type

    of switch must be in the lives wires.

    2. (ON OFF) push- to- make switch is for doorbell.

    3. (ON OFF) push- to- break switch is also for doorbell. This

    switch can be ON in both positions, switching on a separate

    device. In each case, it is often called a change over switch

    example; a SPOT switch can be used to switch ON red lamp in

    one position and a green lamp in another position.

    Reed switch:

    The contacts of a reed switch are closed by bringing a small

    magnet near the switch. They are used in security circuits, for

  • 28

    example to check the doors and close. Standard reed switches

    are SPST (simple ON/ OFF)

    3.2.1 THREE FEATURES OF EXISTING SWITCH

    Contacts (example single pole, double throw)

    Rating (maximum voltage and current)

    Methods of operation (toggle, slide, key) etc.

    3.3 THE PROBEM OF THE EXISTING SWITCHES (SYSTEM)

    Electrocution: Those switches claim a lot of lives as a result of

    direct contact of the operator with them for example; the

    operator might be electrocuted in the process of carrying out

    power change over.

    Time wastage: it takes time to go from one switch to the other

    to ON or OFF them whenever there is power failure.

    Friction: friction is applied in operating these switches. Worn

    out switches can lead to the damage of the electrical devices

    which it is controlling.

  • 29

    Frequent touching of the switch causes the damage of the switch

    circuit.

    Bad switch control might result to serious inferno to industrial

    equipment and other valuables.

    3.4 OVERVIEW OF THE PROPOSED SOLUTION:

    Now that the shortcomings of the present system have been

    identified, it becomes necessary to specify what the new system

    will achieve:

    The new system must eliminate direct contact with switch by

    providing an interface on the computer screen through which

    the electrical devices will be controlled.

    The new system will save the time it takes the device and

    operator in going from one switch to another.

    The new system must be able to turn ON or OFF the

    selected electrical devices anytime any day. To implement an

    efficient system integrated with software and hardware

    components for the purpose of creating a microcontroller- based

    mains switch control system for electrical appliances.

  • 30

    The new system must respond in real- time.

    There must be a (new) system that is efficient in controlling

    power switch without causing any sparking. This help to avoid

    interference which may affect any mobile devices.

    The new system will have program controlled switching, which

    will help to reduce the use of manual switches in the industry.

    The new system reduces the movement of the user in switching

    ON or OFF the appliances and would be an advantage to the

    physically challenged.

    3.4.1 HIGH LEVEL MODEL OF THE PROPOSED

    SOLUTION.

    The High Level model (HLM) is a top- down design

    specification of those modules and sub modules identified for

    automation. This high level model comprises the power supply

    section, MAX- 232, microprocessor, GUI (computer system),

    the relay, and the appliances. It is this HLM that is taken to the

    system design chapter as the control center, decomposed,

    exploded, analyzed, programmed and finally a cohesion is

    achieved at the end to bring a system into existence.

  • 31

    APPLIANCE 1 APPLIANCE 2 ... APPLIANCE n

    Figure 3.1: High-level model of the proposed system

    COMPUTER

    MAX - 232

    MICROCONTROLLER POWER CIRCUIT

    RELAY 1 RELAY 2 RELAY n

  • 32

    CHAPTER FOUR: SYSTEM DESIGN

    4.0 INTRODUCTION:

    In this chapter, the design of a switch control system is described for

    controlling appliances such as bulbs using a computer system through a

    serial port. The Graphical user interface (GUI) through which command is

    given to the switch controller circuit is achieved with visual basic. The

    system can control other appliances such as Television, Refrigerator, Ceiling

    fan etc. This design is a prototype of a switch control system which can be

    used in a large organization to control several electrical appliances

    connected to it. There is an interface provided by visual basic programming

    language, which contains ON buttons and OFF buttons through which

    control command is sent to electrical devices. Therefore when any command

    button is clicked to switch on or off, device signals go from the control

    module through the serial port, serial cable to the Max- 232 interface which

    amplifies the signals. The signal goes to the microcontroller and from the

    microcontroller the signal gets to the relay through the transistor down to the

    bulbs which are the receiving module. The design consists of two modules:

    the hardware and the software modules both working together to achieve the

  • 33

    desired result. In the hardware module, the power source supplies current to

    all the hardware component of the control box. Max 232 acts as buffer that

    amplifies the signals coming from the computer. The 8051 microprocessor

    used is the controller that controls the relay and makes it function like a

    switch.

    Figure 4.1 Project Block Diagram

  • 34

    4.1 THE DESIGN OBJECTIVE

    The objective of the design is to implement a system (prototype) that will

    turn ON or OFF three electric bulbs through a computer system. With

    this system an operator will not move from one switch point to another in

    order to control the appliances as with the case of manual system.

    4.2 DESIGN PROCESS

    The design process is a basic step by step sequence of tasks that are

    performed in various situations. The first step assumes we have an initial

    concept about what should be achieved in the design process to generate an

    initial design. This often requires a lot of manual effort because most designs

    have some specific goals that can be reached only through the designers

    skillful knowledge. The next step is the simulation of the design at hand. The

    Computer Aided Design (CAD) tools can be helpful in this step. Adequate

    input conditions that can be applied to the design that is being simulated and

    later to the final product that has to be tested is necessary. By applying these

    input conditions, the simulator tries to verify that the designed product will

    perform as required under the original product specifications. If the

    simulation reveals some errors, then the design must be changed to

  • 35

    overcome the errors. Simulation efforts are necessary because errors are

    typically much harder to fix if they are discovered late in the design process.

    Simulation of redesigned version is to determine whether the errors have

    disappeared. Figure 4.1 below is a design sequence. The loop is repeated

    until the simulation indicates design successful.

    Design Concept

    Initial Design

    Simulation

    Design Correct?

    Design Successful

    Redesign

    No

    Yes

    Figure 4.2: The Design Loop

  • 36

    4.3 CONTROL CENTER.

    To bring the system into existence, the high level model or the control center

    in chapter three is analyzed and divided into modules. The different modules

    or sections include: the hardware module (control module, relay section,

    power supply section and microcontroller control section). The control

    centre activates the module of interest at any time.

    4.3.1 THE HARDWARE MODULE

    The hardware module is the main switch controller. It takes power from the

    main switch control. There is also a serial cable meant to be connected to the

    serial port of a computer system. A USB to Serial (DB-9) adapter could also

    be used to connect the serial port to the computer system. The program

    which controls the hardware module is written in Assembly and Visual

    Basic Programming Language. The assembly language converts the high-

    level language which is the VB programming language to machine language

    of Zeros (0) and Ones (1).

  • 37

    Figure 4.3: Diagram of the Hardware Module

    The hardware module is made up of the three circuits

    The data circuit

    The switching circuit and

    The power supply circuit.

    4.3.2 SWITCHING CIRCUIT

    The switching circuit is made up of BC 337 transistor switching circuit; each

    circuit is connected to a relay, a transistor and diode. The relay when

    activated, ON or OFF any appliance connected to it. The three lines from the

  • 38

    microcontroller are each connected respectively to the BASE pin of the three

    corresponding transistor

    Figure 4.4: The data circuit diagram

    The circuit is the heart of this module. It comprises of 9-pin Dip-male

    connector, Max-232, 8952 microcontroller, crystal oscillator. The circuit

    connects directly to the computer serial port through a pin cable. The MAX-

    232 amplifies signal (VS) that goes into the microcontroller from the

    computer system through the serial cables. Serial data is transmitted from

    the PC as a series of positive and negative voltage on a single wire, which

    serial data occurred at a pre-determined time established by the base wire.

  • 39

    The 11-0597MHZ crystal oscillator determines the speed of the 8952

    microcontroller used. The microcontroller is connected to the three BC 337A

    transistors that operate the relays. Pin 2 and 3 of the serial port are connected

    to line 14 and 13 of the MAX- 232.

    4.3.3 CONTROL MODULE

    The control module consists of the graphical user interface (GUI) and the

    software, which controls the hardware and are based on the computer

    system. A user interface that is graphical in nature; that is, the user can enter

    commands by using a mouse, icons and windows.

    4.3.4 TRANSMITTING MODULE

    This module consists of the software and some parts of hardware. On

    clicking a device button (Command button) on the GUI (graphical user

    interface) depending on the previous state of the device, the software should

    determine whether to turn ON or OFF the device. The term

    transmitter means an electronic device, which with the antenna propagates

    an electromagnetic signal such as radio, television or other

  • 40

    telecommunications. A transmitter usually has a power supply, an oscillator,

    a modulator and amplifiers for audio frequency, intermediate frequency (IF)

    and radio frequency (RF). Sometimes a device, e.g. a cell phone contains

    both a transmitter and a radio receiver or transceiver. The modulator is the

    device which modulates the signal information onto the carrier frequency

    which is then broadcasted.

    In industrial process, control transmitter is any device which converts

    measurement from a sensor into a signal to be received usually sent through

    wires by some display or control device located a distance away. Some

    transmitter require excellent frequency stability, there are usually several

    amplifier stages between oscillator and antenna. Special standard frequency

    transmitters use frequency synthesis referenced is to a very stable atomic

    clock. This is generated from the oscillators output, filtered with

    combination of inductors and capacitors and then amplified.

  • 41

    4.3.5 RECEIVING MODULE

    This is where the processes are to command and control the desires device.

    A receiver is a device whose main function is the reception of signals. It is

    designed to perform the task of low and high frequency reception. Receiver

    is useful in appliances such as the detection of signals from high-frequency

    impendence bridges, signal strength measurement, frequency measurement

    and even detection and display of individual component of high frequency

    wave. It selects the desired signal from all unwanted signal, amplifying and

    demodulating it and displaying it in the desired manner. Then receiver tunes

    to the desired signal and converts the incoming signals to an intermediate

    frequency is the same for all received signals, regard less of the original

    frequency of the signals. Therefore, once the signal has been translated to

    the intermediate frequency, circuitry optimized to perform the critical

    receiver function at this signal. A Receiver converts all signals to IF value

    and then performs the steps needed to fully receive the modulated

    information.

  • 42

    4.4 RELAY SECTION

    A relay is an electrically operated switch that makes or breaks one or more

    of the contacts between its terminals [1]. Current flowing through the coil of

    the relay creates a magnetic field which attracts a lever and changes the

    switch contacts. The coil current can be ON or OFF so relays have two

    switch positions and they are double throw (change over) switches. The coil

    of a relay passes a relatively large current, typically 10VDC for a 12v relay,

    but it can be as much as 10mA for relay designed to operate from lower

    voltages.

    Three electromagnetic relays are connected to the po (port) of the

    microprocessor/microcontroller one of the relay switch is to be connected to

    the individual Diode and also has its own separate transistor all connected to

    MAX-232. The Diode is located at the back of the circuit board. The circuit

    is ON when the relay coil is on and the contact closes. When the coil is off

    the circuit is OFF and the contact opens.

  • 43

    Figure 4.5: Circuit diagram of relay.

    NO- Normally Open: Com is connected to this when the relay coil is on.

    COM- Common always connects to this, (NO) it is the moving part of the

    switch

    NC- Normally closed: Com is connected to this when the relay coil is off.

    4.4.1 RELAY DRIVER UNIT

    The Relay diver circuit show in figure 4.6 below is designed to control three

    different electrically operated appliances. Relay contacts are normally open

    and therefore devices are not working at the beginning until energized

    through proper order by the micro controller or microprocessor. The relay

    output is simply a pull down transistor or open collector output. It can

    connect to a power flash with ease. In this design, we employed the BC 337

    RL3OMIH-SH-124D

  • 44

    transistor. The transistor is used to establish the current necessary to

    energize the relay in the collector circuit. With no inputs at the base of the

    transistor, the base current, collector current and the coil current are

    essentially zero and the relay sits in the un-energized states.

    However, when a positive pulse is applied to the base, the transistor turns

    on, establishing sufficient current through the coil of the electromagnet to

    close the relay. Ideally, the current through the coil and transistor will

    quickly drop to zero, the arm of the relay will be released and the relay will

    simply remain dormant until the next on signal.

    1K MICRO CONTROLLER

    1K

    1K

    BC337

    +5V+5V IN4001

    RELAY 1 RELAY 2 RELAY 3

    IN4001 +5V IN4001

    BC337 BC337

    Figure 4.6: Relay driver circuit diagram

  • 45

    The characteristics of BC337 transistor used is as follows

    Lead current is 5mA 10mA

    Max voltage 7volts

    PD (max) 100mw at 250C

    To calculate for the limiting Resistor

    R1= Vin = 5

    I 5 x 10 3

    Therefore a value of 1k is used as the limiting resistor.

    4.5 POWER SUPPLY SECTION (CIRCUIT)

    There are many types of power supply. The one used for this project is

    designed to convert high voltage AC mains electricity to a suitable low

    voltage supply for electronic circuits and other devices. The power supply is

    broken down into a series of blocks, each of which performs a particular

    function.

    240AC MAINS

    Regulated 5VDC

    Figure 4.7: Block Diagram of a Regulated Power Supply System

    TRA NSFORMER RECTIFIER

    CIRCUIT

    SMOOT

    HING

    VOLTAGE

    REGULATOR

  • 46

    Transformer: steps down high voltage AC main to low voltage AC.

    Rectifier: converts AC to DC, but the DC output is varying Smoothing:

    Smoothes the DC from varying greatly to a smaller ripple Regulator:

    Eliminates ripple by setting DC output to a fixed voltage. The power

    supplies made from these blocks are described below with a circuit diagram.

    It consists of 12v 350mA transformer, a rectifier, a 100 out capacitor for

    smoothing and a 5v regulator. The 12v transformer input is connected

    directly to the 240Vac mains to give a 12Vac. The 12VAC output from the

    transformer is passed through four Diodes connected as a bridge rectifier to

    rectify the 12Vac voltage to 12VDC which powers and derives the

    transistor, 12Vv relay switching after passing through the smoothing

    circuits. It also powers a 5v regulator, which converts the 12v dc, which now

    drives the ICS.

  • 47

    Figure 4.8: Block diagram of the power supply circuit

    4.5.1 ELECTRICAL COMPONENTS USED

    Other components used for the design are:

    1. Resistor (1000)

    2. Transistors (BC 337A- NPN configuration)

    3. Capacitors

    4. Diodes

    5. LED (red)

    6. Crystal oscillation (11.0592MHZ)

    7. Relay (12v)

    8. The microcontroller (Intel 8952)

    9. The serial port

    10. Serial cable

    11. Max- 232

    In 7812 out

    In 7805 out

    To relay

    To other ICs

  • 48

    4.6 FUNCTIONS

    In this design, a resistor (1000) is placed in series with each of the

    transistors and one with a light- emitting diode (LED) to limit the current

    passing through the Transistor and the LED respectively. The NPN transistor

    (BC 337A) is used in the design of this project. This semiconductor device

    provides current amplification. A small current of I mA flowing between

    base and emitter can produce as large as 100MA or more in the collector

    emitter circuit. Transistors are therefore widely used as current amplifiers

    and as relay drivers. Transistor amplify current, they are used to amplify the

    small output current from a logic chip so that it can operate a lamp (bulb) in

    relay or other high current device. The B 337A NPN, which are low power

    transistors are used to switch the relays coils. A transistor may be sued as

    switch (either fully ON with maximum current, or fully OFF with no

    current) and as an amplifier (always partly ON).

    The amount of current amplification is called the current gain, hFE. When

    transistor is saturated the collector current IC is determined by the voltage

    and the external resistance in the collector circuit, not by the transistor

    current gain.

  • 49

    Therefore, the ratio of IC/IB for saturated transistor is tested. Where IB =

    Base current, IE = Emitter current. The emitter current IE = IC +IB, but IC

    (collector current) is larger than IB, so roughly IE =IC.

    Diodes allow electric current to flow in only one direction. The purpose of

    the diode in this design is to prevent spikes from the relay coil from

    damaging the transistor and the computer on which the circuit is connected

    to. It protects the serial port against voltage higher than +5v signal and

    against wrong polarity signals. Diodes are used to protect transistor and

    integrated circuits from the brief high voltage produced when the relay coil

    is switched off. The protection diode is connected across the relay; it is

    connected so that it will normally not conduct. Conduction only occurs when

    the relay coil is switched off, at this moment current tries to continue

    flowing through the coil and it is harmlessly diverted through the diode.

    Without the diode no current could flow and the coil would produce a

    damaging voltage spike in its attempt to keep the current flowing. The

    Crystal oscillator determines the speed of the microprocessor in the

    hardware module.

  • 50

    4.7 MAX 232 SERIAL INTERFACE

    For communication between the personal computer and the

    microprocessor an interface is needed. The Max-232 serial converter IC

    is connected between computer and the microprocessor. It works with

    voltages =15V to +15V. Modern low power consumption logic operates

    in the range of 0V and +3.3V or even lower. To receive serial data from

    the interface the voltage has to be reduced. Also the low and high voltage

    level has to be inverted. This level converter uses a Max232 and five

    capacitors. The MAX232 from Maxim was the first IC which in one

    package contains the necessary drivers and receivers to adapt the RS-232

    signal voltage levels to TTL logic [18].

  • 51

    Figure 4.9: Schematic Max-232 diagram

    4.7.1 SERIAL CONNECTION TO THE PC

    The expanded drawing below shows the actual connections to a PC from the

    MAX 232A in the circuit above. T1 OUT, pin#14 on the MAX232A goes to

    pin#2 on the DB9 attached to the PC serial port. Pin# 13, R1 IN on the

    MAX232A goes to pin# 3 of the DB9 connector attached to a PC serial

    port. Make sure to connect pin#5 from the DB9 connector to the circuit

    GND. Below is a quick hookup diagram showing (only) the connections to

    the DB9 serial connector without the capacitors. Make these last three

  • 52

    connections after building the circuit above to connect the programmer to

    your PCs serial port.[18]

    Figure 4.10: Serial connection to the PC

    Here's an expanded drawing showing the actual connections to your PC

    from the MAX232A in the circuit above. T1 OUT, pin#14 on the

    MAX232A goes to pin#2 on the DB9 attached to the PC serial port. Pin#

    13, R1 IN on the MAX232A goes to pin# 3 of the DB9 connector attached

    to your PC serial port. Make sure to connect pin#5 from the DB9 connector

    to your circuit GND. Below is a quick hookup diagram showing (only) the

    connections to the DB9 serial connector without the capacitors. Make these

  • 53

    last three connections after you have built the circuit above to connect your

    programmer to your PCs serial port.[18]

    Figure 4.11: RS-232 Connections using the Max-232

    Five capacitors are normally required for the MAX232A. If you don't mind

    the added expense, or you want to conserve board space, you can use the

    MAX233 that doesn't require the 5 external capacitors; however the

    MAX233 is considerably more expensive so I chose to use the 232 to keep

    the project costs to a minimum [18].

  • 54

    4.8 MICROCONTROLLER SECTION The 8051 microprocessor is a low- power, high performance CMOS 8- bit

    microprocessor with 4KB of flash Erasable and programmable read only

    memory (EPROM). This devices is compatible with the industry standard

    8051 instruction set and pin configuration. The on-chip flash allows the

    program memory to be quickly reprogrammed using non-volatile memory

    programmer such as PG302.

    Figure 4.12: Shows the pin- out of the 8952 Microcontroller.

  • 55

    The 8952 microcontroller has 40 pins functioning 1/0 port lines. Each pin

    can operate as a control line or pin of the address or data bus. Each line can

    operate independently in interfacing to single- bit devices like switches,

    LEDS, transistors, speakers etc.

    Port 0: port 0 is a dual-purpose port on pins 32-39 of the 8952 IC. It is use as

    a general- purpose 1/0 port.

    Port 1: port 1 pin is available for interfacing to external devices required. No

    alternate function are assigned for port 1 pins, thus they are for interfacing to

    external devices.

    Port 2: Port 2 is a dual-purpose port as well as general-purpose 1/0 design

    with external code memory or more than 256bytes of external memory.

    Port 3: These pins are multifunctional with each having an alternate purpose

    related to special features of the 8051.

    RESET: This is on pin 9 of the 8952-microcontroller audio used for

    resetting the device. The circuit is shown in the figure below;

    GND: The on pin 20. It is an input pin and is used for the circuit ground of

    the system.

    ALE: This is on pin 30. It means Address Latch Enable. It is an output

    function pin for latching the low byte of the address during access to

    external memory.

    EA: This is on pin 31. It is an input function pin for external access enables

    it must be strapped to GND to enable the device to fetch code from external

    program memory.

  • 56

    XTAL1: XTAL1 is on pin 18.It is an input function to the inverting

    oscillator amplifier (crystal) and to the internal clock operating

    circuit.XTAL2 is on pin 19 and is an output function pin from the inverting

    oscillator amplifier. Also two capacitors is connected of 30 PF value is also

    connected where one side of the capacitor is connected to the ground as

    shown below in fig 4.7

    Figure 4.13: Circuit diagram of quartz Crystal Oscillator

    The essence of the crystal oscillator is to control the speed of the

    microcontroller. Here, the speed of the microcontroller refers to the

    maximum oscillator frequency connected to XTAL1; in this case a crystal

    with 11.059MHZ frequency was used. The frequency can be observed on the

    XTAL2 pin using the oscilloscope.

    30F

    30F

  • 57

    4.8.1 MATHEMATICAL SPECIFICATION

    CALCULATION ON MICROCONTROLLER

    Mathematically; the 8952 microcontroller operate at a maximum frequency

    of 24MHZ. Any crystal oscillator frequency within this range will operate

    the controller effectively. However, we chose to use an 11.059 MHZ crystal

    12 crystal pulses make 1 cycle (instruction line), so using an 11.059MHZ

    crystal oscillator i.e. 11.059,000 crystals pulses/sec => 11.059,000. Then the

    controller executes approximately 1,000,000 instructions every seconds.

    Thus the time it takes to execute a single instruction is =1/1000,000 =1s

    which implies that it takes 1 micro second to execute a single instructions.

    1 s= 1000,000.

    4.9 SYSTEM SOFTWARE ALGORITHM

    After building the hardware, the chip is as good as nothing if there is no

    software program to direct the actions of the microcontroller. The sequence

    of operation used to solve a problem is often called ALGORITHM. It is this

    sequence of operation that constitutes the action of the microcontroller chip.

    A very simply way of representing these sequence of actions is by the use of

  • 58

    flow charts. This is a guide in writing the assembly language program that

    runs the microcontroller. A program is an orderly sequence of machine

    instructions that can be obtained using a high level or low level

    programming language statement. The written program is burn in

    microcontroller using EEPROM programmer. Shown below is a flow chart

    that describes the action of this project.

  • 59

    Figure 4.14: The overall program flow chart

    IS THE

    APPLIANCE

    ON?

    START

    SWITCH ON THE

    APPLIANCE

    SWITCH OFF THE

    APPLIANCE

    NO YES

    MAX-232

    MICROPROCESSOR

    RELAY 1 RELAY 2 RELAY n

    APPLIANCE 1 APPLIANCE 2 APPLIANCE n

  • 60

    4.10 JUSTIFICATION AND CHOICE OF PROGRAMMING LANGUAGE

    For this project, assembly language was chosen because it is hardware

    driven i.e. language that is close to the hardware than the high level or other

    languages. Assembly language is a language which is one step above

    machine, where abbreviations called mnemonics substitute for the

    machine code. Unlike other programming languages, assembly language is

    not a single language, but a group of languages. Each processor family has

    its own assembly language.

    4.11 DATA DICTIONARY

    Data dictionary contains the list and meaning of all the variables to be used

    in the development of the application including alias names:

    Mov it is used to move the content of a register to another register.

    Org it is used to initialize the assembler

    Clr it is used for clearing a port or a register

    Cancel it is a name use for representing the port for the cancel button.

  • 61

    Jnb it is a short form of jump on bit. It checks if its first variable is set and

    if true, it executes the second variable

    Call it is a name used for calling a function

    Scan it is used as a label in a program

    Ret it is used for returning to a call from a subroutine.

    Setb it is used for sending a 1 to a register or to a port.

  • 62

    CHAPTER FIVE: SYSTEM IMPLEMENTATION AND TESTING

    5.0 INTRODUCTION

    The various units of the microcontroller- based mains switch control system

    (both the hardware and software subsystems) are implemented using

    different circuitry formulations that satisfy the aim of the design, and

    software coding using a specific software language that provide appropriate

    control as specified in the design

    Concerning the implementation of this system the hardware part of the

    design; that is, the wired diagram of the system is shown. In chapter four the

    design of the system was shown to be consisting of three circuits, the power

    supply circuit, switching circuit and the data circuit. This chapter also states

    the system operation of the device. Brief attention was given to the issue of

    programming and the other constructions carried out during the design

    process. The chapter five of this work will deal with the implementation of

    the hardware and software designs, testing the system, and performance

    evaluation.

  • 63

    5.1 HARDWARE REQUIREMENTS

    Microcontroller

    Transistors

    Relays

    AC bulbs

    Capacitors

    LEDS

    Switches

    Diodes

    Resistors

    5.2 THE CONTROL SUBSYSTEM

    The implementation of the control subsystem is done using a single

    microcontroller chip. This chip, the AT89C52WD belong to the 8051 family

    of chips and comes as a 40pin integrated circuit (IC). The AT89C52WD is a

    low power; high-performance CMOS 8-bit microcontroller (microcomputer)

    with 20K byte of flash programmable and erasable read only memory

    (ROM). Manufactured using Atmels high density nonvolatile memory

    technology this device is compatible with the industry standard 80C51

    instruction set and pin out. The on-chip flash allows the program memory to

    be reprogrammed in system or by a conventional non-volatile memory

  • 64

    programmer. By combining a versatile 8-bit CPU with Flash on a monolithic

    chip, the Atmel AT89C52 is a powerful microcontroller which provides a

    highly flexible and cost effective solution to many embedded control

    applications [19, 20].

    This microcontroller chip runs on a clock frequency of up to 33MHZ and

    has a 256 x 8bit internal RAM, with 32 programmable I/O lines including

    other features making it very suitable for output application. The

    programmable 32 I/O lines are grouped into four ports each having 8 pins.

    These ports labeled P0 to P3 can be used as an 8 bit data bus with the port

    address or single bit data each using the particular pin address [20]. The

    connection of the controller for our application is as shown figure 5.1.

  • 65

    Figure 5.1: The AT89C52 Implementing the control Subsystem

    The specification sheet of the AT89C52 shows that the reset (RST) input

    voltage is 0.7Vmin to (Vcc + 0.5)Vmax. Meaning the microcontroller will

    reset at an input voltages of - 0.7V to Vcc + 0.5V. This implies that the chip

    will run only when the reset input is below 0.7V down to 0V. It is required

    that the chip reset to start the execution of internal program from the origin

    XTAL218

    XTAL119

    ALE30

    EA31

    PSEN29

    RST9

    P0.0/AD0 39

    P0.1/AD1 38

    P0.2/AD2 37

    P0.3/AD3 36

    P0.4/AD4 35

    P0.5/AD5 34

    P0.6/AD6 33

    P0.7/AD7 32

    P1.0/T21

    P1.1/T2EX2

    P1.23

    P1.34

    P1.45

    P1.56

    P1.67

    P1.78

    P3.0/RXD 10

    P3.1/TXD 11

    P3.2/INT0 12

    P3.3/INT1 13

    P3.4/T0 14

    P3.7/RD 17P3.6/WR 16

    P3.5/T1 15

    P2.7/A15 28

    P2.0/A8 21

    P2.1/A9 22

    P2.2/A10 23

    P2.3/A11 24

    P2.4/A12 25

    P2.5/A13 26

    P2.6/A14 27

    U1

    AT89C55

    33pf

    33pf

    CRYSTAL

    10u

    10k

    TO LC

    D D

    ATA LIN

    ES

    TO K

    EYP

    AD

    CO

    NTROL S

    IGN

    AL OU

    T

    TO D

    EVIC

    E I/

    O

  • 66

    at startup. The differentiator circuit connected to the reset input ensures a

    good startup at about 0.04V in 0.5s when powered. As earlier stated, the

    essence of the crystal oscillator is to control the speed of the microcontroller.

    Here, the speed of the microcontroller refers to the maximum oscillator

    frequency connected to crystal; in this case a crystal with 11.059MHZ

    frequency was used. Higher crystal value may be used in order to meet with

    speed demand of most logic chips if high speed systems are to be developed.

    5.3 INSTALLATION PROCESS

    The set up program prepares your computer to stall the software from the

    CD.

    To install the program;

    Insert the CD in the CD Drive;

    Double click on My computer on the Desktop

    Double click on CD drive icon

    Double click on setup icon

    Follow the screen instructions to complete installation.

    5.4 HOW TO OPEN THE SOFTWARE

    Click to view start menu

    Click on all program

    Click on control

    Finally click on control

  • 67

    The interface will appear:

    Check the ON/ OFF box and click on desired relay button

    When the status is B or D or F the relays are ON, but when the status

    is A or C or E then the relays are OFF.

    5.5 HARDWARE GUIDE

    The switch controller must be connected to the system unit. The guides on

    how to connect it to the computer are:

    Insert the serial cable female port into D- shape male 9- pins serial

    port at the back of system unit and screw.

    Connect the power cable into any power source of 240V

    Ensure the computer system cables are properly fixed.

    5.6 SYSTEM TESTING

    The importance of the testing stages in the development of any new product

    or repair of existing ones cannot be over emphasized. Tracing of faults is

    very difficult in a finished work, especially when the work to be tested is too

    complex. Therefore, Software or hardware testing is very important element

  • 68

    of assurance and it represents the ultimate view of specification, design and

    coding. Two stages of testing are involved for the purpose of this project.

    The objectives of embarking on new software and hardware project through

    testing are to ensure that it meets the requirements in the specification. The

    two stages are:

    i. Pre-implementation testing.

    ii. Post-implementation testing.

    5.6.1 PRE-IMPLEMENTATION TESTING

    Pre-implementation testing is carried out on the components before they

    are soldered to the veroboard. This is to ensure that each component is in

    good working condition on board. The components used in this design

    can be grouped into:

    Discrete components e.g. resistors, light emitting diodes, capacitors,

    transistors. Etc.

    Integrated circuit components. The discrete components are tested

    with a multimeter by switching the meter to the required value and

  • 69

    range corresponding to each discrete component to check for

    continuity.

    5.6.2 POST-IMPLEMENTATION TESTING

    After implementing the circuit on a project board, the different sections of

    the complete system were tested to ensure that they were in good operating

    condition. The continuity test carried out is to ensure that the circuit or

    components are properly linked together. This test was carried out before the

    circuit was powered.

    After the testing stages and troubleshooting has been done on the whole

    circuit, it was powered. Visual troubleshooting was also carried out at this

    stage to ensure that the components do not burn out. Different load was

    added or connected to the power outlet ranging from 25 watts to 200 watts

    of power to check if the circuit can carry it without any effect to the circuit.

    After all the test and observation as explained above, the project was now

    certified ready for packaging.

  • 70

    Table 5.1 Showing the operational status of the system

    RELAY NO STATE STATUS APPLIANCE

    1 ON B Bulb

    OFF A Bulb

    2 ON D Bulb

    OFF C Bulb

    3 ON F Bulb

    OFF E Bulb

    5.7 PROGRAM DOCUMENTATION (OPERATION) The microprocessor/microcontroller- based main switch control system is a

    system consisting of software and hardware module. The hardware module

    is the controller circuit, which must be connected to the system unit and the

    software module is in a CD-ROM and needed to be installed in the system

    unit (hard disk). This takes effect only when the controller is properly

    connected to the computer system through the serial port and to the power

    source. Any electrical device connected to it can be switch ON or OFF

    through the interface provided by the software. Depending on the previous

  • 71

    state ON or OFF bulbs, when the command button of any relay is clicked,

    signals goes from there to desirable bulb.

    When relay 1 is off the status will display A but when it is ON, the status

    will display B.

    Also when relay 2 is off the status will display C, when it is ON the status

    will display D.

    Finally when relay 3 is off the status will display E but the relay is ON the

    status will display F.

    5.8 MAINTENANCE DETAILS Maintenance involves the preventing the development of faults and even its

    correction when it occurs. Things to do to effect this are:

    Ensure that proper connections are done with accurate power voltage.

    Ensure that the points of connection or joining on the wires are firmly

    soldered to avoid exposure of the circuits inside the casing.

    Ensure that the system is kept on a safe place.

    Proper connection especially the circuit should be done orderly to

    ensure continuity in the circuit.

  • 72

    The management of any organization using this project should employ

    a computer literate who will be able to operate it to avoid damage due

    to carelessness.

    5.9 PERFORMANCE EVALUATION

    This project work or prototype by evaluation, perform up to 98% of its

    proportion. 100 % performance can still be achieved by way of adjustment

    of error noticed.

    5.10 PROJECT COSTING

    (a) Cost of prototype = N39,000.00

    (b) Cost of commercial Production = N25,000.00

    (c) Average Cost of conventional type = N60,000.00

  • 73

    Figure 5.2 Overall Circuit Diagram

    1K

    12V

    RELAY

    1K

    12V

    RELAY

    1K

    12V

    RELAY

    11.0592MHZ

    Vcc

    18 19

    20

    40

    1K

    10F

    30F 30F

    8952

    39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

  • 74

    CHAPTER SIX: SUMMARY AND CONCLUSION

    6.0 SUMMARY

    In summary, the project work (A microcontroller-based mains switch control

    system) was introduced in chapter one giving us an insight that it was a

    microcontroller- based mains switch control system interfaced to a personal

    computer through which appliances could be switched ON or OFF without

    leaving ones seat. In chapter two of the research work, various literatures on

    the topic under study were reviewed analyzing the invention, operations,

    function of microcontroller to control appliances. Chapter three provides an

    analysis of the existing system and proposed system as well as the

    methodology. Chapter four was based on the system design. Chapter five

    dealt with the system implementation and testing of the entire

    microcontroller- based mains switch control system. Finally this project is

    able to switch ON or OFF a device using computer system via serial port.

    The system was designed in such a way that maintenance and repairs are

    easily done in case of any faults. Soldering techniques and practical

  • 75

    electronic were carefully studied and the experience gained from it was

    instrumental to the success of this project

    6.1 PROBLEMS ENCOUNTERED

    Some problems were encountered in the cause of developing the prototype

    of this system. Most prominent is the issue of frequent power failure from

    the public power supply. This prolonged the wiring time. Secondly, the

    problem of some components initially tested okay not functioning on circuit

    board during testing.

    6.2 CONTRIBUTION TO THE BODY OF KNOWLEDGE

    The microcontroller based controlled system approach is an automated

    switching of appliances that leads to:

    The elimination of direct contact with switch by providing an

    interface on the computer screen through which the electrical devices

    will be controlled.

    The saving of the time it takes the operator going from one switch to

    another is a delight to the Operator.

  • 76

    The ability to turn ON or OFF the selected electrical devices

    anytime any day (e.g. in the hotel room, childrens room etc) is a plus

    to the system.

    Real- time response.

    System reliability in controlling power switch.

    The elimination of users movement in switching ON or OFF the

    appliances is an advantage to the physically challenged.

    6.3 RECOMMENDATIONS

    (a) Before going ahead to wire components on the circuit board ensure

    that you test the hardware properly and simulate the design. This

    will enable you make all necessary adjustments to reduce mistakes

    and design errors.

    (b) For better implementation use the same family of chips if possible

    (i.e only TTL or only CMOS). This will ensure compatibility of

    components.

    (c) Ensure to keep within specified values; because exceeding any of

    these values may cause a permanent damage to either the clips in

    particular or the entire system as a whole.

  • 77

    (d) It is recommended that this work be used in industries such as

    hotels, schools to provide easy and safe use of the electrical

    devices. The management of any organization using this work

    should employ a computer literate person to operate the system.

    6.4 CONCLUSION

    The result achieved in the design and construction of the microcontroller-

    based mains switch control system is actually a move away from manual

    mode of switching to that of automation. For the fact that the materials used

    are locally sourced make room for cost effectiveness of design and economic

    application viable.

    The system was designed in such a way that maintenance and repairs are

    easily done in case of any faults.

  • 78

    REFERENCES

    [1]. IEEE Std 610.10-1994, IEEE Standard Glossary of Computer Hardware

    Terminology (Computer Hardware Dictionary)

    [2]. Osinuga and Oresotu (2001) Description of a Computer Port Interface

    (2001).

    [3]. Wikipedia the free encyclopedia (2008). History of Modern computing

    (http://www.wiki.com/histroy/mordencomputing).

    [4]. Sayers, A.P. Robson, A.E. Adams and G.E.Chester,(1991) Principles of

    Microprocessor, Hewlett-Packard Journal.

    [5]. Ismail, and V.M Rooney, (1987) Microprocessor Hardware and

    Software Concepts IT Press, Chicago.

    [6]. Takashi (1990) Observed the increase in processing capacity of evolving

    Microprocessors.

    [7]. Chris Kotoroski, (2008) A push to break breaks word toggle switch.

    [8]. Tendler,J.M. Dobson, S. Field, S. LE and Sinharoy, B. (2002) Power for

    system micro architecture, IBM Journal of Research and Development.

    [9]. Addison, Wesley k. and Takashi 9 (1990) Power electronics for the

  • 79

    microprocessor Age, Oxford University Press.

    [10]. Alluwalia. A and Yeralan: Programming and interfacing the Beyond

    Logic (2008), Interfacing the serial RS-232 Port,

    (http//www.Interface com/ MAX-232/html)

    [11]. Boylston, R.L.,and L Nashalsky. Electronic Devices and Circuit

    Theory, edition, Prentice Hal/ of India private Ltd., New Delhi, 8th

    edition, 2004

    [12]. Douglas, V.H; Microprocessor and Interfacing .Tata McGraw-Hill,

    New Delhi; 2nd Edition Electrical Technology, ELBS and Longman

    group,

    [13]. Hennessy, J,L and Patterson D.A (2002), Interfacing the serial RS-232

    Port. (http//www.interface.com/Max-232/html).

    [14]. Hughes Edward; 4thEdition, 1972 8951 micro controller adhesion_

    Wesley, 1995.

    [15]. Kassakian, John G. Martin, F. Schechter, and George C. Varghese,

    (1991). Principles of power Electronic Microprocessor and Computer

    (http://www.electronic org/microcomputer/kit/html).

    [16]. Kerrville, Gregg (1998) Practice guide to the low voltage directive

    Oxford, Boston Newness, vll, 203p.

    [17]. Kingenstein (1996) Switch power control circuit in practice Willy,

  • 80

    338p.ISBN047692005 2nd Edition, Osborne McGraw Hill, Berkley

    California, ISBNO-93 1988- 34-9 PG1-1

    [18]. Max-232 Serial Converter. (http://www. sodoityourself.com)

    [19]. B. RAM: Fundamentals of Microprocessor and Microcomputers, 6th

    edition, Dhanpat Rai 2008.

    [20]. Microchip AT89C51, Micro controller datasheet

    http://www.microchip.com, copyright 2000-2004 pg 5-10.

    [21].Thomas L. Floyd, Digital Fundamentals, 10th Edition, Prentice Hall

    2009.

    [22]. James Watt, Related Articles, Microsoft Encarta Premium 2009.

    [23]. Hermiza Binti Abdullah Sani, Project on Lighting Controller-Based On

    PC Serial Port, Mara University of Technology, Shah Alam 2006.

    Pg 8.

    [24]. http://www. Linkedin.com/pub/dir/martin/leo

    [25]. Stephanie (2002), International Business Machine Corporation,

    Microsoft Encarta 2009.

  • 81

    APPENDIX I: SOURCE CODE

    PROJECT: A MICROCONTROLLER-BASED MAINS SWITCH CONTROL SYSTEM.

    AUTHOR: GWAGWA O. TUBUKARE

    PROCESSOR: AT89C52WD

    DATE: 03/06/2010

    org 00h

    mov SCON,#01010000b

    mov TMOD,#00100000b

    mov a,PCON

    setb acc.7

    mov PCON,a

    mov TH1,#250 ;baud rate = 9,600

    setb TR1

    relay1 equ p0.0

    relay2 equ p0.1

    relay3 equ p0.2

    CPU EQU 40

    CPUIN EQU 41

    clr RI

    clr TI

    mov p0, #00h

    CLR P2.0

  • 82

    MOV 40, #00H

    MOV 41, #00H

    SCL BIT P1.0 ;SCL BIT IS PORT 1, BIT 0

    SDA BIT P1.1 ;SDA BIT IS PORT 1, BIT 1

    SLV_ADDR EQU 0101B ;FIXED SLAVE ADDRESS BITS

    DATAOUT EQU R5 ;DATA READ FROM DEVICE

    ACK_READ EQU 10000101B ;READ FOR ACK POLLING 18

    DSEG

    ORG 006EH

    PAGE_DATA: DS 1

    BLK_ADDR: DS 1

    BYTE_ADDR: DS 1

    BYTE_DATA: DS 1

    CSEG

    ORG 0040H

    C