72
CHAPTER 1 INTRODUTION 1.1 Introduction:- Automatic meter reading (AMR) is the technology of automatically collecting data from energy metering devices (water, gas, and electric) and transferring that data to a central database for billing and/or analyzing. This saves employee trips, and means that billing can be based on actual consumption rather than on an estimate based on previous consumption, giving customers better control of their use of electric energy, gas usage, or water consumption. This means that billing can be based on actual consumption rather than on an estimate based on previous consumption, giving customers better control of their use of electric energy. The Transmitter is connected to the meter and it counts the pulses from it and displays it over the seven segment display. It transmits the data over radio frequency. At the receiver end the data is received by an receiver module and the microcontroller will display it over the seven segment display. 1.2 Brief History: - The primary driver for the automation of meter reading is not so much to reduce labor costs, but to 1

automatic meter reading

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: automatic meter reading

CHAPTER 1

INTRODUTION

1.1 Introduction:-

Automatic meter reading (AMR) is the technology of automatically collecting

data from energy metering devices (water, gas, and electric) and transferring that data

to a central database for billing and/or analyzing. This saves employee trips, and

means that billing can be based on actual consumption rather than on an estimate

based on previous consumption, giving customers better control of their use of

electric energy, gas usage, or water consumption.

This means that billing can be based on actual consumption rather than on an

estimate based on previous consumption, giving customers better control of their use

of electric energy. The Transmitter is connected to the meter and it counts the pulses

from it and displays it over the seven segment display. It transmits the data over radio

frequency. At the receiver end the data is received by an receiver module and the

microcontroller will display it over the seven segment display.

1.2 Brief History:-

The primary driver for the automation of meter reading is not so much to

reduce labor costs, but to obtain data that is otherwise unattainable. Many meters,

especially water meters, are located in areas that require an appointment with the

homeowner. Gas and Electricity tend to be more valuable commodities than water,

and the need to offer actual readings instead of estimated readings can drive a utility

to consider automation. While early systems consisted of walk-by, and drive-by AMR

for residential.

Remote meter reading (or AMR) refers to the system that uses a

communication technique to automatically collect the meter readings and other

relevant data from utilities’ gas meters, without the need to physically visit the gas

meters. The development of AMR technology has catapulted meter data to center

stage of the utility business plan.

1

Page 2: automatic meter reading

1.3 Benefits of AMR:-

The automatic meter reading (AMR) technology is very useful in many

applications. By using AMR technology we can accommodate a lot of benefits. Some

benefits of AMR are as follow-

1.3.1 Electrical Company Benefits:-

Smart automated processes instead of manual work.

Accurate information from the network load to optimize maintenance and

investments.

Customized rates and billing dates.

Streamlined high bill investigations.

Detection of tampering of Meters.

Accurate measurement of transmission losses.

Better network performance and cost efficiency.

Demand and distribution management.

More intelligence to business planning.

Better company credibility.

1.3.2 Customer Benefits:-

Precise consumption information.

Clear and accurate billing.

Automatic outage information and faster recovery.

Better and faster customer service.

Flag potential high consumption before customer gets a high bill.

1.4 AMR Applications:-

As technology continues to improve in price/performance, the number of

municipal utilities implementing automatic meter reading (AMR) systems continues

to grow. Today, most AMR deployments are “walk-by” or “drive-by” systems. A

battery-operated transmitter in each meter sends a radio frequency (RF) signal that is

read by a special receiver either carried by hand or mounted in a vehicle. These

solutions require a much smaller staff of meter readers, who merely need to walk or

2

Page 3: automatic meter reading

drive by the many meters in any neighborhood. Although this form of AMR is an

enormous improvement over manual meter reading, continued high labor and vehicle

costs are driving the industry to an even better solution.

Among the many advantages are the ability to monitor daily demand,

implement conservation programs, create usage profiles by time of day, and detect

potentially hazardous conditions, such as leaks or outages. But there is still one

drawback with these AMR deployments: the costly network backhaul required by

leased lines or cellular services from a local telephone company, or Power Line

Carrier (PLC) solutions from the local power company.

AMR is the remote collection of consumption data from customers’ utility

meters using telephony, radio frequency, power lines and satellite communications

technologies. AMR provides water, gas and electric utility-service companies the

opportunity to increase operational efficiency, improve customer service, reduce data-

collection costs and quickly gather critical information that provides insight to

company decision-makers. [4]

1.5 Different AMR Technologies:-

There are many different technologies which are used in the AMR. Using

these technologies data can be send from transmitting end to the receiving end. In our

project we are using RF technology for transmitting the meter reading from one point

to other point. The different types of technologies are described below. Out of which

handheld technology is uses rarely. [1]

1.5.1 Handheld:-

In handheld AMR, a meter reader carries a handheld computer with a built-in

or attached receiver/transceiver (radio frequency or touch) to collect meter readings

from an AMR capable meter. This is sometimes referred to as "walk-by" meter

reading since the meter reader walks by the locations where meters are installed as

they go through their meter reading route. Handheld computers may also be used to

manually enter readings without the use of AMR technology.

3

Page 4: automatic meter reading

1.5.2 Touch Based:-

With touch based AMR, a meter reader carries a handheld computer or data

collection device with a wand or probe. The device automatically collects the readings

from a meter by touching or placing the read probe in close proximity to a reading

coil enclosed in the touchpad. When a button is pressed, the probe sends an

interrogate signal to the touch module to collect the meter reading. The software in

the device matches the serial number to one in the route database, and saves the meter

reading for later download to a billing or data collection computer.

1.5.3 Mobile:-

Mobile or "Drive-by" meter reading is where a reading device is installed in a

vehicle. The meter reader drives the vehicle while the reading device automatically

collects the meter readings. With mobile meter reading, the reader does not normally

have to read the meters in any particular route order, but just drives the service area

until all meters are read components often consist of a laptop or proprietary computer,

software, RF receiver or transceiver, and external vehicle antennas.

1.5.4 Fixed Network:-

Fixed Network AMR is a method where a network is permanently

installed to capture meter readings. This method can consist of a series of antennas,

towers, collectors, repeaters, or other permanently installed infrastructure to collect

transmissions of meter readings from AMR capable meters and get the data to a

central computer without a person in the field to collect it. [2]

There are several types of network topologies in use to get the meter data back

to a central computer. A star network is the most common, where a meter transmits its

data to a central collector or repeater. Some systems use only collectors which receive

and store data for processing. Others also use a repeater which forwards a reading

from a more remote area back to a main collector without actually storing it. A

repeater may be forwarded by RF signal or sometimes is converted to a wired network

such as telephone or IP network to get the data back to a collector. Some

manufacturers are developing mesh networks where meters themselves act as

repeaters passing the data to nearby meters until it makes it to a main collector. A

4

Page 5: automatic meter reading

mesh network may save the infrastructure of many collection points, but is more data

intensive on the meters. One issue with mesh networks it that battery operated ones

may need more power for the increased frequency of transmitting. [7]

1.5.5 Radio Frequency Network:-

Radio frequency based AMR can take many forms. The more common ones

are Handheld, Mobile, and Fixed network. There are both two-way RF systems and

one-way RF systems in use that use both licensed and unlicensed RF bands. In a two-

way or "wake up" system, a radio transceiver normally sends a signal to a particular

transmitter serial number, telling it to wake up from a resting state and transmit its

data. The Meter attached transceiver and the reading transceiver both send and receive

radio signals and data. In a one-way “bubble-up” or continuous broadcast type

system, the transmitter broadcasts readings continuously every few seconds. This

means the reading device can be a receiver only, and the meter AMR device a

transmitter only.

Data goes one way, from the meter AMR transmitter to the meter reading

receiver. There are also hybrid systems that combine one-way and two-way

technologies, using one-way communication for reading and two way communication

for programming functions.RF based meter reading usually eliminates the need for the

meter reader to enter the property or home, or to locate and open an underground

meter pit. The utility saves money by increased speed of reading, has lower liability

from entering private property, and has less chance of missing reads because of being

locked out from meter access.

1.5.6 Power Line Communication:-

AMR is a method where electronic data is transmitted over power lines back

to the substation, then relayed to a central computer in the utility's main office. This

would be considered a type of fixed network system the network being the

distribution network which the utility has built and maintains to deliver electric

power. Such systems are primarily used for electric meter reading. Some providers

have interfaced gas and water meters to feed into a PLC type system.

5

Page 6: automatic meter reading

1.5.7 Wireless Fidelity(Wi-Fi):-

Today many meters are designed to transmit using Wi-Fi even if a Wi-Fi

network is not available, and they are read using a drive-by local Wi-Fi hand held

receiver. Narrow-banded signal has a much greater range than Wi-Fi so the numbers

of receivers required for the project are far fewer the number of Wi-Fi access points

covering the same area. These special receiver stations then take in the narrow-band

signal and report their data via Wi-Fi Most of the automated utility meters installed in

the Corpus Christi area are battery powered. Compared to narrow-band burst

telemetry, Wi-Fi technology uses far too much power for long-term battery-powered

operation. Thus Wi-Fi is the efficient mean of communication in AMR technologies,

which allows communication between the central data base and the end users, and

defines the efficient reliability of the system. Thus offering a ultimate mean to fulfill

the requirement.

1.6 Description of RF Based AMR:-

Originally AMR devices just collected meter readings electronically &

matched them with accounts.

As technology has advanced, additional data could then be captured,

stored, and transmitted to the main computer, and often the metering devices

could be controlled remotely.

This can include events alarms such as tamper, leak detection, low battery, or

reverse flow.

Many AMR devices can also capture interval data, and log meter events.

Radio frequency based AMR can take many forms. The more common one are

Handheld, Mobile, and Fixed network.

6

Page 7: automatic meter reading

CHAPTER 2

CIRCUIT AND BLOCK DIAGRAMS

2.1 Transmitter Unit:-

The transmitter circuit diagram and block diagram are shown in figure 2.1 &

2.2 respectively. The data is transmitted from transmitter unit to the receiver unit

through RF channel.

Figure-2.1-Circuit diagram of transmitter unit

7

Page 8: automatic meter reading

Figure-2.2-Block diagram of transmitter unit

8

Page 9: automatic meter reading

2.2 Receiver Unit:-

The receiver unit circuit diagram and block diagram are shown in figure 2.3

and 2.4 respectively. The main purpose of the receiver unit is to receive the sending

end data. The is finally display on the seven segment display.

Figure-2.3-Circuit diagram of receiver unit

9

Page 10: automatic meter reading

Figure-2.4-Block diagram of receiver unit

10

Page 11: automatic meter reading

CHAPTER 3

TRANSMITTER UNIT

3.1 Introduction:-

Transmitter unit is used to send the meter reading to the receiving end. The

data is send to the receiver end through RF channel. The transmitter unit consist of

transmitter module, encoder HT12E, microcontroller AT89C2051 and display driver

74LS244.The pulses are given to the of microcontroller via optocoupler. For display

the meter reading we are using seven segments. The supply which is given to the

transmitter unit is +5 volt.

3.2 Microcontroller AT89C2051:-

3.2.1 Features:-

Compatible with MCS®-51Products

2K Bytes of Reprogrammable Flash Memory

2.7V to 6V Operating Range

Fully Static Operation: 0 Hz to 24 MHz

Two-level Program Memory Lock

128 x 8-bit Internal RAM

15 Programmable I/O Lines

Two 16-bit Timer/Counters

Six Interrupt Sources

Programmable Serial UART Channel

Direct LED Drive Output

On-chip Analog Comparator

Low-power Idle and Power-down Modes

Green (Pb/Halide-free) Packaging Option

11

Page 12: automatic meter reading

Figure-3.1-Pin configuration of AT89C2051

3.2.2 Description:-

The AT89C2051 is a low-voltage, high-performance CMOS 8-bit

microcomputer with 2K bytes of Flash programmable and erasable read-only

memory (PEROM). The device is manufactured using Atmel’s high-density

nonvolatile memory technology and is compatible with the industry-standard MCS

instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip,

the Atmel AT89C2051 is a power-full microcomputer which provides a highly-

flexible and cost-effective solution to many embedded control applications. The

AT89C2051 provides the following standard features: 2K bytes of Flash, 128 bytes

of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt

architecture, a full duplex serial port, a precision analog comparator, on-chip

oscillator and clock circuitry. In addition, the AT89C2051 is designed with static

logic for operation down to zero frequency and supports two software selectable

power saving modes. The Idle Mode stops the CPU while allowing the RAM,

timer/counters, serial port and interrupt system to continue functioning. . The power-

down mode saves the RAM contents but freezes the oscillator disabling all other chip

functions until the next hardware reset. [5]

12

Page 13: automatic meter reading

Figure-3.2-Block diagram of AT89C2051

13

Page 14: automatic meter reading

3.2.3 Pin Description:-

Table-3.1-Pin description of AT89C2051

Pin Number Description

1 RESET - Reset

2 P3.0 - Port 3 - RXD

3 P3.1 - Port 3 - TXD

4 XTAL2 - Crystal

5 XTAL1 - Crystal

6 P3.2 - Port 3 - INT0

7 P3.3 - Port 3 - INT1

8 P3.4 - Port 3 - TO

9 P3.5 - Port 3 - T1

10 GND - Ground

11 P3.7 - Port 3

12 P1.0 - Port 1 - AIN0

13 P1.1 - Port 1 – A1N1

14 P1.2 - Port 1

15 P1.3 - Port 1

16 P1.4 - Port 1

17 P1.5 - Port 1

18 P1.6 - Port 1

19 P1.7 - Port 1

20 Vcc - Positive Power Supply

1. Vcc

Supply voltage

2. GND

Ground

3. Port 1

14

Page 15: automatic meter reading

Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal

pull-ups. P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as

the positive input (AIN0) and the negative input (AIN1), respectively, of the

on-chip precision analog comparator. The Port 1 output buffers can sink 20

mA and can drive LED displays directly. When 1s are written to Port 1 pins,

they can be used as inputs. When pins P1.2 to P1.7 are used as inputs and are

externally pulled low, they will source current (IIL) because of the internal

pull-ups. Port 1 also receives code data during Flash programming and

verification.

4. Port 3

Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal

pull-ups. P3.6 is hard-wired as an input to the output of the on-chip

comparator and is not accessible as a general purpose I/O pin. The Port 3

output buffers can sink 20 mA. When 1s are written to Port 3 pins they are

pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

3 pins that are externally being pulled low will source current (IIL) because of

the pull-ups.

5. RST

Reset input. All I/O pins are reset to 1s as soon as RST goes high. Holding the

RST pin high for two machine cycles while the oscillator is running resets the

device. Each machine cycle takes 12 oscillator or clock cycles.

Table-3.2-Special features of AT89C2051 serve by Port 3

Port Pin Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

15

Page 16: automatic meter reading

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

6. XTAL1

Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

3.2.4 Oscillator Characteristics:-

The XTAL1 and XTAL2 are the input and output, respectively, of an inverting

amplifier which can be configured for use as an on-chip oscillator, as shown in Figure

5-1 . Either a quartz crystal or ceramic resonator may be used. To drive the device

from an external clock source, XTAL2 should be left unconnected while XTAL1 is

driven as shown in Figure 5-2 . There are no requirements on the duty cycle of the

external clock signal, since the input to the internal clocking circuitry is through a

divide-by-two flip-flop, but minimum and maximum voltage high and low time

specifications must be observed.

3.2.5 Restrictions on Certain Instructions:-

The AT89C2051 and is an economical and cost-effective member of Atmel’s

growing family of microcontrollers. It contains 2K bytes of flash program memory. It

is fully compatible with the MCS-51 architecture, and can be programmed using the

MCS-51 instruction set. However, there are a few considerations one must keep in

mind when utilizing certain instructions to program this device. All the instructions

related to jumping or branching should be restricted such that the destination address

falls within the physical program memory space of the device, which is 2K for the

AT89C2051. This should be the responsibility of the software programmer. For

example, LJMP 7E0H would be a valid instruction for the AT89C2051 (with 2K of

memory), whereas LJMP 900H would not.

3.2.6 Branching Instructions:-

16

Page 17: automatic meter reading

LCALL, LJMP, ACALL, AJMP, SJMP, JMP @A+DPTR These

unconditional branching instructions will execute correctly as long as the programmer

keeps in mind that the destination branching address must fall within the physical

boundaries of the program memory size (locations 00H to 7FFH for the 89C2051).

Violating the physical space limits may cause unknown program behavior. CJNE [...],

DJNZ [...], JB, JNB, JC, JNC, JBC, JZ, JNZ With these conditional branching

instructions the same rule above applies. Again, violating the memory boundaries

may cause erratic execution. For applications involving interrupts the normal interrupt

service routine address locations of the 80C51 family architecture have been

preserved.

3.3 Display Driver 74LS244:-

The 74LS244 is Octal Buffer and Line Driver designed to be employed as

memory address drivers, clock drivers and bus-oriented transmitters/receivers which

provide improved PC board density.

Hysteresis at Inputs to Improve Noise Margins.

3-State Outputs Drive Bus Lines or Buffer Memory Address Registers.

Figure-3.3-Logic and connection diagrams DIP (Top view)

Truth Table-3.3-74LS244

17

Page 18: automatic meter reading

H = High voltage level, L = Low voltage level

X = Immaterial, Z = High Impedance

Table-3.4-Guaranteed Operating Ranges

3.4 Optocoupler MCT2E:-

There are many situations where signals and data need to be transferred from

one subsystem to another within a piece of electronics equipment, or from one piece

of equipment to another, without making a direct ohmic electrical connection. Often

this is because the source and destination are (or may be at times) at very different

voltage levels, like a microprocessor which is operating from 5V DC but being used

to control a triac which is switching 240V AC. In such situations the link between the

two must be an isolated one, to protect the microprocessor from over voltage damage.

Relays can of course provide this kind of isolation.

18

Page 19: automatic meter reading

Because they’re electro-mechanical, relays are also not as reliable. And only

capable of relatively low speed operation. Where small size, higher speed and greater

reliability are important, a much better alternative is to use an optocoupler. These use

a beam of light to transmit the signals or data across an electrical barrier, and achieve

excellent isolation. Optocouplers typically come in a small 6-pin or 8-pin IC package,

but are essentially a combination of two distinct devices: an optical transmitter,

typically a gallium arsenide LED (light-emitting diode) and an optical receiver such

as a phototransistor or light-triggered diac. The two are separated by a transparent

barrier which blocks any electrical current flow between the two, but does allow the

passage of light.

Along with the usual circuit symbol for an optocoupler. Usually the electrical

connections to the LED section are brought out to the pins on one side of the package

and those for the phototransistor or diac to the other side, to physically separate them

as much as possible. This usually allows optocouplers to withstand voltages of

anywhere between 500V and 7500V between input and output. Optocouplers are

essentially digital or switching devices, so they’re best for transferring either on-off

control signals or digital data. Analog signals can be transferred by means of

frequency or pulse-width modulation. The package consists of a gallium-arsenide

infrared-emitting diode and an npn silicon phototransistor mounted on a 6-lead frame

encapsulated within an electrically nonconductive plastic compound. The case can

withstand soldering temperature with no deformation and device performance

characteristics remain stable when operated in high-humidity conditions. Unit weight

is approximately 0.52 grams. [8]

Figure-3.4-MCT2E Package (Top view)

19

Page 20: automatic meter reading

3.4.1 Features:-

Gallium Arsenide Diode Infrared Source Optically Coupled to a Silicon npn

Phototransistor

High Direct-Current Transfer Ratio

Base Lead Provided for Conventional Transistor Biasing

High-Voltage Electrical Isolation ,1.5-kV, or 3.55-kV Rating

Plastic Dual-In-Line Package

High-Speed Switching: tr = 5 s, tf = 5 s Typical

Designed to be Interchangeable with General Instruments MCT2 and MCT2E

3.4.2 Absolute maximum ratings at 25C free-air temperature:

Input-to-output voltage MCT2E……………………………………………...+ 3.55

kV

Collector-base voltage……………………………………………………………..70 V

Collector-emitter voltage…………………………………………………………..30 V

Emitter-collector voltage………………………………………………………........7 V

Input-diode reverse voltage…………………………………………………………3 V

Input-diode continuous forward current…………………………………………60 mA

Continuous power dissipation at (or below) 25°C free-air temperature:

a) Infrared-emitting diode……………………………………...200 mW

b) Phototransistor. . …………………………………………..200 mW

c)Total, infrared-emitting diode plus phototransistor………….250 mW

Operating free-air temperature range, TA……………………………..–55°C to 100°C

Lead temperature 1,6 mm (1/16 inch) from case for 10 seconds………………...260°C

Table-3.5-Switching characteristics

20

Page 21: automatic meter reading

Figure-3.5-Typical characteristics

3.5 Encoder HT12E:-

3.5.1 Features:-

Operating voltage

2.4V~12V for the HT12E

Low power and high noise immunity CMOS technology

Low standby current: 0. (typ.) at VDD=5V

HT12A with a 38kHz carrier for infrared transmission medium

Minimum transmission word

Four words for the HT12E

Built-in oscillator needs only 5% resistor

21

Page 22: automatic meter reading

Data code has positive polarity

Minimal external components

HT12A/E: 18-pin DIP/20-pin SOP package

3.5.2 Applications:-

Burglar alarm system

Smoke and fire alarm system

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control systems

3.5.3 General Description:-

The 2^12 encoders are a series of CMOS LSIs for remote control system

applications. They are capable of encoding information which consists of N address

bits and 12-N data bits. Each address/data input can be set to one of the two logic

states. The programmed addresses/data are transmitted together with the header bits

via an RF or an infrared transmission medium upon receipt of a trigger signal. The

capability to select a TE trigger on the HT12E or a DATA trigger on the HT12A

further enhances the application flexibility of the 2^12 series of encoders.

22

Page 23: automatic meter reading

Figure-3.6-Pin assignment of HT12E-18 DIP

Table-3.6-Pin description of HT12E

PIN

NAMEI/O

INTERNAL

CONNECTION DESCRIPTION

A0-A8 I

NMOS transmissionGate protection

diode

Input pins for address A0~A7 setting These pins can be

externally set to VSS or left open

AD8~AD11 I

NMOS transmissionGate protection

diode

Input pins for address/data AD8~AD11 settingThese pins can be

externally set to VSS or left

open

DOUT O CMOS OUTEncoder data serial

transmission output

L/MB ICMOS INPull-high

Latch/Momentary transmission format selection

pin:Latch: Floating or VDD

Momentary: VSS

I CMOS INPull-high

Transmission enable, active low

OSC1 I OSCILLATOR 1 Oscillator input pin

OSC2 O OSCILLATOR 1 Oscillator output pin

X1 I OSCILLATOR 2455kHz resonator oscillator

input

X2 O OSCILLATOR 2455kHz resonator oscillator

output

23

Page 24: automatic meter reading

VSS I ------------Negative power supply,

grounds

VDD I ------------- Positive power supply

3.5.4 Functional Description:-

3.5.4.1 Operation:

The 2^12 series of encoders begin a 4-word transmission cycle upon receipt of

a transmission enable (TE for the HT12E or D8~D11 for the HT12A, active low).

This cycle will repeat itself as long as the transmission enable (TE or D8~D11) is held

low. Once the transmission enables returns high the encoder output completes its final

cycle and then stops as shown below.

Figure-3.7-Transmission timing for the HT12E

3.5.4.2 Information Word:-

If L/MB=1 the device is in the latch mode (for use with the latch type of data

decoders). When the transmission enable is removed during a transmission, the

DOUT pin outputs a complete word and then stops. On the other hand, if L/MB=0 the

device is in the momentary mode. When the transmission enable is removed during a

transmission, the DOUT outputs a complete word and then adds 7 words all with the

“1” data code. An information word consists of 4 periods as illustrated below.

24

Page 25: automatic meter reading

Figure-3.8-Composition of information

3.5.4.3 Address/Data Waveform:-

Each programmable address/data pin can be externally set to one of the

following two logic states as shown in figure 3.9.

Figure-3.9-Address/Data bit waveform for the HT12E

3.5.5 Address/Data Programming (Preset):-

The status of each address/data pin can be individually pre-set to logic “high”

or “low”. If a transmission- enable signal is applied, the encoder scans and transmits

the status of the 12 bits of address/data serially in the order A0 to AD11 for the

HT12E encoder and A0 to D11 for the HT12A encoder. During information

transmission these bits are transmitted with a preceding synchronization bit. If the

trigger signal is not applied, the chip enters the standby mode and consumes a reduced

current of less than 1 A for a supply voltage of 5V.

25

Page 26: automatic meter reading

Figure-3.10-Application circuit of Encoder HT12E

3.6 Seven Segment Display:-

A seven-segment display less commonly known as a seven-segment indicator,

is a form of electronic display device for displaying decimal numerals that is an

alternative to the more complex dot-matrix displays. Seven-segment displays are

widely used in digital clocks, electronic meters, and other electronic devices for

displaying numerical information.

A seven segment display, as its name indicates, is composed of seven

elements. Often the seven segments are arranged in an oblique, or italic, arrangement,

which aids readability. The seven segments are arranged as a rectangle of two vertical

segments on each side with one horizontal segment on the top and bottom.

Additionally, the seventh segment bisects the rectangle horizontally. There are also

fourteen-segment displays and sixteen-segment displays (for full alphanumeric);

however, these have mostly been replaced by dot-matrix displays. In a simple LED

package, each LED is typically connected with one terminal to its own pin on the

outside of the package and the other LED terminal connected in common with all

other LEDs in the device and brought out to a shared pin. This shared pin will then

make up all of the cathodes (negative terminals) OR all of the anodes (positive

terminals) of the LEDs in the device; and so will be either a "Common Cathode" or

"Common Anode" device depending how it is constructed. Hence a 7 segment plus

DP package will only require nine pins to be present and connected.

26

Page 27: automatic meter reading

3.7 AM Transmitter Module:-

Amplitude modulated transmitter module is attached in the transmitter unit.

The module has four connecting leads. The pin number 1 is connected to the ground

terminal, pin number 2 is connected to the DOUT terminal of the encoder IC HT12E.

The +5 volt supply is given to the pin number 3 of the transmitter module. And finally

the last pin number 4 is connected to the antenna through which data is send over RF.

The AM transmitter is based on the principle of sending data by modulate the

amplitude of the output of encoder. Here is used to eliminate the noise which occurs

during the data transmission.

The supply which is given to the transmitter module is given by the regulated

power supply. By which a regulate power is drawn by the AM transmitter. The

module has also crystal oscillators which are attached to the upper portion of the

transmitter module. The market price of this module is very high. They are not easily

available very easily. Thus the general importance of AM transmitter module is very

large in many applications. [11]

3.8 Antenna:-

An antenna for use in an automatic meter reading (AMR) module comprises a

pin and a radiator. The radiator may be a disk radiator for example, that comprises an

opening which may receive the pin. Desirably, the pin is affixed to the radiator at one

end, and is disposed on a ground plane at the other end. The antenna may be a top

loaded short monopole antenna, for example. Additionally, the antenna may be used

in a module for a water meter. The pin and disk radiator may be stamped from a

single sheet of material. AMR devices must be able to communicate in various

unfriendly environments. For example, AMR devices for water meters must be able to

communicate in the RF unfriendly environment of the iron water pit. Typically, this is

accomplished by placing an antenna on top of the water pit lid, with the connection to

the meter going through a hole in the lid. This allows a large antenna area, but the

antenna often protrudes dangerously high above the lid, and requires a field installed

connection between the antenna and the water meter. Another typical installation has

the antenna protruding through a hole in the pit lid. This has the advantages of a low

profile above the lid, and the connection from the antenna to the water meter can be

27

Page 28: automatic meter reading

made at the factory. The main drawbacks that the entire antenna must be small

enough to fit through a small hole in the lid, and cannot have much elevation above

the lid.

3.9 Pulse Generator:-

A pulse generator can either be an internal circuit or a piece of electronic test

equipment used to generate pulses. Simple pulse generators usually allow control of

the pulse repetition rate (frequency), pulse width, delay with respect to an internal or

external trigger and the high- and low-voltage levels of the pulses. More-sophisticated

pulse generators may allow control over the rise time and fall time of the pulses. Pulse

generators may use digital techniques, analog techniques, or a combination of both

techniques to form the output pulses. For example, the pulse repetition rate and

duration may be digitally controlled but the pulse amplitude and rise and fall times

may be determined by analog circuitry in the output stage of the pulse generator. With

correct adjustment, pulse generators can also produce a 50% duty cycle square wave.

Pulse generators are generally single-channel providing one frequency, delay, width

and output. To produce multiple pulses, these simple pulse generators would have to

be ganged in series or in parallel. Pulse generators are generally voltage sources, with

true current pulse generators being available only from a few suppliers. Light pulse

generators are the optical equivalent to electrical pulse generators with rep rate, delay,

width and amplitude control. The output in this case is light typically from a LED or

laser diode. These pulses can then be injected into a device under test and used as a

stimulus or clock signal or analyzed as they progress through the device, confirming

the proper operation of the device or pinpointing a fault in the device. [12]

28

Page 29: automatic meter reading

Figure-3.11-Connection diagram of Pulse Generator

CHAPTER 4

RECEIVER UNIT

4.1 Introduction:-

The R.F. Solutions range of AM ‘Super Regen’ Receiver modules are compact

hybrid RF receivers, which can be used to capture uudecoded data from any AM

Transmitter, such as R.F. Solutions AM-RT4 / 5 range of transmitters. These modules

show a very high frequency stability over a wide operating temperature even when

subjected to mechanical vibrations or manual handling. A unique laser trimming

process which has been patented gives a very accurate on board inductor, removing

the need for any adjustable components. and require connections to power and

29

Page 30: automatic meter reading

antenna only. In addition the it operates from a 5Vdc supply. RF Solutions also offer a

range of Super Heterodyne Receivers.

4.2 AM Receiver Module:-

The receiver module has IC RX3400/RX3400 crystal oscillator, capacitor,

inductor and many components. The RX3400/RX3400-LF is low powers ASK

receiver IC which is fully compatible with the Mitel KESRX01 IC and is suitable for

use in a variety of low power radio applications including remote keyless entry. The

RX3400/RX3400-LF is based on a single-conversion, super-heterodyne receiver

architecture and incorporates an entire phase-locked loop (PLL). [9]

4.2.1 Features:-

Frequency Range: 433.92MHz

Modulate Mode: ASK

Circuit Shape: LC

Date Rate:-4800bps

Selectivity:-106dBm

Channel Spacing: ±500KHz

Supply Voltage: 5V

High Sensitivity Passive Design.

Figure-4.1-Pin assignment

30

Page 31: automatic meter reading

Figure-4.2- Circuit diagram

Table-4.1-Pin description of RX3400

31

Page 32: automatic meter reading

4.2.2 Functional Description:-

The RX3400/RX3400-LF ASK receiver IC incorporates an LNA; mixer; PLL-

based local oscillator including VCO, fixed divider (÷ 64), reference crystal oscillator,

phase-frequency detector (PFD), and charge pump; IF filter; logarithmic amplifier;

data filter; peak detector; and 1-bit comparator and is capable of demodulating ASK

input signals.

4.2.3 PLL Power-Down Function:

The PLL portion of the IC can be powered up and down through the control of

the PD input (pin 14). During PLL power down operation (pin 14 pull low), the

reference crystal oscillator, fixed VCO divider, PFD, and charge pump are all shut off

and the current consumption of the IC drops by approximately 600 μA. The VCO

circuitry remains on and may be configured to operate as a buffer amplifier for an

external SAW-based oscillator.

32

Page 33: automatic meter reading

Figure-4.3-Application circuit of RX3400

4.3 Antenna:-

The antenna is also used at the receiver unit to collect the data which is send

by the transmitting antenna. The antenna receives the desired signal and sends the

data to the decoder circuit. For example, AMR devices for water meters must be able

to communicate in the RF unfriendly environment of the iron water pit. Typically, this

is accomplished by placing an antenna on top of the water pit lid, with the connection

to the meter going through a hole in the lid. This allows a large antenna area, but the

antenna often protrudes dangerously high above the lid, and requires a field-installed

connection between the antenna and the water meter.

4.4 Decoder HT12D:-

33

Page 34: automatic meter reading

4.4.1 Features:-

Operating voltage: 2.4V~12V

Low power and high noise immunity CMOS technology

Low standby current

Capable of decoding 12 bits of information

Binary address setting

Received codes are checked 3 times

Address/Data number combination- HT12D: 8 address bits and 4 data bits

Built-in oscillator needs only 5% resistor

Valid transmission indicator

Easy interface with an RF or an infrared transmission medium

Minimal external components

Pair with Holtek’s 212 series of encoders

18-pin DIP, 20-pin SOP package

4.4.2 Applications:-

Burglar alarm system

Smoke and fire alarm system

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control systems

4.4.3 General Description:-

The 2^12 decoders are a series of CMOS LSIs for remote control system

applications. They are paired with Holtek’s 2^12 series of encoders (refer to the

encoder/decoder cross reference table). For proper operation, a pair of

encoder/decoder with the same number of addresses and data format should be

chosen. The decoders receive serial addresses and data from a programmed 2^12

series of encoders that are transmitted by a carrier using an RF or an IR transmission

34

Page 35: automatic meter reading

medium. They compare the serial input data three times continuously with their local

addresses. If no error or unmatched codes are found, the input data codes are decoded

and then transferred to the output pins. The VT pin also goes high to indicate a valid

transmission. The 2^12 series of decoders are capable of decoding informations that

consist of N bits of address and 12-N bits of data. Of this series, the HT12D is

arranged to provide 8 address bits and 4 data bits, and HT12F is used to decode 12

bits of address information. [10]

8-Address & 4-Data

Figure-4.4-Pin diagram of HT12D

Table-4.2-Pin description of HT12D

4.5 Seven Segment Display:-

35

Page 36: automatic meter reading

A seven-segment display (abbreviation:"7-segment display"), less commonly

known as a seven-segment indicator, is a form of electronic display device for

displaying decimal numerals that is an alternative to the more complex dot-matrix

displays. Seven-segment displays are widely used in digital clocks, electronic meters,

and other electronic devices for displaying numerical information.

A seven segment display, as its name indicates, is composed of seven

elements. Often the seven segments are arranged in an oblique, or italic, arrangement,

which aids readability. The seven segments are arranged as a rectangle of two vertical

segments on each side with one horizontal segment on the top and bottom.

Additionally, the seventh segment bisects the rectangle horizontally. There are also

fourteen-segment displays and sixteen-segment displays (for full alphanumeric);

however, these have mostly been replaced by dot-matrix displays. In a simple LED

package, each LED is typically connected with one terminal to its own pin on the

outside of the package and the other LED terminal connected in common with all

other LEDs in the device and brought out to a shared pin. This shared pin will then

make up all of the cathodes (negative terminals) OR all of the anodes (positive

terminals) of the LEDs in the device; and so will be either a "Common Cathode" or

"Common Anode" device depending how it is constructed. Hence a 7 segment plus

DP package will only require nine pins to be present and connected. [15]

4.6 Microcontroller AT89C2051:-

The AT89C2051 is a low-voltage, high-performance CMOS 8-bit

microcomputer with 2K bytes of Flash programmable and erasable read-only memory

(PEROM). The device is manufactured using Atmel’s high-density nonvolatile

memory technology and is compatible with the industry-standard MCS instruction set.

By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel

AT89C2051 is a powerful microcomputer which provides a highly-flexible and cost-

effective solution to many embedded control applications. The AT89C2051 provides

the following standard features: 2K bytes of Flash, 128 bytes of RAM, 15 I/O lines,

two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex

serial port, a precision analog comparator, on-chip oscillator and clock circuitry.

4.7 Display Driver 74LS244:-

36

Page 37: automatic meter reading

The 74LS244 is Octal Buffer and Line Driver designed to be employed as

memory address drivers, clock drivers and bus-oriented transmitters/receivers which

provide improved PC board density.

Hysteresis at Inputs to Improve Noise Margins.

3-State Outputs Drive Bus Lines or Buffer Memory Address Registers.

Input Clamp Diodes Limit High-Speed Termination Effects.

4.8 Regulated Power Supply:-

4.8.1 Features:-

Output Current up to 1A

Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V

Thermal Overload Protection

Short Circuit Protection

Output Transistor Safe Operating Area Protection

4.8.2 Description:-

The LM7805C series of three terminal positive regulators are available in the

TO-220/D-PAK package and with several fixed output voltages, making them useful

in a wide range of applications. Each type employs internal current limiting, thermal

shut down and safe operating area protection, making it essentially indestructible. If

adequate heat sinking is provided, they can deliver over 1A output current.

Figure-4.5-Circuit diagram of Regulated Power Supply

CHAPTER 5

37

Page 38: automatic meter reading

AMR WORKING

5.1 Working of Transmitter Unit:-

The data is send from the transmitter unit to the receiver unit via RF channel.

In transmitter unit we use 20 pin microcontroller AT89C2051.The pin no.7 of the

microcontroller receives the pulses from the pulse generator output pin 8.The pulse

generator also having a AT89C2051 microcontroller. In connection diagram of pulse

generator pin no.16 to 19 of the microcontroller is connected to 200W, 100W, 50W

and 20W switches respectively. When the switches are close as our requirement the

pulses are generated. The no. of pulses are different for each combination of closing

of switches. These pulses are now send from pin no.8 of pulse generator

microcontroller. The pulses are now given to a LED which emits the light when

pulses are come out from the pulse generator otherwise not. The emitting light from

the LED is given to the optocoupler MCT2E.It behaves like a isolator device. Due to

emitting light the optocoupler trigger. The collector terminal of the MCT2E is

connected to the pin no.7 of the transmitter unit microcontroller.

In transmitter unit we also use the four seven segment display, which shows

the reading of the meter. Each seven segment display has 7 LEDs.Each LED has two

lead. One lead of each LED is connected to the pin no.13 to 19 of microcontroller.

The second pin of each LED is connected to each other. The power required for the

glowing of the LEDs is drawn from the display driver 74LS244, which acts like a

current amplifier. The data can also be send from the transmitting antenna. But the

noise present in the signal. So to reduce the noise we use the encoder HT12E between

microcontroller and AM transmitter. The encoder HT12E has 18 pin. In which pin

no.12 receive clock pulse and the pin no.13 receive the data signal from the pin no.3

of microcontroller. The output of the encoder is taken out from the pin no.17.The pin

no.17 of the encoder is connected to the pin no.2 of the AM transmitter. In AM

transmitter the signal is amplitude modulated. Output of the AM transmitter is given

to the antenna from the pin no.4.The antenna transmit the data signal through RF.

5.2 Working of Receiver Unit:-

38

Page 39: automatic meter reading

The transmitted data is received by the antenna situated at the receiver unit.

After receiving the signal the data is given to the pin no.8 of the AM receiver. The

output the AM receiver is given to the decoder HT12D.The decoder is used to decode

the encoded data. The pin no.2 of the AM receiver is connected to the pin no.14 of the

decoder. Pin no.14 of the decoder is the DIN (Data Input).The pin no. 13 of the

decoder is connected to microcontroller pin no.2 from which data is given to the

microcontroller. The pin no. 17 of decoder is VT (Valid Transmission) which is a

active high terminal. When the reading is comes it become active high, and a high

signal is appear at the base terminal of the transistor.

When the VT=1, the transistor is turn on and a high signal appear at the

collector terminal. Due to which the LED which is connected to the collector terminal

is glow up and emit the light. This shows power consumption is taking place at the

transmitter unit.VT terminal is also connected to the pin no.6 of the microcontroller.

Pin no.13 to 19 of the microcontroller is connected to the one terminal of each LED.

The second pin of each LED is connected to each other. In parallel combination of

seven segments display each segment glow simultaneously. But the glowing time

interval between successive segments is very low. And it seems like that all the

segments are growing at the same time. By using special instruments we can see the

simultaneously glowing of the two successive seven segment display.

The power required for the glowing of the LEDs is drawn from the display

driver 74LS244, which acts like a current amplifier. If we do not use display driver

the LED will not glow because the proper power required to display the data is not too

much. Thus display driver 74LS244 is used to provide proper to seven segment

display. By which we can easily read out the reading from the seven segment display

unit. Thus the actual meter reading can be seen at the seven segment display. The dc

supply given to all the IC is generally. The meter reading is very useful in many

applications.

CHAPTER 6

39

Page 40: automatic meter reading

FUTURE ADVANCEMENT AND CONCLUSION

6.1 Introduction:-

Originally AMR devices just collected meter readings electronically and

matched them with accounts. As technology has advanced, additional data could then

be captured, stored, and transmitted to the main computer, and often the metering

devices could be controlled remotely. This can include events alarms such as tamper,

leak detection, low battery, or reverse flow. Many AMR devices can also capture

interval data, and log meter events. The logged data can be used to collect or control

time of use or rate of use data that can be used for water or energy usage profiling,

time of use billing, demand forecasting, demand response, rate of flow recording, leak

detection, flow monitoring, water and energy conservation enforcement, remote

shutoff, etc. Advanced Metering Infrastructure, or AMI is the new term coined to

represent the networking technology of fixed network meter systems that go beyond

AMR into remote utility management. The meters in an AMI system are often

referred to as smart meters, since they often can use collected data based on

programmed logic.

The AMR project has been more difficult than originally expected. Initially,

the design was going to be much simpler than what it has grown into. The objectives

that are set currently are quite ambitious. Features such as a new emitter/detector and

a new PIC that required a different code were added during the progress of the

project. While these features are a welcomed benefit for the user, they do present

considerable design challenges. Also, the op-amp used as a buffer was not part of the

primary concept. It was integrated into the system to match the impedance of the

sensor with the impedance of the transistor. This is a unique and helpful feature for

the system. The portions of the design that we were able to get to work was with the

breadboard circuit output going to LEDs and with the breadboard circuit being able to

communicate with a PC via RS232 cable.

6.2 EMETCON DLC:-

40

Page 41: automatic meter reading

DLC stands for Distribution Line Carrier, referring to the fact that this power

line carrier system can communicate over utility-owned distribution power lines.

EMETCON is an acronym for Electronic Metering and Control. The system is two-

way, data-on-demand, with the ability to read a remote meter in around six second’s

start-to-finish.

6.3 TWACS System:-

TWACS® two-way power line communication technology which provides

unique capabilities ideally suited for Automatic Meter Reading (AMR), load control,

distribution automation and other value adding services. The TWACS technology

delivers over 99% message reliability, which results in highly efficient and

dependable AMR demand-side management and distribution automation systems.

Unlike conventional power line carrier systems, which superimpose a high frequency

on the power lines, TWACS works by modulating the voltage waveform at the Zero-

crossing point.

Conclusion:-

Thus we have studied RF based automatic meter reading used in different

places. We got that this technology is very useful in present and future demand. AMR

served well for commercial or industrial accounts. What was once a need for monthly

data became a need for daily and even hourly readings of the meters. Consequently,

the sales of drive-by and telephone AMR has declined in the US, while sales of fixed

networks has increased. It is use in remote areas and measuring reading from water

meter, energy meter, gas meter etc. It can be modified to control many meter reading

by TDM system. It is simple to operate and user friendy.In this project we can control

the data which is sending from transmitter to receiver by using microcontroller

AT89C2051.

REFERENCES

41

Page 42: automatic meter reading

[1] Chu T.S. and Hogg D.C. “Different RF Technologies”, Bell System Technical

Journal, PP.723; May-June 1986.

[2] Wa T.H. and Burrowes M.E.“Feasibility of long distance transmission through

RF Wave” IEEE Communication Mag.PP.-64-73; October 1989.

[3] Lin Y.-K.M., Spears D.R. and Yin M. “RF based local access network

architectures” IEEE Comm. Mag. PP. 64-73;October 1989.

[4] Gallager I., Ballance J. and Adams J. “The application o AMR Technique to

the network”Br.Telecom. Technol.J., 7(2), PP. 151-160; 1989.

[5] Smith D.R., “Different Microcontroller IC’s IEEE Comm. Mag. 24(1), PP. 9-

15;1986.

[6] Molenaur L.F., Gorden J.P. & Evagavides S.G., “Advancement in the field of

Microcontroller” Proc. IEEE, vol. 81, PP. 972-983;July 1993.

[7] Jaiynt N.S, “Signal Compression Technology” IEEE Journal on selected areas

of comm., vol. 10, No.5, PP.-796-815; June 1992.

[8] Culshow B., Foley J. and Giles I.P. “Different types of optocouplers” IEEE

Comm. Mag., 28(8), PP.22-23; 1984.

[9] Ready J.W. & Jones G.R. “Description about RF Modules” IEEE Journal on

selected areas in comm. SAC-3(6), PP. -890-896;1985.

[10] Y.K.M.Lin, Spears D.R and Yin M. “Decoder IC’s” IEEE comm. Mag, PP.

64-73; Oct 1989.

[11] Ritchie W.K., “Different Display Device” British Telecommunication Engg.1

(4), PP. 205-210; 1983.

[12] Walker. E.H. “AM Transmission Module” IEEE Transmission Module” IEEE

Telecommunication Conference; 1992.

[13] Yacoub M.D., “Fundamental of different pulse generating ckts and their

operation”, CRC Press; 1993.

[14] Xiong F., “Transmission through different types of R.F Module”, IEEE

Comm. Mag. PP 84-97; Aug 1994.

[15] Trischitta P.R. & Chen D.T.S., “Opto Electronics Devices”, IEEE Comm.

Mag., PP.16-21; May 1989.

APPENDICES

42

Page 43: automatic meter reading

Appendix A: Programming at Transmitting Unit

#include <REGX51.H>

void MSDelayeeeeee (unsigned int );

unsigned char segment_value (unsigned char );

unsigned char receive_data [7]="012345",pointer = 0,pointer1 = 0,mux

= 0x01,digit,count=0;

bit blink_digit=0;

void timer0 (void) interrupt 1

{

TR0 = 0;

TL0 = 0x24;

TH0 = 0xFA;

P1 = 0;

P2 = mux;//<<3;

if (mux == receive_data [6])

{

count++;

if (count == 20)

{

count = 0;

blink_digit = ~blink_digit;

}

if (blink_digit)

P1 = 0;

else

P1 = segment_value (receive_data [pointer1]);

}

else

{

P1 = segment_value (receive_data [pointer1]);

}

43

Page 44: automatic meter reading

pointer1++;

if (pointer1 == 6)

pointer1 = 0;

mux = mux << 1;

// mux = mux+1;

if (mux == 0x40)

mux = 0x01;

TR0 = 1;

}

void main ()

{

unsigned int temp;

IE = 0x82;

TMOD = 0x21;

TL0 = 0x24;

TH0 = 0xFA;

TH1 = 0xFD;

SCON = 0x50;

TR1 = 1;

MSDelay (100);

RI = 0;

TR0 = 1;

while (1)

{

/*

MSDelay (1);

P2 = mux;

P0 = segment_value (receive_data [pointer1]);

pointer1++;

if (pointer1 == 5)

pointer1 = 0;

mux = mux << 1;

mux = mux+1;

44

Page 45: automatic meter reading

if (mux == 0xDF)

mux = 0xFE;

*/

temp = count_pulse_per_second ();

temp = convert_pulse_to_unit (temp);

send_data (temp);

}

}

unsigned char segment_value (unsigned char value)

{

//unsigned char segment;

if ((value&0x80)== 0x80)

{

value = value&0x7F;

switch (value)

{

case '0':

return 0x7F;

case '1':

return 0x1C;

case '2':

return 0xBB;

case '3':

return 0xBE;

case '4':

return 0xDC;

case '5':

return 0xEE;

case '6':

return 0xEF;

case '7':

return 0x3C;

case '8':

return 0xFF;

45

Page 46: automatic meter reading

case '9':

return 0xFE;

case 0x2D:

return 0x88;

default:

return 0;

}

}

else

{

switch (value)

{

case '0':

return 0x77;

case '1':

return 0x14;

case '2':

return 0xB3;

case '3':

return 0xB6;

case '4':

return 0xD4;

case '5':

return 0xE6;

case '6':

return 0xE7;

case '7':

return 0x34;

case '8':

return 0xF7;

case '9':

return 0xF6;

case 0x2D:

return 0x80;

46

Page 47: automatic meter reading

default:

return 0;

}

}

}

void MSDelay (unsigned int itime )

{

unsigned int i,j;

for (i=0;i<itime;i++)

for (j=0;j<356/*1275*/;j++);

//for (j=0;j<1275;j++);

}

Appendix B: Programming at receiver unit:-

#include <REGX51.H>

void MSDelay (unsigned int );

unsigned char segment_value (unsigned char );

unsigned char receive_data [7]="012345",pointer = 0,pointer1 = 0,mux

= 0x01,digit,count=0;

bit blink_digit=0;

void timer0 (void) interrupt 1

{

TR0 = 0;

TL0 = 0x24;

TH0 = 0xFA;

P1 = 0;

P2 = mux;//<<3;

if (mux == receive_data [6])

{

count++;

if (count == 20)

{

47

Page 48: automatic meter reading

count = 0;

blink_digit = ~blink_digit;

}

if (blink_digit)

P1 = 0;

else

P1 = segment_value (receive_data [pointer1]);

}

else

{

P1 = segment_value (receive_data [pointer1]);

}

pointer1++;

if (pointer1 == 6)

pointer1 = 0;

mux = mux << 1;

// mux = mux+1;

if (mux == 0x40)

mux = 0x01;

TR0 = 1;

}

void main ()

{

IE = 0x82;

TMOD = 0x21;

TL0 = 0x24;

TH0 = 0xFA;

TH1 = 0xFD;

SCON = 0x50;

TR1 = 1;

MSDelay (100);

RI = 0;

TR0 = 1;

//send_char ('A');

48

Page 49: automatic meter reading

//send_char ('m');

//send_char ('i');

//send_char ('t');

while (1)

{

/*

MSDelay (1);

P2 = mux;

P0 = segment_value (receive_data [pointer1]);

pointer1++;

if (pointer1 == 5)

pointer1 = 0;

mux = mux << 1;

mux = mux+1;

if (mux == 0xDF)

mux = 0xFE;

*/

while (RI == 0);

RI = 0;

if (SBUF == ';')

pointer = 0;

else

{

//if ((SBUF >= '0')||(SBUF <= '9'))

receive_data [pointer] = SBUF;

pointer++;

//if (pointer == 5)

//pointer = 0;

}

}

}

unsigned char segment_value (unsigned char value)

{

49

Page 50: automatic meter reading

//unsigned char segment;

if ((value&0x80)== 0x80)

{

value = value&0x7F;

switch (value)

{

case '0':

return 0x7F;

case '1':

return 0x1C;

case '2':

return 0xBB;

case '3':

return 0xBE;

case '4':

return 0xDC;

case '5':

return 0xEE;

case '6':

return 0xEF;

case '7':

return 0x3C;

case '8':

return 0xFF;

case '9':

return 0xFE;

50

Page 51: automatic meter reading

case 0x2D:

return 0x88;

default:

return 0;

}

}

else

{

switch (value)

{

case '0':

return 0x77;

case '1':

return 0x14;

case '2':

return 0xB3;

case '3':

return 0xB6;

case '4':

return 0xD4;

case '5':

return 0xE6;

case '6':

return 0xE7;

case '7':

return 0x34;

51

Page 52: automatic meter reading

case '8':

return 0xF7;

case '9':

return 0xF6;

case 0x2D:

return 0x80;

default:

return 0;

}

}

}

void MSDelay (unsigned int itime )

{

unsigned int i,j;

for (i=0;i<itime;i++)

for (j=0;j<356/*1275*/;j++);

//for (j=0;j<1275;j++);

}

52