You are on page 1of 97

DECLARATION

I hereby declare that I carried out the work reported in this thesis in the department of

Mechanical Engineering, Covenant University, under the supervision of Prof. Christian Bolu. I also

solemnly declare that to the best of my knowledge, no part of this report has been submitted

elsewhere in a previous application for award of a degree. All sources of knowledge used have

been duly acknowledged.

_______________________________________

OMEONU CHIDIEBERE JAMES


(11CE012794)

ii
CERTIFICATION

This is to certify that the project titled “Construction of an Automated Paper Towel Dispensing

System that uses a Roller Driven by a Position-Controlled DC Motor” by Omeonu Chidiebere

James (11CE012794), meets the requirements and regulations governing the award of Bachelor

of Engineering (Mechanical Engineering) degree of Covenant University and is approved for its

contribution to knowledge and literary presentation.

Supervisor: Sign_________________ _______________________

Name: Prof. Christian Bolu Date

External Examiner: Sign___________________ _______________________

Name:_________________ Date

Head of Department: Sign___________________ _______________________

Name: Dr. Ajayi O. O. Date

iii
DEDICATION

I dedicate this project to GOD Almighty who made it possible for me to achieve all I set out from

the beginning of this project, despite the difficult situations encountered, my Supervisor Prof.

Christian Bolu, my parents Mr. and Mrs C.O. Ochiobi and lastly to my mentor and big brother

Kelechi Fidelis.

iv
ACKNOWLEDGEMENT

I deeply appreciate the Holy Spirit for his divine inspiration during the course of this project, to

God Almighty for the grace to start this project, the wisdom to go about implementing it and the

grace to finish it.

Special thanks to my Supervisor, Prof. Christian Bolu, whose guidance, patience and continuous

encouragement helped me through to the end of this project.

To my parents Mr. and Mrs C.O. Ochiobi, I say thank you for their constant encouragement,

prayers and financial support while working on this project.

To Prof. Christian Bolu and my siblings who helped me with experiences and made themselves

available for consultation whenever I had challenges, I say thank you.

v
ABSTRACT

Toilet paper holders have been in use for years and are routinely located in a toilet seat for a user

to access when required.

An automated paper dispenser consists of an Ultrasonic sensor that can detect a user’s hand or

hand movement. When the user is detected by the sensor, the DC motor inside the dispenser is

activated. The motor is coupled to the paper roll and advances a paper segment out of the

dispenser. The use of an automated paper dispenser is increasingly becoming a requirement in

hospitals and conveniences used by physically challenged persons. This provides flexibility over

conventional paper dispensing.

This project attempts to develop an automated paper dispenser with some intelligence. It uses a

microcontroller that serves as the brain of the system to which all the operating procedures of

each component are programmed.

vi
Table of Contents
DECLARATION ............................................................................................................................................... ii
CERTIFICATION ............................................................................................................................................ iii
DEDICATION................................................................................................................................................. iv
ACKNOWLEDGEMENT .................................................................................................................................. v
ABSTRACT .................................................................................................................................................... vi
LIST OF FIGURES ........................................................................................................................................... x
LIST OF TABLES ........................................................................................................................................... xii
LIST OF SYMBOLS........................................................................................................................................xiii
CHAPTER 1 .................................................................................................................................................... 1
INTRODUCTION.............................................................................................................................................. 1
1.1 Project Background .............................................................................................................................. 1
1.2 STATEMENT OF THE PROBLEM............................................................................................................. 2
1.3 AIM AND OBJECTIVES ........................................................................................................................... 3
1.3.1 AIM ............................................................................................................................................... 3
1.3.2 The Objectives............................................................................................................................... 3
1.4 SIGNIFICANCE AND IMPACT OF THE DESIGN ........................................................................................ 4
1.5 Scope of Project ................................................................................................................................... 4
1.6 DEFINITION OF IMPORTANT TERMS ..................................................................................................... 5
LITERATURE REVIEW ...................................................................................................................................... 7
2.1 Basic Definitions of Mechatronics ........................................................................................................ 7
2.1.1 Historical Perspective of Mechatronics ...................................................................................... 9
2.1.2 Mechatronic System Components............................................................................................... 12
2.2 Sensors, Signals, and Systems ............................................................................................................ 13
2.2.1 Sensor Classification .................................................................................................................... 16
2.3 Ultrasonic Definition .......................................................................................................................... 17
2.3.1 Ultrasonic distance measurement principle ................................................................................ 18
2.3.2 Ultrasonic Application ................................................................................................................. 18
2.3.3 Photo Interrupter ........................................................................................................................ 19
2.4 MICROCONTROLLERS ......................................................................................................................... 19
2.4.1 PWM OUTPUT AND RESET OPERATIONS ..................................................................................... 20
2.4.2 PROGRAMMING LANGUAGE ....................................................................................................... 21
2.4.3 COMPILER MIKROC PRO FOR PIC................................................................................................. 23

vii
2.4.4 PROGRAMMERS .......................................................................................................................... 23
2.5 Theory of DC Motor ........................................................................................................................... 24
2.7 LCD DISPLAY ....................................................................................................................................... 26
2.8 Previous Works .................................................................................................................................. 28
2.9 Contribution....................................................................................................................................... 30
3 METHODOLOGY ........................................................................................................................................ 32
3.1 PROTOTYPE USING LEGO MINDSTORM .............................................................................................. 32
3.2 Hardware implementation ................................................................................................................. 38
3.2.1 The Microcontroller .................................................................................................................... 38
3.2.2 Power Supply .............................................................................................................................. 39
3.2.3 SETTING THE ULTRASONIC SENSORS ........................................................................................... 40
3.2.4 LCD Connecting ........................................................................................................................... 42
3.2.5 Using the BUZZER ........................................................................................................................ 45
3.2.6 Using the LDR and LED to create a photo interrupter .................................................................. 45
3.4 CONCEPTUAL DESIGN ........................................................................................................................ 48
3.4.1 Weight Estimation ....................................................................................................................... 48
3.4.2 Modular Design ........................................................................................................................... 53
3.5 Programming Microcontrollers .......................................................................................................... 54
3.6 Modeling of DC Motor ................................................................................................................... 56
CHAPTER 4 ................................................................................................................................................... 58
RESULTS AND DISSCUSION ........................................................................................................................... 58
4.1 Introduction ....................................................................................................................................... 58
4.2 SYSTEM SIMULATION ......................................................................................................................... 58
4.3 Hardware system ............................................................................................................................... 60
4.3.1 User detecting function by the ultrasonic sensor ........................................................................ 61
4.4 BLOCK TESTING .................................................................................................................................. 61
4.4.1 Power Supply .............................................................................................................................. 61
4.4.2 Ultrasonic sensor testing ............................................................................................................. 62
4.4.3 Photo Interrupter Testing............................................................................................................ 62
4.4.4 Actuator Testing .......................................................................................................................... 64
4.5 SUMMARY.......................................................................................................................................... 68
CHAPTER 5 ................................................................................................................................................... 69
CONCLUSION ........................................................................................................................................... 69

viii
5.1 ACHIEVEMENTS.................................................................................................................................. 69
5.2 FUTURE WORK ................................................................................................................................... 70
5.3 LIMITATIONS ...................................................................................................................................... 70
5.4 RECOMMENDATION .......................................................................................................................... 71
5.5 PROBLEMS ENCOUNTERED & SOLUTIONS.......................................................................................... 71
5.6 SUMMARY.......................................................................................................................................... 71
REFERENCES ................................................................................................................................................ 74
APPENDIX A ................................................................................................................................................. 79
APPENDIX B ............................................................................................................................................ 84
APPENDIX C ................................................................................................................................................ 85

ix
LIST OF FIGURES

Figure 1: Illustration of PWM signal ........................................................................................................... 21


Figure 2: PICkit 3 programmer .................................................................................................................... 24
Figure 3: Typical DC Motor System with Encoder or Resolver Feedback. .................................................. 25
Figure 4: Example of an LCD Display ........................................................................................................... 26
Figure 5: automated paper dispenser by Jouaneh ..................................................................................... 29
Figure 6: Action Blocks ................................................................................................................................ 33
Figure 7: Flow control Blocks ...................................................................................................................... 33
Figure 8: Sensor Blocks ............................................................................................................................... 33
Figure 9: Data Operations Block ................................................................................................................. 33
Figure 10: Advanced Blocks ........................................................................................................................ 34
Figure 11: block programming for touch sensor ........................................................................................ 34
Figure 12: block programming for ultrasonic sensor .................................................................................. 35
Figure 13: block programming with colour sensor and ultrasonic sensor.................................................. 35
Figure 14: Project prototype using LEGO MINDSTORM ............................................................................. 36
Figure 15: Diagram of the Microcontroller from Proteus Simulation......................................................... 39
Figure 16: Ultrasonic sensor during testing ................................................................................................ 42
Figure 17: LCD display 1 .............................................................................................................................. 43
Figure 18: LCD display 2 .............................................................................................................................. 43
Figure 19: LCD display 3 .............................................................................................................................. 44
Figure 20: LCD display 4 .............................................................................................................................. 44
Figure 21: LCD display 5 .............................................................................................................................. 45
Figure 22: Photo Interrupter ....................................................................................................................... 46
Figure 23: Circuit design using Proteus 8 Professional .............................................................................. 47
Figure 24: First Conceptual design - Isometric View................................................................................... 49
Figure 25: First Conceptual design - Side and back view ............................................................................ 50
Figure 26: First Conceptual design - Front View ........................................................................................ 50
Figure 27: Final Conceptual Design - Front and side view ......................................................................... 52
Figure 28: Final Conceptual Design - Top View........................................................................................... 52
Figure 29: Writing the C program using MikroC for PIC ............................................................................. 54
Figure 30: Programming software .............................................................................................................. 55
Figure 31: DC motor wiring diagram ........................................................................................................... 56
Figure 32: Proteus simulation of the circuit design .................................................................................... 59
Figure 33: The .asm file program used as source code in Proteus 8 .......................................................... 59
Figure 34: Full Circuit system ...................................................................................................................... 60
Figure 35: Power supply pack ..................................................................................................................... 61
Figure 36: Ultrasonic sensor during testing and Ultrasonic sensor in the system...................................... 62
Figure 37: LDR & LED placed facing each other to form the Photo interrupter ......................................... 63
Figure 38: Two motors at both ends of the shaft to form the actuator ..................................................... 64
Figure 39: Snapshots of the Actuating system............................................................................................ 65
Figure 40: Snapshot of the system showing the LCD display...................................................................... 66
Figure 41: Snapshot showing the position of the LCD display and Ultrasonic sensor ................................ 66
Figure 42: Snapshots of the system after dispensing the paper roll .......................................................... 67

x
Figure 43: Snapshots showing the design body .......................................................................................... 67
Figure 44: Snapshot of the support base .................................................................................................... 68

xi
LIST OF TABLES

Table 1: Description of LCD function pins ................................................................................................... 27


Table 2: Features and descriptions of PIC18F452 ....................................................................................... 38
Table 3: Table showing the Electric parameter of the Ultrasonic sensor ................................................... 40
Table 4 DC motor Parameter ..................................................................................................................... 56
Table 5: Cost of Project Materials ............................................................................................................... 72

xii
LIST OF SYMBOLS

DC - Direct Current

RF - Radio Frequency

PIC - Programmable Interface Controller

V - Voltage

Rpm - Rotation per minute

PWM - Pulse Width Modulation

ROM - Read only memory

RAM - Random Access Memory

I/O - Input/Output

ADC - Analog to Digital Converter

MHz - Megahertz

GHz - Gigahertz

m - metre

cm - centimetre

LCD - Liquid Crystal Display

ADC - Analog to Digital Converter

AM - Amplitude Modulation

FM - Frequency Modulation

xiii
CHAPTER 1

INTRODUCTION

The introduction gives a general overview of the design project, giving the reader the background

or basis of the problem to be reported.

1.1 Project Background

Paper towel dispensers were a very common hand drying method used in the early 1990’s. These

hand dryers consist of a long roll paper located inside the dispenser which loops back into the

machine when the user would pull down on the paper in sheets so that they can dry their hands

on dry unused paper. New paper dispensers no longer require the user to pull down on the paper;

instead an infrared sensor used in conjunction with a motor provides a fresh section of the paper

roll to the user after every use (Sherry, 2009).

An automated paper dispenser consist of a proximity or motion sensor that can be able to detect

a user’s hand or hand movement. When the user is detected by the sensor, the DC motor inside

the dispenser is activated. The motor is coupled to the paper roll and advances a paper segment

out of the dispenser. The use of an automated paper dispenser has become common in the

modern society and provides flexibility in conventional paper dispensing.

It is designed to dispense metered length paper without requiring the user to touch any part of

the dispenser other than the leading edge of the paper roll.

1
It uses a microcontroller that serves as the brain of the system to which all the operating

processes of each component are chronologically programmed in it. The microcontroller is

programmed to control and monitor the quantity of paper to be dispensed, and it controls the

LCD which displays status of the dispenser. The LCD display indicates when the system is active,

when the paper is unwinding, when the battery is low and the paper roll is small. It will alert the

microcontroller and this will also be displayed in the LCD as well. The combined features make

the design suitable for efficient use.

1.2 STATEMENT OF THE PROBLEM

The typical toilet paper dispenser has two major problems: sanitation and convenience.

Normally, a manual paper dispenser enables the user to pull a portion of the roll from the

dispenser and if the paper roll is perforated, then the user can be able to unwind a desired

number of perforated segments from the roll then tears the segments away from the roll along

one of the perforations. Alternatively, the toilet may not be perforated in which the user in this

case will be forced to press down the paper roll portion against a knife or other severing means

to separate the user-selectable portion from the roll. In both cases, the user still has unlimited

access to the paper roll in the dispenser. Wastage will then occur as the user pulls a long portion

of the roll from the dispenser and does not use it thereby allowing the portion hanging out of the

dispenser and/or laying on the floor.

Another problem with known paper dispensers is that the users typically have to reach under

the dispensers to grab the leading edge of the toilet paper roll, then pull the leading edge

downwards in order to extract paper from the dispenser. This can be highly frustrating especially

2
if the dispenser is mounted low, or if there is an insufficient tail protruding under the dispenser

for the user to obtain a firm grip. Persons with disabilities or restricted mobility can find operating

such dispensers to be particularly challenging.

A few dispensers are provided with a rotary knob on the outside of the dispenser to help the

client in dispensing paper. However, numerous clients are hesitant to touch the dispenser, as

such dispensers can be messy and can contain microscopic organisms or other unhygienic

material.

In view of the above, it would be desirable to provide a toilet paper dispenser that can solve

at least some of the shortcomings of present toilet paper dispensers.

1.3 AIM AND OBJECTIVES

1.3.1 AIM

The aim of the project is to build a cost-effective automated paper dispenser that uses an

Ultrasonic sensor to prevent physical contact of user and the machine.

1.3.2 The Objectives

The general objective pertains to the main purpose of the design which addresses the statement

of the problem. The specific objective identifies the functionalities and features that the device

should possess.

General Objectives

1. To build an automated paper dispenser that uses a motion sensor to prevent physical

contact of user and the machine

3
2. To provide an improved automatic paper dispenser that can automatically advance

and cut a paper segment for the user.

3. To indicate the status of dispenser on the LCD display.

4. To signal when the paper roll in the dispenser is empty or almost empty.

1.4 SIGNIFICANCE AND IMPACT OF THE DESIGN

The proposed design is intended to provide the lowest risk of cross-contamination and shall be

used for drying hands. Design is made such that only the dispensed paper is touched during

removal of paper for use. Unlike other automated paper dispensing design, this design contains

a sensor that detects when the paper roll is below low or close to empty.

1.5 Scope of Project

The design emulates the functionality of a manual paper dispenser and matches the normal

automated paper dispenser already created and also improves the flexibility for the change of

paper.

The scopes of this project are:

I. The microcontroller that has been used for this project is PIC 18F4520

II. Controlling the length of paper roll used by an individual.

III. The design has sensors that would detect when the paper roll is empty or almost empty.

IV. The design provides a base platform for the paper to rest on after unwinding. This will

fold the paper roll making it more flexible for the user.

4
1.6 DEFINITION OF IMPORTANT TERMS

1. Automate – To convert to automatic operation.

2. Controller- It is a microprocessor based devices that completes the control loop by

accepting feedback signal as the input, and by generating as an output, the input signal

required by the final control element.

3. Dispenser - container so designed that the contents can be used in prescribed amounts.

4. Incremental Encoders: They are capable of providing both positional measurements and

velocity measurements.

5. Hardware - A general term for the physical artifacts of a technology.

6. Block Diagram - a diagram of a system, in which the principal parts or functions are

represented by blocks connected by lines that show the relationships of the blocks.

7. Capacitor - a passive electronic component consisting of a pair of conductors separated

by a dielectric (insulator). When there is a potential difference (in voltage) across the

conductors, a static electric field develops in the dielectric that stores energy and

produces a mechanical force between the conductors.

8. Proximity Sensor: An electrical transducer that detects the absent/presence of an object

without physical contact been made.

9. LED – Light-emitting Diode

10. LCD – Liquid-crystal-display

11. Resistors are normally designed and operated so that, with varying levels of current,

variations of their resistance values are negligible. Power supply reaches its steady-state

response of a constant 5 volts.

5
12. Power Supply - a device that supplies electrical energy to one or more electric loads.

13. Programming - the process of designing, writing, testing, debugging / troubleshooting,

and maintaining the source code of computer programs.

14. DC Motor – It’s an electrical machines that converts direct current electrical power into

mechanical power.

15. Microcontroller - a small computer on a single integrated circuit containing a processor

core, memory, and programmable input/output peripherals.

16. Ultrasonic Transducer - it is a device that converts energy into ultrasound, or sound waves

above the normal range of human hearing.

17. Rotary Encoder - It is an electro-mechanical device that converts the angular position or

motion of a shaft or axle to an analog or digital code.

18. PICkit Programmer/Debugger - They are used to program and debug microcontrollers.

6
CHAPTER TWO

LITERATURE REVIEW

Literature review was an ongoing process throughout the whole process of the project. It is very

essential to refer to the variety of sources in order to gain more knowledge and skills to complete

this project. These sources include Reference books, thesis, journals and also the materials

obtained from internet. This chapter includes theory about the DC motor, incremental encoder,

Ultrasonic sensor, microcontroller, LCD display and previous work that has been done.

2.1 Basic Definitions of Mechatronics

The meaning of mechatronics has evolved since the original definition by the Yasakawa Electric

Company. In trademark application archives, Yasakawa defined mechatronics in this way : The

word, mechatronics, is made out of "mecha" from mechanism and the "tronics" from electronics.

In other words, innovations and created products will be incorporating electronics more into

mechanisms, intimately and organically, and making it difficult to tell where one closures and

alternate starts (Kyura et al,2000). The meaning of mechatronics kept on advancing after

Yasakawa recommended the first definition. One of cited meaning of mechatronics was exhibited

by Harashima et al (1996). In their words, mechatronics is characterized as the synergistic joining

of mechanical system, with electronics and intelligent computer control in the configuration and

assembling of modern items and procedures. That same year, another definition was proposed

by Auslander & Kempf. (1996): Mechatronics is the utilization of complex decision making to the

operation of physical frameworks. Shetty& Kolk. (1997) defined mechatronics as: Mechatronics

is a procedure utilized for the optimal of electromechanical products.

7
More recently, we discover the proposal by Bolton, W. (1999): A mechatronic framework is not

only a marriage of electrical and mechanical system and is more than only a control framework;

it is a finished incorporation of every one of them. These definitions and articulations about

mechatronics are precise and useful, yet everyone all by itself neglects to catch the totality of

mechatronics. In spite of proceeding with endeavors to characterize mechatronics, to classify

mechatronic items, and to build up a standard mechatronics educational modules, an accord

assessment on a widely inclusive portrayal of "what is mechatronics" escapes us. This absence of

agreement is a sound sign. It says that the field is alive, that it is an energetic subject. Indeed,

even without an unarguably conclusive portrayal of mechatronics, engineers comprehend from

the definitions given above and from their very own encounters the embodiment of the logic of

mechatronics. For some practicing engineers on the cutting edge of building configuration,

mechatronics is nothing new. Numerous engineering products of the most recent 25 years

coordinated mechanical, electrical, and computer system, yet were outlined by engineers that

were never formally prepared in mechatronics essentially. It appears that modern concurrent

engineering design practices, now formally saw as a major aspect of the mechatronics specialty,

are normal outline forms. What is apparent is that the investigation of mechatronics gives a

mechanism to researchers inspired by comprehension and clarifying the building outline

procedure to characterize, order, compose, and coordinate numerous parts of item plan into an

intelligible bundle. As the past divisions between 'mechanical, electrical, aerospace, chemical,

civil, and computer engineering turn out to be less obviously characterized, we ought to enjoy

the presence of mechatronics as a field of study in the scholarly world. The mechatronics

specialty gives an instructive way, that is, a guide, for engineering students examining inside the

8
conventional structure of most engineering schools. Mechatronics is for the most part perceived

worldwide as a lively range of study. Undergrad and graduate projects in mechatronic designing

are currently offered in numerous colleges. Refereed diaries are being distributed and committed

gatherings are being composed and are by and large exceptionally gone to.

It should be understood that mechatronics is not only a convenient structure for investigative

studies by academicians; it is a lifestyle in modern engineering practice. The presentation of the

microprocessor in the early 1980s and the steadily expanding craved execution to cost proportion

changed the worldview of engineering design. The quantity of new items being produced at the

crossing point of customary orders of engineering, software engineering, and the normal sciences

is always expanding. New improvements in these conventional orders are being retained into

mechatronics plan at a regularly expanding pace. The ongoing information technology revolution,

advances in wireless communication, smart sensors design (empowered by MEMS innovation),

and embedded systems engineering guarantees that the engineering design worldview will keep

on evolving in the early twenty-first century.

2.1.1 Historical Perspective of Mechatronics

Attempts to construct automated mechanical systems has a fascinating history. Actually, the

expression "automation" was not popularized until the 1940s when it was instituted by the Ford

Motor Company to mean a procedure in which a machine transferred a sub-assembly item

starting with one station then onto the next and afterward positioned the item precisely for

additional assembly operations. But successful development of automated mechanical systems

occurred long before then. For instance, early utilizations of automatic control systems appeared

9
in Greece from 300 to 1 B.C. with the improvement of float regulator mechanisms (Mayr, O.,

1970). Two essential illustrations incorporate the water clock of Ktesibios that utilized a float

regulator, and an oil lamp devised by Philon, which likewise utilized a float regulator to keep up

a steady level of fuel oil. Later, in the primary century, Heron of Alexandria distributed a book

entitled Pneumatica that depicted distinctive sorts of water-level instruments utilizing float

regulators.

In Europe and Russia, somewhere around seventeenth and nineteenth centuries, numerous

devices were invented that would in the long run add to mechatronics. Cornelis Drebbel (1572–

1633) of Holland conceived the temperature regulator speaking to one of the main criticism

frameworks of that period. In this manner, Dennis Papin (1647–1712) invented a pressure safety

regulator for steam boilers in 1681. Papin's pressure regulator is like a current pressure-cooker

valve. The first mechanical calculating machine was invented by Pascal in 1642 (Tomkinson &

Horne, 1996). The principal verifiable criticism framework guaranteed by Russia was produced

by Polzunov in 1765. Polzunov's water-level float regulator employs a float that rises and brings

in connection down to the water level, thereby controlling the valve that covers the water inlet

in the boiler. Further development in automation was enabled by advancements in control

theory traced back to the Watt flyball governor of 1769. The flyball governor was utilized to

control the rate of a steam motor (Dorf et al, 2000). Utilizing an estimation of the pace of the

yield shaft and using the movement of the flyball to control the valve, the measure of steam

entering the motor is controlled. As the rate of the motor expands, the metal circles on the

representative contraption rise and broaden far from the pole pivot, along these lines shutting

the valve. This is a case of a criticism control framework where the input signal and the control

10
activation are totally coupled in the mechanical equipment. These early fruitful mechanization

improvements were accomplished through instinct, utilization of down to earth abilities, and

perseverance. The following stride in the development of computerization required a hypothesis

of programmed control.

The precursor to the numerically controlled (NC) machines for mechanized assembling (to be

created in the 1950s and 60s at MIT) showed up in the mid-1800s with the innovation of food

forward control of weaving looms by Joseph Jacquard of France. In the late 1800s, the subject

now known as control theory was initiated by J. C. Maxwell (1964) through investigation of the

arrangement of differential equations depicting the flyball governor. Maxwell researched the

effect various system parameters had on the system performance. At about the same time,

Vyshnegradskii (1877) formulated a mathematical theory of regulators. In the 1830s, Michael

Faraday depicted the law of induction that would frame the basis of the electric motor and the

electric dynamo. Subsequently, in the late 1880s, Nikola Tesla invented the alternating-current

induction motor. The fundamental thought of controlling a mechanical system automatically was

firmly established by the end of 1800s. The evolution of automation would accelerate significantly

in the twentieth century.

The advancement of pneumatic control components in the 1930s developed to a state of

discovering applications in the process industries. However, prior to 1940, the design of control

systems remained an art generally characterized by trial-and-error methods. During the 1940s,

proceeded with advances in scientific and explanatory strategies set the idea of control building

as a free designing order. In the United States, the improvement of the phone framework and

electronic input enhancers impelled the utilization of criticism by Bode, Nyquist, and Black at Bell

11
Telephone Laboratories. The operation of the criticism intensifiers was depicted in the

recurrence area and the following outline and investigation practices are presently for the most

part named "established control." During the same time frame, control hypothesis was likewise

creating in Russia and Eastern Europe. Mathematicians and connected mechanicians in the

previous Soviet Union commanded the field of controls and focused on time space details and

differential condition models of frameworks. Further improvements of time space plans utilizing

state variable framework representations happened in the 1960s and led to design and analysis

practices now generally classified as “modern control.”

2.1.2 Mechatronic System Components

Mechatronics integrates electromechanical systems design, modeling, simulation, analysis,

software hardware developments and co-design, intelligence, decision making, advanced control

(including self-adaptive, robust, and intelligent motion control), signal/image processing, and

virtual prototyping. The mechatronic paradigm utilizes the fundamentals of electrical, mechanical,

and computer engineering with the ultimate objective to guarantee the synergistic combination of

precision engineering, electronic control, and intelligence in the design, analysis, and optimization

of electromechanical systems. Electromechanical systems (robots, electric drives,

servomechanisms, pointing systems, assemblers) are highly nonlinear systems, and their accurate

actuation, sensing, and control are very challenging problems. Actuators and sensors must be

designed and integrated with the corresponding power electronic subsystems. The principles of

matching and compliance are general design principles, which require that the electromechanical

system architectures should be synthesized integrating all subsystems and components. The

matching conditions have to be determined and guaranteed, and actuators– sensors–power

12
electronics compliance must be satisfied. Electromechanical systems must be controlled, and

controllers should be designed. Robust, adaptive, and intelligent control laws must be designed,

examined, verified, and implemented. The research in control of electromechanical systems aims

to find methods for devising intelligent and motion controllers, system architecture synthesis,

deriving feedback maps, and obtaining gains. To implement these controllers, microprocessors and

DSPs with ICs (input-output devices, A/D and D/A converters, optocouplers, transistor drivers)

must be used. Other problems are to design, optimize, and verify the analysis, control, execution,

emulation, and evaluation software.

It was emphasized that the design of high-performance mechatronic systems implies the

subsystems and components developments. One of the major components of mechatronic systems

are electric machines used as actuators and sensors. The following problems are usually

emphasized: characterization of electric machines, actuators, and sensors according to their

applications and overall systems requirements by means of specific computer-aided-design

software; design of high-performance electric machines, actuators, and sensors for specific

applications; integration of electric motors and actuators with sensors, power electronics, and ICs;

control and diagnostic of electric machines, actuators, and sensors using microprocessors and

DSPs.

2.2 Sensors, Signals, and Systems

A sensor is frequently characterized as a "device that receives and responds to a signal or stimulus".

This definition is expansive. In fact, it is broad to the point that it covers nearly everything from a

human eye to a trigger in a gun. The administrator alters the level of liquid in the tank by

controlling its valve. Varieties in the channel stream rate, temperature changes (these would

modify the liquid's thickness and subsequently the stream rate through the valve), and comparative

13
unsettling influences must be made up for by the administrator. Without control, the tank is prone

to surge, or run dry. To act suitably, the administrator must acquire convenient data about the level

of liquid in the tank. In this illustration, the data is created by the sensor, which comprises of two

fundamental parts: the sight tube on the tank and the administrator's eye, which delivers an electric

reaction in the optic nerve. The sight tube by itself is not a sensor, and in this specific control

system, the eye is not a sensor either. Only the combination of these two segments makes a narrow-

purpose sensor (detector), which is specifically delicate to the liquid level. In the event that a sight

tube is planned legitimately, it will rapidly reflect varieties in the level, and it is said that the sensor

has a quick speed reaction. On the off chance that the inward breadth of the tube is too little for a

given liquid consistency, the level in the tube may fall behind the level in the tank. At that point,

we need to consider a stage normal for such a sensor. Sometimes, the slack might be entirely

adequate, while in different cases, a superior sight tube outline would be required. Thus, the

sensor's execution must be surveyed just as a major aspect of an information procurement

framework. This world is separated into normal and human-made articles. The common sensors,

similar to those found in living life forms, for the most part react with signs, having an

electrochemical character, that is, their physical nature depends on particle transport, as in the

nerve filaments, (for example, an optic nerve in the liquid tank administrator). In synthetic gadgets,

data is additionally transmitted and handled in electrical structure, in any case, through the vehicle

of electrons. Sensors that are utilized as a part of the manufactured frameworks must talk the same

dialect as the gadgets with which they are interfaced.

This dialect is electrical in its tendency and a man-made sensor ought to be equipped for reacting

with signs where data is conveyed by relocation of electrons, as opposed to ions.1 Thus, it ought

14
to be conceivable to associate a sensor to an electronic framework through electrical wires instead

of through an electrochemical arrangement or a nerve fiber. Subsequently, we utilize a to some

degree smaller meaning of sensors, which might be stated as a sensor is a gadget that gets a jolt

and reacts with an electrical sign.

The term stimulus is utilized all through this book and should be plainly caught on. The boost is

the amount, property, or condition that is gotten and changed over into an electrical sign. A few

writings utilize an alternate term, measurand which has the same significance, however with the

weight on quantitative normal for detecting.

The reason for a sensor is to react to some sort of an info physical property (stimulus) and to

change over it into an electrical sign that is good with electronic circuits. We may say that a sensor

is an interpreter of a by and large nonelectrical esteem into an electrical quality. When we say

"electrical," we mean a sign, which can be diverted, enhanced, and altered by electronic gadgets.

The sensor's output signal might be as voltage, current, or charge. These might be further depicted

as far as amplitude, polarity, frequency, phase, or advanced code. This arrangement of attributes

is known as the yield signal organization. Hence, a sensor has information properties (of any kind)

and electrical yield properties. Any sensor is a vitality converter. Regardless of what you attempt

to gauge, you generally manage vitality exchange from the object of estimation to the sensor. The

procedure of detecting is a specific instance of data exchange, and any transmission of data requires

transmission of vitality. Obviously, one ought not be befuddled by an undeniable reality that

transmission of vitality can stream both ways – it might be with a positive sign and in addition

with a negative sign; that is, vitality can stream either from an article to the sensor or from the

15
sensor to the item. An uncommon case is the point at which the net vitality stream is zero, which

likewise conveys data about presence of that specific case. For instance, a thermopile infrared

radiation sensor will deliver a positive voltage when the item is hotter than the sensor (infrared

flux is streaming to the sensor) or the voltage is negative when the article is cooler than the sensor

(infrared flux streams from the sensor to the item). At the point when both the sensor and the article

are at the same temperature, the flux is zero and the yield voltage is zero. This conveys a message

that the temperatures are the same.

2.2.1 Sensor Classification

Sensor arrangement plans range from very simple to the complex. Depending on the classification

purpose, different classification criteria may be selected. Here, I offer several practical ways to

look at the sensors.

1. All sensors might be of two kinds: passive and active. A passive sensor does not require any

extra vitality source and specifically creates an electric signal because of an external stimulus. That

is, the input stimulus energy is converted by the sensor into the output signal. The cases are a

thermocouple, a photodiode, and a piezoelectric sensor.

The active sensors require outer force for their operation, which is called an excitation signal. That

signal is changed by the sensor to create the output signal. The active sensors here and there are

called parametric because their own particular properties change in reponse to an outer impact and

these properties can be in this way changed over into electric signals. It can be expressed that a

sensor's parameter regulates the excitation signals and that tweak conveys data of the deliberate

quality. For instance, a thermistor is a temperature delicate resistor. It doesn't create any electric

sign, however by passing an electric current through it (excitation signal) its resistance can be

measured by identifying varieties in current and/or voltage over the thermistor. These varieties

16
(displayed in ohms) specifically identify with temperature through a known exchange capacity.

Another case of a dynamic sensor is a resistive strain gauge in which electrical resistance identifies

with a strain. To gauge the resistance of a sensor, electric current must be connected to it from an

outer force source.

2. Depending on the selected reference, sensors can be characterized into absolute and relative. An

absolute sensor detects a stimulus in reference to an absolute physical scale that is independent of

the measurement conditions, whereas a relative sensor produces a signal that relates to some

special case. An example of an absolute sensor is a thermistor, a temperature-sensitive resistor. Its

electrical resistance directly relates to the absolute temperature scale of Kelvin. Another very

popular temperature sensor thermocouple is a relative sensor. It produces an electric voltage, which

is a function of a temperature gradient across the thermocouple wires. Thus, a thermocouple output

signal cannot be related to any particular temperature without referencing to a known baseline.

Another example of the absolute and relative sensors is a pressure sensor. An absolute pressure

sensor produces signal in reference to vacuum – an absolute zero on a pressure scale. A relative

pressure sensor produces signal with respect to a selected baseline that is not zero pressure, for

example, to the atmospheric pressure.

3. Another way to look at a sensor is to consider some of its properties that might be of a specific

interest.

2.3 Ultrasonic Definition

The human ear can hear sound frequency around 20HZ ~ 20KHZ, and ultrasonic is the sound wave

beyond the human ability of 20KHZ.

17
2.3.1 Ultrasonic distance measurement principle

Ultrasonic transmitter emitted an ultrasonic wave in one direction, and began timing when it

launched. Ultrasonic spread noticeable all around, and would return instantly when it experienced

obstacles in transit. Finally, the ultrasonic collector would quit timing when it got the reflected

wave. As Ultrasonic spread speed is 340m/s in the air, based on the timer record t, we can solve

the distance (s) between the impediment and transmitter, namely: s = 340t/2, which is so-called

time difference distance estimation principle the rule of ultrasonic distance estimation utilized the

definitely known air spreading speed, measuring the time from dispatch to reflection when it

experienced obstacle, and afterward compute the distance between the transmitter and the obstacle

as indicated by the time and the speed. Thus, the rule of ultrasonic distance estimation is the same

with radar. Distance measurement recipe is shown as: L = C X T In the equation, L is the measured

distance, and C is the ultrasonic spreading speed in air, also, T represents time (T is half the time

value from transmitting to receiving).

2.3.2 Ultrasonic Application

Ultrasonic Application Technology is the thing which developed in recent decades. With the

ultrasonic advance, and the electronic technology development, especially as high-power

semiconductor device technology matures, the application of ultrasonic has become increasingly

widespread:

 Ultrasonic measurement of distance, depth and thickness;

 Ultrasonic testing;

 Ultrasound imaging;

 Ultrasonic machining, such as polishing, drilling;

 Ultrasonic cleaning;

18
 Ultrasonic welding;

2.3.3 Photo Interrupter

A phototransistor and an LED are packaged together to make optical sensors that can be used to

detect objects. The LED provides light that is received by the phototransistor. An interruption of

the light received by the phototransistor causes the phototransistor to change state, thus indicating

the presence of an object in the path between the LED and the phototransistor.

2.4 MICROCONTROLLERS

Microcontroller is a highly integrated chip that contains all the components comprising a

controller. Typically this includes a CPU, RAM, some form of ROM, I/O ports, and timers. Unlike

a general-purpose computer, which also includes all of these components, a microcontroller is

designed for a very specific task which to control a particular system. As a result, the parts can be

simplified and reduced, which cuts down on production costs. Microcontrollers are sometimes

called embedded microcontrollers, which just mean that they are part of an embedded system that

is, one part of a larger device or system. Microcontroller is the best choice to be the control system

in controlling a DC motor because of its ability to store and run unique programs. Besides, the

relatively low cost of the microcontroller made it a wise choice in implementing it in the DC motor

speed and position control system. The microcontroller’s ability is to run and store unique

programs and microcontroller is very flexible to work with. As an example, user can program a

microcontroller to carry out a series of functions based on predetermined situations (I/O-line logic)

and selections. Its capability on carrying mathematical and logical functions allows it to imitate

complicated logic and electronic circuit. Higher level microchip PIC18F family can be used to

integrate large amounts of code in a single IC. PIC microcontrollers are one of the fastest growing

19
parts of the embedded integrated circuit market in recent times and suitable for fast implementation

controller and can be programmed for motor control applications.

PIC microcontrollers designed by Microchip Technology are likely the best choice for beginners.

Here is why...The original name of this microcontroller is PICmicro (Peripheral Interface

Controller), but it is better known as PIC. Its ancestor, called the PIC1650, was designed in 1975

by General Instruments. It was meant for totally different purposes. Around ten years later, this

circuit was transformed into a real PIC microcontroller by adding EEPROM memory. Today,

Microchip Technology announces the manufacture of the 5 billionth sample. All PIC

microcontrollers use Harvard architecture, which means that their program memory is connected

to the CPU over more than 8 lines. Depending on the bus width, there are 12-, 14- and 16-bit

microcontrollers.

2.4.1 PWM OUTPUT AND RESET OPERATIONS

None of the MCUs in the PIC16 or PIC18 families have a digital-to-analog conversion capability,

but many PIC MCUs have a built-in module to generate pulse width modulated (PWM) output. A

PWM signal is a square-wave signal of fixed amplitude and frequency, but the width of the on and

off parts of the signal (or duty cycle) can be varied. The PWM output can be used to conveniently

drive H-bridge drives and digital amplifiers. The PWM output mode is one of the three modes of

operation of the Capture/Compare/PWM (CCP) module or enhanced CPP (ECCP) module on the

MCU. The other modes are capture and compare. In the capture mode, the value of the particular

timer associated with the CCP module is copied to a particular register when an input event occurs

on a designated CCP pin. Thus, the capture mode can be used for timing input events. In the

compare mode, an action is triggered when the value in the CCP registers matches the value stored

in the particular timer associated with the CCP module.

20
Figure 1: Illustration of PWM signal

There are different reset operations that are available on a PIC MCU. These include power-on reset

(POR), brown-out reset (BOR), watchdog timer reset, and external MCLR reset. These are

discussed next. A POR occurs whenever the power (VDD line) is turned off and then on to the

chip. After a POR, the code on the chip starts executing at the first program memory instruction,

and some of the registers on the chip will reset to their "Reset" state. A BOR (if enabled) produces

the same result as a POR and occurs whenever the VDD voltage level falls below the rated voltage

(between 2 to 5.5 V for most chips). The BOR does not occur unless certain registers on the chip

were set to detect this condition. This feature is useful in battery-powered applications to detect

low voltage conditions. The watchdog timer reset occurs whenever the counter associated with the

watchdog timer overflows, while a MCLR Reset occurs whenever the MCLR pin line goes to low.

Note that the PIC MCU has a special register (called PCON or power control) that can indicate

which type of reset has occurred.

2.4.2 PROGRAMMING LANGUAGE

The microcontroller executes the program loaded in its Flash memory. This is the so called

executable code comprised of seemingly meaningless sequence of zeros and ones. It is organized

21
in 12-, 14- or 16-bit wide words, depending on the microcontroller’s architecture. Every word is

considered by the CPU as a command being executed during the operation of the microcontroller.

For practical reasons, as it is much easier for us to deal with hexadecimal number system, the

executable code is often represented as a sequence of hexadecimal numbers called a Hex code. It

used to be written by the programmer. All instructions that the microcontroller can recognize are

together called the Instruction set. As for PIC microcontrollers the programming words of which

are comprised of 14 bits, the instruction set has 35 different instructions in total. As the process of

writing executable code was endlessly tiring, the first ‘higher’ programming language called

assembly language was created.

The truth is that it made the process of programming more complicated, but on the other hand the

process of writing program stopped being a nightmare. Instructions in assembly language are

represented in the form of meaningful abbreviations, and the process of their compiling into

executable code is left over to a special program on a PC called compiler. The main advantage of

this programming language is its simplicity, i.e. each program instruction corresponds to one

memory location in the microcontroller. It enables a complete control of what is going on within

the chip, thus making this language commonly used today. However, programmers have always

needed a programming language close to the language being used in everyday life. As a result, the

higher programming languages have been created. One of them is C. The main advantage of these

languages is simplicity of program writing. It is no longer possible to know exactly how each

command executes, but it is no longer of interest anyway. In case it is, a sequence written in

assembly language can always be inserted in the program, thus enabling it.

22
2.4.3 COMPILER MIKROC PRO FOR PIC

The first thing needed to write a program for the microcontroller is a PC program which

understands the programming language used, C in this case, and provides a window for writing

program. Besides, the software must 'know' the architecture of the microcontroller in use. In this

case, you need a compiler for C language. There is no compiler to be used for only one concrete

microcontroller as there is no compiler to be used for all microcontrollers. It’s all about software

used to program a group of similar microcontrollers of one manufacturer. MikroC PRO for PIC

compiler is intended for writing programs for PIC microcontrollers in C language. It is provided

with all data on internal architecture of these microcontrollers, operation of particular circuits,

instruction set, names of registers, their accurate addresses, pinouts etc. When you start up the

compiler, the next thing to do is to select a chip from the list and operating frequency and of course

- to write a program in C language. The installation of mikroC PRO for PIC is similar to the

installation of any Windows program.

2.4.4 PROGRAMMERS

The process of transferring a compiled binary code to the MCU is called "programming" a chip.

Originally, Microchip provided the PICStart Plus programmer, in which the user plugs the chip to

be programmed into the device. Then, through a serial line from the PC to the PICStart Plus, the

MPLAB IDE is used to transmit the binary code to the chip. Once the chip is programmed, the

chip is removed from the programmer and transferred into the target system in which it will be

used. More recently, Microchip introduced the PICkit 2 and then the PICkit 3 Microcontroller

Programmer. These are low-cost development programmers that can be conveniently used to

program many MCU chips.

23
Figure 2: PICkit 3 programmer

2.5 Theory of DC Motor

DC motors are used in closed loop control systems as control variable shown in Figure 2.1. The

DC motor controller normally control using directs operation by sending velocity command

signals to the amplifier, which drives the DC motor. An integral feedback device (resolver) or

devices (encoder and tachometer) are either incorporated within the DC motor or are remotely

mounted, often on the load itself. These provide the DC motor position and velocity feedback that

the controller compares to its programmed motion profile and uses to alter its velocity signal. DC

motors feature a motion profile, which is a set of instructions programmed into the controller that

defines the DC motor operation in terms of time, position, and velocity. The ability of the DC

motor to adjust to differences between the motion profile and feedback signals depends greatly

upon the type of controls and DC motor used.

24
Figure 3: Typical DC Motor System with Encoder or Resolver Feedback.

DC motor is one of the devices that have the applications where precise positioning and speed

required. The big advantage of the DC motor is it’s operated as closed loop system. This means

feedback is required from the motor, it make this system is sensitivity to disturbances and have

ability to correct these disturbances.

Advantages of using PIC over other controlling devices for controlling the DC motor are given

below:

 Speed: The execution of an instruction in PIC IC is very fast (in micro seconds) and can be

changed by changing the oscillator frequency. One instruction generally takes 0.2

microseconds.

 Compact: The PIC IC will make the hardware circuitry compact.

 RISC processor: The instruction set consist only 35 instructions.

 EPROM program memory: Program can be modified and rewritten very easily.

 Inbuilt hardware support: Since PIC IC has inbuilt programmable timers, ports an

interrupts, no extra hardware is needed.

 Powerful output pin control: Output pins can be driven to high state, using a single

instruction. The output pin can drive a load up to 25mA.


25
 Inbuilt I/O ports expansions: This reduces the extra IC’s which are needed for port

expansion and port can be expanded very easily.

 Integration of operational features: Power on reset and brown/out protection ensures that

the chip operates only when the supply voltage is within specification. A watchdog timer

resets PIC if the chip ever malfunctions and deviates from its normal operation.

2.7 LCD DISPLAY

This component is specifically manufactured to be used with microcontrollers, which means that

it cannot be activated by standard IC circuits. It is used for displaying different messages on a

miniature liquid crystal display. The model described here is for its low price and great capabilities

most frequently used in practice and it is used in this project. It is based on the HD44780

microcontroller (Hitachi) and can display messages in two lines with 16 characters each. It can

display all the letters of alphabet, Greek letters, punctuation marks, mathematical symbols etc. It

is also possible to display symbols made up by the user. Other useful features include automatic

message shift (left and right), cursor appearance, LED backlight etc.

Figure 4: Example of an LCD Display

26
Along one side of the small printed board of the LCD display there are pins that enable it to be

connected to the microcontroller. There are in total of 14 pins marked with numbers (16 if there is

a backlight). Their function is described in the table below:

Table 1: Description of LCD function pins


Function Pin Number Name Logic state Description

Ground 1 Vss - 0V

Power supply 2 Vdd - +5v

Contrast 3 Vee - 0- Vdd

4 RS 0 D0-D7 are interpreted as


1 commands
D0-D7 are interpreted as data
5 R/W 0 Write data (from controller to
1 LCD)
Control of Read data (from LCD to
operating controller)

6 E 0 Access to LCD disabled Normal


1 operating Data/commands are
From 1 to 0 transferred to LCD

7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2

10 D3 0/1 Bit 3
Data/commands

11 D4 0/1 Bit 4

12 D5 0/1 Bit 5

27
13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB

LCD Memory

LCD display contains three memory blocks:

 DDRAM Display Data RAM;

 CGRAM Character Generator RAM; and

 CGROM Character Generator ROM.

2.8 Previous Works

Simon et al (2014) achieved Robotic Pill dispenser rotation by attaching cylinder to the stepper

motor which is controlled by microcontroller through a micro stepper driver that provide precise

micro step rotation of stepper motor.

Ruize et al (2012) built Grill-making machine using the global position feedback capability of the

BLUX drive. The machine builder was able to close the Position loop with the load- mounted

encoder, while the velocity feedback was provided by the motor-mounted encoder and signal

processing. The two-encoder providing both position and velocity feedback. The load mounted

encoder was coupled to friction drive nip-rollers close to the cut head.

28
In a recent project published by (Jouaneh , 2013) , The toilet paper roll is pulled between two

spring loaded rollers, one of which is driven by a geared permanent magnet brush DC motor with

an incremental encoder and a VBE user interface is programmed to specify the number of sheets

of paper to be dispensed and the speed of unwinding.

Figure 5: automated paper dispenser by Jouaneh

Time – pressure dispensing which is regarded as the most widely used dispensing technology

due to its low cost, simple operation, ease of maintenance and flexibility for different applications

and it was estimated that about 70% of the dispensing machines or systems currently use the

time-pressure approach, (Cong-Ping Chen, 2007). DC motors are often used in various industrial

applications where a wide range of Reponses are required to follow a predetermined trajectory

of speed or position under variable load ( Faramarzi & Sabahi, 2011).

29
The wheel encoders provide inputs to the DE controller to control the drive speed and

estimation of the current position. The data of the wheel encoders are based on rotational data

obtained by a dynamic tire model that takes into consideration the vertical, lateral and

longitudinal dynamics of the tire (Jorgensen et al, 2015).

2.9 Contribution

In the course of this project, the 18F4520 microcontroller is used to control the DC motor,

Ultrasonic sensor, LCD display, Buzzer and photo interrupter. The DC motor will be connected

indirectly to a roller drive which is designed to pull the tissue paper. The system will be

programmed for the user to activate the ultrasonic sensor for the DC motor to actuate thereby

dispensing metered length of paper. The LCD display will be able to display when the system is

on standby, when the tissue in the system is low and when it is dispensing. So instead of using an

LED indicator, the LCD display was used for it makes the system more user friendly and flexible.

The buzzer serves as a sound indicator as various activities is been done on the system. The photo

Interrupter consists of a phototransistor and LED packaged together to make optical sensors that

can be used to detect objects. In this project, a LDR which serves a phototransistor was used with

an LED placed facing the surface of the LDR with a potentiometer connected to the LED to

regulate the intensity. These was put together to create a photo interrupter used to detect

whether there is tissue paper in the system or not.

30
Basic Flow Diagram describing the feedback system

STANBY

IS MOTION
NO
SENSOR
ACTIVE?

Yes

IS TEAR BAR YES DRIVE MOTOR IN


SWITCH REVERSE
ACTIVE?

No

DISPENSE PER
PROGRAM

TOWEL DELAY

31
CHAPTER THREE
3 METHODOLOGY

This chapter will describe the method that will be used for this project in order to achieve the

desire objectives. It involves the system prototype, modeling, design and analysis.

3.1 PROTOTYPE USING LEGO MINDSTORM

The first step I took in achieving the desired design and mechatronics functions, was to construct

a simple prototype to analyze the system design and functionality problem. The prototype

consists of LEGO parts assembled in a desired way that keeps the toilet paper, large motor, Colour

sensor, touch sensor and the ultrasonic sensor in place. The base has dimensions of 20cm X 18cm,

and is constructed so that there is a bar through the middle of the paper to hold the roll in place.

The toilet paper rests on a stand and the large motor was connected to a rod that serves as the

roller drive located below the stand of the toilet paper as shown in figure a. The roller contains

four gripped tires which was arranged side by side to hold the tissue and dispenses the paper

when the large motor rotates.

Firstly, I programmed the large motor to run for one rotation by pressing the touch sensor which

sends the output data to the microprocessor which then sends feedback to the large motor and

it runs for one rotation which it worked right. I used it to note the length of paper to be dispensed

and for one rotation, 36cm length of paper was rolled out by the large motor. Next, I changed

the mode of rotation to timing which I set it to six seconds and 148cm was dispensed which was

too long. I then reduced the time of rotation to two seconds and 92cm length of paper was

32
dispensed which was more preferred. The use of touch sensor worked as programmed but it still

required the user to touch the system for the metered length of paper to be dispensed.

LABVIEW PROGRAMMING USING BLOCK DIAGRAM EV3

Figure 6: Action Blocks

Figure 7: Flow control Blocks

Figure 8: Sensor Blocks

Figure 9: Data Operations Block

33
Figure 10: Advanced Blocks

Figure 11: block programming for touch sensor

Next, I removed the touch sensor block on the program and replaced it with the ultrasonic sensor

block and set the threshold frequency to 6cm. The sound block to say hello was added with a

delay block of 1 second to make it more user friendly and flexible. The aim to replace the touch

sensor for the ultrasonic sensor was for user to activate the system without the need to touch it.

It worked to dispense the tissue paper but for the user to cut the desired length of paper being

dispensed, it requires holding of the system for balance so a tear bar will be placed in the real

design to solve that problem.

34
Figure 12: block programming for ultrasonic sensor

In the prototype, I programmed the color sensor which was located just above the tissue paper

to detect if the tissue paper was finished. The color sensor was programmed in such a way that

if the color detected was white, meaning there’s tissue paper else for other colors detected, it

sounds error to alert the user and there’s a delay of 0.5 seconds before it says goodbye.

Figure 13: block programming with colour sensor and ultrasonic sensor

35
After finishing the first iteration, of the automated toilet paper dispenser and beginning work on

the second iteration, I have cemented my specifications for the design project. The main goal of

our project is to create a sensor operated toilet paper dispenser that works easily with the wave

of the user’s hand, in order to create a no touch toilet paper experience. In addition to this goal,

we plan to have simple and intuitive toilet paper loading design with little to no touch, as well as,

a sleek and aesthetically pleasing, non-industrial design.

Figure 14: Project prototype using LEGO MINDSTORM

36
A Flow Chart describing the feedback system

STAND BY

NO

IS ULTRASONIC
SENSOR ACTIVE?

YES

YES DISPLAY ON LCD:


IS THE LDR
TRIGGERED? NO MORE TISSUE

NO

DISPENSE PER
PROGRAM

DELAY MODE

37
3.2 Hardware implementation

3.2.1 The Microcontroller


Microcontroller is the central component which controls all the activities. It interprets the

Ultrasonic sensor information based on the programming, reads data of the LDR, controls the

PWM of the DC motor, displaying information on LCD display and controlling the buzzer. The

microcontroller used in this project is the PIC 18F452 family. Below shows the features and

descriptions:

Table 2: Features and descriptions of PIC18F452

Features PIC18F4520
Operating Frequency DC- 40 MHz
Program Memory (Bytes) 32768
Program Memory (Instructions) 16384
Data Memory (Bytes) 1536
Data EEPROM Memory (Bytes) 256
I/O Ports Ports A, B, C, D, E
Timers 4
Capture/Compare/PWM Modules 1
Enhanced 1
Capture/Compare/PWM Modules
Serial Communications MSSP, Enhanced USART
Parallel Communications (PSP) Yes
10-bit Analog-to-Digital Module 13 Input Channels
Resets (and Delays) POR, BOR,
RESET Instruction,
Stack Full, Stack
Underflow (PWRT, OST),
MCLR (optional), WDT
Programmable Yes
High/Low-Voltage Detect
Programmable Brown-out Reset Yes
Instruction set 75 Instructions;
83 with Extended
Instruction Set enabled
Packages 40-pin PDIP
44-pin QFN
44-pin TQFP

38
Figure 15: Diagram of the Microcontroller from Proteus Simulation

In order to do all the activities, a program (sequence of instruction) is written for the

microcontroller. This program is called firmware. In order to execute the program,

Microcontroller requires basic configuration like 5V regulated power supply, clock and reset

circuit.

3.2.2 Power Supply


It is necessary to create a separate power supply unit for the circuitry in a separate module, based

on packaging and other requirements. The justification for the voltage regulator used I s related

to the fact that it simply supplies the voltage level we need in a discrete package. The power

supply supplies +5v for the Ultrasonic sensor, LCD display, the microcontroller and +3v for the DC

motors.

39
3.2.3 SETTING THE ULTRASONIC SENSORS
The sensor used by the user to activate the system in this project was the Ultrasonic ranging

module HC-SR04 and it provides 2cm-400cm non-contact measurement function with ranging

accuracy reaching 3mm. It consists of the ultrasonic transmitters, receiver and control circuit.

The table below states the Electric parameter:

Table 3: Table showing the Electric parameter of the Ultrasonic sensor

Working Voltage DC 5V

Working Current 15Ma

Working Frequency 40Hz

Max Range 4m

Min Range 2cm

Measuring Angle 15 degree

Trigger Input Signal 10uS TTL pulse

Echo Output Signal Input TTL lever signal and the range in

proportion

Dimension 45*20*15mm

Wire connecting direct as following:

 5V supply

 Trigger pulse Input

 Echo Pulse Output

40
 0v ground

After wire connection, to get a suitable non-contact distance between the user and the sensor,

the microcontroller was programmed for the LCD to display the non-contact measurement

distance. I first set the non-contact distance at 11cm, but noticed the distance was not suitable

for use because a user can trigger the sensor unconsciously. The distance I set for this project

was 6cm because it was closer.

According to the formula : distance = (high level time*ultrasonic spreading velocity in air) / 2, to

calculate the high level time since the test distance used in this project is 6cm,

The ultrasonic spreading velocity (v) = 340m/s

Test distance (S) = 6cm = 0.06m

340𝑡
𝑆= (I)
2

2𝑆 2 × 0.06
𝑡= = = 0.000353 𝑠𝑒𝑐𝑜𝑛𝑑𝑠
340 340

41
Figure 16: Ultrasonic sensor during testing

3.2.4 LCD Connecting

Depending on how many lines are used for connecting an LCD to the microcontroller, there are

8-bit and 4-bit LCD modes. The appropriate mode is selected at the beginning of the operation in

the process called 'initialization'. The 8-bit LCD mode uses outputs D0- D7 to transfer data as

explained on the previous page.

The main purpose of the 4-bit LCD mode is to save valuable I/O pins of the microcontroller. Only
4 higher bits (D4-D7) are used for communication, while others may be left unconnected. Each
piece of data is sent to the LCD in two steps- four higher bits are sent first (normally through the
lines D4-D7), then four lower bits.

The LCD display used in this project was the 16x2 LCD display to illustrate the use of an
alphanumeric LCD display. The function libraries simplify this program, which means that the
effort made to create software pays off in the end.

The first message written in two lines as the system is switched on appears on the display as:
“Automated paper”

42
“Dispensing Sys “

Figure 17: LCD display 1

Three seconds later, the message in both lines is changed and displays the standby message as:

“Final Yr Project”
“By James O.”

Figure 18: LCD display 2

43
Once the Ultrasonic sensor is activated and there’s no tissue paper, the LCD display is
programmed to display;

“No more Tissue”

Figure 19: LCD display 3

If there is tissue, before the system dispenses tissue the LCD display shows thus;

“Pls wait……”
“Dispensing”

Figure 20: LCD display 4

After a given metered length of tissue paper finish dispensing, the LCD display shows;

“Take ur Tissue”

44
Figure 21: LCD display 5

The programming in C is shown in Appendix A.

3.2.5 Using the BUZZER

The buzzer serves as a sound indicator as various activities is been done on the system. As the

system is turned on, it buzzes for one second. Once the ultrasonic sensor is activated, it buzzes

for one second and goes silent till the tissue is dispensed then it buzzes for one second and goes

standby. If there is no tissue in the system, it buzzes for five second. The programming in C is

shown in Appendix A.

3.2.6 Using the LDR and LED to create a photo interrupter

A light dependent resistor also known as a LDR, photoresistor, photoconductor or photocell, is a

resistor whose resistance increases or decreases depending on the amount of light intensity. It

serves as a light sensor to detect the light intensity. A photo Interrupter consists of a

phototransistor and LED packaged together to make optical sensors that can be used to detect

objects.

45
POTENTIOMETER

LDR LED

Figure 22: Photo Interrupter

In this project, the LDR which serves a phototransistor was used with an LED placed facing the

surface of the LDR with a potentiometer connected to the LED to regulate the intensity. These

was put together to create a photo interrupter used to detect whether there is tissue paper in

the system or not. The tissue paper goes in between the LDR and LED thereby blocking the light

on the LED for the LDR not to detect the light dissipated. This will indicate that there’s tissue

paper in the system. When no tissue paper is between the photo interrupter, light of the LED falls

on the semi conductive material it absorbs the light photons and the energy transferred to the

electrons. The Threshold frequency set for the LDR was threshold>160. The programming in C

is shown in appendix A.

3.2.7 FULL CIRCUIT DESIGN

The circuit system of the project was designed using Proteus 8 professional. All components were

put in place as well as the microcontroller and the C programming was added to the Proteus

program for simulation as .asm file. The figure below shows the full circuit design.

46
Figure 23: Circuit design using Proteus 8 Professional

47
3.4 CONCEPTUAL DESIGN

In this design phase, the overall shape, dimensions and weight of the tissue dispenser is

determined. Factors like dimensions and size are determined considering structural constrains.

However factors like the shape of the system was determined based on non-structural

considerations. For instance, the base firm covering the tissue was chosen according to the tissue

size characteristics and it is sized to give the required fit.

3.4.1 Weight Estimation

The breakdown of the weight for the tissue paper dispenser is estimated and shown in Appendix

B. The total weight of the system is estimated by adding up the total weight of all the components

that was been used.

To account for changes or improvements or additions to the system, an additional 25% of the

weight is added.

Therefore total estimated weight = (4.81 + 0.25) Kg

≈ 5.06 kg

48
Conceptual design drawing

Automated Tissue Dispenser

Figure 24: First Conceptual design - Isometric View

49
Automated Tissue Dispenser

Figure 25: First Conceptual design - Side and back view

Figure 26: First Conceptual design - Front View

50
Final Conceptual Design

Automated Tissue paper Dispenser

51
Automated Tissue Paper dispenser

Figure 27: Final Conceptual Design - Front and side view

Figure 28: Final Conceptual Design - Top View

52
3.4.2 Modular Design

A modular designed automated paper dispenser of the two design is also intended for to allow

for the disassembly and interchangeability of parts. This accommodates for the changing of parts

as well as easy maintenance, transportation and testing. This ability for the disintegration of the

system gives rise to smaller components known as modular units.

The first conceptual design consists of the roller drive and gear train as calculated previously, but

The main goal of our project is to create a sensor operated toilet paper dispenser that works

easily with the wave of the users hand, in order to create a no touch toilet paper experience and

first conceptual design gave me difficulty in trying to construct it in a short space of time. The

first design can still be referenced for future modification.

The final design was chosen to be used in this project because it have a simple and intuitive toilet

paper loading design with little to no touch, as well as, a sleek and aesthetically pleasing, non-

industrial design and still meet user friendly ergonomic design that one would want in a private

bathroom.

The automated tissue paper dispenser was designed to be able to be separated into modular

units.

They are:

1. 1x Tissue firm
2. 1x base
3. 1x Support firm
4. 1x LCD display
5. 1x Ultrasonic sensor
6. 3x DC motor
7. 1x Main firm

53
Total number of parts: 9

3.5 Programming Microcontrollers

The programming is written in embedded C. The MikroC for PIC compiler was used in this project

to program the microcontroller. The MikroC for PIC is a free, integrated GCC-based toolset for

the development of embedded applications employing Microchip’s PIC. It runs as a 32 or 64 bit

application on Microsoft, and includes several free software components for application

development, hardware simulation and debugging. C programming language is used with MikroC

for PIC. Figure 19 shows the image of a program written using MikroC for PIC.

Figure 29: Writing the C program using MikroC for PIC

54
PICkit 3 Programming Software is a software which is used to write a program directly to the

targeted microcontroller together with the UIC00A. By importing a HEX file that contains a

specific program for desired microcontroller, this software will automatically recognized the type

of the targeted microcontroller and easily program it by clicking the „Write‟ button. Figure 23

shows the detail of each function inside the PICkit 3 Programming Software.

Figure 30: Programming software

55
3.6 Modeling of DC Motor

A DC motor is used in a control system where an appreciable amount of shaft power is required.

This DC motors used in instrument employ a fixed permanent-magnet field, and the control signal

is applied to the armature terminals. Figure 24 show the DC motor wiring diagram and the Table

3.2 show the parameter of the DC motor

Figure 31: DC motor wiring diagram

Table 4 DC motor Parameter

Symbol Description

Ra Armature resistance

La Armature inductance

Ia(t) Armature current

Tm(t) Motor torque

56
Va(t) Armature input voltage

Eb(t) Back emf

Ꝋm(t) Motor angular displacement

Wm(t) Motor angular velocity

Jm Moment of inertia of motor + load

Bm Viscous frictional constant of motor + load

57
CHAPTER 4

RESULTS AND DISSCUSION

4.1 Introduction

In this chapter, all the result of experiments carried out in this project and interpretation

experiments both on the hardware and software part. The automated paper towel dispenser

system was successfully integrated to produce desired result which fulfill this project objective.

Based on the result, the system has three main functions which were User detecting function by

the ultrasonic sensor, paper towel detecting function by the photo interrupter and the

mechanical actuating function by the DC motors. Everything regarding of this final result and

discussion on this system is further discussed in details in this chapter.

4.2 SYSTEM SIMULATION

The entire circuit could not be simulated on the Proteus software due to the ultrasonic sensor,

so the system simulation excluded the Ultrasonic sensor part because it can only be tested by

physically indicating the physical presence of an object. The power supply circuit was also

removed from system simulation for its insignificance to software simulation. A code was written

into the Microcontroller to carry this operation. The simulation is as shown in Figure 1. The Source

code is also shown in Figure 2.

58
Figure 32: Proteus simulation of the circuit design

Figure 33: The .asm file program used as source code in Proteus 8

59
4.3 Hardware system

In this project, the PIC 18F452 based project is designed to develop the automated paper

dispensing system which consists of the buzzer circuit, power supply circuit, Ultrasonic circuit,

LCD display circuit, DC motor circuit and photo interrupter (LED and LDR) circuit shown in figure

11. All the circuit designs were done using Proteus and simulated as well before implementing

the hardware components for soldering.

Figure 34: Full Circuit system

60
4.3.1 User detecting function by the ultrasonic sensor

Based on the hardware description above, the automated paper towel dispenser stays on

standby when the ultrasonic sensor is not activated by presence of a user. The threshold function

of the sensor has to be met for it to sense human presence (i.e: the non-contact distance of 6cm

has to be met to activate the system). When the sensor is activated by a user, The LCD will display

a message ‘pls wait… dispensing’. But when there’s no paper towel in the system, the LCD will

display ‘no more tissue’.

4.4 BLOCK TESTING

Here, the circuit components were physically tested to assure compliance with design.

4.4.1 Power Supply

A ready power supply circuit was used which contained all components of the power supply

circuit on a PCB except the 7805 Voltage Regulator. Wires were welded onto the inputs and

outputs of the board (for case of connection) and the outputs were connected to the regulator.

Figure 35: Power supply pack

61
4.4.2 Ultrasonic sensor testing

The sensor is used by the user to activate the system. During the course of testing, the

microcontroller was programmed for the LCD to display the non-contact measurement distance.

I first set the non-contact distance at 11cm and ran series of tests. It was noticed that the distance

was not suitable for use because the sensor was triggered unconsciously during testing. After

series of distance testing, 6cm of non-contact distance was finally used for the project because it

was closer.

After getting the non-contact distance to use, I then connected the ultrasonic sensor to the

system to test for compliance with design. At first, the body design was blocking the sound waves

thereby making the system to trigger continuously before the problem was resolved.

Figure 36: Ultrasonic sensor during testing and Ultrasonic sensor in the system

4.4.3 Photo Interrupter Testing

The photo Interrupter consists of Light Dependent Resistor (LDR) and LED packaged together to

make optical sensors that can be used to detect objects. These was put together to create a photo

interrupter used to detect whether there is tissue paper in the system or not. The tissue paper

62
goes in between the LDR and LED thereby blocking the light on the LED for the LDR not to detect

the light dissipated. This will indicate that there’s tissue paper in the system. When no tissue

paper is between the photo interrupter, light of the LED falls on the semi conductive material it

absorbs the light photons and the energy transferred to the electrons. The Threshold frequency

set for the LDR was threshold>160.

Figure 37: LDR & LED placed facing each other to form the Photo interrupter

63
4.4.4 Actuator Testing

The DC motors were connected to the microcontroller (to control the speed and time of

rotation by a 5V signal from the microcontroller). The DC motor was attached to a shaft

constructed using LEGO mindstorm component, these offers the grip to the paper roll for

rotation. This enables the system to dispense the paper roll for the user. The DC motor

implemented in this project was the RF-300FA-11420 model with speed of 2900 rev/min when

no load is attached to it at 3V.

I first connected just one DC motor to the system but the load of the paper roll and the shaft

was too much for just one DC motor. I had to connect two motor at both ends of the shaft to

produce more force required to push the paper roll hence dispensing the required length of

paper.

Figure 38: Two motors at both ends of the shaft to form the actuator

64
The final design was chosen to be used in this project because it have a simple and intuitive toilet

paper loading design with little to no touch, as well as, a sleek and aesthetically pleasing, non-

industrial design and still meet user friendly ergonomic design that one would want in a private

bathroom. Wood material was used in constructing the body of the system because it’s less

expensive and simple to construct.

Figure 39: Snapshots of the Actuating system

65
Figure 40: Snapshot of the system showing the LCD display

Figure 41: Snapshot showing the position of the LCD display and Ultrasonic sensor

66
Figure 42: Snapshots of the system after dispensing the paper roll

Figure 43: Snapshots showing the design body

67
Figure 44: Snapshot of the support base

4.5 SUMMARY

In this chapter, the various testing and implementation were discussed. All the units and sub

systems of the entire automated system were properly tested. The challenges encountered

were appropriately tackled.

68
CHAPTER 5

CONCLUSION

The system design and software implementation have proven to be effective and efficient. The

adoption of automated dispensing technology in public application is feasible, and provides a

more hygienic way of dispensing paper towel to various users, since it is a technology that

minimizes the risk of direct contact by the users. The use of the system helps to control the

amount of paper towel dispensed by each user so as to minimize cost in buying paper roll. The

implementation of automated paper dispensing operations are bound to increase in the future.

The advantages, efficiency and reliability of the system have made it manifest itself over the

manual dispensing systems.

5.1 ACHIEVEMENTS

The project successfully designed and implemented a system that can dispense metered length

of paper roll using a proximity sensor known as Ultrasonic sensor. The project objectives fully

met are:

 To build an automated paper dispenser that uses a motion sensor to prevent physical

contact of user and the machine

 To design a photo interrupter using LED and LDR to sense when the paper roll is empty or

almost empty

 To indicate the system status on the LCD display

 Using low budget cost in designing the project

69
 Providing a non-industrial design that still meet user friendly ergonomic design that one

would want in a private bathroom.

5.2 FUTURE WORK

Further improvements can be implemented on this system to enhance its features and

functionality:

1. The use of roller drive and gear train can be implemented for an improved dispensing

system.

2. A battery back-up of 12v would be a possible feature for continuous operation of the

dispensing system to avoid failure during power outages.

3. A mechanism using stepper motor can be integrated and programmed to automatically

advance and cut paper segment dispensed for the user.

4. The system is also compatible for the future upgrades like a mechanism that automatically

rolls the paper as it dispense.

5.3 LIMITATIONS

 Finding the right component required for the device production. Several alternations had

to be made to the initial design due to lack of means of acquisition of required

components.

 Cost of components for expanding the project for other purposes.

 Time constraint.

 Limited knowledge on required software expertise.

70
5.4 RECOMMENDATION

I recommend that this project should be well implemented as it will help to improve flexibility in

using a paper dispensing system. However, for this study to be relevant in the society and publicly

accepted, the following recommendations are therefore made:

 Further research should be made on this project by studying its applicability and

usefulness as it applies to other fields.

 Back-up power supply to continuously supply power to the system.

5.5 PROBLEMS ENCOUNTERED & SOLUTIONS

 During soldering, many of the connections become short circuited, so I desoldered the

connection and did soldering again.

 A leg of the crystal oscillator was broken during mounting, so it had to be replaced.

Care should be taken while soldering so that there would be no shorting of joint and proper

power supply should also be maintained.

5.6 SUMMARY

The project was a very interesting one as it expanded my knowledge based on Mechatronics

and its means of application. This project could be marketed anywhere in the world because it is

a trending technology and it’s necessity is geared towards the elimination of poor hygiene in our

society.

71
Table 5: Cost of Project Materials

ITEM NO Components Quantity Unit price(-N-) Total price(-N-)

1 PIC 18F452 Microcontroller 1 400 400

2 LCD display 1 1500 1500

3 DC motor 3 500 1500

4 Ultrasonic sensor 1 1250 1250

5 Light dependent resistor 1 200 200

6 LED 4 10 40

7 Voltage regulator (7805) 1 50 50

8 Resistors and Capacitors 1000

9 Duracell 9V battery 3 350 1050

10 Mechanical switch 1 50 50

11 Veroboard 2 400 800

12 Power pack 1200

72
13 Wooden construction 7000

TOTAL COST 16,040

73
REFERENCES

 Albert, J., Anu, S., Arun, C., Neethu, J., Nisha, V., & Yuvaraj, V. (2014). Robotic pill

dispenser. The Journal of Pharmacy and Biological Sciences, 9(4), 60-63.

 Allen, Y., Roozbeh, J., Shankar, S., & Ruzena, B. (2009). Distributed recognition of

human actions using wearable motion sensor networks. Journal of Ambient Intelligence

and Smart Environments, 54, 1–5.

 Balaram, K. (2015). Beneficial design of unbaffled shell-and-tube heat exchangers for

attachment of longitudinal fins with trapezoidal profile. Journal of Case Studies in

Thermal Engineering, 5, 104-112.

 Basturk, O., & Namazov, M. (2010). DC motor position control using fuzzy proportional-

derivative controllers with different defuzzification methods. The Journal of Turkish

Fuzzy Systems Association, 1(1), 36-54.

 Budynas, R., & Nisbett, K. (2010). Shigley's Mechanical Engineering Design. McGraw-

Hill.

 Christo, B., & Sheeba, M. (2016). A survey on automatic liquid dispensing and database

management robotic systems. Research Journal of Pharmaceutical, Biological and

Chemical Sciences, 7(1), 712-718.

 Craig, K., & Roger, J. (2005). On hardware optimization of stepper motor system

dynamics. Journal of Mechatronics, 15, 291-316.

 Delpoux, R., & Bodson, M., & Floquet, T. (2014). Parameter estimation of permanent

magnet stepper motors without mechanical sensors. Journal of Control Engineering

Practice, 26, 178-187.

74
 Elecfreaks. (n.d.). HC-SR04 User Guide. Retrieved from

http://elecfreaks.com/estore/download/EF03085-HC-SR04_Ultrasonic_Module_User_Guide.pdf.

 Elecfreaks. (n.d.). Ultrasonic Ranging Module HC-SRO4. Retrieved

from http://www.micropik.com/PDF/HCSR04.pdf.

 Elsodany, N., Rezeka, S., & Maharem, N. (2010). Adaptive PID control of a stepper motor

driving a flexible rotor. Journal of Alexandria Engineering, 50, 127-136.

 Fleming, W. (2001). Overview of automotive sensors. Journal of IEEE Sensors, 1(4), 296-

308.

 Fraden, J. (2010). Handbook of modern sensors: Physics, Designs and Applications (4th

ed.). Retrieved from http://www.plentyofebooks.net

 Hasanien, H. (2011). FPGA implementation of adaptive ANN controller for speed

regulation of permanent magnet stepper motor drives. Journal of Energy Conversion

and Management, 52, 1252-1257.

 José, C., Ernesto, V., & Jaime, G. (2010). Position and speed control of brushless DC

motors using sensorless techniques and application trends. The Journal of Sensors, 10,

6901-6947. doi:10.3390/s100706901

 Jumaa, A. (2005). Hand hygiene: simple and complex. International Journal of Infectious

Diseases, 9, 3-14. Retrieved from http://intl.elsevierhealth.com/journals/ijid.

 Kang, H., Hanxu, S., Qingxuan, J., & Yanheng, Z. (2012). An autonomous positioning and

navigation system for spherical mobile robot. Journal of Procedia Engineering, 29, 2556

– 2561.

75
 Lisjak, A., Grasselli, G. (2014). A review of discrete modeling techniques for fracturing

processes in discontinuous rock masses. Journal of Rock Mechanics and Geotechnical

Engineering, 6, 301-314.

 Martin, C., Larsen, P., & Rasmus, J. (2015). Robotic Design Choice Overview Using Co-

Simulation and Design Space Exploration. The Journal of Robotics, 4, 398-421. doi:

10.3390/robotics4040398

 Microchip Technology. (2009). PICkit 3 programmer/debugger user’s guide. Retrieved

from ww1.microchip.com/downloads/en/DeviceDoc/51795B.pdf

 Microchip Technology. (2008). PIC18F2420/2520/4420/4520 Data sheet. Retrieved from

http://www.xinpian.net/pic/PIC18/PIC18F4520.pdf

 Milan, R., Zarko, C., & Dragan, L. (2012).Intelligent control of DC motor driven

electromechanical fin actuator. Journal of Control Engineering Practice, 20, 610–617.

 Mondal, R., Arumay, M., & Basak, D. (2013). Embedded System of DC Motor Closed

Loop Speed Control based on 8051 Microcontroller. Journal of Procedia Technology, 10,

840-848.

 Morar, A. (2014). A study of development of a dedicated control IC for a five phase

stepper motor driver. Journal of Procedia Technology, 12, 83-89.

 Norfadilah, B. Z. (2012). Direction and speed control of DC motor (master’s thesis).

Retrieved from http://umpir.ump.edu.my/4873/1/cd6775_99.pdf.

 Normanyo, E., Stephen, S., & Boadi, S. (2012). Domestic power efficiency using sensors

and a programmable logic controller. The Journal of Engineering and Technology, 2(5),

775-786.

76
 Provincial Infectious Diseases Advisory Committee.(2008). Best practices for hand

hygiene in all health care settings. Retrieved from

https://www.publichealthontario.ca/en/eRepository/2010-12%20BP%20Hand%20Hygiene.pdf.

 Ravi, R., & Dipa, T., (2015). Microcontroller based automatic paint marking machine. The

Journal of Advance Research in Engineering, Science &Technology(IJAREST), 2(5), 1-3.

 Ruize, X., Shengli, Z., & Wen, J. (2012). MEMS Accelerometer Based Nonspecific-User

Hand Gesture Recognition. Journal of IEEE Sensor, 12(5), 145-197.

 Samarth, V., Marco, B., John, B., Brendan, O., Nicholas, H., & Paul, D. (2015). Low-power

wireless liquid monitoring system using ultrasonic sensors. International Journal on

Smart Sensing and Intelligent Systems, 8(1), 26-44.

 Shetty, D., & Kolk, R. A. (2011). Mechatronics System Design (SI ed.). Cengage

Learning.

 Siripala, P., & Sekercioglu, Y. (2013). A generalized solution for generating stepper motor

speed profiles in real time. Journal of Mechatronics, 23, 541-547.

 Wyrowol, B., & Hrynkiewicz, E. (2015). Implementation of the FITA fuzzy inference

system on the specific microcontroller platform. Journal of International Federation of

Automatic Control, 48(4), 165-169.

 Yaxin, L., Liguo, C., & Lining, S. (2009). Design and fabrication of MEMS flow sensor and

its application in precise liquid dispensing. The Journal of Sensor, 9, 4138-4150. doi:

10.3390/s90604138

77
 Yaziz, N. H. B. (2014). Digital Speed and Position Control System Incorporating an

Incremental Encoder (master’s thesis). Retrieved from

http://eprints.uthm.edu.my/6672/1/NOR_HIDAYAH_YAZIZ.pdf.

 Zeina, B., Samih, J., & Imad, K. (2014). Modeling and simulation of series DC motors in

electrice car. The Journal of Technologies and Materials, 50, 460-470.

 Zagade, S., & Kawitkar, R. (2012). Wireless sensor network for greenhouse. The Journal

of Science and Technology, 2(3), 130-133.

78
APPENDIX A

float read_sensor();

const float range=10.0; //edit to change the detecting range

char thres=0;

char text1[]="Automated paper" ;

char text2[]="Dispensing Sys" ;

char text3[]="Pls wait..." ;

char text4[]="Dispensing " ;

char text5[]="Take ur Tissue" ;

char text6[]="No more Tissue" ;

char texta[]="Final Yr Project" ;

char textb[]="by James.O" ;

sbit LCD_RS at RB0_bit; sbit LCD_RS_Direction at TRISB0_bit;

sbit LCD_EN at RB1_bit; sbit LCD_EN_Direction at TRISB1_bit;

sbit LCD_D4 at RB4_bit; sbit LCD_D4_Direction at TRISB4_bit;

sbit LCD_D5 at RB5_bit; sbit LCD_D5_Direction at TRISB5_bit;

sbit LCD_D6 at RB6_bit; sbit LCD_D6_Direction at TRISB6_bit;

sbit LCD_D7 at RB7_bit; sbit LCD_D7_Direction at TRISB7_bit;

sbit buzzer at RD2_bit;

sbit tear_motor at RC7_bit;

sbit tissue_roller_motor at RD5_bit;

sbit tissue_folding_motor at RD4_bit;

79
sbit echo at RD7_bit;

sbit Trigger at RD6_bit;

float distance ;

char distance_txt[5];

void main() {

PORTA=0;

PORTB=0;

PORTC=0;

PORTD=0;

TRISA=0b11111111;

TRISB=0;

TRISC=0;

TRISD=0b10000000;

ADCON1=0b00000000;

T1CON=0b00110000;//1:8

delay_ms(3000);

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear LCD display

Lcd_Cmd(_LCD_CURSOR_OFF);

buzzer=1;

delay_ms(1000);

buzzer=0;

lcd_out(1,1,text1);

lcd_out(2,1,text2);

delay_ms(3000);

Lcd_Cmd(_LCD_CLEAR);

80
while(1){ //main loop

lcd_out(1,1,texta);

lcd_out(2,1,textb);

distance=read_sensor();

delay_ms(500);

if(distance>=2 && distance<=400){

if(distance <=range){

// Lcd_Cmd(_LCD_CLEAR);

// do{

thres=adc_read(1)>>2;

////inttostr(thres,distance_txt); distance_txt[4]=0;

//lcd_out(1,1,distance_txt);

//delay_ms(1000);

//}while(1);

if(thres<160){

buzzer=1;

delay_ms(1000);

buzzer=0;

Lcd_Cmd(_LCD_CLEAR);

lcd_out(1,1,text3);

lcd_out(2,1,text4);

tissue_roller_motor=1;

delay_ms(2000);

tissue_folding_motor=1;

delay_ms(3000);

81
tissue_roller_motor=0;

delay_ms(2000);

tissue_folding_motor=0;

delay_ms(1000);

tear_motor =1;

delay_ms(2000);

tear_motor =0;

Lcd_Cmd(_LCD_CLEAR);

lcd_out(1,1,text5);

delay_ms(3000);

Lcd_Cmd(_LCD_CLEAR);

else {

Lcd_Cmd(_LCD_CLEAR);

buzzer=1;

lcd_out(1,1,text6);

delay_ms(5000);

buzzer=0;

else{ distance=0;

} //main loop

82
float read_sensor(){

float sensor_value;

int m;

float asn;

TMR1ON_bit=0;

TMR1H=0;

TMR1L=0;

Trigger=0;

delay_us(2);

Trigger=1;

delay_us(10);

Trigger=0;

m=0xffff;

while(!echo&& m--);

m=0xffff;

TMR1ON_bit=1;

while(echo && m--);

TMR1ON_bit=0;

asn=(TMR1L|(TMR1H<<8 ));

sensor_value=(0.175*asn/0.625);

sensor_value=sensor_value/10;

return sensor_value;

83
APPENDIX B

84
APPENDIX C
PIC 18F452 40-44 PIN BLOCK DIAGRAM. SOURCE FROM MICROCHIP PIC 18F SERIES DATA
SHEET.

85

You might also like