AUTO WATERING CONTROL WEE SHAO JIONG

AUTO WATERING CONTROL 2008/2009 II WEE SHAO JIONG √ 10 TMN Intan KG Koh PROF DR SHAMSUDIN BIN HJ MOHD AMIN 32000 Sitiawan, Perak 15 MAY 2009 15 ...
Author: Anne Powell
6 downloads 0 Views 1MB Size
AUTO WATERING CONTROL

2008/2009 II WEE SHAO JIONG



10 TMN Intan KG Koh

PROF DR SHAMSUDIN BIN HJ MOHD AMIN

32000 Sitiawan, Perak 15 MAY 2009

15 MAY 2009

“I hereby declare that I have read this thesis and in my opinion this thesis is sufficient in term of scope and quality for the award of the Bachelor’s degree of Electrical Engineering (Mechatronics)”

Signature

: …………………………………………

Name of Supervisor

PROF DR SHAMSUDIN HJ MOHD AMIN : …………………………………………

Date

: …………………………………………

15 MAY 2009

i

AUTO WATERING CONTROL SYSTEM

WEE SHAO JIONG

A thesis submitted in fulfillment of the requirements for the award of the degree of Bachelor in Electrical Engineering- Mechatronics

Faculty of Electrical Engineering Universiti Teknologi Malaysia

MAY 2009

ii

I declare that this thesis entitled “Auto Watering Control System” is the result of my own work except as cited in the references. The thesis has not been accepted for any degree and is not concurrently submitted in candidature of any other degree.

Signature

: …………………………………….

Name

SHAO JIONG : WEE …………………………………….

Date

MAY 2009 : 15 …………………………………….

iii

To my beloved mother and father

iv

ACKNOWLEDGEMENT

First of all I would like to thank my supervisor Prof. Dr. SHAMSUDIN BIN HJ MOHD AMIN for his caring and guidance throughout this two semesters’ final year project.

I would like to thank my PA and all the lecturers who had taught me starting from the first year until now.

I would like to thank all the UTM staff in CICT, robotic lab, FKE office, library, hostel office, canteens and many so on.

And also all my course mate, room mate, and friend, thank you.

v

ABSTRACT

The implementation and designing of a system so call ‘Auto-watering System’ which consists of electronics pumps, real time clock chip, and a wireless communication system using a pair of transmitter and receiver used to equip the watering process in small scale.

All of these components are well controlled by

microcontroller (PIC16F876A).

By using the microcontroller, it serves as a

long-term, rigid, and convenient way to water different types of plants.

Though

observing the time needed for watering wide variety of the plants, this control system can be modified to suit the different needs of watering accordingly. And the time to activate the pumps is calculated depending on the amount of the water needed in volume.

The outcome of this project is a system that will continuously water the

plants in small scale at certain time interval without involved much man working. Also this system will inform the user to refill the fertilizer by the mean of wireless application.

This project can be seen as a solution for watering activities in a

time-saving, safety, and pleasure way.

vi

ABSTRAK

Pelaksanaan dan rekabentuk sesuatu sistem yang bernama “Sistem Penyiraman Automatik” yang dibina daripada komponen-kompenen elektronik seperti pump elektronik, chip ‘real time clock’, dan sistem komuinkasi yang terdiri pelancar dan penerima untuk meyempurnakan proses penyiraman dalam julat yang kecil.

Semua ini dikawal oleh mikropengawal (PIC 16F876A).

Dengan

penggunaan mikropengawal ini, ia berfungsi sebagai suatu penyelesaian yang mantap, berjanka panjang, dan selesa untuk menyiram pelbagai jenis tumbuhan. Masa yang diperlukan untuk meyiram pelbagai jenis tumbuhan dikaji secara terliti, dan sistem ini boleh diubahsuai untuk memenuhi keperluan-keperluan penyiraman tertentu. Juga, masa untuk mengaktifkan pump-pump dikira berdasarkan kuantiti air yang diperlukan dalam isipadu.

Hasil daripada projek ini ialah suatu sistem yang

berkebolehan menyiram pokok bunga secara berterusan dalam skala yang kecil pada jangka masa tertentu tanpa melibatkan banyak tenaga kerja.

Sistem ini juga akan

memeritahu pengguna supaya mengisi baja cecair melalui teknologi ‘wireless’. Projek ini boleh dilihan sebagai cara untuk menjadikan aktiviti penyiraman penuh dengan keriangan, jimat masa, dan selamat diguna.

vii

TABLE OF CONTENT

CHAPTER

1

2

TITLE

PAGE

DECLARATION OF THESIS

ii

DEDICATION

iii

ACKNOWLEDGEMENT

iv

ABSTRACT

v

ABSTRAK

vi

TABLE OF CONTENTS

vii

LIST OF FIGURES

ix

LIST OF APPENDICES

xi

INTRODUCTION 1.1 Project Objective

1

1.2 Project Scope

2

1.3 Project Summary

2

1.4 Layout of the thesis

3

LITERATURE REVIEW AND DOCUMENTATION 2.1 Introduction

5

2.2 Real Time Clock DS 1307

7

2.2.1

Operation Concept of DS 1307

7

2.3 Electronic Pump

12

2.4 Interlock system

12

2.5 RF Transmitter

13

viii 2.6 RF Receiver

3

METHODOLOGY 3.1 Hardware Design Real Time Clock System

19

3.1.2

Pump Water

20

3.1.3

Pump Fertilizer

21

3.1.4

Interlock System

22

3.1.5

Wireless Alarm System

23

3.1.6

The Hose

23

3.1.7

Water Level Control Mechanizes

24 25

3.2.1

Initialize the Signal

27

3.2.2

Buzzer Activation

29

3.2.3

Energy Saving Design

29

3.3 Summary of Chapter 3

5

19

3.1.1

3.2 Software Design- Water Timing Design

4

15

31

TESTING AND RESULT 4.1 Pump Performance

33

4.2 Testing on Wireless Alarm System

36

CONCLUSION AND FUTURE ACTIONS 5.1 Conclusion

37

5.2 Recommendations

38

REFEREENCES

39

APPENDICES

40

ix

LIST OF FIGURES

FIGURE

TITLE

PAGE

1.1

The overall view of the project

2

1.2

The layout

4

2.1

Gravity driven watering system

5

2.2

Communication diagram of SCADA system

6

2.3

DS 1307 8-pin

7

2.4

DS 1307 block diagram

8

2.5

2-wire bus configurations

10

2.6

Data transfer on 2-wire serial bus

10

2.7

RF transmitter

13

2.8

Transmit status and control register

14

2.9

USART transmit block diagram

14

2.10

RF receiver

15

2.11

Receive status and control register

16

2.12

USART receive block diagram

17

3.1

Application of air pressure

20

3.2

Pump for the fertilizer in liquid form

21

3.3

The overall picture of the system

22

3.4

Limit switch

22

3.5

Receiver and alarm buzzer

23

3.6

Hose divider and the flower plant

24

3.7

Floater

24

x 3.8

Watering timing control program

25

3.9

Block diagram for the timing control

26

3.10

Signal initialization

27

3.11

The overall design of programming path

27

3.12

Push button design

28

3.13

Buzzer’s sound design

29

3.14

Toggle the bit wise of PORTB control register

29

3.15

Circuit layout

30

4.1

The best hose orientation

33

xi

LIST OF APPENDICES

APPENDIX A

TITLE Source Code in C Language

PAGE 40

Source Code for Main Control

B

Source Code for RF Transmitter

66

Source Code for RF Receiver

69

Circuit Schematics

72

CHAPTER 1

INTRODUCTION

The origin of this project idea was inspired by the irrigation system in the farm, where this activity is automatically done. And aware that we have to make our global greener and surrounded by fresh air, the direct implication to achieve this is by planting the plants.

By considering this factor, thus this project was conducted to contribute as a little convenient solution in a small scale of house-hold gardening, to fulfill the responsibility to applicant technology for the welfare of the public.

1.1

Project objective

i.

To built an auto-watering control system which is labor less and time saving.

ii.

Optimization the usage of the water resource.

2

1.2

Project Scope

This system use limit switch and RF transmitter as a device to send the signal to the RF receiver which has equipped with the buzzer to function as an alarm system, the electronic pumps are act as a device to drive the water from the tank for watering process. The microcontroller PIC 16F876A was used as an embedded device to centralize all the controlled process. The software MPLAB IDE was used to compile the source code in C language which can be written in text pad and is burn into the PIC for the controlling process. To do this a programmer ‘UIC00A’ needed to load the program into the PIC using USB connector. The PIC can be reprogrammed again and again according to some specifications of the task.

1.3

Project Summary

Water pump to high position

Auto Water in

watering System

Water out Water pump to low position Wireless signal for user awareness

Figure 1.1

The overall view of the project

3

In this system the water source required to continuously supply to the tank, and the water level in the tank is always full. The source can be the water that collected from the rain water and also can be taken from the tab (household water supply). The water in this system is used to water the plants under the control by the microcontroller which is well programmed to do the watering task, the water is well managed to be pumped to difference destinations (position).

This is the

advantage of the application of electronic pumps where the gravity force can be ignored, no matter how high the position it is, the water still can pump up.

After some time passed, the liquid form of fertilizer will used out, at this moment a signal will be send to the user through wireless to inform the user to refill the fertilizer. This is the part that cannot be fully automated, because the fertilizer has to change time by time.

1.4

Layout of the Thesis

The following figure showed the layout of this project system:

4

Lid

Limit switch

Antenna

Fertilizer container

Control box Span

Fertilizer Pump Inlet

Tank

Hose divider

Floater Water Pump

Figure 1.2

Outlet

The layout



Inlet: To let the water go into the tank.



Water pump: Pump out the water.



Fertilizer pump: Pump out the fertilizer.



Floater: Maintain the water level in tank.



Hose divider: Need to divide the hose into difference direction.



Tank: The huge container contains the water.



Control box: the main controller control all the process.



Fertilizer container: contain the liquid fertilizer.



Antenna: Need to transmit signal to the receiver through wireless.



Lid, Span, Limit Switch: act as interlock system to activate transmitter.



Outlet: the opening to let the water out.

5

CHAPTER 2

LITERATURE REVIEW AND DOCUMENTATION

2.1

Introduction

There are many alternative ways to build this system for the purpose of irrigation and watering. One of these is by using gravity force to drive the water as shown in figure below:

Figure 2.1

Gravity driven watering system

6

This method is very convenient, which involved no electronic components. It can drive the water out, but in near surrounding area only. It is unpractical to be used in a large scale context.

Another way for implemented these is by using very advance technology call supervisory control and data acquisition (SCADA) system given the micro irrigation system characteristics. It is a centralized system, with all the decisions concentrated in one central computer. The SCADA system required a computer unit, a programmable logic controller (PLC) connected to different equipment, and a communication system between the computer and PLC.

This system can be

implemented in a large scale context, but very costly.

Figure 2.2

Communication diagram of the SCADA system

By considering all the factors mention above, in order to make a system similar to these function but in small scale, this is possible and attainable by study in detail the following components.

7

2.2

Real Time Clock DS 1307

The DS1307 Serial Real Time Clock is a low power, full BCD clock/calendar plus 56 bytes of nonvolatile SRAM. The address and data are transferred serially via a 2-wire bi-directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information.

At the end of the month, the date is automatically adjusted for months with less than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The DS1307 has a built-in power sense circuit which detects power failures and automatically switches to the battery supply.

2.2.1 Operation Concept of DS 1307

Figure 2.3

DS 1307 8-Pin

Inside the DS 1307, there have an internal oscillator (or external X1 & X2) to synchronize the data movement on serial interface. It will drive a square wave

8

(SQW/OUT) with certain frequency. A logic control will interface with the memory storage and address register to generate timing information data.

Figure 2.4

DS1307 block diagram

When VCC (+5v for fully data access) falls below 1.25 x VBAT (battery input voltage), the device terminates an access in progress and resets the device address

9

counter. Inputs to the device will not be recognized at this time to prevent erroneous data from being written to the device.

When VCC falls below VBAT the device switches into a low current battery backup mode. Upon power up, the device switches from battery to VCC when VCC is greater than VBAT +0.2V and it start recognizes inputs when VCC is greater than 1.25 x VBAT.

The time and calendar information is obtained by reading the appropriate register bytes. The real time clock registers are illustrated in Figure 2.4. The time and calendar are set or initialized by writing the appropriate register bytes. The contents of the time and calendar registers are in the Binary-Coded Decimal (BCD) format. Bit 7 of Register 0 is the Clock Halt (CH) bit. When this bit is set to a 1, the oscillator is disabled. When cleared to a 0, the oscillator is enabled.

The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined as the 12-hour or 24-hour mode select bit. When high, the 12-hour mode is selected. In the 12-hour mode, bit 5 is the AM/PM bit with logic high being PM. While in the 24-hour mode, bit 5 is the second 10 hour bit (20-23 hours).

Data transfer may be initiated only when the bus is not busy. During data transfer, the data line must remain stable whenever the clock line is HIGH. The DS1307 supports a bi-directional 2-wire bus and data transmission protocol. A device that sends data onto the bus is defined as a transmitter and a device receiving

10

data as a receiver. The device that controls the message is called a master. The devices that are controlled by the master are referred to as slaves. The bus must be controlled by a master device which generates the serial clock (SCL), controls the bus access, and generates the START and STOP conditions. The DS1307 operates as a slave on the 2-wire bus as shown in below:

Figure 2.5

Figure 2.6

2-wire bus configurations

Data transfer on 2-wire serial bus

11



When Bus not busy: Both data and clock lines remain HIGH.



When Start data transfer: A change in the state of the data line, from HIGH to LOW, while the clock is HIGH, defines a START condition.



When Stop data transfer: A change in the state of the data line, from LOW to HIGH, while the clock line is HIGH, defines the STOP condition.



When Data valid: The state of the data line represents valid data when, after a START condition, the data line is stable for the duration of the HIGH period of the clock signal. The data on the line will changed during the LOW period of the clock signal. There is one clock pulse per bit of data. Each data transfer is initiated with a START condition and terminated with a STOP condition.

The information is transferred byte-wise and each receiver

acknowledges with a ninth bit. 

When Acknowledge: Each receiving device, when addressed, is obliged to generate an Acknowledge after the reception of each byte. The master device must generate an extra clock pulse which is associated with this acknowledge bit. A device that acknowledges must pull down the SDA line during the acknowledge clock pulse in such a way that the SDA line is stable LOW during the HIGH period of the Acknowledge related clock pulse. Of course, setup and hold times must be taken into account. A master must signal an end of data to the slave by not generating an acknowledge bit on the last byte that has been clocked out of the slave. In this case, the slave must leave the data line HIGH to enable the master to generate the STOP condition.

12

2.3

Electronic Pump

There are many pump can be used, some of these is valve-opened, some of these can operated in the water, and some of these need high power supply. Typically, the pump is a kind of one directional motor which operated in certain conditions. The power of the pump depend on it mechanical structure’s size and type of energy supply needed. For the valve-opened pump the valve is always open, when the pump is inactive, the water will continuous flow though the pump with relative to the gravity force and the air pressure level.

2.4

Interlock System

Interlocks provide means of preventing the system from continuing unless a certain or set of conditions are satisfied. Interlocks are essential for the coordination and synchronization of activities which could not be accomplished through timing alone. There are two type of interlocks, the first on is call Input interlocks, it make use of signals sent from the components device to the controller to indicate that certain conditions have been met and that the programmed work sequence can continue. The second one call output interlocks it makes use of signals sent from the controller to other devices or machines in a system.

Interlocks would be used to ensure that a raw materials was in the sufficient level before the system going on, and to indicate that the materials has been

13

successfully loaded so that the cycle of that system can be proceeded. It will be good if the interlock system use wireless application.

2.5

RF Transmitter

These RF Transmitter Modules are very small in dimension and have a wide operating voltage range (3V-12V). The RF Transmitter can be used to transmit signal up to 100 meters, but the distance travel will be affected by the determinant like antenna design, working environment and supply voltage.

Figure 2.7

RF transmitter

This device interacts with microcontroller via The Universal Synchronous Asynchronous Receiver Transmitter (USART). The control resister in PIC 16F876A that associated to control the byte signal sending is call TXSTA register which consists of the following bit definition:

14

Figure 2.8

Figure 2.9

Transmit status and control register

USART transmit block diagram

The USART transmitter block diagram is shown in Figure 2.9. The heart of the transmitter is the Transmit (Serial) Shift Register (TSR). The shift register

15

obtains its data from the Read/Write Transmit Buffer, TXREG.

The TXREG

register is loaded with data in software. The TSR register is not loaded until the Stop bit has been transmitted from the previous load. As soon as the Stop bit is transmitted, the TSR is loaded with new data from the TXREG register (if available). Once the TXREG register transfers the data to the TSR register (occurs in one TCY), the TXREG register is empty and flag bit, TXIF (PIR1), is set. This interrupt can be enabled/disabled by setting/clearing enable bit, TXIE (PIE1). Flag bit TXIF will be set regardless of the state of enable bit TXIE and cannot be cleared in software. It will reset only when new data is loaded into the TXREG register.

Another bit, TRMT (TXSTA), shows the status of the TSR register. Status bit TRMT is a read-only bit which is set when the TSR register is empty. No interrupt logic is tied to this bit so the user has to poll this bit in order to determine if the TSR register is empty.

2.6

RF Receiver

Figure 2.10

RF receiver

16

These RF receiver modules can be used to receive RF signal from transmitter at the specific frequency which determined by the specifications types of RF Receiver Modules.

When this module is used with microcontroller, the clock frequency

should be under 4MHz, and an antenna is needed.

The control register for receiver (RCSTA) of PIC 16F876A that deal with this is listed as followed:

Figure 2.11

Receive status and control register

17

Figure 2.12

USART receive block diagram

The data is received on the RC7/RX/DT pin and drives the data recovery block. The data recovery block is actually a high-speed shifter, operating at x16 times the baud rate; whereas the main receive serial shifter operates at the bit rate or at FOSC.

Once Asynchronous mode is selected, reception is enabled by setting bit CREN (RCSTA). The heart of the receiver is the Receive (Serial) Shift Register (RSR). After sampling the Stop bit, the received data in the RSR is transferred to the RCREG register (if it is empty). If the transfer is complete, flag it, RCIF (PIR1), is set. The actual interrupt can be enabled/disabled by setting/clearing enable bit, RCIE (PIE1). Flag bit RCIF is a read-only bit which is cleared by the hardware. It is cleared when the RCREG register has been read and is empty. The RCREG is a double-buffered register. On the detection of the Stop bit of the third byte, if the RCREG register is still full, the Overrun Error bit, OERR (RCSTA), will be set, then the word in the RSR will be lost. The RCREG register can be read twice to

18

retrieve the two bytes in the FIFO. Overrun bit OERR has to be cleared in software. This is done by resetting the receive logic (CREN is cleared and then set). If bit OERR is set, transfers from the RSR register to the RCREG register are inhibited and no further data will be received. It is, therefore, essential to clear error bit OERR if it is set.

19

CHAPTER 3

METHODOLOGY

3.1

Hardware Design

3.1.1 Real Time Clock System

In order to build a time decoding system which is compact and act as an independence devices with little power consumption, the chip DS 1307 was used, a lithium battery with 48mA or greater will back up the DS1307 for more than 10 years. To ease the interface this chip with the user, an LCD screen was used in this project. The DS 1307 will act as a time reference to monitor the whole system’s process.

Push button are also added to let the user set the time, the programmed microcontroller can shift the mode of DS 1307 in write and read mode by using the push button which will call out a subroutine in the program.

20

3.1.2 Pump Water

Because of the washer pump that used was valve-opened, it is a part of car’s component which is used to inject the water to wash the windshield in front and at the back side of the car. Thus the following mechanism was made:

Hose 1 Three-hose divider

Main channel

Washer pump

Figure 3.1

Application of air pressure

Due to the pump that is always open, after the pump finish activated, the water still continuous flow if the end of the hose was put lower that the water level in the tank. To solve this problem three-hose divider equipment was put in the orientation as shown in Figure 3.1. The end of the hose 1 will be tied with air inside, so that after the pump deactivated, the water that push up into this hose by the pump will push back to main channel thus the air will fill the main channel and air burbles that created will thoroughly stop the flow for continuous.

21

In this context, the water can be pumped either higher or of course lower than the water tank level. This enables the water pump to the higher destinations (location).

3.1.3 Pump Fertilizer

Extra hose

Fertilizer flow direction

Figure 3.2

Pump for the fertilizer in liquid form

Figure 3.2 shown another pump needed to mix the liquid fertilizer with the water in the tank according to certain ratio. It also needed an extra hose to push the air into the main channel in order to stop the flow.

22

3.1.4 Interlock System

Main controller Interlock design

Figure 3.3

The overall picture of the system

Thee interlock system used to awake the user to refill the insufficient liquid fertilizer, it consist of a span, and a rod that support the lid. The span will float according to the fertilizer liquid level. This method is direct and straight forward to meet the purpose. When the lid presses presses the limit switch, an alarm system will activated.

Figure 3.4

Limit switch

23

3.1.5 Wireless Alarm System

When the switch is pressed, a signal in bit wise will send serially though the RF Transmitter to be received by the RF Receiver; both have the same baud rate. The receiver are equip with the buzzer to sound when it is necessary to inform the user to refill the fertilizer. It can detect the signal 30m away from the water tank (without the iron barrier).

Thus it can be put in an obvious or your always

occurrence place.

Buzzer

Figure 3.5

Receiver and alarm buzzer

3.1.6 The Hoses

The end of the hose can be further divided by using hose divider, but there are some constrains. Special caution should be take which is: 

One pump only can apply to one air pressure level.

24



Numerous pumps can be implied, provided the I/O pin of the PIC are enough.

Hose divider

Figure 3.6

Hose divider and the flower plant

3.1.7 Water Level Control Mechanizes.

The water can be continuously supply to the water tank with same mechanism as the water tank upside the ceiling. The pipe can be connected to the tab or can be connected to the big rain water collection outside the house. The water level inside the tank will always full-filled.

Figure 3.7

Floater

25

3.2

Software Design- Watering Timing Design

Figure 3.8

watering timing control program

The outer IF is use for select the time interval for watering the plant, it can be choose every hour or minutes, the above shown the example that recycle the watering process every 5 minutes interval. The value of ‘minutesl’, ‘secondh’ are the value in decimal that are already assigned in it and will continuous to upgrade following the DS 1307 clock system.

The inner IF is for two different activation time for each pump. Assigning value 1 for TTL output pin of PIC 16F mean assign 5V to the output pin which is represents by the identified ‘pump1’.

This will active the delay and directly

generates 12V that needed to power up the pump.

26

The ‘status’ identifier server as a key to close and re-open the outer IF, the overall outcome is the pump water will active first for one minutes, and the fertilizer will follow the step for 30 seconds. And this will happen in every 5 minutes, the cycle will repeat again and again. By changing the variable assign to the conditional expression in the IF instruction, every combination of watering time can be achieved.

No If lower digit minutes = 5 or 0 and status = 0

Yes

If upper digit of second = 0

No

Yes Pump2 activate for 1 minute while pump1

If lower digit minutes = 1

Turn status key to 1

No

Yes Pump1 activate for 30 seconds while pump2 deactivate

Pump2 and pump1 deactivate and status key turn 0

Yes If lower minutes = 7 or = 3

No

Figure 3.9

Block diagram for the timing control

27

3.2.1 Initialize the Signal

Figure 3.10

Signal initialization

If LW == 0 No

Is increase button press

Yes Send the parameter value

Yes

Increase the num No

and send the num

Is decrease button press Yes

No

Decrease the num and send the num

Send the num

Figure 3.11

The overall design of programming path

28

The ‘num’ are not been equalized to any number in the first IF instruction, because, after the switch open (LW==1), the PIC will send it previous num value but not number 7, the first IF instruction will be escaped and the program executed the rest program as usual (using WHILE instruction that always looping by assign true value in conditional expression).

The number 7 are chooses as a default

number, in fact any number can be choose. ‘uart_send’ is a subroutine that sends the signal to the RF receiver.

All the above mention push buttons are active low, where when it is no press, the VCC will supply the 5V into the input pin. But when the button was press, the current will short circuit letting the input pin to receive zero which mean low in TTL system of PIC. The design was shown in Figure 3.12.

Figure 3.12

Push button designs

29

3.2.2 Buzzer Activation

If the IF condition are satisfied, the buzzer will sound by assign 1 to it. To avoid noise, the buzzer = 1 instruction are squeeze in the middle to make a short, sharp and nice to listen’s sound.

Figure 3.13

Buzzer’s sound designs

3.2.3 Energy Saving Design

We can toggle the TRISB bits by assign EX-OR operator with an operand of 1. Then the 7 segment will ON and OFF when the push switch is pressed like below:

Figure 3.14

Toggle the bit wise of PORTB control register

30

Another way to save the energy is by cutting off the VCC of the LCD display by using slide switch. The power supply to both of the circuit consists of DS 1307 and RF transmitter and RF receiver need (9-12) V. Hence the voltage adapter was used. The power supply for circuit of DS 1307 and RF transmitter can be combined by connecting both of their ground and positive terminal together.

Cut off the Vcc supply

Figure 3.15

Circuit layout

31

3.3

Summary of Chapter 3

The controller box is the crucial part in this system, it is responsible to synchronizes the whole process as to water the plant in according to particular time of interval and to inform the user the system fault that was occur after some time of implementation of the system. It is interacted with some subsystem like the interlock system, wireless communication system and floating system. The LCD screen and the 7 segment decoder used will in OFF mode after the initialization of the system is done to save the electricity. During start and setting, the system used these devices (LCD screen and 7 segments) to serve as a platform for user interface.

Due to the washer pumps are valve-opened, thus the hose orientation are built to have a desire gravity force mechanism to push back the water. The interlock system which consists of buzzer and RF transmitter and receiver serve as indicator to awake the user about the system fault like lack of fertilizer or the system is malfunction.

The program for controlling the process can be changed according the difference specifications measure in the time interval, the amount of the activation time (for pump), the time for activate the alarm system and so on. The design of this system is flexible and the PIC microcontroller can be reprogrammed many times (unlimited).

There are some constrains in using this system because the output port that can be provided by the PIC microcontroller are limited due to small data storage of

32

the PIC microcontroller. The program are thus designed is suite particular needs, there are many ways of program which can be write to suite to difference conditions, and it is depend on the programmer’s creativity thinking.

Before the success of build out this system, the process of trouble-shooting should go through; it may involve testing the circuit connection, testing the signal drive out from the output port, checking the validity of the wireless communications and so on. The following chapter showed the details.

33

CHAPTER 4

TESTING AND RESULT

4.1

Pump Performance

The determinant factors for the water to pump to the destination (flower pots) are many, which consists position levels of the pots, the hose dimension, the distance of the pots from the water tanks, the motor turbine speed and so on.

The hose with air tie inside 3

The end of this hose is tied Starting point of hose 3

1

2

Water that goes to the

Water pump out

pot either can be in high

from pump

and low position

Figure 4.1

The best hose orientation

34

If the hose 2 is put higher than the starting point of hose 3, all the water will insert into the hose 3 due to it low gravity force if compare to the hose 2. Because the hose 3 are tied at it end point, thus after water fill full of this hose 3, all the excessive water will be flow into the hose 2, because the pump use the turbine to pump the water, the result is the water still can go up. After finish activate the pump, due to the gravity different, the water that pump inside the hose 3 will push back to the hose 1 and 2. Press the air burble into the hose 1 and 2, thus stopping the water from continuous to flow.

The output pin that assigns a value 1 in programming (which equal generate 5V from output pin) can be test by using the Multi-meter. Before implementing this 5V to activate the pump, trouble shooting is needed to make sure the signal ‘high’ (5V) are stable, than a delay is need to protect the PIC from high current. In order to activate the pump (which is operated in different circuit) by using an output pin from PIC, a complete circle loop must be built by connecting the ground of both PIC circuit and the pump circuit together.

In this testing, an activation time of 1 minute for the pump is assigned, and then the amount of the water that can pump out in 1 minute at certain position (in this testing the pot is place 170cm height) is observed. The roughly result is for 1 minute, the pump can pump 500ml of water in the height of 170cm. deactivated, the water flow will stopped.

After

35

Basically the watering time’s frequency needed for different kind of plants is difference. In this system the only considerations that can be solved is shown in table below:

Table 4.1 Considerations

The consideration elements The solutions

Frequency of watering time

Can be solve by programming

Height of the pot

No limitation but the time for activate the pump need longer

Water the numerous pots in same Can be achieve by using only hose position level

divider

The frequency of putting fertilizer

Can be solve by using second pump but in difference activation time

The ratio in between water and the The time of activation the water pump fertilizer

and the fertilizer pump are inverse proportional to their mixture ratio

The distance of the pots from the water Calculate the amount of the water that tank

have

to

compensated

during

the

travelling distance in the hose

After setting the time clock, and the RF transmitter and RF receiver, the LCD display and the 7 segment decoder are turn off in the condition that the PIC microcontroller still in working.

The result is, the system quite robust, and stable in performance in term of it sustainability of pumping out the water that meet the expected outcome continuously.

36

4.2

Testing on Wireless Alarm System

It is observed that the RF receiver perform effectively only in the condition that there are no barriers in between the transmitter and the receiver. The receiver quite sensitive, when the transmitter is OFF it will sound ‘pit…pit…pit….’ Thus inform the user to check the system’s fault; beside indicate that there is insufficient of liquid fertilizer

To have a best result it is observed that the receiver should put in high position relative to the transmitter, where the barriers are less in the upper half space of a house.

37

CHAPTER 5

CONCLUSION AND FUTURE ACTIONS

5.1

Conclusion

An automatic irrigation system which involved the concept of intelligent system was successfully been conducted, this project will allow efficient control of water flows to various zones and also included the liquid fertilizers; Beside that, the rain water will be reused or go through a cycle under this project thus the water resource will be saved. This project also enable the water to flow in the expected quantity and at the right time to achieve high efficiency in watering activities, these devices have involved microcontroller as an embedded systems that allow accurate control of water and energy. It is hope that this project will promote the household to aggressively be a green hand for the planet welfare.

38

5.2

Recommendations

Its hope that at the future, the following action can be realized to improve the wellness of this project’s system design:



An irrigation system that is adaptable to the parameters change and fully automatic under control by a centre computer or GUI system, and can be implemented into a large scale in the plantation sector of our country.



An error detection system which are going to detect the lower liquid level in the container and send the signal to owner by wireless in 3G or via SMS, which are very efficient.



Further to take the humidity of soil and the different watering styles of the plants into the consideration.

39

REFERENCES

1. John Marton. The PIC Microcontroller introductory. Third edition. Great Britain: Elsevier. 2005. 2. Ajay V. Deshmukh. Microcontrollers Theory and Applications. First edition. New Delhi: McGraw Hill. 2005. 3. Martin Bates. Interfacing PIC Microcontrollers Embedded Design by Interactive Simulation. First edition. Great Britain: Elsevier. 2006. 4. http://www.microchip.com. (April 2009). 5. http://www.cytron.com. (2009). 6. http://www.farnell.com.my. (December 2008). 7. Tharek Abd Rahman (2009). Wireless Communication Technologies. Wireless Communication Centre (WCC), FKE, UTM. Report. 8. Shamsudin H. M. Amin., Rosbi Mamat., and Mohamad Fauzi Zakaria. (). User Interface Design for Internet-based Telerobotics System. Centre for Artificial Intelligence and robotics (CAIRO), FKE, UTM. Report. 9. Microchip Technology Inc (2007). PIC16F876/877A. .Data Sheet. 10. Ober Choo. PIC Microcontroller for Robotic & Mechatronic Seminar. Function and Abilities of PIC. 22 February 2009. Kuliah P19: Cytron Technologies Ltd. 2-82.

40

APPENDIX A

Sources Code in C Language Source Code for Main Control //========================================================================================== //

Project description : Display time, day, date, month and year by using

//

DS 1307 real time clock chip and LCD display.The

//

time and calender can be changeed by pressing push

//

button.

//=========================================================================================

//

include

//========================================================================================== #include

//

configuration

//========================================================================================== __CONFIG ( 0x3F32 );

//

define

//========================================================================================== #define

sw0

RC0

#define

sw1

RC1

#define

sw2

RC2

#define

rs

RA0

#define

e

RA1

#define

led_yellow

RA2

#define

led_white

RA3

#define

lcd_data

PORTB

#define

sdata

RC4

#define

tclk

RC3

#define

pump1

RA5

#define

pump2

RC7

41

//

global variable

//========================================================================================== unsigned char step=0; unsigned char store=0; unsigned char clksec=0; unsigned char clkmin=0; unsigned char clkhrs=0; unsigned char day=0; unsigned char date=0; unsigned char month=0; unsigned char year=0; unsigned char status=0;

unsigned char secondh=0; unsigned char secondl=0; unsigned char minutesh=0; unsigned char minutesl=0; unsigned char hourh=0; unsigned char hourl=0; unsigned char dateh=0; unsigned char datel=0; unsigned char monthh=0; unsigned char monthl=0; unsigned char yearh=0; unsigned char yearl=0; unsigned char PM_AM=0;

//

function prototype

//========================================================================================== void delay(unsigned long data); void send_config(unsigned char data); void send_char(unsigned char data); void e_pulse(void); void lcd_goto(unsigned char data); void lcd_clr(void); void send_string(const char *s); void rtcclkout(unsigned char data);

42 void waitackrtc(void); void setstop(void); void setstart(void); void sendackread(void); void sendnotackread(void); void rtcclkread(void); void writertc(void); void readrtc(void);

//

interrupt prototype

//========================================================================================== //static void interrupt isr (void) {}

//

//no interrupt

main function

//========================================================================================== void main(void) { unsigned char i;

ADCON1 = 0b00000110;

//set all portA as digital I/O

TRISA = 0b00000000;

//set all PORTA pin as OUTPUT

TRISB = 0b00000000;

//set all PORTB pin as output

TRISC = 0b00000111;

//set all PORTC pin as output

led_white=0;

//led white off

led_yellow=0;

//led yellow off

send_config(0b00000001);

//clear display at lcd

send_config(0b00000010);

//Lcd Return to home

send_config(0b00000110);

//entry mode-cursor increase 1

send_config(0b00001100);

//diplay on, cursor off and cursor blink off

send_config(0b00111000);

//function

readrtc(); }

43 //

Write to RTC function

//========================================================================================== void writertc(void) { led_yellow=0;

//led yellow off

led_white=1;

//led white on

while(sw0==0)continue;

//waiting sw0 to depress

TRISC3=0;

//set SCL as output

TRISC4=0;

//set SDA as output

tclk=1;

//set tclk pin

sdata=1;

//set sdata pin

setstop(); //=======================sethour============================================================ while(sw0==1) //infinity loop if switch0 is not pressed { if(sw1==1)

//if switch 1 is not pressed

{ lcd_goto(1);

//maintain current hour value on LCD and //make it blinking

send_char(0x30+hourl); lcd_goto(0); send_char(0x30+hourh); delay(10000); lcd_goto(1); send_char(' '); lcd_goto(0); send_char(' '); delay(10000); } if(sw1==0)

//if switch 1 is pressed

{ while(sw1==0)continue;

//wait switch1 to depress

if((((hourh>1;

//shift right orf by 1 bit

}

} //

LCD

functions

//========================================================================== void delay(unsigned long data) { for( ;data>0;data-=1); } void send_config(unsigned char data) { rs=0;

//clear rs into config mode

lcd_data=data; delay(300); e_pulse(); }

void send_char(unsigned char data) { rs=1; lcd_data=data; delay(300); e_pulse(); }

//set rs into write mode

66

void e_pulse(void) { e=1; delay(300); e=0; delay(300); }

void lcd_goto(unsigned char data) { if(dataF (data in Hexadecimal)

//==========================================================================

67 //

include

//=================================================================================== #include

//

configuration

//=================================================================================== __CONFIG (0x3F32);

//

define

//=================================================================================== #define lw #define

inc_button

RA0 RA1

#define dec_button RA2 #define

send_button

#define display

RA3 PORTB

//

function prototype

//=================================================================================== void uart_send(unsigned char data);

//

main function

//=================================================================================== void main(void) {

//assign variable unsigned char num,no; //7 segment display unsigned char _7seg[16]={0b01111111,0b00001101,0b10110111,0b10011111,

//0,1,2,3

0b11001101,0b11011011,0b11111011,0b00001111,

//4,5,6,7

0b11111111,0b11011111,0b11101111,0b11111001,

//8,9,A,B

0b01110011,0b10111101,0b11110011,0b11100011};

//C,D,E,F

ADCON1= 0x06;

//configure PortA as digital I/O

TRISA = 0b111111;

//configure PORTA input

TRISB = 0b00000000;

//configure PORTB as output

//setup USART BRGH = 0;

//baud rate low speed option

SPBRG = 255;

//set boud rate to 1200bps for 20Mhz crystal

68 TX9 = 0;

//8-bit transmission

TXEN = 1;

//enable transmission

SYNC = 0;

//asynchronous

SPEN = 1;

//enable serial port

num=0; no=0; display=_7seg[num]; while(1)

//infinity loop

{ TRISA0=0; if(lw==0)

//when the limit switch press

{ display=_7seg[7]; uart_send(7); }

if(inc_button==0)

//increase number per press

{ if(num==15) num=0;

//back to 0 after F

else num+=1;

//one increment

display=_7seg[num];

//display number on 7 segment

while(inc_button==0) uart_send(no);

//continuous send data

}

else if(dec_button==0)

//decrease number per press

{ if(num==0) num=15;

//go to F after 0

else num-=1;

//one decrement

display=_7seg[num];

//display number on 7 segment

while(dec_button==0) uart_send(no);

//continuous send data

} else if(send_button==0)

//send the desired number

no=num; uart_send(no); } }

//continuous send data

69

//

functions

//=================================================================================== void uart_send(unsigned char data) { while(TXIF==0);

//only send the new data after

TXREG=data;

//the previous data finish sent

}

Source Code for RF Receiver

//======================================================================== //

Project description : The receiver will receive the data(0->F) from transmitter

//

and display the data on 7-segment display.

//==========================================================================

//

include

//=================================================================================== #include

//

configuration

//=================================================================================== __CONFIG (0x3F32); //

define

//=================================================================================== #define display

PORTB

#define buzzer

RC4

//

function prototype

//=================================================================================== unsigned char uart_rec(void);

//

main function

//=================================================================================== void main(void) { //assign variable unsigned char num,no;

70 // 7 segment display unsigned char _7seg[16]={0b01111111,0b00001101,0b10110111,0b10011111,

//0,1,2,3

0b11001101,0b11011011,0b11111011,0b00001111,

//4,5,6,7

0b11111111,0b11011111,0b11101111,0b11111001,

//8,9,A,B

0b01110011,0b10111101,0b11110011,0b11100011};

//C,D,E,F

//set I/O input output TRISB = 0b00000000;

//configure PORTB as output

TRISC4=0;

//setup USART

BRGH = 0;

//baud rate low speed option

SPBRG = 255;

//set boud rate to 1200bps for 20Mhz crystal

SPEN = 1;

//enable serial port

RX9 = 0;

//8-bit reception

CREN = 1;

//enable reception

num=0; display=_7seg[num];

while(1)

//infinity loop

{ CREN=1;

//enable continuos receive

if(OERR==0) no=uart_rec();

//receive sata if overrun error free

else CREN=0;

//if overrun error, disable continuos receive

if((no==0)||(no==1)||(no==2)||(no==3)|| (no==4)||(no==5)||(no==6)||(no==7)|| (no==8)||(no==9)||(no==10)||(no==11)|| (no==12)||(no==13)||(no==14)||(no==15)) num=no;

if(num==7) { unsigned int x; for(x=0;x