Professional Documents
Culture Documents
INTRODUTION
1.1 Introduction:-
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
1.3 Benefits of AMR:-
2
solutions require a much smaller staff of meter readers, who merely need to walk or
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]
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:-
3
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:-
4
repeaters passing the data to nearby meters until it makes it to a main collector. A
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]
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.
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
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.
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
CHAPTER 2
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.
7
Figure-2.2-Block diagram of transmitter unit
8
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.
9
Figure-2.4-Block diagram of receiver unit
10
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.1 Features:-
11
Figure-3.1-Pin configuration of AT89C2051
3.2.2 Description:-
12
Figure-3.2-Block diagram of AT89C2051
13
3.2.3 Pin Description:-
1. Vcc
Supply voltage
2. GND
14
Ground
3. Port 1
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.
15
Alternate Functions
Port Pin
P3.0 RXD (serial input port)
6. XTAL1
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
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.
16
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.
17
Truth Table-3.3-74LS244
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
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]
19
3.4.1 Features:-
Table-3.5-Switching characteristics
20
Figure-3.5-Typical characteristics
3.5.1 Features:-
Operating voltage
2.4V~12V for the HT12E
Low power and high noise immunity CMOS technology
Low standby current: 0.1µ Α (typ.) at VDD=5V
HT12A with a 38kHz carrier for infrared transmission medium
Minimum transmission word
Four words for the HT12E
21
Built-in oscillator needs only 5% resistor
Data code has positive polarity
Minimal external components
HT12A/E: 18-pin DIP/20-pin SOP package
3.5.2 Applications:-
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
Figure-3.6-Pin assignment of HT12E-18 DIP
PIN INTERNAL
I/O
NAME CONNECTION DESCRIPTION
NMOS transmission Input pins for address A0~A7
Gate protection setting These pins can be
A0-A8 I
diode externally set to VSS or left
open
Input pins for address/data
NMOS transmission AD8~AD11 setting
Gate protection These pins can be
AD8~AD11 I
diode
externally set to VSS or left
open
Encoder data serial
DOUT O CMOS OUT
transmission output
Latch/Momentary
transmission format selection
CMOS IN
L/MB I pin:
Pull-high
Latch: Floating or VDD
Momentary: VSS
CMOS IN Transmission enable, active
I
Pull-high low
23
OSC2 O OSCILLATOR 1 Oscillator output pin
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.
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
24
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.
Figure-3.8-Composition of information
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
Figure-3.10-Application circuit of Encoder HT12E
26
3.7 AM Transmitter Module:-
3.8 Antenna:-
27
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.
28
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
antenna only. In addition the it operates from a 5Vdc supply. RF Solutions also offer a
range of Super Heterodyne Receivers.
4.2.1 Features:-
Figure-4.1-Pin assignment
30
Figure-4.2- Circuit diagram
31
4.2.2 Functional Description:-
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
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.
33
4.4.1 Features:-
4.4.2 Applications:-
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
34
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
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]
35
4.5 Seven Segment Display:-
36
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.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
37
shut down and safe operating area protection, making it essentially indestructible. If
adequate heat sinking is provided, they can deliver over 1A output current.
CHAPTER 5
AMR WORKING
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.
38
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.
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
39
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
6.1 Introduction:-
40
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.
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.
Conclusion:-
41
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
[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.
42
[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
#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;
43
{
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 ()
{
unsigned int temp;
IE = 0x82;
TMOD = 0x21;
TL0 = 0x24;
TH0 = 0xFA;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
MSDelay (100);
RI = 0;
44
TR0 = 1;
while (1)
{
/*
MSDelay (1);
P2 = mux;
P0 = segment_value (receive_data [pointer1]);
pointer1++;
if (pointer1 == 5)
pointer1 = 0;
45
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;
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':
46
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;
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++);
}
#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;
47
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]);
}
pointer1++;
if (pointer1 == 6)
pointer1 = 0;
mux = mux << 1;
// mux = mux+1;
if (mux == 0x40)
mux = 0x01;
TR0 = 1;
}
48
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');
//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;
49
else
{
//if ((SBUF >= '0')||(SBUF <= '9'))
receive_data [pointer] = SBUF;
pointer++;
//if (pointer == 5)
//pointer = 0;
}
}
}
case '1':
return 0x1C;
case '2':
return 0xBB;
case '3':
return 0xBE;
case '4':
return 0xDC;
50
case '5':
return 0xEE;
case '6':
return 0xEF;
case '7':
return 0x3C;
case '8':
return 0xFF;
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':
51
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;
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
53