Sem 6 full Report Projek Politeknik

January 18, 2017 | Author: AMar Ridhwan | Category: N/A
Share Embed Donate


Short Description

full report untk sem 6 projeck...

Description

CHAPTER 1 INTRODUCTION OF THE PROJECT

1.1

Introduction

We had made a major modification of our final project, the amazing Water Recycle System in previous entry with something which is more useful. Thus, our current activity was set up to refining our prior project into something that give meaningful effect to us as a students, as a designer and a human being. The main reason of building this Water Recycle System is to encourage young people to pay respect to environment.

1.2

Synopsis

This project shows the basic of developing a simple system recycle using microcontroller and can be further developed for more advanced application. This project will be use to reuse water from two source that come from rain water and river water. And, this system also will display it on LCD display.

We used the PIC16F877A system to operate the circuit. This PIC system will control the program. Beside that, we also using IC Clock and LCD 20x4 (LM004L) to display real time and date.

1

1.3

Objective

Objective for project subject that compulsory to be taken by all student of Diploma in Electronic Engineering at POLYTECHNIC TUANKU SULTANAH BAHIYAH are:

The main objective of this project can be described as:

1.4



Reuse the contaminated water.



Prevent pollution.



To reduce organisation's operating cost



To make a technology as a way for solving a human problem.

Scope of Project

This project using the PIC 16F877A that have 8-bit microcontroller with 34 I/O, that operate with 5V supply and their output baud rate is 9600 bps, LCD (20x4character display), LED as the output for PIC microcontroller, PCB circuit board and also related electronic circuits.

This project will use following main hardware: 

PIC 16F877A



Clock IC (DS1307)



LCD Alphanumeric 20x4 (LM004L)



Water Sensor



Buzzer



Motor Pump

2

1.5

System Overview

Figure 1.1 System Overview

1.6

Problem Statement

A study was being conducted our upper project that entitled Water Recycle System taken based on with sparked idea from our monitoring and observation on human way of life nowadays. This project coined to ease consumer to engage of water quickly and easy and save cost organize. Furthermore, with the existence of this project it able facilitate more work to carried out with long distance area perimeter and condition getting more complicated if uncertain weathers lately. To overcome the problem with run it at anytime is wanted.

3

CHAPTER 2 LITERATURE REVIEW

2.1

Introduction

A literature review is a body of text that aims to review the critical points of current knowledge and or methodological approaches on a particular topic. Literature reviews are secondary sources, and as such, do not report any new or original experimental work. Most often associated with academic-oriented literature, such as theses, a literature review usually precedes a research proposal and results section. Its ultimate goal is to bring the reader up to date with current literature on a topic and forms the basis for another goal, such as future research that may be needed in the area. A well-structured literature review is characterized by a logical flow of ideas; current and relevant references with consistent, appropriate referencing style; proper use of terminology and an unbiased and comprehensive view of the previous research on the topic.

The report that we want to be produced needed a few factor that should be taken consideration until that project implemented. To get a quality project result, we need to study about the type of material, design , components that we used, framework installation , installation method and maintenance ,level of product safety, structural strength, project size and so on that we need make it and consider the result that we get. This is all ensure that no any

4

problems would arise during the completion or even when presenting the project.

Hence, systematic and detailed planning must be arranged for produce a complete and perfect project. First step that we need made it, was design daub (sketching) for get the real image of machine that we want to be produced. Due to this, the work design and study that we made is a continuing process and it involving problem solving activity creatively namely which is known as literature study.

2.2

MOTOR DC PUMP Description: KNF's NMP08 miniature diaphragm pump is capable of transferring the largest volume of water in this size range with high efficiency and contamination-free operation. It is ideal for use in portable, battery operated equipment where performance, power consumption, minimal weight, and size are important. KNF's “OEM Project Pump” program provides a variety of cost reductions and affordable modifications that will optimize our product to match your design‟s performance requirement.

2.2.1

Pump Features: • Oil-Free, Contamination-Free Transfer: Retains pumped medium purity and increases system reliability as they are maintenance-free and have no sliding seals to wear away. • Patented, Multi-Port Valves: KNF‟s multi-port valve system maximize flow rate for high

5

efficiency. An integral sealing-ridge reduces back flow to negligible levels. • Fits Into The Smallest Devices: KNF's engineers combined high performance with precision miniature packaging to produce an efficient, compact unit. Portable instruments

can be made smaller and lighter, and run

longer between recharges. A brushless DC model is available as standard product for high reliability and continuous-duty applications. • Excellent Mechanical Stability and Chemical Resistance: Ryton® heads exhibit consistent performance throughout the life of the pump. Ryton® also has excellent chemical resistance. Other diaphragm and valve materials are available. • Flexible Mounting Options: Optimally placed mounting holes in the compressor housing enable you to mount this pump in any position. • Low Noise Level An enclosed compressor housing minimizes noise transmission and keeps dirty away from critical components.

2.2.2

Applications: • Asbestos Particle

• Portable Dosimeters

Counters • Gas or Odor Leak

• Gas Chromatography

Detectors • Portable Analytical

• Portable Analytical

6

Instruments

Instruments

• Blood Pressure Monitors

• Medical Diagnostic Equipment

Table 2.1: Applications of motor

2.2.3 Electric Usage Motor

6 VDC, 12 VDC

Voltage Motor

6 VDC, 12 VDC,

6 VDC

24 VDC 85 mA, 40 mA

50 mA, 40 mA,

Current @

175 mA

20 mA

Free-Flow Motor

Brushless:

Brushless:

Brushless:

Type

DC/Integrated

Type DC

Type DC

driver

Table 2.2: Electric Usage

7

2.2.4 Performance Characteristic

Figure 2.1: Performance Characteristic

2.3

PIC16F877A

Microcontroller PIC16F877A is one of the PIC Micro Family microcontroller which is popular at this moment, start from beginner until all professionals. Because it is very easy using PIC16F877A and use FLASH memory technology so that can be write-erase until thousand times. The superiority this Risc Microcontroller compared to with other microcontroller 8-bit especially at a speed of and his code compression. PIC16F877A have 40 pin by 33 path of I/O.

8

PIC16F877A perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption. EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F877A applicable even in areas where microcontrollers had not previously been considered (example: timer functions, interface replacement in larger systems, coprocessor applications, etc.).In System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assembly-line production, to store calibration data available only after final testing, or it can be used to improve programs on finished product.

Figure 2.2: PIC16F877A

9

Figure 2.3: PIC16F877A Pin Diagram

Figure 2.4: Schematic Diagram Of Microcontroller Connections

10

2.3.1 Benefit of PIC 

Lower Cost: Pic were originally create to decrease the cost of the user of it compare with the plc that weremore expensive that pic. Therefore in this project we choose pic as the brain in this project. 

Sizes: The pic is the smallest that other programming control that has many types of input and output pin such as 16 pin to 40 pin.



Communication Capability: A pic can read and program all the input that has to program with it and easy to to program with any programmer and software.



Faster Respond Time: Pic are design for high-speed and real-time applications. It can operate in real times, which mean that an even taking place in the field will result in the execution of an operation or output.

2.3.2 Characteristic of PIC

NO.

FEATURES

PIC16F877A

1.

Operating Frequency

DC – 20 MHz

2.

Resets and delays

POR, BOR (PWRT, OST)

3.

Flash Program Memory (14-bit words)

8K

4.

Data Memory (bytes)

368

11

5.

EEPROM Data Memory (bytes)

256

6.

Interrupts

15

7.

I/O Ports

Ports A, B, C, D, E

No.

features

Pic16f877a

8.

Timers

3

9.

Capture/Compare/PWM modules

2

10.

Serial Communications

MSSP, USART

11.

Parallel Communications

PSP

12.

10-bit Analog-to-Digital Module

8 input channels

13.

Analog Comparators

2

14.

Instruction Set

35 Instructions40-pin PDIP

15.

Packages

44-pin PLCC 44-pin TQFP 44-pin QFN

Table 2.3: Features of PIC16F877A

2.4

LCD (4 x 20 Character)

Recently, a number of projects using intelligent Liquid Crystal Display (LCD) modules have been featured in EPE. Their ability to display not just numbers, but also letters, words and all manner of symbol, makes them a good deal more versatile than the familiar 7-segment light emitting diode (LED) display.

12

Figure 2.5: LCD (2 x 20 Characters)

2.4.1 Connections of LCD

Most LCD modules conform to a standard interface specification. A 14-pin access is provided (14 holes for solder pin insertion or for an IDC connector) having eight data lines, three control lines and three power lines. The connections are laid out in one of two common configurations, either two rows of seven pins, or a single row of 14 pins. The two layout alternatives are displayed in figure 2.5.

Figure 2.6: Two Layout Alternatives

13

Table 2.4: Pin Outs Functions for All the LCD Types Pins 1 and 2 are the power supply lines, Vss and Vdd .The Vdd pin should be connected to the positive supply, and Vss to the 0V supply or ground. Although the LCD module data sheet specify a 5V DC supply (at only a few milliamps), supplies of 6V and 4.5 both work well, and even 3V is sufficient for some modules. Consequently, these modules can be effectively, and economically, powered by batteries. Pin 3 is a control pin, Vee, which is used to alter the contrast of the display. Ideally, this pin should be connected to a variable voltage supply.

A preset potentiometer connected between the power supply lines, with its wiper connected to the contrast pin is suitable in many cases, but be aware that some modules may required a negative potential; as low as 7V in some cases. For absolute simplicity, connecting this pin to 0V will often suffice. Pin 4 is the Register Select (RS) line, the first of the three command control inputs. When this line is low, data bytes transferred to the display are treated as commands, and data bytes read from the display indicate its status.

14

By setting the RS line high, character data can be transferred to and from the module.

Pin 5 is the Read/ Write (R/W) line. This line is pulled low in order to write commands or character data to the module, or pulled high to read character data or status information from its registers.

Pin 6 is the Enable (E) line. This input is used to initiate the actual transfer of commands or character data between the module and the data lines. When writing to the display, data is transferred only on the high to low transition of this signal. However, when reading from the display, data will become available shortly after the low to high transition and remain available until the signal falls low again.

Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to and from the display, either as a single 8-bit byte or as two 4-bit “nibbles”. In the latter case, only the upper four data lines (D4 to D7) are used. This 4-bit mode is beneficial when using a microcontroller, as fewer input/output lines are required.

2.5

Diode In electronics a diode is a two-terminal electronic component which conducts electric current asymmetrically or unidirectional; that is, it conducts current more easily in one direction than in the opposite direction. The term usually refers to a semiconductor diode, the most common type today, which is a crystal of semiconductor connected to two electrical terminals, a P-N junction. A vacuum tube diode, which was the first type of diode invented but is now little used, is a vacuum tube with two electrodes; a plate and a cathode.

15

The most common function of a diode is to allow an electric current in one direction (called the forward direction) while blocking current in the opposite direction (the reverse direction). Thus, the diode can be thought of as an electronic version of a check valve. This unidirectional behavior is called rectification, and is used to convert alternating current to direct current, and remove modulation from radio signals in radio receivers.

Figure 2.7: Diode

Figure 2.8: Diode Symbols

16

2.6

Crystal A crystal is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency.

This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them were called "crystal oscillators".

Standard frequency crystals - use these crystals to provide a clock input to our microprocessor. Rated at 20pF capacitance and +/- 50ppm stability.

Figure 2.9: Crystal

17

CHAPTER 3 METHODOLOGY

3.1

Introduction Methodology can be the „analysis of the principles of methods, rules, and postulates employed by a discipline‟, „the systematic study of methods that are, can be, or have been applied within a discipline‟ or „a particular procedure or set of procedures‟.

Methodology includes a philosophically coherent collection of theories, concepts or ideas as they relate to a particular discipline or field of inquiry. Methodology refers to more than a simple set of methods, rather it refers to the rationale and the philosophical assumptions that underlie a particular study relative to the scientific method. This is why scholarly literature often includes a section on the methodology of the researchers. Each step of project is a process to complete the project. Every step must be followed one by one and must be done carefully. If some error occurs it can make a project probably could not operate or do not look neat and perfect. Before the project finish, various process needs to be done according to proper procedures to ensure that projects do not have any problems. Among the measures the work done in preparing this project are:

18



Process of designing circuits



Circuit board trace



Soldering process in circuit board.



Programming process in programes and so on

3.1.1 Flow Chart Plan Of Project Of E4006 And E5006

19

Flow Chart 1.0: Plan Of Project For E4006 And E5006

20

3.1.2

Flow Chart Preparation Of E4006

21

Flow Chart 1.1: Flow Chart Preparation Of E4006

22

3.1.3

Flow Chart Of Water Recycle System

Flow Chart 1.2: Flow Chart Of Water Recycle System

23

3.2

Gantt Chart

SEMESTER 5

WEEK / ACTIVITY

W e e k 1

W e e k 2

W e e k 3

W e e k 4

W e e k 5

W e e k 6

W e e k 7

W e e k 8

W e e k 9

W e e k 1 0

W e e k 1 1

W e e k 1 2

W e e k 1 3

W e e k 1 4

W e e k 1 5

Students Registration Project Briefing Submission of Project Title Submission of Proposal Assistance and Discussion Progress The Project and First Draft of The Report 50% Progress The Project and Second Draft of The Report 75% Preparation for presentation Submission of Final Report Presentation Table 3.1: Gantt Chart

3.3

Draw Schematic Diagram Of Water Recycle System Using Proteus

PROTEUS VSM 6.9 allows professional engineers to run interactive simulations of real designs, and to reap the rewards of this approach to circuit simulation. And then, a range of simulator models for popular microcontrollers and a set of animated models for related peripheral devices such as PIC and LCD displays, resistor, and more. It is possible to simulate complete micro-controller systems and thus to develop the software for them without access to a physical prototype. In a world where time to market is becoming

24

W e e k 1 6

W e e k 1 7

W e e k 1 8

more and more important this is a real advantage. Structurally, Proteus 6 Professional separated into two main components, which are ISIS 6 Professional and ARES 6 Professional. ISIS 6 Professional mainly involved on circuit designing and simulation. In our project we use Proteus to design a schematic diagram.

Figure 3.1: ISIS 6 Professional User Interface

3.3.1 Simulate The Circuit Using Proteus

After completing the circuit assembly and configuration, now its time to verify whether the source code compiled is virtually accurate or not. Proteus offer a whole lot of variety virtual devices. In fact, simulation using oscilloscope and function generator can be done using Proteus. Even virtual hyperterminal is provided to demonstrate how your code performs in real world without really doing the hardware section yet.

Figure 3.2 : Toolbar Of Proteus Simulation

25

3.4

Process Of The Circuit Designing

3.4.1 Design The Circuit Diagram

After decide what kind of project that we want to build. We need to make a research about the circuit, electronic component that we need to used, hardware and so on. These things actually can help us to make a better in designing circuit. For example, we need to know the size, foot of component, polarity of the component, the component method compilation and etc to make a circuit diagram.

In the first step in Circuit Designing process is make a circuit diagram that can be use in the next process. Among steps in the circuit diagram are:-

i. Before the circuit is produced, the things that we need to be emphasized are the position of symbols and components used in the Schematic circuit. Once we know the entire production circuit, the circuit can be drawn using special software, namely Proteus ISIS Professional. ii. Then, make sure that the connection of the component is correct.

26

Figure 3.3: Water Recycle System Circuit Diagram

3.5

Etching

Etching is a "subtractive" method used for the production of printed circuit boards. Acid is used to remove unwanted copper from a prefabricated laminate. This is done by applying a temporary mask that protects parts of the laminate from the acid and leaves the desired copper layer untouched. Etching is where the excess copper is removed to leave the individual tracks or traces as they are sometimes called. Buckets, bubble tanks, and spray machines lots of different ways to etch, but most firms currently use high pressure conveyerised spray equipment. Many different chemical solutions can be used to etch circuit boards. Ranging from slow controlled speed etches used for surface preparation to the faster etches used for etching the tracks. Some are best used in horizontal spray process equipment while others are best used in tanks.

27

3.5.1 Risk Of Etching

i. There is a risk of injuries due to the chemicals involved. ii. The quality of the results depends on several factors which you won't be able to master completely the first time. This can be somewhat compensated by using good machinery. iii. There is the problem of waste disposal. Toxic chemicals require a proper disposal service.

3.5.2 Safety

Since the work involves dangerous chemicals and power tools, we will need to take the necessary safety precautions:

i. Wear safety equipment during the whole process - gloves, protection glasses, and an apron ii. Work near an emergency eyewash station, a first aid box and a phone iii. Familiarize yourself with the proper use of all equipment and tools in the lab - if you are unsure of anything, ask a supervisor of the project. 3.5.3 Etching Process

Etching is the process of using acid to remove coppers that not need on the PCB (PRITED CIRCUIT BOARD). This acid is Acid Ferric Chloride III. Acid Ferric Chloride III is used to remove that coppers. The steps of the etching process are: i. Print the schematic onto transparent paper and cut it with the same size of PCB board.

28

Figure 3.4 Transparent Paper That Have Cut

ii. Stick the schematic diagram on PCB board. iii. Paste the etching circuit onto transparent paper with UV Board using expose machine. It‟s to make PCB paper joined with board. iv. This process takes about 30 second.

Figure 3.5. UV Expose Process v. Dilute the acid with a little hot water and make sure that the mixture is not too liquid and too concentrated. vi. Then, put the board into the mixed (Acid Ferric Chloride III + Hot water) to remove the useless copper.

Figure 3.6: Process To Remove Unused Chopper

29

vii. When PCB was soaked into this mix, we must always shake the container with the acid so that the unwanted copper will remove. viii. After Acid remove unused copper, take the PCB to wash with clean water. ix. Then, use sand paper to rub the lines colors. In addition, detergent powder can also be used to remove the ink. Next, just leave only the desired circuit PCB only.

3.6

Drilling Process

3.6.1 Material and Equipments : 

Bench clamp or support



Dot punch or sharp tool



Drilling machine or hand drill



1mm bits

3.6.2 Introduction of Drilling Process

After the etching process finished, the PCB will be punched using hand drilling machine. Hole is necessary to mount component (example: resistor, capacitor, inductor, tip 122, crystal, PIC base and etc). Before drilling, a dot punch is used to mark the hole position. This serves as a shallow guide for the drill bit to align easily while drilling. Any other sharp pointed tool can be use to do the marking. Points/eye drill used must be appropriate to the hole to be punched between 0.75 to 1.0 mm.

The purpose of this process is to facilitate the installation work on the circuit components of the PCB. During drilling, do not be pressed too strong because it may cause eye drill broken up and dangerous for the

30

people around. Hold the drill steady and drill in straight slowly. The hole will be drilled with little force applied.

3.7

Insert the Component

Foot of component was inserted into the drilled hole that has been completed. It is easier if started with the low component first. Components that are installed must be inspected prior to use multimeter to find out whether these components are in good condition or not. This process is quite important because we should insert the component correctly to avoid from circuit failure. Besides, some components have their own pole like diode, capacitor and other else. After finished the inserting process, we check it once again with the schematic to make sure all the component were at the position or holes.

3.8

Soldering Process

Soldering is defined as "the joining of metals by a fusion of alloys which have relatively low melting points". In other words, we use a metal that has a low melting point to adhere the surfaces to be soldered together. Soldering is more like gluing with molten metal than anything else. Soldering is also a must have skill for all sorts of electrical and electronics work. It is also a skill that must be taught correctly and developed with practice.

Steps to Solder :

i.

Quickly remove the tip of the soldering iron from Heat up the soldering iron for five to 10 minutes, allowing the iron to reach maximum operating temperature. If the soldering iron has two

31

temperature settings selectable with a switch, select lower temperature when soldering small electronic components to a board and select the higher temperature when soldering heavier wires. Apply a small amount of solder to the tip and rotate so the entire tip becomes lightly covered with a thin layer of solder. This is called "tinning" the tip.

ii.

Connect the two surfaces to be soldered together so the metal parts are touching. If soldering wires, simply twist the two wire ends together so they don't pull apart while being soldered. If soldering electronic components, simply seat the component wires into the holes of the circuit board where the component is to be placed.

iii.

Touch the hot tip of the soldering iron to all metal parts touching together so they are evenly heated. Allow the surface to heat for just three to five seconds, then touch the tip of the solder to the heated metal objects, not directly to the tip of the soldering iron. Allow a small amount of solder to flow onto the metal components or wires until just enough solder has been applied to cover the entire surface of the wires or components.

iv.

the soldered surface and wipe the tip of the iron on a wet sponge immediately to remove solder. Wiping the solder off the tip will prevent it from burning and forming a black coat on the soldering iron tip.

v.

Allow the solder joint to cool for several minutes before applying power to the wires or the device soldered.

32

3.9

Circuit Testing

For testing and improvement process, we took almost four weeks to make it work. In the calendar project activities, we were given four weeks to settle all the testing and improvement process. The purpose of testing the electric was to determined and located any of the following conditions :

1) An open circuit 2) A short circuit with another conductor in the same circuit. 3) A ground, which is a short circuit between the conductor and circuit. 4) Leakage ( a high resistance path across a portion of the circuit, to another circuit, or to ground ). 5) A cross ( a short circuit or leakage between conductors of different circuit )

As a first step, we have done the short circuit testing using an analog multimeter. Before used the multimeter, we set up the multimeter to zero. To pointer the meter exactly on the zero line, we rotate the adjusting screw, Then we connect the multimeter probes to the circuit being tested. After that, we observed the meter needle movement. Luckily the needle does not move, this means circuit was not short.

Then we move on the second step, which is testing an open circuit. Open circuit test, sometimes called no – load test, is one of the method in electrical engineering order to determine a break exists in a complete conducting pathway. Open circuit can cause by excessive current. Again, multimeter was used to check whether the circuits are open or in normal condition. We only gave the required current to the circuit, so we did not face an open circuit problem. This mean our circuits were in normal condition.

33

3.10

Troubleshooting

The most problem like the fault soldering. Check all the soldering joint suspicious. If you discover the short track or the short soldering joint, resolder at that point and check other the soldering joint. Check the position of all component on the PCB. See that there are no components missing or inserted in the wrong places. Make sure that all the polarised components have been soldered the right way round.

3.11 Project Designation

3.11.1

Research and Analysis Project

Research is important to ensure the project that is yet to progress can have a good start so that it would not cost any problem during the project development. So, the vital information such as the circuit, the component usage ,the commercial needs and much are indeed important . It is as the circuit, ensure the can understand more on how important is the project. The source can be obtained from lectures, books and also internet.

3.11.2

The Project Reformation

We must read and understand all data that we have. Data and information have to be compiled and all information we had got had to be arranged systematically for progress. From time all information and data must to upgrade for information and follow the project‟s progression.

34

3.11.3

Session Discussion and Problem Settle

Discussion session were held every week to discuss the project development. All the problem are discussed so that it can be solved quickly. Problem that can‟t be handled were too addressed quickly to the project supervisor. To make the project difficult everything that is going to be done must be planned properly (proper planning). This can ensure the project flow is smooth without any interruptions.

3.12

Software Part

3.12.1 Identify Every Software Components Inside The Schematic Diagram

i. Proteus VSM 6.9 to design schematic diagram ii. Eagle to design PCB

3.13

Study About The PIC16F877A That Has Been Use

Microcontroller PIC16F877A is one of the PIC Microcontroller Family microcontroller which is popular at this moment, start from beginner until all professionals. Because very easy using PIC16F877A and use FLASH memory technology so that can be write-erase until thousand times. The superiority this Risc Microcontroller compared to with other microcontroller 8-bit especially at a speed of and his code compression. PIC16F877A have 40 pin by 33 path of I/O.

PIC16F877A is a small piece of semiconductor integrated circuits. The package type of this integrated circuits is DIP package. DIP stand for Dual Inline Package for semiconductor IC. This package is very easy to be

35

soldered onto the strip board. However using a DIP socket is much more easier so that this chip can be plugged and removed from the development board. PIC16F877A is very cheap. Apart from that it is also very easy to be assembled. Additional components that you need to make this IC work is just a 5V power supply adapter, a 20MHz crystal oscillator and 2 units of 22pF capacitors. The advantage of this IC can be reprogrammed and erased up to 10,000 times. Therefore it is very good for new product development phase.

Figure 3.7: Structure and Diagram of PIC16F877A

3.13.1 PIC16F877A Microcontroller Features Special Microcontroller Features i. 100,000 erase/write cycle Enhanced Flash program memory typical ii. Self-reprogrammable under software control iii. Single-supply 5V In-Circuit Serial Programming iv. Watchdog Timer (WDT) with its own on-chip RC oscilloscope v. Programmable Code Protection vi. Power-Saving Sleeping mode

36

Peripheral Features i.

Two 8-bit (TMR0, TMR2)timer/counter with Pre-scalar

ii.

One 16-bit timer/counter

iii.

Brown-out detection circuitry

iv.

Parallel Slave Port (PSP): 40/44 pin-device only

High-Performance RISC CPU i.

Only 35 single-word instructions to learn

ii.

DC-20MHz clock input

iii.

Up to 8K x 14 words of Flash Program Memory

iv.

Pin out Compatible to other 28-pin or 40/44-pin

Analog Features i.

10-bit, up to 8-channel Analog-to-Digital Converter (A/D)

ii.

Brown-out Reset(BOR)

iii.

Two analog comparators

iv.

Programmable on-chip voltage reference (VREF) module

CMOS Technology i.

Low-power, high-speed Flash/EEPROM technology

ii.

Fully static design

iii.

Wide operating voltage range (2.0V to 5.5V)

iv.

Low-power consumption

37

3.13.2 PIC16f877A Block Diagram

Figure 3.8 : PIC16F877A block diagram

38

3.13.3 PIC16F877A Register File Map

Figure 3.9 : PIC16F877A Register File Map

39

3.13.4 Function Of PIC16f877A Pin Out

No.

Descriptions

Pin 1

MCLR / VPP Master Clear (input) or programming voltage (output). This is an active low RESET to the device.

2

RA0 / AN0 can also be analog input 0.

3

RA1 / AN1 can also be analog input 1.

4

RA2 / AN2 / VREF – can also be analog input 2 or A/D reference voltage ( LOW ) input.

5

RA3 / AN3 / VREF + can be also analog input 3 or A/D reference voltage ( HIGH ) voltage.

6

RA4 / T0CK1 / C1OUT can also be timer 0 external clock input. Comparator 1 output.

7

RA5 / AN4 / SS can also be analog input4 or the salve Select. for the synchronous serial port

8

RE0/RD/AN5 can also be analog input4 or the salve Select. for the synchronous parallel port5

9

RE1/WR/AN6 can also be analog input4 or the salve Select. for the synchronous serial port6

10

RE2/CS/AN7 can also be analog input4 or the salve Select for the synchronous serial port7

11

VSS can also be ground reference for logic and i/o pins

12

VDD can also be positive supply for logic and i/o pins.

13

OSC1/CLKIN oscillator crystal input/external clocsk source input.

14

OSC2/CLKOUT oscillator crystal output

15

RC0 / T1OSO / T1CKI can also be Timer 1 oscillator output. Timer1 external clock input

16

RC1/ T1OSI / CCP2 can also be Timer1 oscillator input. Capture2 input, Compare2 output, PWM2 output

17

RC2 / CCP1 can also be Capture1 input, Compare1 output, PWM1

40

output. 18

RC3 / SCK / SCL can also be synchronous serial clock input/output for SPI mode. Synchronous serial clock input/output for IC mode.

19

RD0/PSP0

20

RD1/PSP1

21

RD2/PSP2

22

RD3/PSP3

23

RB3 / PGM can also be low-voltage ( single supply ) ICSP programming enable pin.

24

RC5 / SDO can also be SPI data out

25

RC6 / TX / CK can also be USART asynchronous transmit. USART 1 synchronous clock

26

RC7 / RX / DT can also be USART asynchronous receive. USART synchronous data.

27

RD4/PSP4

28

RD5/PSP5

29

RD6/PSP6

30

RD7/PSP7

31

RC4 / SDI / SDA can also be SPI data in. IC data i/o.

32

VSS can also be ground reference for logic and i/o pin

33

VDD can also be positive supply for logic and i/o pins

34

RBO / INT can also be external interrupt

35

RB1 can also be digital i/o.

36

RB2 can also be digital i/o.

37

RB4 can also be digital i/o.

38

RB6 / PGC can also be In-circuit debugger and ICSP programming clock.

39

RB5 can also be digital i/o.

40

RB7 / PGD can also be In-circuit debugger

Table 3.2: Function Of PIC16f877A Pin Out

41

3.14

Programming

3.14.1 Source Code Define OSC 8

' Core is running at 48MHz

Define LCD_DREG PORTb Define LCD_DBIT 4 Define LCD_RSREG PORTB Define LCD_RSBIT 1 Define LCD_EREG PORTB Define LCD_EBIT 3 DEFINE LCD_RWREG PORTB DEFINE LCD_RWBIT 2 DEFINE I2C_SLOW 1 ' Alias pins SDA Var PORTc.7 SCL Var PORTc.6 TRISd = %00001111 TRISC = %00101111 ' Allocate variables RTCYear Var Byte RTCMonth Var Byte RTCDate Var Byte RTCDay Var Byte RTCHour Var Byte RTCMin Var Byte RTCSec Var Byte RTCCtrl Var Byte mybcd var byte mybyte var byte mybcd1 var byte mybyte1 var byte b2 var byte j var byte TEMPHOUR VAR BYTE TEMPMIN VAR BYTE HOURBTN VAR PORTD.0 MINBTN VAR PORTD.1 ENTERBTN VAR PORTC.3 SETBTN VAR PORTC.2 buzzer var portd.5 alarmhour var byte alarmmin var byte portd = %00000010 sensor_water var portd.2 sensor_rain var portd.3 pump_siram var portd.7 pump_water var portd.6 sensor var portc.5 i var word Pause 500 ' Wait for LCD to startup sensor1 var word

42

sensor2 var word ' Set initial time to 8:00:00AM 06/21/05 RTCYear = $05 RTCMonth = $06 RTCDate = $21 RTCDay = $02 RTCHour = $08 RTCMin = 2 RTCSec = 4 RTCCtrl = 0 low pump_siram low pump_water low buzzer pause 2000 Gosub settime

' Set the time

mainloop: if sensor_water = 0 then sensor1 = 0 low pump_water pause 10 endif if sensor_water = 1 then sensor1 = 1 high pump_water high buzzer pause 100 low buzzer pause 100 endif if sensor_rain = 1 then sensor2 = 1 endif if sensor_rain = 0 then sensor2 = 0 endif if enterbtn= 0 then high pump_siram pause 1000 endif if enterbtn = 1 then low pump_siram pause 100 endif

43

gosub set_time Gosub gettime gosub compare_alarm Lcdout $fe, 1 LCDOUT $FE, 2 LCDOUT " TIME: ", hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec LCDOUT $FE, $C0 LCDOUT "RAIN= ",DEC SENSOR2, " WATER= ", DEC SENSOR1 Pause 200 IF SETBTN =0 THEN GOTO SET_ALARM ENDIF Goto mainloop End SET_TIME: IF HOURBTN = 0 THEN GOSUB GETTIME 'MYBCD= RTCHOUR TEMPHOUR = ((RTCHOUR >> 4 ) * 10 ) + (RTCHOUR & 15 ) TEMPHOUR = TEMPHOUR + 1 IF TEMPHOUR >=24 THEN TEMPHOUR = 0 ENDIF RTCHOUR = ((TEMPHOUR / 10 )
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF