You are on page 1of 85

CHAPTER 1

OVERVIEW

1
1.1 Introduction:
Now-a-days as there is rapid growth in the number of industries and the different
technologies used there, fault monitoring has become a primary task since the occurrence of one
fault will affect the entire functioning of the system as a result of sequential faults.
This project displays the faults occurred in an industry using RF Technology since each
load cannot be monitored manually.

1.2 Block Diagram Description:

FIGURE1 :block diagram

Block diagram mainly consist of

• Current transformer(CT)

• Potential transformer(PT)

• Signaling circuit

 A/D converter

2
 Temperature sensor

• Micro controller(ATMEGA8)

• ASK-RF transmitter

 Encoder

 AK-RF module

• ASK-RF Receiver

 Decoder

 ASK-RF module

Current Transformer (CT):


• A current transformer (CT) is a type of instrument transformer designed to provide a
current in its secondary winding proportional to the alternating current flowing in its
primary.

• Current transformers measure power flow and provide electrical inputs to power
transformers and instruments.

• It produce either an alternating current or alternating voltage that is proportional to the


measured current.

• The C.T. steps down the current to the level of micro controller.

Potential Transformer (PT):


• The primary winding of the P.T. is connected across the line carrying the voltage to be
measured and the voltage circuit is connected across the secondary winding

• The design of a potential transformer is quite similar to that of a power transformer but
the loading of a potential transformer is alwayssmall,sometimes only a few Volt-amperes.

• The secondary is designed so that a voltage of 9 volts is delivered to the instrument load

Signalling Circuit:
• It consist of both A/D converter,Temperature sensor.
• The main operation of this circuit is that it is used to remove the negative peak of a
sine wave by adding +5V so that the sine wave lies only in the positive peak only.
• The signal generator consist of Zenor diode which is operated at 4.3v

3
• Signal generator consist of pins such as Vcc, Ground(G), Current(I), Voltage(V), DC off,
Temperature
A/D converter:
• The ADC contains a Sample and Hold circuit, which ensures that the input voltage to
the ADC is held at a constant level during conversion.
• The ADC has a separate analog supply voltage pin, AVCC. It must not differ more than
±0.3 V from VCC.

• The voltage reference may be externally decoupled at the AREF pin by a capacitor for
better noise performance.

Temperature Sensor:
The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an
advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to
subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The
LM35 does not require any external calibration or trimming to provide typical accuracies of
±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost
is assured by trimming and calibration at the wafer level. The LM35’s low output impedance,
linear output, and precise inherent calibration make interfacing to readout or control circuitry
especially easy. It can be used with single power supplies, or with plus and minus supplies. As it
draws only 60 μA from its supply, it has very low self-heating, less than 0.1°C in still air. The
LM35 is rated to operate over a −55° to +150°C temperature range, while the LM35C is rated for
a −40° to +110°C range

Micro Controller:
A Microcontroller (also microcomputer, MCU or µC) is a small computer on a single
integrated circuit consisting internally of a relatively simple CPU, clock, timers/ I/O ports, and
memory. Program memory in the form of NOR flash or OTP ROM is also often included on
chip, as well as a typically small amount of RAM.

ATmega8 (L):

In this it uses the following pins


4
AVCC: AVCC is the supply voltage pin for the A/D Converter,
Port C (3-0),and ADC (7-6). It should be externally connected to VCC, even if the ADC is not
used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port
C (5-4) use digital supply voltage, VCC.
AREF: AREF is the analog reference pin for the A/D Converter.

ADC7-6: In the TQFP and QFN/MLF package, ADC7-6 serve as analog inputs to the A/D
converter.
These pins are powered from the analog supply and serve as 10-bit ADC channels.

ASK-RF TRANSMITTER:
TLP434A is an Ultra Small Transmitter manufactured by Laipac Technology, Inc. This
transmitter transmits RF signals upon reception of digital serial data from its Data In (pin2). It
operates between 2.0-12V and uses the Amplitude Shift Keying modulation.Pin 4 of this
transmitter can be connected directly to an appropriate antenna via a 50P resister in order to
provide a power output of 14 dBm at 5V operation. Shown in table 3.2, below are the Electrical
characteristics of the transmitter. Out of the 315 MHz, 418 MHz and 433.92 MHz versions, this
project used the 433.92 MHz version of the transmitter.
It consist of four pins 1.Ground
2.Data In
3.Vcc
4.Antenna(RFout)
Encoder:
HT12E encoder is a CMOS IC built especially for remote control system applications. It
is capable of encoding 8 bits of address (A0-A7) and 4 bits of data (AD8-AD11) information.
Each address/data input can be set to one of the two logic states, 0 or 1. Grounding the pins is
taken as a 0 while a high can be given by giving +5V or leaving the pins open (no connection).
Upon reception of transmit enable (TE-active low), the programmed address/data are transmitted
together with the header bits via an RF medium.

ASK-RF Receiver:

5
RPL434A is a Surface Acoustic Wave (SAW) based receiver, which receives ASK
modulated RF signals and outputs the serial format of data which were embedded in the received
signal via its Digital data out (pin 2). It operates between 3.3 to 6.0V and also has an analog
output (linear out) for received signal testing purposes. Shown in table 3.3 are the parameters and
Electrical characteristics of the receiver. Out of the 315 MHz, 418 MHz and 433.92 MHz
versions, this project used the 433.92 MHz version of the receiver.
It consist of total eight pins
1.Ground
2. Digital Data out
3. Linear out/Test
4. Vcc
5. Vcc
6. Ground
7. Ground
8. Antenna

Decoder:
The HT12D is a decoder IC made especially to pair with the HT12E encoder. It is a
CMOS IC made for remote control system applications. The decoder is capable of decoding 8
bits of address (A0-A7) and 4 bits of data (AD8-AD11) information. Like the encoder, this
decoder’s address pins can be set to logic low by grounding and set to logic high by either
connecting the pins to +5V or leaving them open (no connection). The decoder receives serial
addresses and data from a programmed encoder transmitted by a carrier using RF or an IR
transmission medium.

1.3 Advantages of ASK RF Technology

1. Power system monitoring in real time.


2. Fault identification and clearing.
3. Remote monitoring and controlling.
4. Its uses normal antenna.
5. Its uses 4bit and 8bit for data transmission.

6
6. Its uses 413 HRZ of operating frequency.
7. It is cheap and best.
8. Easy to implement.
9. Detection is easy.
10. It is easy to modulate and demodulate compare to FSK.

1.4 Applications of ASK RF Technology

• Light switches
• Fire & smoke detectors
• AMR
• Wireless alarm & security
• Thermostats
• HVAC
• Nuclear Reactor

Wireless Alarm and Security

Wireless alarm systems are battery-powered security systems designed to alert occupants
of a building to certain kinds of danger, like a burglar breaking into a home at night or a fire
starting in an office building. Typically, wireless alarm systems communicate triggering
conditions to building occupants using wireless signals, such as line carrier, infrared, or radio
waves, which are transmitted on a special frequency. A wireless security system can protect
users from more than just an authorized intruder. Many systems are also equipped with smoke
and gas detectors, motion sensors, water detectors, and low temperature detectors.

Wireless alarm systems are common in both home and work environments. Home
security systems are typically used to prevent triggering events from occurring in a private
residence while commercial security systems are usually designed to keep a company secure.
Depending on how the security system is structured, it can notify building occupants of an

7
intrusion, a flood, a fire, or other dangers. Some of these security systems include wireless door
alarms, which use wireless technology to set off alarms when doors are opened.

Wireless digital security systems are distinct from wired security systems. Wired security
systems use wires in order to signal the occurrence of a break-in, the presence of smoke, a water
leak, or other triggering event. Wired security systems generally require electrical power to
operate. They are often more expensive to install because the wires need to be routed through the
building’s walls.

HVAC:

HVAC is particularly important in the design of medium to large industrial and office
buildings such as skyscrapers and in marine environments such as aquariums, where safe
and healthy building conditions are regulated with temperature and humidity, as well as "fresh
air" from outdoors.

Here are different types of standard heating systems. Central heating is often used in cold
climates to heat private houses and public buildings. Such a system contains a boiler, furnace,
or heat pump to heat water, steam, or air, all in a central location such as a furnace room in a
home or a mechanical room in a large building. The use of water as the heat transfer medium is
known as hydronics. The system also contains either ductwork, for forced air systems, or piping
to distribute a heated fluid and radiators to transfer this heat to the air. The term radiators in this
context is misleading since most heat transfer from the heat exchanger is by convection,
not radiation. The radiators may be mounted on walls or buried in the floor to give under-floor
heat.

In boiler fed or radiant heating systems, all but the simplest systems have a pump to
circulate the water and ensure an equal supply of heat to all the radiators. The heated water can
also be fed through another (secondary) heat exchanger inside a storage cylinder to provide hot
running water.

8
Home Appliances:
Home appliances like washing machine or micro wave oven an act these all can be controlled
using ASK RF technology. If current increases Load automatically offs

1.5 Embedded Systems:


An embedded system is a special-purpose computer system designed to perform a
dedicated function. Unlike a general-purpose computer, such as a personal computer, an
embedded system performs one or a few pre-defined tasks, usually with very specific
requirements, and often includes task-specific hardware and mechanical parts not usually found
in a general-purpose computer.

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. In terms of complexity embedded systems run from simple,
with a single microcontroller chip, to very complex with multiple units, peripherals and networks
mounted inside a large chassis or enclosure.

Mobile phones or handheld computers share some elements with embedded systems,
such as the operating systems and microprocessors which power them, but are not truly
embedded systems themselves because they tend to be more general purpose, allowing different
applications to be loaded and peripherals to be connected.

1.6 Examples of Embedded Systems:


Examples of embedded systems are chips that monitor automobile functions, including
engine controls, antilock brakes, air bags, active suspension systems, environmental systems,
security systems, and entertainment systems. Everything needed for those functions is custom
designed into specific chips. No external operating system is required.
Network managers will need to manage more and more embedded systems devices,
ranging from printers to scanners, to handheld computing devices, to cell phones. All of these

9
have a need to connect with other devices, either directly or through a wireless or direct-connect
network.
For example, refrigerators, washing machines, and even coffee brewers will benefit in
some way from embedded systems. A critical feature of an embedded system is its ability to
communicate, so embedded systems support Ethernet, Bluetooth (wireless), infrared, or other
technologies.

A weather station on top of a building may employ an embedded system that gathers information
from external sensors. This information can be pushed or pulled. In the push scenario, the data is
automatically sent to devices that have requested it. In the pull scenario, users or network devices
access the weather station to read the latest information.
• 7 Segment Display.
• Keypad.
• Buzzer.
• Water Level Sensor.
• Temperature Sensor.
• Motor Control.
• Relays.
• Safety Switched.
• Control Algorithms.
• Wash Cycle Algorithms - Fuzzy Logic .

1.7 Organization of Report


Chapter 2 gives a concise introduction of ASK RF Technology.
Chapter 3 gives the introduction to ATMEGA8L MC.
Chapter 4 gives a concise introduction of hardware components like Potential
Transformer, Current Transformer.
Chapter 5 gives brief introduction of the technical components like ADC, Encoders.
Chapter 6 provides complete software description and program code.
Chapter 7 gives the results, conclusion and future scope.

10
CHAPTER 2:
INTRODUCTION TO ASK-RF TECHNOLOGY

11
2.1 Description of ASK Technology:

Amplitude-shift keying (ASK) is a form of modulation that represents digital data as


variations in the amplitude of a carrier wave.

The amplitude of an analog carrier signal varies in accordance with the bit stream
(modulating signal), keeping frequency and phase constant. The level of amplitude can be used
to represent binary logic 0s and 1s. We can think of a carrier signal as an ON or OFF switch. In
the modulated signal, logic 0 is represented by the absence of a carrier, thus giving OFF/ON
keying operation and hence the name given. Like AM, ASK is also linear and sensitive to
atmospheric noise, distortions, propagation conditions on different routes in PSTN (PUBLIC
SWITCH TELEPHONE NETWORK), etc.

Both ASK modulation and demodulation processes are relatively inexpensive. The ASK
technique is also commonly used to transmit digital data over optical fiber. For LED transmitters,
binary 1 is represented by a short pulse of light and binary 0 by the absence of light. Laser
transmitters normally have a fixed "bias" current that causes the device to emit a low light level.
This low level represents binary 0, while a higher-amplitude lightwave represents binary 1.

12
FIGURE: 2 ASK WAVEFORM
The un-modulated carrier is multiplied to the digital signal 101001011 which in turn
produces the outgoing ASK modulated signal. The transmitter of this project uses the ASK
modulation. This is obvious since the project requires transfer of digital data.
ASK is a digital modulation technique whereby the carrier signal is multiplied by the digital
form of data that is to be transmitted.

2.2 Radio Frequency (RF)

RF refers to radio frequency, the mode of communication for wireless technologies of


all kinds, including cordless phones, radar, ham radio, GPS, and radio and television From baby
monitors to cell phones, Bluetooth to remote control toys, RF waves are all around us. RF waves
are electromagnetic waves which propagate at the speed of light, or 186,000 miles per second
(300,000 km/s).

The frequencies of RF waves, however, are slower than those of visible light, making RF
waves invisible to the human eye. The frequency of a wave is determined by its oscillations or
cycles per second. One cycle is one hertz (Hz)

A station on the AM dial at 98, for example, broadcasts using a signal that oscillates
98,000 times per second, or has a frequency of 98 KHz. A station a little further up the dial at
710 broadcasts using a signal that oscillates 710,000 times a second, or has a frequency of 710

13
KHz. With a slice of the RF pie licensed to each broadcaster, the RF range can be neatly divided
and utilized by multiple parties.

Every device in the United States that uses RF waves must conform to the Federal
Communications Commission's (FCC) regulations. A baby monitor, must operate using the
designated frequency of 49 MHz Cordless phones and other devices have their own designated
frequencies.At present, according to the FCC, frequencies from 9 KHz — 275 GHz have been
allocated, with the highest bands reserved for satellite and radio astronomy

In actuality, there are no gaps between categories, as hundreds of other uses are also
assigned, from garage door openers and alarm systems to amateur radio and emergency
broadcasting.

The sample chart below lists some of the major categories with approximate RF ranges

Aeronautical/Maritime 9 KHz - 535 KHz


AM radio 535 KHz - 1,700 KHz
Shortwave radio 5.9 MHz - 26.9 MHz
Citizen's Band (CB) 26.96 MHz - 27.41 MHz
TV stations 2-6 54 MHz - 88 MHz
FM radio 88 MHz - 108 MHz
TV stations 7-13 174 MHz - 220 MHz
Cell phones CDMA 824 MHz - 849 MHz
Cell phones GSM 869 MHz - 894 MHz
Air Traffic Control 960 MHz - 1,215 MHz
GPS 1,227 MHz - 1,575 MHz
Cell phone PCS
1,850MHZ-1,990MHZ

TABLE 1: Radio Frequency Spectrum

14
Each of the bands illustrated in the above figure The RF table is divided and labeled
according to frequency, with extremely low frequency (ELF) occupying one end at just 3-30 Hz,
and extremely high frequency (EHF) at the other, representing 30-300 GHz. used by radio and
television stations 2-13

UHF (ultra high frequency), used by other television stations, mobile phones and two-
way radios. Microwave ovens even use RF waves to cook food, but these waves are in the super
high frequency band or SHF Following the electromagnetic spectrum into even higher
frequencies, one finds infrared waves, and finally visible.

2.3 Radio Frequency Communication Overview:


Radio Frequency (RF) refers to that portion of the electromagnetic spectrum in which
electromagnetic waves can be generated by an antenna if a changing current is applied to it.

These frequencies form part of a Radio Frequency spectrum, as shown below have their
own frequency range.

FIGURE 2: FREQUENCY RANGE

Table below shows this range and their uses in several fields of wireless communication.

15
Table 2: Band Frequency Range

This project used a transmitter that worked at 433.92 MHz, hence falling into the Ultra High
Frequency (UHF) Band.

2.4 Features of ASK-RF:

• Low Power Consumption for 2.5~12V Operation.


• Designed for 280~434 MHz communication systems.
• ASK Modulation/Demodulation
• Low spurious noise
• Data rate 4800 bps typical
• Dimension (TX: 13.3×11.2×2.6mm﹔Rx:44.2×12.4×5.9mm)

2.5 Working of RF Technology:

In real world situations, the data to be sent is encoded within the transmitted signal so
that a well designed receiver can separate the data from the signal upon reception of this signal.
The decoded data can then be used to perform specified tasks. There are several methods of
incorporating data into a signal that is to be transmitted. This process is known as modulation.

16
In real world application, there are several modulation techniques, the Amplitude
modulation (AM), Frequency Modulation (FM) and slight variation of AM and FM modulation
such as Amplitude Shift Keying (ASK), Frequency Shift Keying (FSK) and Phase Shift Keying
(PSK). It has to be highlighted that ASK, FSK and PSK are used in digital modulation. Since this
project was on transmission of digital data, the transmitter chosen used the ASK modulation as a
means of sending the data signal.

2.6 RF Advantages:

• Not blocked by common materials:


• can penetrate most solids and pass through walls
• Longer range
• Not light sensitive
• Not as sensitive to weather/environmental conditions

2.7 RF Disadvantages:

• Interference: communication devices using similar frequencies - wireless phones,


scanners, wrist radios and personal locators can interfere with transmission
• Lack of security: easier to "eavesdrop" on transmissions since signals are spread out in
space rather than confined to a wire
• Higher cost than infrared
• Federal Communications Commission(FCC) licenses required for some products
• Lower speed: data rate transmission is lower than wired and infrared transmission

17
18
CHAPTER 3:

INTRODUCTION TO ATMEGA8L MC

3.1 Microcontrollers:

A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor


emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose
microprocessor (the kind used in a PC).

A microcontroller (also microcomputer, MCU or µC) is a small computer on a single


integrated circuit consisting internally of a relatively simple CPU, clock, timers, I/O ports, and
memory. Program memory in the form of NOR flash or OTP ROM is also often included on
chip, as well as a typically small amount of RAM.

19
Microcontrollers are designed for small or dedicated applications. Thus, in contrast to
the microprocessors used in personal computers and other high-performance or general purpose
applications, simplicity is emphasized.

Some microcontrollers may use four-bit words and operate at clock rate frequencies as
low as 4 kHz, as this is adequate for many typical applications, enabling low power consumption
(milliwatts or microwatts). They will generally have the ability to retain functionality while
waiting for an event such as a button press or other interrupt; power consumption while sleeping
(CPU clock and most peripherals off) may be just nano watts, making many of them well suited
for long lasting battery applications.

Other microcontrollers may serve performance-critical roles, where they may need to act
more like a digital signal processor (DSP), with higher clock speeds and power consumption.

Microcontrollers are used in automatically controlled products and devices, such as


automobile engine control systems, implantable medical devices, remote controls, office
machines, appliances, power tools, and toys.

By reducing the size and cost compared to a design that uses a separate microprocessor,
memory, and input/output devices, microcontrollers make it economical to digitally control even
more devices and processes. Mixed signal microcontrollers are common, integrating analog
components needed to control non-digital electronic systems.

3.2 Architecture of Microcontroller:

All components in the below figure are connected via an internal bus and are all integrated on
one chip. The modules are connected to the outside world via I/O pins.

20
FIGURE 4: Basic Layout of Microcontroller

Processor Core: The CPU of the controller. It contains the arithmetic logic unit, the control unit,
and the registers (stack pointer, program counter, accumulator register, register file . . .).

Memory: The memory is sometimes split into program memory and data memory. In larger
controllers, a DMA controller handles data transfers between peripheral components and the
memory.

Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case of
(important) external or internal events. In conjunction with sleep modes, they help to conserve
power.

Timer/Counter: Most controllers have at least one and more likely 2-3 Timer/Counters, which
can be used to timestamp events, measure intervals, or count events. Many controllers also
contain PWM (pulse width modulation) outputs, which can be used to drive motors or for safe
breaking (antilock brake system, ABS). Furthermore the PWM output can, in conjunction with
an external filter, be used to realize a cheap digital/analog converter.

21
Digital I/O: Parallel digital I/O ports are one of the main features of microcontrollers. The
number of I/O pins varies from 3-4 to over 90, depending on the controller family and the
controller type.

Analog I/O: Apart from a few small controllers, most microcontrollers have integrated
analog/digital converters, which differ in the number of channels (2-16) and their resolution (8-
12 bits). The analog module also generally features an analog comparator. In some cases, the
microcontroller includes digital/analog converters.

3.3 FEATURES:

• High-performance, Low-power AVR® 8-bit Microcontroller


• Advanced RISC Architecture
– 131 Powerful Instructions – Most Single-clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
• Nonvolatile Program and Data Memories
– 16K Bytes of In-System Self-Programmable Flash
• Endurance: 10,000 Write/Erase Cycles
– Optional Boot Code Section with Independent Lock Bits
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
– 512 Bytes EEPROM
• Endurance: 100,000 Write/Erase Cycles
– 1K Byte Internal SRAM
– Programming Lock for Software Security
• JTAG (IEEE std. 1149.1 Compliant) Interface
• Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support

22
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the
JTAG Interface
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and
Capture Mode
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
• 8 Single-ended Channels
• 7 Differential Channels in TQFP Package Only
• 2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power- down,
Standby and Extended Standby
• I/O and Packages
– 32 Programmable I/O Lines
– 40-pin PDIP, 44-lead TQFP, and 44-pad MLF
• Operating Voltages
– 2.7 - 5.5V for ATmega16L
– 4.5 - 5.5V for ATmega16
• Speed Grade

23
3.4 MICROCONTROLLER PIN DIAGRAM:

FIGURE 5: Pin Diagram of ATmega8L

3.5 AVR CODE CORE:


• Hardware architecture

• Separate memories and buses for program and data

• 32x8-bit general purpose working registers

• Large Accumulator

24
• Single clock cycle access time

• 3 register pair act as 16-bit data pointers

• Single-cycle Arithmetic Logic Unit (ALU) operation

• 16-bit Stack Pointer

• Program Count

FIGURE 6: AVR CORE CODE

3.6 Pin Description :


VCC: Digital supply voltage.
25
GND: Ground.

Port B (PB7-PB0): Port B is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port B output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port B pins that are externally pulled low will
source current if the pull-upresistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
Depending on the clock selection fuse settings, PB6 can be used as input to the inverting
Oscillator amplifier and input to the internal clock operating circuit.
Depending on the clock selection fuse settings, PB7 can be used as output from the inverting
Oscillator amplifier. If the Internal Calibrated RC Oscillator is used as chip clock source

PORT C6: Is used as TOSC2..1input for the Asynchronous Timer/Counter2 if the AS2 bit in
ASSR is set.
Port C (PC5-PC0): Port C is a 7-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port C output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port C pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active, even if the clock is not running.

PC6/RESET: If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin.Note that the
electrical characteristics of PC6 differ from those of the other pins of Port C.
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on
this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not
running. Shorter pulses are not guaranteed to generate a Reset.

Port D (PD7-PD0): Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-upresistors are activated. The Port D pins are tri-stated when a reset
condition becomes active, even if the clock is not running.

26
RESET: Reset input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running.

ATmega8 (L)
AVCC: AVCC is the supply voltage pin for the A/D Converter,
Port C (3-0),and ADC (7-6): It should be externally connected to VCC, even if the ADC is not
used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port
C (5-4) use digital supply voltage, VCC.

AREF: AREF is the analog reference pin for the A/D Converter.

ADC7-6: In the TQFP and QFN/MLF package, ADC7-6 serve as analog inputs to the A/D
converter. These pins are powered from the analog supply and serve as 10-bit ADC channels

27
CHAPTER 4:

HARDWARE DESCRIPTION

4.1 Current Transformer:

28
Current being measured by Current transformer is shown in fig.2.2.1. The Primary
winding is so connected that the current being measured passes through it and the secondary
winding is connected to the Signal conditioning circuit. The C.T. steps down the current to the
level of micro controller.

4.1.1 Working of Current Transformer


Current transformers measure power flow and provide electrical inputs to power
transformers and instruments. Current transformers produce either an alternating current or
alternating voltage that is proportional to the measured current.

Primary current, the load of the current transformer, is the measured current. Secondary
current is the range of current outputs. Insulation voltage represents the maximum insulation that
current transformers provide when connected to a power source.

Accuracy is the degree of certainty with which the measured current agrees with the ideal
value. Burden is the maximum load that devices can support while operating within their
accuracy ratings. Typically, burden is expressed in volt-amperes (VA), the product of the voltage
applied to a circuit and the current.

4.1.2 Types of current transformers:


• Wound current transformers consist of an integral primary winding that is inserted in
series with the conductor that carries the measured current.
• Toroidal or donut-shaped current transformers do not contain a primary winding.
Instead, the wire that carries the current is threaded through a window in the toroidal
transformer.

4.1.3 Applications of Current Transformers.


• Some devices are used to measure current in electronics equipment or motors.

29
• Others are used in street lighting.
• Current transformers with small footprints mount on printed circuit boards (PCBs) and
are used to sense current overloads, detect ground faults, and isolate current feedback
signals.
• Larger devices are used in many three-phase systems to measure current or voltage.
Commercial class current transformers that monitor low-power currents are also
available.
• Some current transformers are weatherproof or are rated for outdoor use. for power
monitoring applications where high accuracy and minimum phase angle are required.

4.1.4 Signal conditioning circuit for Current measurement


The signal conditioning circuit of a Current Transformer basically consists of two major parts
namely, burden resistance R1 and Level Shifting circuitry as shown below. The actual current to
be measured, Primary current Ip, has to be determined in terms of Vout, voltage at the ADC,.

30
Figure 8: Waveforms of C.T.

Thus the Actual Primary current in the Line Ip, can be obtained by multiplying the Secondary
current, Is, with the Transformation Ratio (or current Ratio) .

4.2 Potential Transformer:


Voltage being measured by Potential transformer is shown The primary winding is
connected to the voltage being measured and the secondary winding, to a voltmeter. The P.T
steps down the voltage to the level acceptable to the micro controller.

4.2.1Working of Potential Transformer:


The primary winding of the P.T. is connected across the line carrying the voltage to be
measured and the voltage circuit is connected across the secondary winding. The design of a
potential transformer is quite similar to that of a power transformer but the loading of a potential

31
transformer is always small, sometimes only a few Volt-amperes.The secondary is designed so
that a voltage of 9 volts is delivered to the instrument load.

Figure 9: A Simple circuit with Potential Transformer

4.2.2 Precautions:
The secondary of a potential transformer should not be short circuited while
the primary circuit is energized.

4.3 RELAYS:
A relay is an electrical switch that opens and closes under the control of another electrical
circuit. In the original form, the switch is operated by an electromagnet to open or close one or
many sets of contacts.
It was invented by Joseph Henry in 1835. Because a relay is able to control an output
circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form
of an electrical amplifier
4.3.1 Operation of relay:
When a current flows through the coil, the resulting magnetic field attracts an armature
that is mechanically linked to a moving contact.The movement either makes or breaks a
connection with a fixed contact. When the current to the coil is switched off, the armature is
returned by a force approximately half as strong as the magnetic force to its relaxed position.
Usually this is a spring, but gravity is also used commonly in industrial motor starters.

Most relays are manufactured to operate quickly. In a low voltage application, this is to reduce
noise. In a high voltage or high current application, this is to reduce arcing.

32
If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the
energy from the collapsing magnetic field at deactivation, which would otherwise generate a
spike of voltage and might cause damage to circuit components. Some automotive relays already
include that diode inside the relay case. Alternatively a contact protection network, consisting of
a capacitor and resistor in series, may absorb the surge.

By analogy with the functions of the original electromagnetic device, a solid-state relay is made
with a thruster or other solid-state switching device. To achieve electrical isolation an opt
coupler can be used which is a light-emitting diode (LED) coupled with a photo transistor.

The following is a 5 pin relay:

_______________________________
| |
1 | | 5
---------|---+ o------------|----------------
| |-----------/---- s |
| / s |
3 | / s |
---------|-----------o/ coil s | 4
| o---s-------|----------------
| | |
| | |
2 | | |
----------|---------------------+ |
|_____________________________|

Figure 10: Relay pin diagram

In the above diagram pin 3 is connected to pin 5, by default. By sending +12V between pin 1 and
pin 2, you will turn on a switch. Pin 1 and pin 2 will disconnect, and pin 5 and pin 4 will connect.

33
Figure 11: Different Relays

4.3.2 CHOOSING A RELAY:


You need to consider several features when choosing a relay

• Physical size and pin arrangement


If you are choosing a relay for an existing PCB you will need to ensure that its
dimensions and pin arrangement are suitable. You should find this information in the
supplier's catalogue.

• CoilVoltage
The relay's coil voltage rating and resistance must suit the circuit powering the
relay coil. Many relays have a coil rated for a 12V supply but 5V and 24V relays are
also readily available. Some relays operate perfectly well with a supply voltage which
is a little lower than their rated value.
• Coil resistance
The circuit must be able to supply the current required by the relay coil. One can
use Ohm's law to calculate the current
• Switch ratings (voltage and current):
The relay's switch contacts must be suitable for the circuit they are to control. You
will need to check the voltage and current ratings. Note that the voltage rating is
usually higher for AC, for example: "5A at 24V DC or 125V AC".
• Switch contact arrangement (SPDT, DPDT etc)
Most of relays are SPDT or DPDT which are often described as "single pole
changeover" (SPCO) or "double pole changeover" (DPCO).

34
Figure12: Coil Resistance Circuit Diagram

4.3.3 Advantages of Relays

• Relays can switch AC and DC, transistors can only switch DC.
• Relays can s Relays are a better choice for switching large currents (> 5A).
• Relays can switch many contacts at once.

4.3.4 Disadvantages of Relays:


• Relays are bulkier than transistors for switching small currents.
• Relays cannot switch rapidly (except reed relays), transistors can switch many times per
second.
• Relays use more power due to the current flowing through their coil.
• Relays require more current than many ICs can provide, so a low power transistor may be
needed to switch the current for the relay's coil.
• Works with high voltages, where transistors cannot.

4.4 The LM35-Temperature Sensor

4.4.1 General Description


The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an
advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to
subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The
LM35 does not require any external calibration or trimming to provide typical accuracies of

35
±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost
is assured by trimming and calibration at the wafer level. The LM35’s low output impedance,
linear output, and precise inherent calibration make interfacing to readout or control circuitry
especially easy. It can be used with single power supplies, or with plus and minus supplies. As it
draws only 60μA from its supply, it has very low self-heating, less than 0.1°C in still air. The
LM35 is rated to operate over a −55° to +150°C temperature range, while the LM35C is rated for
a −40° to +110°C range

Figure13: LM35 Temperature Sensor

The LM35 series is available packaged in


hermetic TO-46 transistor packages, while the
LM35C, LM35CA, and LM35D are also
available in the plastic TO-92 transistor package.
The LM35D is also available in an 8-lead surface
mount small outline package and a plastic TO-220
package.

4.4.2 Features of LM35:


• Calibrated directly in ° Celsius (Centigrade)
• Linear + 10.0 mV/°C scale factor
• 0.5°C accuracy guarantee able (at +25°C)
• Rated for full −55° to +150°C range
• Suitable for remote applications
• Low cost due to wafer-level trimming
• Operates from 4 to 30 volts
• Less than 60μA current drain
• Low self-heating, 0.08°C in still air
• Nonlinearity only ±1⁄4°C typical
• Low impedance output, 0.1 W for 1mA load

4.4.3 Applications of LM35:

• The LM35 can be applied easily in the same way as other


Integrated-circuit temperature sensors.

36
• It can be glued or Cemented to a surface and its temperature will be within About
0.01°C of the surface temperature.

• These devices are sometimes soldered to a small Light - weight heat fin, to
decrease the thermal time constant and speed up the response in slowly-moving air.

• On the Other hand, a small thermal mass may be added to the Sensor, to give the
steadiest reading despite small deviations in the air temperature.

4.5 POWER SUPPLY:


Three-phase electric power is a common method of alternating-current electric
power transmission.[1] It is a type of polyphase system, and is the most common method used
by electric power distribution grids worldwide to distribute power. It is also used to power
large motors and other large loads.

A three-phase system is generally more economical than others because it uses less conductor
material to transmit electric power than equivalent single-phaseor two-phase systems at the
same voltage.

In a three-phase system, three circuit conductors carry three alternating currents (of the
same frequency) which reach their instantaneous peak values at different times. Taking one
conductor as the reference, the other two currents are delayed in time by one-third and two-thirds
of one cycle of the electrical current.

This delay between phases has the effect of giving constant power transfer over each
cycle of the current, and also makes it possible to produce a rotating magnetic field in an electric
motor.

Three-phase systems may or may not have a neutral wire. A neutral wire allows the three-
phase system to use a higher voltage while still supporting lower-voltage single-
phase appliances. In high-voltage distribution situations, it is common not to have a neutral wire
as the loads can simply be connected between phases (phase-phase connection).

Three-phase has properties that make it very desirable in electric power systems:

37
• The phase currents tend to cancel out one another, summing to zero in the case of a linear
balanced load. This makes it possible to eliminate or reduce the size of the neutral
conductor; all the phase conductors carry the same current and so can be the same size,
for a balanced load.

• Power transfer into a linear balanced load is constant, which helps to reduce generator
and motor vibrations.

• Three-phase systems can produce a magnetic field that rotates in a specified direction,
which simplifies the design of electric motors.

Three is the lowest phase order to exhibit all of these properties.

Most household loads are single-phase. Even in areas where it does, it is typically split out at the
main distribution board and the individual loads are fed from a single phase. Sometimes it is
used to power electric stoves and washing machines.

Figure14: 1/3 Phase Power Supply

38
CHAPTER 5:

TECHNICAL COMPONENTS

5.1 ANALOG - DIGITAL CONVERTER

39
The ATmega16 features a 10-bit successive approximation ADC. The ADC is connected
to an 8-channel Analog Multiplexer, which allows 8 single-ended voltage inputs constructed
from the pins of Port A. The single-ended voltage inputs refer to 0V (GND). The device also
supports 16 differential voltage input combinations. Two of the differential inputs (ADC1,
ADC0 and ADC3, ADC2) are equipped with a programmable gain stage.
Seven differential analog input channels share a common negative terminal (ADC1), while any
other ADC input can be selected as the positive input terminal.
The ADC contains a Sample and Hold circuit, which ensures that the input voltage to the ADC is
held at a constant level during conversion. The ADC has a separate analog supply voltage pin,
AVCC. AVCC must not differ more than ±0.3 V from VCC. Internal reference voltages of nominally
2.56V or AVCC are provided On-chip. The voltage reference may be externally decoupled at the
AREF pin by a capacitor for better noise performance.

5.1.1 OPERATION OF ADC CONVERTER:


The ADC converts an analog input voltage to a 10-bit digital value through successive
approximation. The minimum value represents GND and the maximum value represents the
voltage on the AREF pin minus 1 LSB.

The analog input channel and differential gain are selected by writing to the MUX bits in
ADMUX. Any of the ADC input pins, as well as GND and a fixed band gap voltage reference,
can be selected as single ended inputs to the ADC. A selection of ADC input pins can be selected
as positive and negative inputs to the differential gain amplifier. If differential channels are
selected, the differential gain stage amplifies the voltage difference between the selected input
channel pair by the selected gain factor.

This amplified value then becomes the analog input to the ADC. Setting the ADC Enable
bit, ADEN in ADCSRA, enables the ADC. Voltage reference and input channel selections will
not go into effect until ADEN is set. The ADC does not consume power when ADEN is cleared,
so it is recommended to switch off the ADC before entering power saving sleep modes. The
ADC generates a 10-bit result, which is presented in the ADC Data Registers, ADCH and

40
ADCL. By default, the result is presented right adjusted, but can optionally be presented left
adjusted by setting the ADLAR bit in ADMUX.

If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to
read ADCH. Otherwise, ADCL must be read first, then ADCH, to ensure that the content of the
Data Registers belongs to the same conversion. Once ADCL is read, ADC access to Data
Registers is blocked. Thus, if ADCL has been read, and a conversion completes before ADCH is
read, neither register is updated nor the result from the conversion is lost

When ADCH is read, ADC access to the ADCH and ADCL Registers is re-enabled. The
ADC has its own interrupt, which can be triggered when a conversion completes. When ADC
access to the Data Registers is prohibited between reading of ADCH and ADCL, the interrupt
will trigger even if the result is lost.

5.1.2 Block Diagram of A\D Converter

41
Figure 15: Block Diagram of A\D converter

5.1.3 Starting a Conversion

A single conversion is started by writing a logical one to the ADC Start Conversion bit,
ADSC. This bit stays high as long as the conversion is in progress and will be cleared by
hardware when the conversion is completed. If a different data channel is selected while a
conversion is in progress, the ADC will finish the current conversion before performing the
channel change.
In Free Running mode, the ADC is constantly sampling and updating the ADC Data Register.

Free Running mode is selected by writing the ADFR bit in ADCSRA to one. The first
conversion must be started by writing a logical one to the ADSC bit in ADCSRA. In this mode

42
the ADC will perform successive conversions independently of whether the ADC Interrupt Flag,
ADIF is cleared or not.

5.1.4 A/D Conversion Result

After the conversion is complete (ADIF is high), the conversion result can be found in
the ADC Result Registers (ADCL, ADCH).
For single ended conversion, the result is
|| ADC = (VIN .1024) /VREF ||
Where VIN is the voltage on the selected input pin and VREF the selected voltage reference

5.2 EEPROM Data Memory:

The ATmega16 contains 512 bytes of data EEPROM memory. It is organized as a


separate data space, in which single bytes can be read and written.

The EEPROM has an endurance of at least 100,000 write/erase cycles. The access
between the EEPROM and the CPU is described in the following, specifying the EEPROM
Address Registers. The EEPROM Data Register, and the EEPROM Control Register.

5.2.1 EEPROM Read/Write access


The EEPROM Access Registers are accessible in the I/O space. The write access time
for the EEPROM. A self-timing function, however lets the user software detect when the next
byte can be written. If the user code contains instructions that write the EEPROM, some
precautions must be taken.

In heavily filtered power supplies, VCC is likely to rise or fall slowly on Power-
up/down. This causes the device for some period of time to run at a voltage lower than specified
as minimum for the clock frequency used.

In order to prevent unintentional EEPROM writes, a specific write procedure must be


followed. When the EEPROM is read, the CPU is halted for four clock cycles before the next

43
instruction is executed. When the EEPROM is written, the CPU is halted for two clock cycles
before the next instruction is executed.

5.3 HT12E SERIES ENCODER

The HT12E encoder is a CMOS IC built especially


for remote control system applications. It is capable of
encoding 8 bits of address (A0-A7) and 4 bits of data
(AD8-AD11) information. Each address/data input can be
set to one of the two logic states, 0 or 1

Fig16:Holtek HT12E Encoder

Grounding the pins is taken as a 0 while a high can be given by giving +5V or leaving the
pins open (no connection). Upon reception of transmit enable (TE-active low), the programmed
address/data are transmitted together with the header bits via an RF medium.

5.3.1 FEATURES OF HT12E

• 2.4-12VOperation
• Low power, high noise immunity CMOS technology
• Low standby current of < 1µA at 5V supply
• Built-in oscillator with only a 5% resister
• Minimal external components

44
Table3: Pin Descriptions for HT12E

45
Table4: Electrical Characteristics for HT12E

46
5.3.2 Encoder Operation

The encoder starts a 4 word transmission cycle upon reception of a transmit enable (TE is active
low). This cycle repeats itself as long as TE is held low. Once the TE goes high, the encoder
completes its final cycle and stops as shown in Fig below.

Figure17: Encoder timing cycle

As soon as a transmit enable occurs, the encoder scans and transmits the status of the 12 bits of
address/data serially in the order A0 to AD11

47
5.3.3 ENCODER OPERATION FLOWCHART

The above operation in chapter 3.1.1 can be represented by a flowchart as shown below in

Figure 18: Encoder operation flowchart

As an illustration of the way the data is sent serially, if all the 8 address lines were left open (no
connection) and all 4 data lines were grounded, then the serial output would look like:

As stated earlier in chapter 3.1, all open circuit address lines will be read as logic high and all 4 data
bits will be read as 0 since they were grounded.

48
5.3.4 ENCODER OSCILLATION FREQUENCY
Since the encoder comes with a built in RC oscillator, its oscillation frequency can be set by
connecting a resistor between OSC1 (pin 16) and OSC2 (pin15). The oscillation frequency
depends on the resistor value as well as the supply voltage, as shown in Fig.

Fig:19 Encoder oscillation graph

This project will use a 5V supply hence will use a 1MP resistor to attain a 3 kHz
oscillation (as stated in the Fig. under typical oscillation frequency)

5.4 TLP434A ASK RF TRANSMITTER MODULE

Fig:20 TLP434A Transmitter and Pins

49
TLP434A is an Ultra Small Transmitter manufactured by Laipac Technology, Inc.
This transmitter transmits RF signals upon reception of digital serial data from its Data In
(pin2). It operates between 2.0-12V and uses the Amplitude Shift Keying modulation, detailed
explanation of which is given in chapter 2.2.3. Pin 4 of this transmitter can be connected directly
to an appropriate antenna via a 50P resister in order to provide a power output of 14dBm at 5V
operation. Shown in table 3.2, below are the Electrical characteristics of the transmitter. Out of
the 315 MHz, 418 MHz and 433.92 MHz versions, this project used the 433.92 MHz version of
the transmitter.

TABLE: 5 Electrical characteristics of transmitter

5.4.1 RF TRANSMITTER MODULE :

• Excellent performance.

• Simple to use.

50
5.4.2 SPECIFICATIONS:

• Frequency range: 315/433.92MHZ

• Supply voltage: 3~12V

• Operating temperature:-20 to +85

5.4.3 APPLICATIONS:

• Car security systems.


• Remote keyless entry.
• Garage door controller.
• Home security.
• Wireless mouse.
• Automation system.

5.5 HT12D 212 series Decoder


The decoder is capable of decoding 8 bits of
address (A0-A7) and 4 bits of data
(AD8-AD11) information.
Like the encoder, this decoder’s address pins
can be set to logic low by grounding and set
to logic high by either connecting the pins to
+5V or leaving them open (no connection).
Fig:21 HT12D Decoder
The decoder receives serial addresses and
data from a programmed encoder transmitted by a carrier using RF or an IR transmission
medium.

51
5.5.1 Features of HT12D:

• 2.4 – 12V operation


• Low power and high noise immunity CMOS technology
• Low standby current of < 1µA at 5V supply
• Binary address setting
• Three times of received address checking
• Built-in oscillator with only a 5% resistor
• Valid transmission indicator
• Easy interface with a RF or IR transmission medium
• Minimal external components

5.5.2 Decoder operation

HT12D receives digital serial data from its DIN (pin 14). A signal in the DIN activates
the oscillator which then decodes the incoming address and data. Figure below shows how the
decoder corresponds to the data sent by the encoder.

Fig:24
Figure 22: Decoder timing cycle
After decoding, it then checks the serial input data three times continuously with its local
addresses. If no error or unmatched codes are found, the input data codes are decoded and then
transferred to the data output pins. The valid transmission (VT- pin 17) also goes high to indicate
a successful transmission. This pin remains high for 214 = 16384 decoder clocks after the

52
encoder’s DOUT pin goes low. Since the decoder operates at 150 kHz, it takes 150000-1 * 16384
= 0.1 seconds for the VT pin to go low. This pin also goes low if the address code is incorrect or
no signal is received. The 4 data pins are latched to their respective pins, meaning that the
previous data remains on the pins unless a new data arrives to replace the existing one.

5.5.3 Decoder Operation flowchart


The decoder operation described above can be represented by a flowchart as shown in below Fig

Fig: 23 Decoder operation flowcharts

53
5.5.4 Decoder oscillation frequency

The decoder has a built in oscillator hence its clock can de set by connecting a resister
between OSC1 (pin 16) and OSC2 (pin 15). The oscillation frequency depends on the resistor
value as well as the power supply as shown in Fig below.

This project uses a 5V supply and it is recommended by the Holtek that Oscillator frequency of
decoder = 50 x oscillator frequency of encoder. Since the HT12E encoder works at 3 kHz, the
decoder frequency has to be 150 kHz. This requires a 51k resistor.

Fig: 24 Decoder oscillation graph

54
5.6 RLP434A ASK RF Receiver Module

Fig:25 RLP434A Receiver and Pins

RPL434A is a Surface Acoustic Wave (SAW) based receiver, which receives ASK
modulated RF signals and outputs the serial format of data which were embedded in the received
signal via its Digital data out (pin 2). It operates between 3.3 to 6.0V and also has an analog
output (linear out) for received signal testing purposes. Shown in table below are the parameters
and Electrical characteristics of the receiver. Out of the 315 MHz, 418 MHz and 433.92 MHz
versions, this project used the 433.92 MHz version of the receiver.

Table:6 Electrical Characteristics of receiver

55
5.6.1 RF RECEIVER MODULE:

It is a very good capability of UHF high frequency module.

• It is used by most advanced integrated circuits.

• It is widely used in high interfacing places.

5.6.2 SPECIFICATIONS:

• Modulation method: ASK


• Operating voltage:5.0Vdc +/-0.5v
• Operating current:<=9.5mA(5Vdc)
• Frequency:250MHZ-450MHZ
• Dimension:39.12*14.48*7.19

5.6.3 APPLICATIONS:

• Industrial control.
• Low-boud signal transport.
• Access control system.
• Not line of sight

56
CHAPTER 6:

AVR STUDIO4.1

57
6.1 Software Description

The startup wizard

Figure 26: Start up page


The Startup wizard:
The startup wizards are displayed every time we start AVR Studio 4. 18 From within this
dialog we can quickly platform/device setup or create a new project. reopen the latest used
projects, change debug.

New project:
If you want to create a new project, use this function.

Open:
If you want to load an existing project or a single debug object file, press this button.

Next Step:
This button is highlighted when a project is selected. Press next to select platform and device to
eventual change the debug platform or device setup for the selected project.

58
Project Details:

FIGURE 27: Select AVR GCC


Project types

• Currently two project types are available listed in the project type list box.
• Atmel AVR Assembler and AVR GCC. The assembler (AVRASM2) are
distributed with AVR Studio, but you have to download a GCC compiler to create
and use an AVR GCC project.

Project name and initial file


• Input the project name. Default the initial file will have the same name (ASM or C) and
will be created, but this can be changed.
• A folder with the project name can be created, but this is not default selected

59
Selecting Device

FIGURE 28 : Select ATMEGA MC

Selecting Device and simulator

FIGURE 29:Selecting device

60
Selecting Frequency
Go to Project->Configuration Options to bring the Project option dialog.

FIGURE 30: Select clock frequency


CPU frequency and compiler optimization
Enter the CPU frequency. If you are using xBoard™ or xBoard™ MINI enter 8 MHz i.e.
8000000. In addition, select optimization as -O2. Click ok. Now you have entered the code now
time to compile and build the project
Compilation or Build
Press F7 or select Build->Build or click the toolbar button for Build active configuration.

If the code is error free AVR studio will show you the following message.
Output Window

FIGURE 31: Build complete

61
Hex File Location

FIGURE 32: Select hex file

62
6.2 Source Code of the Project:

6.2.1 Transmitter code :

/********************************************/
//#includes
/********************************************/
// Standard Input/Output functions
#include <avr/io.h>
#include <stdio.h>
#include <util/delay.h>
#include<avr/interrupt.h>
#include <math.h>
#define F_CPU 8000000UL
#include<inttypes.h>
#include <avr/pgmspace.h>
#define VOLT_OFF 2.55
#define CURR_OFF 2.5
/********************************************/
//#defines
/********************************************/
#define ADC_VREF_TYPE 0x20 // Reserved see datasheet

********************************************/
// Read the AD conversion result
/********************************************/
Static int usart_putchar (char c, FILE *stream);
Static FILE mystdout=FDEV_SETUP_STREAM (usart_putchar, NULL,
_FDEV_SETUP_WRITE);

static int usart_putchar(char c, FILE *stream)

63
{
if (c == '\r')
usart_putchar(' ', stream);
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
unsigned char read_adc(unsigned char adc_input)
{
ADMUX = adc_input|ADC_VREF_TYPE;
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
DCSRA|=0x10;
return ADCH;
}
/********************************************/
// global variables
/********************************************/
int limit,m,n,s;
int i,temp;
float VOUT,data3,f_data3,gain,Temperature;
float ADC_1_Data;
float ADC_2_Data;
double ADC_1_RMS;
float ADC_2_RMS;
float VOLT_RMS;
double CUR_RMS;
double ADC_1_square;
float ADC_2_square;
static int counter = 0;

64
Unsigned nit volt,cur, Power,volt1,cur1;
void send( int a)
{
if(a==0)
PORTB=0b00000000;
if(a==1)
PORTB=0b00000001;
if(a==2)
PORTB=0b00000010;
if(a==3)
PORTB=0b00000011;
if(a==4)
PORTB=0b00000100;
if(a==5)
PORTB=0b00000101;
if(a==6)
PORTB=0b00000110;
if(a==7)
PORTB=0b00000111;
if(a==8)
ORTB=0b00001000;
if(a==9)
PORTB=0b00001001;
_delay_ms(150);
}
int main(void)
{
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;

65
UBRRL=51;
DDRB=0xff;
DDRD=0b10000000;
ACSR=0x80;
SFIOR=0x00;
ADMUX=ADC_VREF_TYPE;
ADCSRA=0x87;
FIOR&=0xEF;

Stdout = &mystdout;
Printf ("welcome\n\r");
While (1)
{
data3 = read_adc (0);
f_data3 = data3*5.0/256.0; // OPAMP VOTLAGE OUTPUT
Gain = 9.2; // gain = 1+(6K/1k)
VOUT = f_data3/gain; // lm 35 output voltage
Temperature= (100.0*VOUT);
Temp=Temperature;

ADC_1_Data = read_adc (2); //current


ADC_1_Data = ADC_1_Data*5.0/256.0;
ADC_1_Data = (ADC_1_Data - CURR_OFF);

ADC_2_Data = read_adc (1);//voltage


ADC_2_Data = ADC_2_Data*5.0/256;
ADC_2_Data = (ADC_2_Data - VOLT_OFF);

ADC_1_square += ADC_1_Data*ADC_1_Data; //current


ADC_2_square += ADC_2_Data*ADC_2_Data;//voltage
counter++;

66
if(counter >=500)
{
ADC_1_RMS = sqrt(ADC_1_square/500.0);
ADC_2_RMS = sqrt(ADC_2_square/500.0);
counter =0;
ADC_1_square =0;
ADC_2_square =0;

CUR_RMS=ADC_1_RMS*0.3;//TURN RATIO (1170)/RESISTANCE 3.3KOHMS)

VOLT_RMS = 4.77*ADC_2_RMS*230.0/9;

volt=VOLT_RMS;
volt1=volt;
Cur= CUR_RMS*1000;
cur1=cur;
PORTB=0b00001110;//temperature
_delay_ms(105);

Send (temp/10); //data

PORTB=0b00001011; //end
_delay_ms(105);
Send (temp%10);//data

PORTB=0b00001110; //temperature
_delay_ms(105);

PORTB=0b00001010; //tab condition


_delay_ms(105);
printf("\n\rTEMPERATURE= %d\n\r",temp);

67
if(temp>39)
{
PORTB=0b00001110; // over temperature condition
_delay_ms(105);
printf("\n\r\t\tOVER TEMPERATURE\n\r");
s=1;
}
else
{
s=0;
}

PORTB=0b00001101;//voltage
_delay_ms(105);

send(volt/100); //data
volt=volt%100;

PORTB=0b00001011; //end
_delay_ms(105);

send (volt/10); //data


Volt=volt%10;

PORTB=0b00001011; //end
_delay_ms(105);

send(volt); //data

68
PORTB=0b00001101;//voltage
_delay_ms(105);

PORTB=0b00001010; //tab
_delay_ms(105);
printf("\n\rVOLTAGE = %dV \n\r ", volt1);

if(volt1>250)
{
PORTB=0b00001101; //over voltage condition
_delay_ms(105);
printf("\n\r\t\tOVER VOLTAGE\n\r");
m=1;
}
else
{
m=0;
}
PORTB=0b00001100;//current
_delay_ms(105);

Send (cur/100); //data


cur=cur%100;

PORTB=0b00001011; //end
_delay_ms(105);

send(cur/10); //data
cur PORTB=0b00001100;//current
_delay_ms(105);

69
send(cur/100); //data
cur=cur%100;

PORTB=0b00001011; //end
_delay_ms(105);

send(cur/10); //data
cur=cur%10;
PORTB=0b00001011; //end
_delay_ms(105);

send(cur); //data

PORTB=0b00001100;//current
_delay_ms(105);

PORTB=0b00001010; //newline
_delay_ms(105);
printf("\n\rCURRENT = %dmA \n\r ",cur1);
if(cur1>470)
{
PORTB=0b00001100; //over current condition
_delay_ms(105);
printf("\n\r\t\tOVER CURRENT\n\r");
n=1;
}
else
{
n=0;
}

70
if(n==1 || m==1 || s==1)
{
printf("\n\rload off\n\r");
if(n==1)
{
PORTD=0x00;
}

else
{
PORTD=0x00;
}
}
else
{
PORTD=0b10000000;
printf("\n\rload on\n\r");
}
}
}
} // END MAIN

71
6.2.2 Receiver Code

/********************************************/
//#includes
/********************************************/
// Standard Input/Output functions
#include <avr/io.h>
#include <stdio.h>
#include <util/delay.h>
#include "LCDC.c"
/********************************************/
//#defines
/********************************************/
#define ADC_VREF_TYPE 0x20 // Reserved see datasheet
/********************************************/
// Read the AD conversion result
/********************************************/
static int usart_putchar(char c, FILE *stream);
staticFILEmystdout=FDEV_SETUP_STREAM(usart_putchar,NULL,_FDEV_SETUP_WRITE)
;
static int usart_putchar(char c, FILE *stream)
{
if (c == '\r')
usart_putchar(' ', stream);
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
unsigned char read_adc(unsigned char adc_input)

72
{
ADMUX = adc_input|ADC_VREF_TYPE;
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);

ADCSRA|=0x10;
return ADCH;
}
void receive(void)
{
if((PINC&0b00001111)==0b0000001)
{
while( ((PINC&0b00001111)==0b0000001) );
{
printf("1");
}
}
if((PINC&0b00001111)==0b0000010)
{
while( ((PINC&0b00001111)==0b00000010) );
{
printf("2");
}
}

if((PINC&0b00001111)==0b0000011)
{
while( ((PINC&0b00001111)==0b00000011) );
{

73
printf("3");
}
}
if((PINC&0b00001111)==0b0000100)
{
while( ((PINC&0b00001111)==0b00000100) );
{
printf("4");
}
}
if((PINC&0b00001111)==0b0000101)
{
while( ((PINC&0b00001111)==0b00000101) );
{
printf("5");
}
}
if((PINC&0b00001111)==0b0000110)
{
while( ((PINC&0b00001111)==0b00000110) );
{
printf("6");
}
}
if((PINC&0b00001111)==0b0000111)
{
while( ((PINC&0b00001111)==0b00000111) );
{
printf("7");
}
}

74
if((PINC&0b00001111)==0b0001000)
{
while( ((PINC&0b00001111)==0b00001000) );
{
printf("8");
}
}

if((PINC&0b00001111)==0b0001001)
{
while( ((PINC&0b00001111)==0b00001001) );
{
printf("9");
}
}

if((PINC&0b00001111)==0b0000000)
{
while( ((PINC&0b00001111)==0b00000000) );
{
printf("0");
}
}
}
/********************************************/
// global variables
/********************************************/
int limit;
int i,temp;
float VOUT,data3,f_data3,gain,Temperature;
int main(void)

75
{
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=51;
DDRC=0x00;
PORTC=0xff;
LCDclr();
LCDinit();
stdout = &mystdout;
printf("welcome hi\n\r");
while(1)
{
if((PINC&0b00001111)==0b0001110)
{
while( ((PINC&0b00001111)==0b00001110) );
{
printf("\n\rTEMPERATURE :");
}
LCDGotoXY(2,1);
receive();
if((PINC&0b00001111)==0b00001011)
{
while( ((PINC&0b00001111)==0b00001011) );
}
LCDGotoXY(3,1);
receive();
if((PINC&0b00001111)==0b0001110)
{
while( ((PINC&0b00001111)==0b00001110) );

76
}
if((PINC&0b00001111)==0b0001010)
{
while( ((PINC&0b00001111)==0b00001010) );
{
printf("\n\r");
}
}
if((PINC&0b00001111)==0b0001110)
{
while( ((PINC&0b00001111)==0b00001110) );
{
//LCDGotoXY(1,2);
//LCD string("OVER TEMPERATURE");
printf("\n\r\t\t OVER TEMPERATURE\n\r");
}
}

if((PINC&0b00001111)==0b0001101)
{
while( ((PINC&0b00001111)==0b00001101) );
{
printf("\n\r VOLTAGE :");
}
LCDGotoXY(5,1);
receive();
if((PINC&0b00001111)==0b00001011)
{
while( ((PINC&0b00001111)==0b00001011) );
}
LCDGotoXY(6,1);

77
receive();
if((PINC&0b00001111)==0b00001011)
{
while( ((PINC&0b00001111)==0b00001011) );
}
LCDGotoXY(7,1);
receive();
if((PINC&0b00001111)==0b0001101)
{
while( ((PINC&0b00001111)==0b00001101) );
}
if((PINC&0b00001111)==0b0001010)
{
while( ((PINC&0b00001111)==0b00001010) );
{
printf("V\n\r");
}
}
if((PINC&0b00001111)==0b0001101)
{
while( ((PINC&0b00001111)==0b00001101) );
{
//LCDGotoXY(1,2);
//LCDstring("OVER VOLTAGE");

printf("\n\r\t\tOVERVOLTAGE\n\r");
}
}

if((PINC&0b00001111)==0b0001100)
{

78
while( ((PINC&0b00001111)==0bs00001100) );
{
printf("\n\rCURRENT :");
}
LCDGotoXY(9,1);
receive();
if((PINC&0b00001111)==0b00001011)
{
while( ((PINC&0b00001111)==0b00001011) );
}
LCDGotoXY(10,1);
receive();
if((PINC&0b00001111)==0b00001011)
{
while( ((PINC&0b00001111)==0b00001011) );
}
LCDGotoXY(11,1);
receive();
if(PINC&0b00001111)==0b0001100)
{
while( ((PINC&0b00001111)==0b00001100) );
}
if((PINC&0b00001111)==0b0001010)
{
while( ((PINC&0b00001111)==0b00001010) );
{
printf("mA \n\r");
}
}
if((PINC&0b00001111)==0b0001100)
{

79
while( ((PINC&0b00001111)==0b00001100) );
{
//LCDGotoXY(1,2);
//LCDstring("tOVER CURRENT");
printf("\n\r\t\tOVER CURRENT\n\r");
}
}

}
}
}
//receive();
}
} // END MAIN

80
CHAPTER 7

CONCLUSIONS

81
CONCLUSION:

Overall the RF Technology implementation works very well in monitoring the industrial faults

and avoiding the damage of loads from high current, voltages, temperature. Hence the project

INDUSTRIAL FIRST FAULT MONITORING USING ASK-RF TECHNOLOGY has been

successfully implemented.

Future Scope:

Now in all industries wired technologies are used so it is can be retrofitted by a wireless
technology where in it can be ASK RF.

82
REFERENCES:

[1] Muhammad Ali Mazidi -The 8051 Microcontroller and Embedded Systems 2nd
edition, PEARSON EDUCATION, 2008
[2] Daniel W Lewis Fundamentals Of Embedded Software
[3] www.howsstuffworks.com
[4] www.alldatasheets.com
[5] www.electronicsforu.com
[6] www.knowledgebase.com
[7] www.8051 projectsinfo.com
[8] Datasheets of Microcontroller AT89C52
[9] Datasheets of 555 timer

83
APPENDIX

ABBREIVATIONS
ASK - AMPLITUDE SHIFT KEYING
RF - RADIO FREQUENCY
HT - HOLTEK’S COMPANY
A/D -ANALOG TO DIGITAL CONVERTOR
CT -CURRENT TRANSFORMER
PT -POTENIAL TRANSFORMER
GND -GROUND
AREF -ANALOG REFERENCE PIN
AVCC -ANALOG POWER SUPPLY
P0 - PORT 0
P1 - PORT 1
P2 - PORT 2
P3 - PORT 3
IE - INTERRUPT ENABLE CONTROL
IP - INTERRUPT PRIORITY CONTROL
TMOD- TIMER/COUNTER MODE CONTROL
TCON - TIMER/COUNTER CONTROL
T2CON - TIMER/COUNTER 2 CONTROL

84
T2MOD - TIMER/COUNTER MODE2 CONTROL
TH0 - TIMER/COUNTER 0HIGH BYTE
TL0 - TIMER/COUNTER 0 LOW BYTE
TH1 - TIMER/COUNTER 1 HIGH BYTE
TL1 - TIMER/COUNTER 1 LOW BYTE
ALU -ARITHMETIC LOGIC UNIT
TH2 - TIMER/COUNTER 2 HIGH BYTE
TL2 - TIMER/COUNTER 2 LOW BYTE
PCON - POWER CONTROL
PCB - PRINTED CIRCUIT BOARD

85

You might also like