Nothing Special   »   [go: up one dir, main page]

Nadeem

Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

AUTOMATIC TRAIFF CALCULATION

WITH
WIRELESS ENERGY METER

K. Sai Deekshith
MD. Nadeem
P. Dhawan Maruthi

Department of Electronics and Communication Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, T.S.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad – 500 075 (T.S)


2023 -2024

AUTOMATIC TRAIFF CALCULATION


WITH
WIRELESS ENERGY METER

MAIN PROJECT REPORT


SUBMITTED IN PARTIAL FULFILLMENT
OF THE REQUIREMENTS FOR THE DEGREE OF
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
BY

K. Sai Deekshith (20261A0497)


MD. Nadeem (20261A04A2)
P. Dhawan Maruthi (20261A04B0)

Department of Electronics and Communication Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, T.S.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad – 500 075 (T.S)

2023 -2024
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, T.S.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad-500 075
Department of Electronics and Communication Engineering

CERTIFICATE

Date: MAY 2024

• This is to certify that the Main project work entitled “ AUTOMATIC TRAIFF
CALCULATION

WITH WIRELESS ENERGY METER” is a bonafide work carried out by

K. Sai Deekshith (20261A0497)

MD. Nadeem (20261A04A2)

P. Dhawan Maruthi (20261A04B0)

in partial fulfillment of the requirements for the degree of BACHELOR OF TECHNOLOGY


in ELECTRONICS & COMMUNICATION ENGINEERING by the Jawaharlal Nehru
Technological University, Hyderabad during the academic year 2023-24.

The results embodied in this report have not been submitted to any other University or
Institution for the award of any degree or diploma.

--------------------------

K.N.Mallesh
Faculty Advisor Dr.S.P.Singh
(i)
ACKNOWLEDGEMENT

We express our deep sense of gratitude to our Guide K.N.Mallesh, Associate Professor, for his
invaluable guidance and encouragement in carrying out our Project.
We are highly indebted to our Faculty Liaison Dr.CH Raja, Associate Professor,
Dr.M.Fayazur Rahaman, Associate Professor and Mr.B.Kesava Rao, Assistant Professor,Electronics
and Communication Engineering Department, who has given us all the necessary technical guidance
in carrying out this Project.

We wish to express our sincere thanks to Dr. S.P.Singh, Head of the


Department of Electronics and Communication Engineering, M.G.I.T., for permitting us to
pursue our Project, and encouraging us throughout the Project.

Finally, we thank all the people who have directly or indirectly help us through the course of our
Project.

K. Sai Deekshith

MD. Nadeem

P. Dhawan Maruthi

(ii)

ABSTRACT
This project proposes an innovative approach for Automatic Tariff Calculation with Wireless Energy
Meter using Zigbee technology.

The system aims to revolutionize traditional energy metering by integrating Zigbee communication
to enable wireless data transmission between the energy meter and a central processing unit.

This allows for real-time monitoring and automatic tariff calculation based on consumption patterns.

The system’s architecture, including hardware and software components, is detailed, highlighting the
benefits of Zigbee technology in achieving efficient energy management. Experimental results
demonstrate the system’s effectiveness in accurately calculating tariffs and its potential to enhance
energy conservation efforts.

(iii)

TABLE OF CONTENTS

CERTIFICATE FROM ECE DEPARTMENT (i)


ACKNOWLEDGEMENT (ii)
ABSTRACT (iii)
CHAPTER 1: INTRODUCTION

1.1 Introduction of the project ………………………………..………..………1

1.2 Project overview……………………………………………………….…….1

1.3 Thesis……………………..…………………………………………………..2

CHAPTER 2: EMBEDDED SYSTEMS

2.1 Introduction to embedded systems………………………………...………3

2.2 Need of embedded systems………………………………………….……...6

2.3 Explanation of embedded systems………………………………….……...8

2.4 Applications of embedded systems……………………………………...…11

CHAPTER 3: HARDWARE DESCRIPTION

3.1 Introduction with block diagram……………………………..……….….14

3.2 Microcontroller……………………………………………...………….….15

3.3 Regulated power supply…………………………………………………...26

3.4 LED indicator…………………..……..…………………………………....36

3.5 Energy meter……...……………………………………………….……….38

3.6 Optocoupler………………………………………..………………………..39

3.7 Zigbee………………….………………………………………………….….42

3.8 LCD display……….…………………………………………………………47


3.9 USBTTL……………………………………………………………………...51

CHAPTER 4: SOFTWARE DESCRIPTION

4.1 Express PCB…………………………………………………………….…53

4.2 PIC C Compiler……………………………………………………………56

4.3 Procedural steps for compilation, simulation and dumping……………………56

CHAPTER 5: PROJECT DESCRIPTION…………………………………..67

CHAPTER 6: ADVANTAGES, DISADVANTAGES AND APPLICATIONS..69

CHAPTER 7: RESULTS, CONCLUSION, FUTURE PROSPECTS…………70

REFERENCES………………………………………………………………………..71
CHAPTER 1: INTRODUCTION

1.1Introduction:

The existing energy meter reading technology uses man power which has disadvantages like
errors during calculation, absence of consumer during billing time and extra expenses for the billing
process. The wireless energy meter monitoring system aims to minimize these difficulties by
providing energy meter monitoring through wireless medium. Power consumed by consumer in the
home side module is monitored by Electricity Board through wireless technology. This wireless
technology is implemented by using ZigBee modules.
This is done by using a ZigBee transceiver interfaced with both the PC (Electricity Board) section as
well as the consumer side. The Microcontroller based system continuously records the readings.
These live meter readings are displayed in the LCD and also sent to the PC side through ZigBee. The
-PC (Electricity Board) takes the responsibility of calculating the bill with the data received from the
home side, and the tariff provided by the operator and displays the same in the LCD placed in the
consumer’s home by transmitting the data through ZigBee transceiver.
Zigbee is a WPAN technology based on the IEEE 802.15.4 standard. Unlike Bluetooth or
wireless USB devices, Zigbee devices have the ability to form a mesh network between nodes.
Meshing is a type of daisy chaining from one device to another. This technique allows the short range
of an individual node to be expanded and multiplied, covering a much larger area.
The design of this system is very much sensitive and should be handled with utmost care
because the microcontroller is a 5 volts device and it is employed to monitor the house hold power
consumption per day where it should be interfaced with a 230 volts Energy meter. So every small
parameter should be given high importance while designing the interfacing circuit between the
controller and the Energy meter.

1.2 Project Overview:

An embedded system is a combination of software and hardware to perform a dedicated task. Some
of the main devices used in embedded products are Microprocessors and Microcontrollers.
Microprocessors are commonly referred to as general purpose processors as they simply accept the
inputs, process it and give the output. In contrast, a microcontroller not only accepts the data as inputs
but also manipulates it, interfaces the data with various devices, controls the data and thus finally
gives the result.
The project “Automatic Tariff Calculation with Wireless Energy Meter” using
PIC16F72, Microcontroller is an exclusive project that can continuously monitoring of the Domestic
Energy meter using Zigbee technology. By using this method; Electricity Department read the meter
readings regularly without the person visiting each house and also add the automatic tariff calculations
will be display on LCD module.

1.3 Thesis Overview:

The thesis explains the implementation of “Automatic Tariff Calculation with


Wireless Energy Meter” using 16F72 microcontroller. The organization of the thesis is explained here
with:

1
Chapter 1 Presents introduction to the overall thesis and the overview of the project. In the project
overview a brief introduction of Automatic Tariff Calculation with Wireless Energy Meter and its
applications are discussed.
Chapter 2 Presents the topic embedded systems. It explains the about what is embedded systems,
need for embedded systems, explanation of it along with its applications.
Chapter 3 Presents the hardware description. It deals with the block diagram of the project and
explains the purpose of each block. In the same chapter the explanation of microcontrollers, power
supplies, Zigbee modules, LCD and energy meter along with optocoupler are considered.
Chapter 4 Presents the software description. It explains the implementation of the project using PIC
C Compiler software.
Chapter 5 Presents the project description along with each module interfacing to microcontroller.

Chapter 6 Presents the advantages, disadvantages and applications of the project.

Chapter 7 Presents the results, conclusion and future scope of the project.

2
CHAPTER 2: EMBEDDED SYSTEMS

2.1 Embedded Systems:

An embedded system is a computer system designed to perform one or a few dedicated functions
often with real-time computing constraints. It is embedded as part of a complete device often including
hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal computer
(PC), is designed to be flexible and to meet a wide range of end-user needs.
Embedded systems control many devices in common use today.

Embedded systems are controlled by one or more main processing cores that are typically either
microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated
to handle a particular task, which may require very powerful processors. For example, air traffic control
systems may usefully be viewed as embedded, even though they involve mainframe computers and
dedicated regional and national networks between airports and radar sites. (Each radar probably includes
one or more embedded systems of its own.)

Since the embedded system is dedicated to specific tasks, design engineers can optimize it to
reduce the size and cost of the product and increase the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.

Physically embedded systems range from portable devices such as digital watches and MP3
players, to large stationary installations like traffic lights, factory controllers, or the systems controlling
nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with
multiple units, peripherals and networks mounted inside a large chassis or enclosure.
In general, "embedded system" is not a strictly definable term, as most systems have some
element of extensibility or programmability. For example, handheld computers share some elements
with embedded systems such as the operating systems and microprocessors which power them, but they
allow different applications to be loaded and peripherals to be connected. Moreover, even systems which
don't expose programmability as a primary feature generally need to support software updates. On a
continuum from "general purpose" to "embedded", large application systems will have subcomponents
at most points even if the system as a whole is "designed to perform one or a few dedicated functions",
and is thus appropriate to call "embedded". A modern example of embedded system is shown in fig: 2.1.

Fig 2.1:A modern example of embedded system

3
Labeled parts include microprocessor (4), RAM (6), flash memory (7).Embedded systems programming
is not like normal PC programming. In many ways, programming for an embedded system is like
programming PC 15 years ago. The hardware for the system is usually chosen to make the device as cheap
as possible. Spending an extra dollar a unit in order to make things easier to program can cost millions.
Hiring a programmer for an extra month is cheap in comparison. This means the programmer must make
do with slow processors and low memory, while at the same time battling a need for efficiency not seen
in most PC applications. Below is a list of issues specific to the embedded field.
2.1.1 History:

In the earliest years of computers in the 1930–40s, computers were sometimes dedicated to a single task,
but were far too large and expensive for most kinds of tasks performed by embedded computers of today.
Over time however, the concept of programmable controllers evolved from traditional electromechanical
sequencers, via solid state devices, to the use of computer technology.
One of the first recognizably modern embedded systems was the Apollo Guidance
Computer, developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At the project's
inception, the Apollo guidance computer was considered the riskiest item in the Apollo project as it
employed the then newly developed monolithic integrated circuits to reduce the size and weight. An early
mass-produced embedded system was the Autonetics D-17 guidance computer for the Minuteman missile,
released in 1961. It was built from transistor logic and had a hard disk for main memory. When the
Minuteman II went into production in 1966, the D-17 was replaced with a new computer that was the first
high-volume use of integrated circuits.
2.1.2 Tools:

Embedded development makes up a small fraction of total programming. There's also a large number of
embedded architectures, unlike the PC world where 1 instruction set rules, and the UNIX world where
there's only 3 or 4 major ones. This means that the tools are more expensive. It also means that they're
lowering featured, and less developed. On a major embedded project, at some point you will almost
always find a compiler bug of some sort.
Debugging tools are another issue. Since you can't always run general programs on your embedded
processor, you can't always run a debugger on it. This makes fixing your program difficult. Special
hardware such as JTAG ports can overcome this issue in part. However, if you stop on a breakpoint when
your system is controlling real world hardware (such as a motor), permanent equipment damage can occur.
As a result, people doing embedded programming quickly become masters at using serial IO channels
and error message style debugging.

2.1.3 Resources:

To save costs, embedded systems frequently have the cheapest processors that can do the job. This means
your programs need to be written as efficiently as possible. When dealing with large data sets, issues like
memory cache misses that never matter in PC programming can hurt you. Luckily, this won't happen too
often- use reasonably efficient algorithms to start, and optimize only when necessary. Of course, normal
profilers won't work well, due to the same reason debuggers don't work well.
Memory is also an issue. For the same cost savings reasons, embedded systems usually have the least
memory they can get away with. That means their algorithms must be memory efficient (unlike in PC
programs, you will frequently sacrifice processor time for memory, rather than the reverse). It also means
you can't afford to leak memory. Embedded applications generally use deterministic memory techniques
and avoid the default "new" and "malloc" functions, so that leaks can be found and eliminated more easily.
Other resources programmers expect may not even exist. For example, most embedded processors do not
have hardware FPUs (Floating-Point Processing Unit). These resources either need to be emulated in
software, or avoided altogether.

4
2.1.4 Real Time Issues:

Embedded systems frequently control hardware, and must be able to respond to them in real time.
Failure to do so could cause inaccuracy in measurements, or even damage hardware such as motors.
This is made even more difficult by the lack of resources available. Almost all embedded systems need
to be able to prioritize some tasks over others, and to be able to put off/skip low priority tasks such as
UI in favor of high priority tasks like hardware control.
2.2 Need For Embedded Systems:

The uses of embedded systems are virtually limitless, because every day new products are introduced
to the market that utilizes embedded computers in novel ways. In recent years, hardware such as
microprocessors, microcontrollers, and FPGA chips have become much cheaper. So when implementing
a new form of control, it's wiser to just buy the generic chip and write your own custom software for it.
Producing a custom-made chip to handle a particular task or set of tasks costs far more time and money.
Many embedded computers even come with extensive libraries, so that "writing your own software"
becomes a very trivial task indeed. From an implementation viewpoint, there is a major difference
between a computer and an embedded system. Embedded systems are often required to provide Real-
Time response. The main elements that make embedded systems unique are its reliability and ease in
debugging.

2.2.1 Debugging:

Embedded debugging may be performed at different levels, depending on the facilities available. From
simplest to most sophisticated they can be roughly grouped into the following areas:
• Interactive resident debugging, using the simple shell provided by the embedded operating
system (e.g. Forth and Basic)
• External debugging using logging or serial port output to trace operation using either a monitor
in flash or using a debug server like the Remedy Debugger which even works for heterogeneous
multi core systems.
• An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via a JTAG
or Nexus interface. This allows the operation of the microprocessor to be controlled externally,
but is typically restricted to specific debugging capabilities in the processor.
• An in-circuit emulator replaces the microprocessor with a simulated equivalent, providing full
control over all aspects of the microprocessor.
• A complete emulator provides a simulation of all aspects of the hardware, allowing all of it to be
controlled and modified and allowing debugging on a normal PC.
• Unless restricted to external debugging, the programmer can typically load and run software
through the tools, view the code running in the processor, and start or stop its operation. The
view of the code may be as assembly code or source-code.

Because an embedded system is often composed of a wide variety of elements, the debugging
strategy may vary. For instance, debugging a software(and microprocessor) centric embedded system
is different from debugging an embedded system where most of the processing is performed by
peripherals (DSP, FPGA, co-processor). An increasing number of embedded systems today use more
than one single processor core. A common problem with multi-core development is the proper
synchronization of software execution. In such a case, the embedded system design may wish to check
the data traffic on the busses between the processor cores, which requires very low-level debugging, at
signal/bus level, with a logic analyzer, for instance.

5
2.2.2 Reliability:

Embedded systems often reside in machines that are expected to run continuously for years
without errors and in some cases recover by them if an error occurs. Therefore the software is usually
developed and tested more carefully than that for personal computers, and unreliable mechanical
moving parts such as disk drives, switches or buttons are avoided.
Specific reliability issues may include:
• The system cannot safely be shut down for repair, or it is too inaccessible to repair. Examples include
space systems, undersea cables, navigational beacons, bore-hole systems, and automobiles.
• The system must be kept running for safety reasons. "Limp modes" are less tolerable. Often backup
s is selected by an operator. Examples include aircraft navigation, reactor control systems,
safety-critical chemical factory controls, train signals, engines on single-engine aircraft.
• The system will lose large amounts of money when shut down: Telephone switches, factory
controls, bridge and elevator controls, funds transfer and market making, automated sales and
service.

A variety of techniques are used, sometimes in combination, to recover from errors—


both software bugs such as memory leaks, and also soft errors in the hardware:
• Watchdog timer that resets the computer unless the software periodically notifies the watchdog
• Subsystems with redundant spares that can be switched over to
• software "limp modes" that provide partial function
• Designing with a Trusted Computing Base (TCB) architecture[6] ensures a highly secure & reliable
system environment
• An Embedded Hypervisor is able to provide secure encapsulation for any subsystem component, so
that a compromised software component cannot interfere with other subsystems, or privileged-level
system software. This encapsulation keeps faults from propagating from one subsystem to another,
improving reliability. This may also allow a subsystem to be automatically shut down and restarted
on fault detection.
• Immunity Aware Programming

2.3 Explanation of Embedded Systems:

2.3.1 Software Architecture:

There are several different types of software architecture in common use.

• Simple Control Loop:

In this design, the software simply has a loop. The loop calls subroutines, each of which manages a
part of the hardware or software.
• Interrupt Controlled System:

Some embedded systems are predominantly interrupt controlled. This means that tasks performed
by the system are triggered by different kinds of events. An interrupt could be generated for example
by a timer in a predefined frequency, or by a serial port controller receiving a byte. These kinds of
systems are used if event handlers need low latency and the event handlers are short and simple.

6
Usually these kinds of systems run a simple task in a main loop also, but this task is not very sensitive
to unexpected delays. Sometimes the interrupt handler will add longer tasks to a queue structure.
Later, after the interrupt handler has finished, these tasks are executed by the main loop.
This method brings the system close to a multitasking kernel with discrete processes.

• Cooperative Multitasking:

A non-preemptive multitasking system is very similar to the simple control loop scheme,
except that the loop is hidden in an API. The programmer defines a series of tasks, and each task gets
its own environment to “run” in. When a task is idle, it calls an idle routine, usually called “pause”,
“wait”, “yield”, “nop” (stands for no operation), etc.The advantages and disadvantages are very
similar to the control loop, except that adding new software is easier, by simply writing a new task,
or adding to the queue-interpreter.

• Primitive Multitasking:

In this type of system, a low-level piece of code switches between tasks or threads based on a timer
(connected to an interrupt). This is the level at which the system is generally considered to have an
"operating system" kernel. Depending on how much functionality is required, it introduces more or
less of the complexities of managing multiple tasks running conceptually in parallel.
As any code can potentially damage the data of another task (except in larger systems using an MMU)
programs must be carefully designed and tested, and access to shared data must be controlled by some
synchronization strategy, such as message queues, semaphores or a non-blocking synchronization
scheme.
Because of these complexities, it is common for organizations to buy a real-time operating system,
allowing the application programmers to concentrate on device functionality rather than operating
system services, at least for large systems; smaller systems often cannot afford the overhead
associated with a generic real time system, due to limitations regarding memory size, performance,
and/or battery life.

• Microkernels And Exokernels:

A microkernel is a logical step up from a real-time OS. The usual arrangement is that the operating system
kernel allocates memory and switches the CPU to different threads of execution.
User mode processes implement major functions such as file systems, network interfaces, etc.

In general, microkernels succeed when the task switching and inter task communication is fast, and
fail when they are slow. Exokernels communicate efficiently by normal subroutine calls. The
hardware and all the software in the system are available to, and extensible by application
programmers. Based on performance, functionality, requirement the embedded systems are divided
into three categories:

2.3.2 Stand Alone Embedded System:

These systems takes the input in the form of electrical signals from transducers or commands from
human beings such as pressing of a button etc.., process them and produces desired output. This entire
process of taking input, processing it and giving output is done in standalone mode. Such embedded
systems comes under stand alone embedded systems
Eg: microwave oven, air conditioner etc..

7
2.3.3 Real-time embedded systems:

Embedded systems which are used to perform a specific task or operation in a specific time period
those systems are called as real-time embedded systems. There are two types of real-time embedded
systems.

• Hard Real-time embedded systems:

These embedded systems follow an absolute dead line time period i.e.., if the tasking is not done in a
particular time period then there is a cause of damage to the entire equipment.
Eg: consider a system in which we have to open a valve within 30 milliseconds. If this valve is not
opened in 30 ms this may cause damage to the entire equipment. So in such cases we use embedded
systems for doing automatic operations.

• Soft Real Time embedded systems:

Eg: Consider a TV remote control system, if the remote control takes a few milliseconds
delay it will not cause damage either to the TV or to the remote control. These systems which will
not cause damage when they are not operated at considerable time period those systems comes under
soft real-time embedded systems.

:
2.3.4 Network communication embedded systems
A wide range network interfacing communication is provided by using embedded systems.

• Consider a web camera that is connected to the computer with internet can be used to spread
communication like sending pictures, images, videos etc.., to another computer with internet
connection throughout anywhere in the world.

• Consider a web camera that is connected at the door lock.

Whenever a person comes near the door, it captures the image of a person and sends to the desktop
of your computer which is connected to internet. This gives an alerting message with image on to the
desktop of your computer, and then you can open the door lock just by clicking the mouse.
Fig: 2.2 show the network communications in embedded systems.

Fig 2.2: Network communication embedded systems

8
2.3.5 Different types of processing units:

The central processing unit (c.p.u) can be any one of the following microprocessor, microcontroller, digital
signal processing.
• Among these Microcontroller is of low cost processor and one of the main advantage of
microcontrollers is, the components such as memory, serial communication interfaces, analog to
digital converters etc.., all these are built on a single chip. The numbers of external components that
are connected to it are very less according to the application.

• Microprocessors are more powerful than microcontrollers. They are used in major applications with
a number of tasking requirements. But the microprocessor requires many external components like
memory, serial communication, hard disk, input output ports etc.., so the power consumption is also
very high when compared to microcontrollers.

• Digital signal processing is used mainly for the applications that particularly involved with
processing of signals

2.4 APPLICATIONS OF EMBEDDED SYSTEMS:

2.4.1 Consumer applications:

At home we use a number of embedded systems which include microwave oven, remote control, vcd
players, dvd players, camera etc….

Fig2.3: Automatic coffee makes equipment

:
2.4.2 Office automation

We use systems like fax machine, modem, printer etc…

Fig2.4: Fax machine Fig2.5: Printing machine


9
2.4.3. Industrial automation:

Today a lot of industries are using embedded systems for process control. In industries we design
the embedded systems to perform a specific operation like monitoring temperature, pressure,
humidity ,voltage, current etc.., and basing on these monitored levels we do control other devices,
we can send information to a centralized monitoring station.

Fig2.6: Robot

In critical industries where human presence is avoided there we can use robots which are programmed to
do a specific operation.
2.4.5 Computer networking:

Embedded systems are used as bridges routers etc..

Fig2.7: Computer networking

2.4.6 Tele communications:

Fig2.8: Cell Phone Fig2.9: Web camera

10
CHAPTER 3: HARDWARE DESCRIPTION:

3.1 Introduction:

In this chapter the block diagram of the project and design aspect of independent modules are considered.
Block diagram is shown in fig: 3.1

Fig 3.1: Block diagram of Automatic Tariff Calculation with Wireless Energy Meter

11
The main blocks of this project are:
 Regulated Power Supply.
 Microcontroller.
 Zigbee modules.
 Energy Meter.
 Optocoupler.
 PC
 LCD displays with driver.
 Reset.
 Crystal oscillator.
 LED indicators.

3.2 Micro control

Microcontroller PIC16F72

Introduction:

The PIC16F72 CMOS FLASH-based 8-bit microcontroller is upward compatible with


PIC16C72/72A and PIC16F872devices. It features 200 ns instruction execution, self programming, an ICD,
2 Comparators, 5 channels of 8-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions,
a synchronous serial port that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a
Parallel Slave Port.

• High performance RISC CPU

• Only 35 single word instructions to learn

• All single cycle instructions except for program branches which are two-cycle

• Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle

• 2K x 14 words of Program Memory

128 x 8 bytes of Data Memory (RAM)

• Pin out compatible to the PIC16C72/72A and PIC16F872

• Interrupt capability

• Eight level deep hardware stack

12
• Direct, Indirect and Relative Addressing modes

Peripheral Features

• Timer0: 8-bit timer/counter with 8-bit prescaler

• Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

• Capture, Compare, PWM(CCP) module

- Capture is 16-bit, max resolution is 12.5 ns

- Compare is 16-bit, max resolution is 200 ns

- PWM max resolution is 10-bit

• 8-bit, 5-channel Analog-to-Digital converter

• Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave)

• Heat sink/Source Current: 25 mA

• Brown-out detection circuitry for Brown-out Reset (BOR)

CMOS Technology:

• Low power, high speed CMOS FLASH technology

• Fully static design

• Wide operating voltage range: 2.0V to 5.5V

• Industrial temperature range

• Low power consumption:

- < 0.6 mA typical @ 3V, 4 MHz

- 20 μA typical @ 3V, 32 kHz

- < 1 μA typical standby current

Following are the major blocks of PIC Microcontroller.

Program memory (FLASH) is used for storing a written program.

13
Since memory made in FLASH technology can be programmed and cleared more than once, it makes this
microcontroller suitable for device development.

EEPROM - data memory that needs to be saved when there is no supply.


It is usually used for storing important data that must not be lost if power supply suddenly stops. For
instance, one such data is an assigned temperature in temperature regulators. If during a loss of power
supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus
our device looses on self-reliance.

RAM- Data memory used by a program during its execution

In RAM are stored all inter-results or temporary data during run-time.

PORTS are physical connections between the microcontroller and the outside world.
PIC16F72 has 22 I/O.

FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program.
On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then
it starts counting over again from zero. As we know the exact timing between each two increments of the
timer contents, timer can be used for measuring time which is very useful with some devices.

Crystal oscillator:

The crystal oscillator speed that can be connected to the PIC microcontroller range from DC to
20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be used and the price is very cheap. The
20 MHz crystal oscillator should be connected with about 22pF capacitor. Please refer to my circuit
schematic.

There are 5 input/output ports on PIC microcontroller namely port A, port B, port C, port D and port
E. Each port has different function. Most of them can be used as I/O port.

Clock / instruction cycle

Clock is microcontroller's main starter, and is obtained from an external component called an "oscillator".
If we want to compare a microcontroller with a time clock, our "clock" would then be a ticking sound we
hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock
can run. Also, force used to wind the time clock can be compared to an electrical supply.
Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller
divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks make
up one instruction cycle (also called machine cycle) during which one instruction is executed.

Execution of instruction starts by calling an instruction that is next in string. Instruction is called from
program memory on every Q1 and is written in instruction register on Q4. Decoding and execution of
instruction are done between the next Q1 and Q4 cycles. On the following diagram we can see the

14
relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks
Q1-Q4. Program counter (PC) holds information about the address of the next instruction.

Pipelining

Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are
connected in such a way that in order to make a call, one instruction cycle is needed, and one more is needed
for decoding and execution. However, due to pipelining, each instruction is effectively executed in one
cycle. If instruction causes a change on program counter, and PC doesn't point to the following but to some
other address (which can be the case with jumps or with calling subprograms), two cycles are needed for
executing an instruction. This is so because instruction must be processed again, but this time from the right
address. Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and
executing begins with Q2, Q3 and Q4 clocks.

Pin description

PIC16F72 has a total of 28 pins. It is most frequently found in a DIP28 type of case but can also be found in
SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In Package. SMD is an abbreviation
for Surface Mount Devices suggesting that holes for pins to go through when mounting aren't necessary in
soldering this type of a component.

15
Pins on PIC16F72 microcontroller have the following meaning:

There are 28 pins on PIC16F72. Most of them can be used as an IO pin. Others are already for specific
functions. These are the pin functions.
1. MCLR – to reset the PIC
2. RA0 – port A pin 0
3. RA1 – port A pin 1
4. RA2 – port A pin 2
5. RA3 – port A pin 3
6. RA4 – port A pin 4
7. RA5 – port A pin 5
8. VSS – ground
9. OSC1 – connect to oscillator
10. OSC2 – connect to oscillator
11. RC0 – port C pin 0 VDD – power supply
12. RC1 – port C pin 1
13. RC2 – port C pin 2
14. RC3 – port C pin 3
15. RC4 - port C pin 4
16. RC5 - port C pin 5

16
17. RC6 - port C pin 6
18. RC7 - port C pin 7
19. VSS - ground
20. VDD – power supply
21. RB0 - port B pin 0
22. RB1 - port B pin 1
23. RB2 - port B pin 2
24. RB3 - port B pin 3
25. RB4 - port B pin 4
26. RB5 - port B pin 5
27. RB6 - port B pin 6
28. RB7 - port B pin 7

By utilizing all of this pin so many application can be done such as:
1. LCD – connect to Port B pin.
2. LED – connect to any pin declared as output.
3. Relay and Motor - connect to any pin declared as output.
4. External EEPROM – connect to I2C interface pin – RC3 and RC4 (SCL and SDA)
5. LDR, Potentiometer and sensor – connect to analogue input pin such as RA0.
6. GSM modem dial up modem – connect to RC6 and RC7 – the serial communication interface using
RS232 protocol.

For more detail function for each specific pin please refer to the device datasheet from
Microchip.
Ports

Term "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on
which we can set the desired combination of zeros and ones, or read from them an existing status.
Physically, port is a register inside a microcontroller which is connected by wires to the pins of a
microcontroller. Ports represent physical connection of Central Processing Unit with an outside world.
Microcontroller uses them in order to monitor or control other components or devices. Due to functionality,
some pins have twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port
A and an external input for free-run counter. Selection of one of these two pin functions is done in one of
the configuration registers. An illustration of this is the fifth bit T0CS in OPTION register. By selecting one
of the functions the other one is disabled.

All port pins can be designated as input or output, according to the needs of a device that's being developed.
In order to define a pin as input or output pin, the right combination of zeros and ones must be written in
TRIS register. If the appropriate bit of TRIS register contains logical "1", then that pin is an input pin, and
if the opposite is true, it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA,
and port B has TRISB. Pin direction can be changed during the course of work which is particularly fitting

17
for one-line communication where data flow constantly changes direction. PORTA and PORTB state
registers are located in bank 0, while TRISA and TRISB pin direction registers are located in bank
1.

PORTB and TRISB

PORTB have adjoined 8 pins. The appropriate register for data direction is TRISB. Setting a bit in TRISB
register defines the corresponding port pin as input, and resetting a bit in TRISB register defines the
corresponding port pin as output.

Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to logic one) which can
be activated by resetting the seventh bit RBPU in OPTION register. These 'pull-up' resistors are
automatically being turned off when port pin is configured as an output. When a microcontroller is started,
pull-ups are disabled.

Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status changes from logical
one into logical zero and opposite. Only pins configured as input can cause this interrupt to occur (if any
RB7:RB4 pin is configured as an output, an interrupt won't be generated at the change of status.) This
interrupt option along with internal pull-up resistors makes it easier to solve common problems we find in
practice like for instance that of matrix keyboard. If rows on the keyboard are connected to these pins, each
push on a key will then cause an interrupt. A microcontroller will determine which key is at hand while
processing an interrupt It is not recommended to refer to port B at the same time that interrupt is being
processed.

PORTA and TRISA

PORTA have 5 adjoining pins. The corresponding register for data direction is TRISA at address 85h. Like
with port B, setting a bit in TRISA register defines also the corresponding port pin as input, and clearing a
bit in TRISA register defines the corresponding port pin as output.

It is important to note that PORTA pin RA4 can be input only. On that pin is also situated an external input
for timer TMR0. Whether RA4 will be a standard input or an input for a counter depends on T0CS bit
(TMR0 Clock Source Select bit). This pin enables the timer TMR0 to increment either from internal
oscillator or via external impulses on RA4/T0CKI pin.

18
Example shows how pins 0, 1, 2, 3, and 4 are designated input, and pins 5, 6, and 7 outputs. After this, it is
possible to read the pins RA2, RA3, RA4, and to set logical zero or one to pins RA0 and RA1.

Memory organization

PIC16F72 has two separate memory blocks, one for data and the other for program. EEPROM memory
with GPR and SFR registers in RAM memory make up the data block, while FLASH memory makes up
the program block.

Program memory

Program memory has been carried out in FLASH technology which makes it possible to program a
microcontroller many times before it's installed into a device, and even after its installment if eventual
changes in program or process parameters should occur. The size of program memory is 1024 locations
with 14 bits width where locations zero and four are reserved for reset and interrupt vector.

Data memory

Data memory consists of EEPROM and RAM memories. EEPROM memory consists of 256 eight bit
locations whose contents are not lost during loosing of power supply. EEPROM is not directly addressable,
but is accessed indirectly through EEADR and EEDATA registers. As EEPROM memory usually serves
for storing important parameters (for example, of a given temperature in temperature regulators) , there is
a strict procedure for writing in EEPROM which must be followed in order to avoid accidental writing.
RAM memory for data occupies space on a memory map from location 0x0C to 0x4F which comes to 68
locations. Locations of RAM memory are also called GPR registers which is an abbreviation for General
Purpose Registers. GPR registers can be accessed regardless of which bank is selected at the moment.

19
Applications

PIC16F72 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 PIC16F72 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 products.

3.3 REGULATED POWER SUPPLY:

3.3.1 Introduction:

Power supply is a supply of electrical power. A device or system that supplies electrical or other types of
energy toan output load or group of loads is called a power supply unit or PSU. The term is most commonly
applied to electrical energy supplies, less often to mechanical ones, and rarely to others.

A power supply may include a power distribution system as well as primary or secondary sources of energy
such as

• Conversion of one form of electrical power to another desired form and voltage, typically involving
converting AC line voltage to a well-regulated lower-voltage DC for electronic devices. Low
voltage, low power DC power supply units are commonly integrated with the devices they supply,
such as computers and household electronics.
• Batteries.

• Chemical fuel cells and other forms of energy storage systems.


• Solar power.

• Generators or alternators.

20
3.3.2 Block Diagram:

Fig 3.3.2 Regulated Power Supply

The basic circuit diagram of a regulated power supply (DC O/P) with led connected as load is shown
in fig: 3.3.3.

Fig 3.3.3 Circuit diagram of Regulated Power Supply with Led connection
The components mainly used in above figure are
• 230V AC MAINS

• TRANSFORMER
• BRIDGE RECTIFIER(DIODES)
• CAPACITOR
• VOLTAGE REGULATOR(IC 7805)
• RESISTOR
• LED(LIGHT EMITTING DIODE)
The detailed explanation of each and every component mentioned above is as follows:

21
Step 1: Transformation: The process of transforming energy from one device to another is called
transformation. For transforming energy we use transformers.

Transformers:

A transformer is a device that transfers electrical energy from one circuit to another through inductively
coupled conductors without changing its frequency. A varying current in the first or primary winding creates
a varying magnetic flux in the transformer's core, and thus a varying magnetic field through the secondary
winding. This varying magnetic field induces a varying electromotive force (EMF) or "voltage" in the
secondary winding. This effect is called mutual induction.

If a load is connected to the secondary, an electric current will flow in the secondary winding and electrical
energy will be transferred from the primary circuit through the transformer to the load. This field is made
up from lines of force and has the same shape as a bar magnet.

If the current is increased, the lines of force move outwards from the coil. If the current is reduced, the
lines of force move inwards.

If another coil is placed adjacent to the first coil then, as the field moves out or in, the moving lines of
force will "cut" the turns of the second coil. As it does this, a voltage is induced in the second coil. With
the 50 Hz AC mains supply, this will happen 50 times a second. This is called MUTUAL INDUCTION and
forms the basis of the transformer.

Fig 3.3.4: Step-Down Transformer

The voltage induced in the secondary is determined by the TURNS RATIO.

For example, if the secondary has half the primary turns; the secondary will have half the primary
voltage.

Another example is if the primary has 5000 turns and the secondary has 500 turns, then
the turn’s ratio is 10:1.

If the primary voltage is 240 volts then the secondary voltage will be x 10 smaller = 24 volts.
Assuming a perfect transformer, the power provided by the primary must equal the power taken by a load
on the secondary. If a 24-watt lamp is connected across a 24 volt secondary, then the primary must supply
24 watts.

22
To aid magnetic coupling between primary and secondary, the coils are wound on a metal CORE.
Since the primary would induce power, called EDDY CURRENTS, into this core, the core is
LAMINATED. This means that it is made up from metal sheets insulated from each other. Transformers to
work at higher frequencies have an iron dust core or no core at all.

Note that the transformer only works on AC, which has a constantly changing current and
moving field. DC has a steady current and therefore a steady field and there would be no induction.

Some transformers have an electrostatic screen between primary and secondary. This is to prevent
some types of interference being fed from the equipment down into the mains supply, or in the other
direction. Transformers are sometimes used for IMPEDANCE MATCHING.

We can use the transformers as step up or step down.

Step Up transformer:

In case of step up transformer, primary windings are every less compared to secondary winding.
Because of having more turns secondary winding accepts more energy, and it releases more voltage at the
output side.

Step down transformer:

Incase of step down transformer, Primary winding induces more flux than the secondary winding,
and secondary winding is having less number of turns because of that it accepts less number of flux, and
releases less amount of voltage.

Step 2: Rectification

The process of converting an alternating current to a pulsating direct current is called as rectification. For
rectification purpose we use rectifiers.

Rectifiers:

A rectifier is an electrical device that converts alternating current (AC) to direct current (DC), a process
known as rectification. Rectifiers have many uses including as components of power supplies and as
detectors of radio signals. Rectifiers may be made of solid-state diodes, vacuum tube diodes, mercury arc
valves, and other components.

A device that it can perform the opposite function (converting DC to AC) is known as an
inverter.

When only one diode is used to rectify AC (by blocking the negative or positive portion of the waveform),
the difference between the term diode and the term rectifier is merely one of usage, i.e., the term rectifier
describes a diode that is being used to convert AC to DC. Almost all rectifiers comprise a number of diodes
in a specific arrangement for more efficiently converting AC to DC than is possible with only one diode.
Before the development of silicon semiconductor rectifiers, vacuum tube diodes and copper (I) oxide or
selenium rectifier stacks were used.

23
Bridge full wave rectifier:

The Bridge rectifier circuit is shown in fig:3.8, which converts an ac voltage to dc voltage
using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit
has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite ends
of the bridge. The load resistance is connected between the other two ends of the bridge.

For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance
RL and hence the load current flows through RL.

For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and D3
remain OFF. The conducting diodes D2 and D4 will be in series with the load resistance R L and hence the
current flows through RL in the same direction as in the previous half cycle. Thus a bi-directional wave is
converted into a unidirectional wave.

Input Output

Fig 3.3.5: Bridge rectifier: a full-wave rectifier using 4 diodes

DB107:

Now -a -days Bridge rectifier is available in IC with a number of DB107. In our project we are using an
IC in place of bridge rectifier. The picture of DB 107 is shown in fig: 3.3.6.

Features:

• Good for automation insertion


• Surge overload rating - 30 amperes peak
• Ideal for printed circuit board
• Reliable low cost construction utilizing molded
• Glass passivated device
• Polarity symbols molded on body

24
• Mounting position: Any
• Weight: 1.0 gram

Fig 3.3.6: DB107

Step 3: Filtration

The process of converting a pulsating direct current to a pure direct current using filters is called as
filtration.

Filters:

Electronic filters are electronic circuits, which perform signal-processing functions, specifically to
remove unwanted frequency components from the signal, to enhance wanted ones.

Introduction to Capacitors:

The Capacitor or sometimes referred to as a Condenser is a passive device, and one which
stores energy in the form of an electrostatic field which produces a potential (static voltage) across its plates.
In its basic form a capacitor consists of two parallel conductive plates that are not connected but are
electrically separated either by air or by an insulating material called the Dielectric. When a voltage is
applied to these plates, a current flows charging up the plates with electrons giving one plate a positive
charge and the other plate an equal and opposite negative charge this flow of electrons to the plates is known
as the Charging Current and continues to flow until the voltage across the plates (and hence the capacitor)
is equal to the applied voltage Vcc. At this point the capacitor is said to be fully charged and this is illustrated
below. The construction of capacitor and an electrolytic capacitor are shown in figures 3.10 and 3.11
respectively.

Fig 3.3.7:Construction Of a Capacitor Fig 3.3.8:Electrolytic

25
Capaticor Units of Capacitance:
Microfarad (μF) 1μF = 1/1,000,000 = 0.000001 = 10-6 F

Nanofarad (nF) 1nF = 1/1,000,000,000 = 0.000000001 = 10-9 F Pico


farad (pF) 1pF = 1/1,000,000,000,000 = 0.000000000001 = 10-12 F
Operation of Capacitor:
Think of water flowing through a pipe. If we imagine a capacitor as being a storage tank
with an inlet and an outlet pipe, it is possible to show approximately how an electronic capacitor works.

First, let's consider the case of a "coupling capacitor" where the capacitor is used to
connect a signal from one part of a circuit to another but without allowing any direct current to flow.

If the current flow is alternating between zero and a maximum,


our
"storage tank" capacitor will allow the current waves to pass
through.

However, if there is a steady current, only the initial short burst will
flow until the "floating ball valve" closes and stops further flow.

So a coupling capacitor allows "alternating current" to pass through because the ball valve doesn't get a
chance to close as the waves go up and down. However, a steady current quickly fills the tank so that all
flow stops.

A capacitor will pass alternating current but (apart from an initial surge) it will not pass d.c.

Where a capacitor is used to decouple a circuit, the effect is to


"smooth out ripples". Any ripples, waves or pulses of current are
passed to ground while d.c. Flows smoothly.

Step 4: Regulation

The process of converting a varying voltage to a constant regulated voltage is called as regulation. For the
process of regulation we use voltage regulators.

26
Voltage Regulator:

A voltage regulator (also called a ‘regulator’) with only three terminals appears to be a simple device, but
it is in fact a very complex integrated circuit. It converts a varying input voltage into a constant ‘regulated’
output voltage. Voltage Regulators are available in a variety of outputs like 5V, 6V, 9V, 12V and 15V. The
LM78XX series of voltage regulators are designed for positive input. For applications requiring negative
input, the LM79XX series is used. Using a pair of ‘voltage-divider’ resistors can increase the output voltage
of a regulator circuit.

It is not possible to obtain a voltage lower than the stated rating. You cannot use a 12V regulator to
make a 5V power supply. Voltage regulators are very robust. These can withstand overcurrent draw due to
short circuits and also over-heating. In both cases, the regulator will cut off before any damage occurs. The
only way to destroy a regulator is to apply reverse voltage to its input. Reverse polarity destroys the
regulator almost instantly. Fig: 3.3.11 shows voltage regulator.

Fig 3.3.9: Voltage Regulator

Resistors:

A resistor is a two-terminal electronic component that produces a voltage across its terminals that
is proportional to the electric current passing through it in accordance with Ohm's law:

V = IR

Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most
electronic equipment. Practical resistors can be made of various compounds and films, as well as resistance
wire (wire made of a high-resistivity alloy, such as nickel/chrome).

The primary characteristics of a resistor are the resistance, the tolerance, maximum working voltage
and the power rating. Other characteristics include temperature coefficient, noise, and inductance. Less
well-known is critical resistance, the value below which power dissipation limits the maximum permitted
current flow, and above which the limit is applied voltage. Critical resistance is determined by the design,
materials and dimensions of the resistor.

27
Resistors can be made to control the flow of current, to work as Voltage dividers, to dissipate power and
it can shape electrical waves when used in combination of other components. Basic unit is ohms.

Theory of operation:

Ohm's law:

The behavior of an ideal resistor is dictated by the relationship specified in Ohm's law:

V = IR

Ohm's law states that the voltage (V) across a resistor is proportional to the current (I) through it where
the constant of proportionality is the resistance (R).

Power dissipation:

The power dissipated by a resistor (or the equivalent resistance of a resistor network) is calculated using
the following:

Fig 3.3.10: Resistor Fig 3.3.11: Color Bands In Resistor

3.4. LED:

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many
devices, and are increasingly used for lighting. Introduced as a practical electronic component in 1962,
early LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet
and infrared wavelengths, with very high brightness. The internal structure and parts of a led are shown
below.

28
Fig 3.4.1: Inside a LED Fig 3.4.2: Parts of a LED

Working:

The structure of the LED light is completely different than that of the light bulb. Amazingly, the LED has
a simple and strong structure. The light-emitting semiconductor material is what determines the LED's
color. The LED is based on the semiconductor diode.

When a diode is forward biased (switched on), electrons are able to recombine with holes
within the device, releasing energy in the form of photons. This effect is called electroluminescence
and the color of the light (corresponding to the energy of the photon) is determined by the energy gap
of the semiconductor. An LED is usually small in area (less than 1 mm2), and integrated optical
components are used to shape its radiation pattern and assist in reflection. LEDs present many
advantages over incandescent light sources including lower energy consumption, longer lifetime,
improved robustness, smaller size, faster switching, and greater durability and reliability. However,
they are relatively expensive and require more precise current and heat management than traditional
light sources. Current LED products for general lighting are more expensive to buy than fluorescent
lamp sources of comparable output. They also enjoy use in applications as diverse as replacements
for traditional light sources in automotive lighting (particularly indicators) and in traffic signals. The
compact size of LEDs has allowed new text and video displays and sensors to be developed, while
their high switching rates are useful in advanced communications technology. The electrical symbol
and polarities of led are shown in fig: 3.4.3.

Fig 3.4.3 Electrical Symbol &Polarities of LED

29
LED lights have a variety of advantages over other light sources:

• High-levels of brightness and intensity


• High-efficiency
• Low-voltage and current requirements
• Low radiated heat
• High reliability (resistant to shock and vibration)
• No UV Rays
• Long source life
• Can be easily controlled and programmed

Applications of LED fall into three major categories:

• Visual signal application where the light goes more or less directly from the LED to the human eye,
to convey a message or meaning.
• Illumination where LED light is reflected from object to give visual response of these objects.
• Generate light for measuring and interacting with processes that do not involve the human visual
system.

3.5 ENERGY METER:

An electric meter or energy meter is a device that measures the amount of electrical energy consumed by
a residence, business, or an electrically-powered device.

Electric meters are typically calibrated in billing units, the most common one being the kilowatt hour.
Periodic readings of electric meters establish billing cycles and energy used during a cycle.

In settings when energy savings during certain periods are desired, meters may measure demand, the
maximum use of power in some interval. In some areas, the electric rates are higher during certain times of
day, to encourage reduction in use. Also, in some areas meters have relays to turn off nonessential
equipment

There are two types of energy meters are available in market one is the conventional energy meter, which
works on the principle of mutual induction. This meter has rotating aluminum wheel that is called free
wheel but this meter has so much energy losses. The second one is the electronics digital energy meter,
which one is we are using here and is interfaced with the microcontroller. This meter has no moving parts
and has low energy losses.

30
How to Connect Energy Meter:
First user need to buy an Analogue Electricity Energy Meter. After it user needs to open it and find
the Pulse LED or Cal LED’s terminals (cathode and Anode). Now solder two wires at both the
terminals and take it out from the energy meter and then close energy meter and tight the screws.

Now user needs to connect anode terminal of LED at pin number 1 of Optocoupler and cathode terminal
to pin 2. Pin number 4 of optocouper should be directly connected to ground. A LED and a Pullup resistor
are connected at pin number 5 of optocoupler. And same terminal should go to the PIC
MICROCONTROLLER pin A4 too.

Before proceeding for the calculations, first we have to keep in mind the pulse rate of energy meter.
There are two pulse rates of energy meter first is 1600 imp/kwh and second is 3200 imp/kwh. So here
we are using 3200 imp/kwh pulse rate energy meter.
So first we need to calculate the Pulses for 100watt, means how many times Pulse LED will blink in
a minute, for the load of 100 watts.

Pulse= (Pluse_rate*watt*time)/ (1000*3600)


So pulses for 100 watt bulb in 60 seconds, with energy meter of 3200 imp/kwh pulse rate can be calculated
as below:

Pulses=3200*100*60/1000*3600

Pulses = ~5.33 pulse per minute

Now we need to calculate Power factor of a single pulse, means how much electricity will be consumed
in one pulse:

PF= watt/(hour*Pulse)

PF=100/60*5.33

PF=0.3125 watt in a single pulse

Units= PF*Total pulse/1000

Total pulses in an hour is around 5.33*60=320

Units = 0.3125*320/1000

Units = 0.1 per hour

If a 100 watt bulb is lighting for a day then it will consume

Units =0.1*24

Units = 2.4 Units

And suppose unit rate is at your region is 5 rupees per unit then

You have to pay for 2.4 Units Rs:

Rupees= 2.4*5 = 12 rupees

31
3.6: OPTOCOUPLER:

An optocoupler-isolated power supply is often the safest and most practical way to
go when it comes to performance and protection. Here’s the basic on today’s LED/photo detector
isolators and what you need to know to apply them to your system. The junior system designer often
places the system’s power requirements at the end of the list, and thus overlooks the importance of
an isolated, versus non-isolated AC/AC, AC/DC, DC/AC, or DC/DC converter. True isolation
(transformer at the input, optoisolator in the supply’s feedback control loops) virtually removes any
direct conductive path between the power supply’s input stage and its output terminals/load. That’s
especially important in the high-power density applications that are becoming more the rule than the
exception, and for more demanding system requirements
That often place power supplies in explosive or otherwise hazardous environments.

The use of an optocoupler also acts to break ground loops, and this functionality is
valuable in eliminating common-mode noise, especially for systems working at the higher operating
voltages. When different power supplies in a system are tied together, ground loop currents tend to be
induced due to slight differences in ground potential.
In addition, power supplies tend to see transient noise in equipment that switches
between various power states (today’s optocouplers are able to withstand up to 40 kV/microsecond
transient common-mode voltage). Typical optocouplers for performing this so-called galvanic
isolation function—in essence to connect intrinsically safe circuitry to circuits that pose a safety
risk—comprise an LED, a photo detector, and appropriate connecting circuitry in the supply’s
outputto-input feedback Loop. In general circuit operation, the optocoupler, driven by the supply’s
PWM, serves as the link to maintain the supply’s desired output voltage When the output voltage
deviates either due to line and/or load changes, the supply’s error amplifier attempts to compensate.
It compares its input with a reference voltage, and the error signal thus controls the output of the
PWM.
In turn, the PWM directs the primary- side Power
MOSFET's via the optocoupler.

The standards

Regulatory agencies such as UL in the United States, CENELEC in Europe, CSA in


Canada, and TIIS in Japan, set the power level needed to make circuitry intrinsically safe. In essence,
the standards set the requirements for the galvanic isolation barrier between the “safe” circuitry and
the outside world. For best results, choose optocouplers with additional reinforced insulation as
suggested by IEC EN-60747- 5-2. Reinforced insulation ensures protection from electric shock as
well as provides a failsafe mode. Fail-safe techniques terminate system operation and leaves system
processes and components in a secure state when a failure occurs.

32
The input-voltage level usually defines the insulation voltage rating, which typically
ranges from 500 volts for some telecom applications to 3500 volts for universal line-voltage
capability. The regulations you need to know about, and the specs you should study, include
IEC60950, EN55022, and IEC 61000. IEC 61000 in particular covers electromagnetic compatibility
(EMC), and part 4 of that document (IEC61000- 4-4) covers fast transient/burst Electrical Fast
Transient (EFT) testing discussed in part 4.4 addresses interference simulated in inductively loaded
switches. In this standard, the modules will be subjected to the following test levels, depending on
the designed environment: Level 1 (Well protected); Level 2 (Protected); Level 3 (Typical Industrial
Environment); and Level 4 (Severe Industrial Environment), where test voltage peaks at the power
supply ports are 0.5 kV (5kHz repetition rate), 1 kV (5kHz), 2 kV (5kHz), and 4 kV (2.5kHz),
respectively.

Simple Remote Reset Power On/Off:


This is a simple schematicfor aremote reset/power on/off device
to use for controlling up to 4 lines via the parallel port.
Depending on the number of lines you require, the opto coupler
will be PC817, PC827 or PC847.

Or you could use the following schematic to drive up to 8 lines,


with the drawback that a reboot of the controlling machine will
probably reboot all your attached devices...

Applications

1. Computer terminals
2. System appliances, measuring instruments
3. Registers, copiers, automatic vending machines
4. Electric home appliances, such as fan heaters, etc.
5. Signal transmission between circuits of different potentials and impedances

33
3.7 HC-12 ZigBee technology
The HC-12 is a half-duplex wireless serial communication module with 100 channels in the 433.4-
473.0 MHz range that is capable of transmitting up to 1 km. This project will begin by using the HC-
12 to create a wireless link between two computers and end with a second article that creates a simple
wireless GPS tracker.

Fig 3.7 ZigBee module

Module Parameter Setting AT Command

AT command is used to set the module parameters and switch the module functions, and after setting, it
will be valid only after exiting from setting state. Meanwhile, modification of parameters and functions will
not be lost in case of power failure.

(1) Command mode entering

The first way to enter: in normal use (energized), put Pin 5 “SET” in low level;

The second way to enter: disconnect power supply, first put Pin 5 “Set” in low level, and then energize
it;
Either of the above two ways can make the module enter AT command mode; release it (not put pin
“SET” in low level), and exit from the command mode. If the module function is changed after
exiting from command mode, it will be switched to corresponding functional status.
In the second way, the module enters AT in the serial port format of 9,600, N, 1 constantly.

(2) Command instruction


AT

Test command.

e.g.:

Send “AT” command to module, and the module returns “OK”.

34
AT+Bxxxx

Change the serial port baud rate. The baud rate can be set to be 1,200bps, 2,400bps, 4,800bps, 9,600bps,
19,200bps, 38,400bps, 57,600bps, and 115,200bps. The default value is 9,600bps.
e.g.: To set serial port baud rate of module to be 19,200bps, first send “AT+B19200” command to
module, and the module returns “OK+B19200”.
AT+Cxxxx

Change wireless communication channel, optional from 001 to 127 (for the wireless channel
exceeding 100, the communication distance cannot be ensured). The default value of wireless
channel is 001, and the working frequency is 433.4MHz. The channel stepping is 400KHz, and
the working frequency of Channel 100 is 473.0MHz.
e.g.:

To set the module to work at Channel 21, first send “AT+C021” command to the module, and the module
returns “COK+C021”. After exiting from the command mode, the module will work at Channel 21, and
the working frequency is 441.4MHz.
Note: As the wireless receiving sensitivity of HC-12 module is relatively high, when the serial port
baud rate is greater than 9,600bps, five adjacent channels shall be staggered to use. When the serial
port baud rate is not greater than 9,600bps, in short-distance (within 10m) communication, also five
adjacent channels shall be staggered to use.
AT+FUx

Change serial port transparent transmission mode of module and three modes are available, namely,
FU1, FU2 and FU3. The default mode of module is FU3, and only when serial port transparent
transmission mode of two modules is set to be the same, can normal communication be available.
For detailed introduction, please see the above “wireless serial port transparent transmission”. e.g.:

Example 1:

Send “AT+RB” to module, and if the module returns “OK+B9600”, it is inquired that the serial port
baud rate of module is 9,600bps.
Example 2:

Send “AT+RC” command to module, and if the module returns “OK+RC001”, it is inquired that the
communication channel of module is 001.
Example 3:

Send “AT+RF” command to module, and if the module returns “OK+FU3”, it is inquired that the
module is working in serial port transparent transmission mode 3. Example 4:
Send “AT+RP” command to module, and if the module returns “OK+RP: +20dBm”, it is inquired that
the transmitting power of module is +20dBm.
AT+RX

Obtain all parameters of module. Return serial port transparent transmission mode, serial port baud rate,
communication channel, and transmitting power in order. e.g.:
Send “AT+RX” command to module, and the module returns “OK+FU3\r\n OK+B9600\r\n
OK+C001\r\n OK+RP: +20dBm\r\n”. (“\r\n” means return\newline)

35
AT+Uxxx

Set data bits, check bit and stop bit of serial port communication. For check bit, N means no check,
O means odd check, and E means even check. For stop bit, 1 means one stop bit, 2 means two stop
bits, and 3 means 1.5 stop bits. e.g.:
To send serial port format to be eight data bits, odd check, and one stop bit, please Send “AT+U8O1”
to module, and the module returns “OK+U8O1”.
AT+V
Inquire firmware version information of module. e.g.:
Send “AT+V” command to module, and the module returns “HC-12_V1.1”.

AT+SLEEP

After receiving the command, the module enters sleep mode after exiting from AT, the
working current is about 22μA, and this mode doesn’t allow serial port data transmission. Then enter AT
setting state again, and the module will exit from sleep
mode automatically.
e.g.:
When wireless data transmission is not needed, to save power, send “AT+SLEEP” command to module,
and the module returns “OK+SLEEP”.

AT+DEFAULT
Set serial port baud rate, communication channel, and serial port transparent transmission mode to
be default value.
e.g.:
Send “AT+DEFAULT” to module, and the module returns “OK+DEFAULT”, and the default vale is
restored. The serial port baud rate is 9,600bps, communication channel is C001, and serial port
transparent transmission mode is FU3.

AT+UPDATE
Put the module in the status of waiting for software update.
After sending the command, the module will not respond to command any more, until it is reenergized.
After sending the command, please close the serial port assistant, and turn on HC-1X updater to
update the software. For detailed operating method, please refer to the following “software update”
introduction.

36
3.8 LCD display:

LCD DISPLAY

LCD Background:

One of the most common devices attached to a micro controller is an LCD display. Some of the most
common LCD’s connected to the many microcontrollers are 16x2 and 20x2 displays. This means 16
characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

Basic 16x 2 Characters LCD

Figure 3.8.1: LCD Pin diagram

Pin description:
Pin No. Name Description

Pin no. 1 VSS Power supply (GND)

Pin no. 2 VCC Power supply (+5V)


VEE
Pin no. 3 Contrast adjust

RS 0 = Instruction input
Pin no. 4
1 = Data input
Pin no. 5 0 = Write to LCD module
1 = Read from LCD module
R/W
Pin no. 6 EN Enable signal

37
Pin no. 7 D0 Data bus line 0 (LSB)

Pin no. 8 D1 Data bus line 1

Pin no. 9 D2 Data bus line 2


D3
Pin no. 10 Data bus line 3
D4
Pin no. 11 Data bus line 4
D5
Pin no. 12 Data bus line 5
D6
Pin no. 13 Data bus line 6
D7
Pin no. 14 Data bus line 7 (MSB)

Table 1: Character LCD pins with Microcontroller

The LCD requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select
whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD
will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is
used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).

The three control lines are referred to as EN, RS, and RW.

The EN line is called "Enable." This control line is used to tell the LCD that we are sending it data. To send
data to the LCD, our program should make sure this line is low (0) and then set the other two control lines
and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for
the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by
bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command
or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent
is text data which should be displayed on the screen. For example, to display the letter "T" on the screen
we would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus
is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the
LCD.

Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will
almost always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6,
and DB7.

38
Schematic:

Circuit Description:

Above is the quite simple schematic. The LCD panel's Enable and Register Select is connected to
the Control Port. The Control Port is an open collector / open drain output. While most Parallel Ports have
internal pull-up resistors, there is a few which don't. Therefore by incorporating the two 10K external pull
up resistors, the circuit is more portable for a wider range of computers, some of which may have no internal
pull up resistors.

We make no effort to place the Data bus into reverse direction. Therefore we hard wire the R/W
line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a result we
cannot read back the LCD's internal Busy Flag which tells us if the LCD has accepted and finished
processing the last instruction. This problem is overcome by inserting known delays into our program.

The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy here. As with all the
examples, I've left the power supply out. We can use a bench power supply set to 5v or use an onboard +5
regulator. Remember a few de-coupling capacitors, especially if we have trouble with the circuit working
properly.

SETB RW

Handling the EN control line:

As we mentioned above, the EN line is used to tell the LCD that we are ready for it to execute an
instruction that we've prepared on the data bus and on the other control lines. Note that the EN line must
be raised/ lowered before/after each instruction sent to the LCD regardless of whether that instruction is
read or write text or instruction. In short, we must always manipulate EN when communicating with the
LCD. EN is the LCD's way of knowing that we are talking to it. If we don't raise/lower EN, the LCD doesn't
know we're talking to it on the other lines.

Thus, before we interact in any way with the LCD we will always bring the EN line low with the
following instruction:

CLR EN

And once we've finished setting up our instruction with the other control lines and data bus lines, we'll
always bring this line high: SETB EN

39
The line must be left high for the amount of time required by the LCD as specified in its datasheet.
This is normally on the order of about 250 nanoseconds, but checks the datasheet. In the case of a typical
microcontroller running at 12 MHz, an instruction requires 1.08 microseconds to execute so the EN line
can be brought low the very next instruction. However, faster microcontrollers (such as the DS89C420
which executes an instruction in 90 nanoseconds given an 11.0592 MHz crystal) will require a number of
NOPs to create a delay while EN is held high. The number of NOPs that must be inserted depends on the
microcontroller we are using and the crystal we have selected.

The instruction is executed by the LCD at the moment the EN line is brought low with a final CLR
EN instruction.

Checking the busy status of the LCD:

As previously mentioned, it takes a certain amount of time for each instruction to be executed by
the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator input of the
LCD as well as the instruction which is being executed.

While it is possible to write code that waits for a specific amount of time to allow the LCD to execute
instructions, this method of "waiting" is not very flexible. If the crystal frequency is changed, the software
will need to be modified. A more robust method of programming is to use the "Get LCD Status" command
to determine whether the LCD is still busy executing the last instruction received.

The "Get LCD Status" command will return to us two tidbits of information; the information that is
useful to us right now is found in DB7. In summary, when we issue the "Get LCD Status" command the
LCD will immediately raise DB7 if it's still busy executing a command or lower DB7 to indicate that the
LCD is no longer occupied. Thus our program can query the LCD until DB7 goes low, indicating the LCD
is no longer busy. At that point we are free to continue and send the next command.

3.9 USBTTL:
USB-TTL Converter:

Fig 3.9: USB-TTL


 The CP2102 is a highly-integrated USB-to-UART Bridge Controller providing a simple solution
for updating RS-232 designs to USB using a minimum of components and PCB space. The CP2102
includes a USB 2.0 full-speed function controller, USB transceiver, oscillator, EEPROM, and
asynchronous serial data bus (UART) with full modem control signals in a compact 5 x 5 mm
MLP28 package. No other external USB components are required.
 Feature
 Single-Chip USB to UART Data Transfer
 Integrated USB transceiver; no external resistors required
 Integrated clock; no external crystal required

40
 Integrated 1024-Byte EEPROM for vendor ID, product ID, serial number, power descriptor, release
number, and product description strings
 On-chip power-on reset circuit
 On-chip voltage regulator: 3.3 V output
 100% pin and software compatible with CP2101
USB Function Controller
USB Specification 2.0 compliant; full-speed (12 Mbps)
USB suspend states supported via SUSPEND pins Virtual
Windows 98 SE/2000/XP
MAC OS-9
MAC OS-X
Linux 2.40 and greater
USBXpress™ Direct Driver Support
Supply Voltage
Self-powered: 3.0 to 3.6 V
USB bus powered: 4.0 to 5.25 V

41
CHAPTER 4: SOFTWARE DESCRIPTION

This project is implemented using following software’s:


• Express PCB – for designing circuit
• PIC C compiler - for compilation part Proteus 7 (Embedded C) – for
simulation part

4.1 Express PCB:

Breadboards are great for prototyping equipment as it allows great flexibility to modify a design when
needed; however the final product of a project, ideally should have a neat PCB, few cables, and survive a
shake test. Not only is a proper PCB neater but it is also more durable as there are no cables which can
yank loose.

Express PCB is a software tool to design PCBs specifically for manufacture by the company
Express PCB (no other PCB maker accepts Express PCB files). It is very easy to use, but it does have
several limitations.

It can be likened to more of a toy then a professional CAD program.

It has a poor part library (which we can work around)

It cannot import or export files in different formats

It cannot be used to make prepare boards for DIY production

Express PCB has been used to design many PCBs (some layered and with surface-mount parts. Print
out PCB patterns and use the toner transfer method with an Etch Resistant Pen to make boards. However,
Express PCB does not have a nice print layout. Here is the procedure to design in Express PCB and clean
up the patterns so they print nicely.

4.1.1 Preparing Express PCB for First Use:

Express PCB comes with a less then exciting list of parts. So before any project is started head over
to Audio logic and grab the additional parts by morsel, ppl, and tangent, and extract them into your Express
PCB directory. At this point start the program and get ready to setup the workspace to suit your style.

Click View -> Options. In this menu, setup the units for “mm” or “in” depending on how you
think, and click “see through the top copper layer” at the bottom. The standard color scheme of red and
green is generally used but it is not as pleasing as red and blue.

4.1.2 The Interface:

When a project is first started you will be greeted with a yellow outline. This yellow outline is
the dimension of the PCB. Typically after positioning of parts and traces, move them to their final position
and then crop the PCB to the correct size. However, in designing a board with a certain size constraint, crop
the PCB to the correct size before starting.

Fig: 4.1 show the toolbar in which the each button has the following functions:

42
Fig 4.1: Tool bar necessary for the interface

• The select tool: It is fairly obvious what this does. It allows you to move and manipulate parts.
When this tool is selected the top toolbar will show buttons to move traces to the top / bottom copper
layer, and rotate buttons.
• The zoom to selection tool: does just that.
• The place pad: button allows you to place small soldier pads which are useful for board connections
or if a part is not in the part library but the part dimensions are available. When this tool is selected
the top toolbar will give you a large selection of round holes, square holes and surface mount pads.
• The place component: tool allows you to select a component from the top toolbar and then by
clicking in the workspace places that component in the orientation chosen using the buttons next to
the component list. The components can always be rotated afterwards with the select tool if the
orientation is wrong.
• The place trace: tool allows you to place a solid trace on the board of varying thicknesses. The top
toolbar allows you to select the top or bottom layer to place the trace on.
• The Insert Corner in trace: button does exactly what it says. When this tool is selected, clicking on
a trace will insert a corner which can be moved to route around components and other traces.
• The remove a trace button is not very important since the delete key will achieve the same result.

4.1.3 Design Considerations:

Before starting a project there are several ways to design a PCB and one must be chosen to suit the project’s
needs.

Single sided, or double sided:

When making a PCB you have the option of making a single sided board, or a double sided board. Single
sided boards are cheaper to produce and easier to etch, but much harder to design for large projects. If a
lot of parts are being used in a small space it may be difficult to make a single sided board without
jumpering over traces with a cable. While there’s technically nothing wrong with this, it should be
avoided if the signal traveling over the traces is sensitive (e.g. audio signals).

A double sided board is more expensive to produce professionally, more difficult to etch on a DIY board,
but makes the layout of components a lot smaller and easier. It should be noted that if a trace is running
on the top layer, check with the components to make sure you can get to its pins with a soldering iron.

Large capacitors, relays, and similar parts which don’t have axial leads can NOT have traces on top unless
boards are plated professionally.

Ground-plane or other special purposes for one side:

When using a double sided board you must consider which traces should be on what side of
the board. Generally, put power traces on the top of the board, jumping only to the bottom if a part cannot
be soldiered onto the top plane (like a relay), and vice- versa.

43
Some projects like power supplies or amps can benefit from having a solid plane to use for ground. In
power supplies this can reduce noise, and in amps it minimizes the distance between parts and their
ground connections, and keeps the ground signal as simple as possible. However, care must be taken with
stubborn chips such as the TPA6120 amplifier from TI. The TPA6120 datasheet specifies not to run a
ground plane under the pins or signal traces of this chip as the capacitance generated could effect
performance negatively.

4.2 PIC Compiler:

PIC compiler is software used where the machine language code is written and compiled. After
compilation, the machine source code is converted into hex code which is to be dumped into the
microcontroller for further processing. PIC compiler also supports C language code.
It’s important that you know C language for microcontroller which is commonly known as
Embedded C. As we are going to use PIC Compiler, hence we also call it PIC C. The PCB, PCM, and
PCH are separate compilers. PCB is for 12-bit opcodes, PCM is for 14-bitopcodes, and PCH is for
16-bit opcode PIC microcontrollers. Due to many similarities, all three compilers are covered in this
reference manual. Features and limitations that apply to only specific microcontrollers are indicated
within. These compilers are specifically designed to meet the unique needs of the PIC
microcontroller. This allows developers to quickly design applications software in a more readable,
high-level language. When compared to a more traditional C compiler, PCB, PCM, and PCH have
some limitations. As an example of the limitations, function recursion is not allowed.
This is due to the fact that the PIC has no stack to push variables onto, and also
because of the way the compilers optimize the code. The compilers can efficiently implement normal
C constructs, input/output operations, and bit twiddling operations. All normal C data types are
supported along with pointers to constant arrays, fixed point decimal, and arrays of bits.
PIC C is not much different from a normal C program. If you know assembly, writing
a C program is not a crisis. In PIC, we will have a main function, in which all your application specific
work will be defined. In case of embedded C, you do not have any operating system running in there.
So you have to make sure that your program or main file should never exit. This can be done with
the help of simple while (1) or for (;;) loop as they are going to run infinitely.

We have to add header file for controller you are using, otherwise you will not be able to
access registers related to peripherals.

#include <16F72.h> // header file for PIC 16F72//

4.3 Procedural steps for compilation, simulation and dumping:

4.4.1 Compilation and simulation steps:

For PIC microcontroller, PIC C compiler is used for compilation. The compilation steps are as follows:

• Open PIC C compiler.


• You will be prompted to choose a name for the new project, so create a separate folder where all
the files of your project will be stored, choose a name and click save.

44
Fig 4.1: Picture of opening a new file using PIC C compiler

• Click Project, New, and something the box named 'Text1' is where your code should be written
later.
• Now you have to click 'File, Save as' and choose a file name for your source code ending with the
letter '.c'. You can name as 'project.c' for example and click save. Then you have to add this file to
your project work.

Fig 4.2: Picture of compiling a new file using PIC C compiler

45
Fig 4.3: Picture of compiling a project.c file using PIC C compiler

• You can then start to write the source code in the window titled 'project.c' then before testing your
source code; you have to compile your source code, and correct eventual syntax errors.

Fig 4.4: Picture of checking errors and warnings using PIC C compiler
46
• By clicking on compile option .hex file is generated automatically.
• This is how we compile a program for checking errors and hence the compiled program is saved in
the file where we initiated the program.

Fig 4.5: Picture of .hex file existing using PIC C compiler

After compilation, next step is simulation. Here first circuit is designed in Express PCB using Proteus
7 software and then simulation takes place followed by dumping. The simulation steps are as follows:

• Open Proteus 7 and click on IS1S6.


• Now it displays PCB where circuit is designed using microcontroller. To design circuit components
are required. So click on component option.
10. Now click on letter ’p’, then under that select PIC16F73 ,other components related to the project
and click OK. The PIC 16F73 will be called your “'Target device”, which is the final destination of
your source code.

47
4.4.2 Dumping steps:
The steps involved in dumping the program edited in proteus 7 to microcontroller are shown
below:

1. Initially before connecting the program dumper to the microcontroller kit the window is appeared as
shown below.

Fig 4.6: Picture of program dumper window

48
2. Select Tools option and click on Check Communication for establishing a connection as shown in below
window

Fig 4.7: Picture of checking communications before dumping program into microcontroller

49
3. After connecting the dumper properly to the microcontroller kit the window is appeared as shown
below.

Fig 4.8: Picture after connecting the dumper to microcontroller

50
4. Again by selecting the Tools option and clicking on Check Communication the microcontroller gets
recognized by the dumper and hence the window is as shown below.

Fig 4.9: Picture of dumper recognition to microcontroller

51
5. Import the program which is ‘.hex’ file from the saved location by selecting File option and clicking on
‘Import Hex’ as shown in below window.

Fig 4.10: Picture of program importing into the microcontroller

6. After clicking on ‘Import Hex’ option we need to browse the location of our program and click the
‘prog.hex’ and click on ‘open’ for dumping the program into the microcontroller.

52
7. After the successful dumping of program the window is as shown below.

Fig 4.11: Picture after program dumped into the microcontroller

53
CHAPTER 5: PROJECT DESCRIPTION

In this chapter, schematic diagram and interfacing of PIC16F72 microcontroller with each
module is considered.

Fig 5.1(i): schematic diagram of Automatic Tariff Calculation with Wireless Energy Meter

Fig 5.1(ii): schematic diagram of Receiver section of Automatic Tariff Calculation


with Wireless Energy Meter

The above schematic diagram of Automatic Tariff Calculation with Wireless Energy
Meter explains the interfacing section of each component with micro controller and energy meter
module. The crystal oscillator connected to 9th and 10th pins of micro controller and regulated power
supply is also connected to micro controller and LEDs also connected to micro controller through
resistors and motor driver connected to micro controller

54
CHAPTER 6: ADVANTAGES AND DISADVANTAGES

Advantages:

 Energy consumption can be monitored on LCD display and PC.

 Using zigbee wireless technology.

 Efficient and low cost design.

 Low power consumption.

 Fast and accurate result.

 Improved fraud detection.

 Smart automated processes instead of manual work.

Disadvantages:

 Interfacing energy meter to the Micro controller is sensitive.

Applications:

 1) These solutions require a much smaller staff of meter readers, who merely need to walk or
drive.

 2) Ability to monitor daily demand, implement conservation programs, create usage profiles
by time of day.

55
CHAPTER 7: RESULTS

7.1 Result:

The project “Automatic Tariff Calculation with Wireless Energy Meter” was
designed an energy meter monitoring system using wireless zigbee technology. This is done by using
a ZigBee transceiver interfaced with both the PC (Electricity Board) section as well as the consumer
side. The Microcontroller based system continuously records the readings. These live meter readings
are displayed in the LCD and also sent to the PC side through ZigBee. The -PC (Electricity Board)
takes the responsibility of calculating the bill with the data received from the home side, and the tariff
provided by the operator and displays the same in the LCD placed in the consumer’s home by
transmitting the data through ZigBee transceiver.

7.2 Conclusion:

Integrating features of all the hardware components used have been developed in it. Presence
of every module has been reasoned out and placed carefully, thus contributing to the best working of
the unit. Secondly, using highly advanced IC’s with the help of growing technology, the project has
been successfully implemented. Thus the project has been successfully designed and tested.

7.3 Future Scope:

This project can be extended by using IOT technology, which helps in sending the theft data to
the predefined web link of the substation. The temperature controlling systems like coolant can also
use in places where temperature level should be maintained.

By connecting wireless camera in industries, factories etc we can see the entire equipments from
our personal computer only by using IOT and GPS technology. The monitoring and controlling of the
devices can be done from the personal computer and we can use to handle so many situations.

56
REFERENCES

1. Anitha.k ,prathik, Smart Energy Meter surveillance Using IoT

,Institute of Electrical and Electronics Engineers(IEEE), 2019.

2. Devadhanishini, et.al Smart Power Monitoring Using IoT5th International Conference


on Advanced Computing & Communication Systems (ICACCS) 2019.

3. Mohammad Hossein Yaghmaee Design and Implementation of an Internet of Things


Based Smart Energy Metering 6th IEEE International Conference on Smart Energy Grid
Engineering 2018.

4. Himanshu kpatel arduino based smart energy meter 2nd Int'l Conf. on Electrical
Engineering and Information &Communication Technology (ICEEICT) 2018.

5. Bibek Kanti Barman, et.al proposed paper smart meter using IoT department of
international electronics and electrical engineering (IEEE) 2017.

6. Garrab.A, Bouallegue.A, Ben Abdullah, A new AMR approach for energy savings in

Smart Grids using Smart meter and partial power line communication, IEEE First

International Conference on ICICS,vol 3, pp. March 2012.

7. Landi,c.: Dipt. Di Ing.dellInf, SecondaUniv di Napoli,Aversa,Italy; Merola p.ARM-


based energy management system using smart meter and Web server,IEEE
instrumentation and measurement technology conference binjing, pp.1-5 may 2011.

8. [8] B. S. Koay, S. S. Cheah, Y. H. Sng, P. H. Chong, P. Shum, Y. C. Tong, X. Y. Wang,


Y. X. Zuo and H. W. Kuek, "Design and implementation of Bluetooth energy meter",
IEEE Proceedings of the 4th International Joint Conference of the ICICS, vol. 3, pp.
1474-1477, Dec,2003.

9. N. Fathima, A. Ahammed, R. Banu, B.D. Parameshachari, and N.M. Naik, Optimized


neighbor discovery in Internet of Things (IoT), In Proc. of International Conference on
Electrical, Electronics, Communication, Computer, and Optimization Techniques
(ICEECCOT), pp. 1-5, 2017

10. A. ZigBee, ZigBee Specification, pp. 1604, Jan.2008.

11. . W. Yang, X. Wang, and J.-P. Linnartz, A Coexistance Model of IEEE 802.15.4 and IEEE
802.11b/g, ieeexplore.ieee.org.

57

You might also like