Академический Документы
Профессиональный Документы
Культура Документы
METER
READING
USING GSM
MODEM
into
memory is connected to .
For meter reading, fisrt of all we send a SMS to this unit from
department ( company phone) . As the sms is received on this
system then GSM modem transfer the sms to
Components used:
STEP DOWN TRANSFORMER
Step down transformer from 220 volt Ac to 9-0-9 ac. We use step down
transformer to step down the voltage from 220 to 9 volt ac. This AC is further
connected to the rectifier circuit for AC to DC conversion. Transformer current
rating is 750 ma .
DIODE.
In this project we use IN 4007 diode as a rectifier. IN 4007 is special diode to
convert the AC into DC
In this project we use two diode as a rectifier. Here we use full wave rectifier.
Output of rectifier is pulsating DC. To convert the pulsating dc into smooth dc we
Reset Circuitry:
This is not a big circuit we are just using a capacitor to charge the
microcontroller and again discharging via resistor.
Crystals
We can also resonators instead of costly crystal which are low cost and
external capacitor can be avoided.
But the frequency of the resonators varies a lot. And it is strictly not
advised when used for communications projects.
Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per
second.
The time is calculated using the formula
No of cycles per second = Crystal frequency in HZ / 12.
For a 10MHZ crystal the number of cycles would be,
10,000,000/12=833333.33333 cycles.
This means that in one second, the microcontroller would execute
833333.33333 cycles.
Overview
Each pixel of an LCD consists of a layer of liquid crystal molecules aligned
between two transparent electrodes, and two polarizing filters, the axes of
polarity of which are perpendicular to each other. With no liquid crystal
between the polarizing filters, light passing through one filter would be blocked
by the other.
The surfaces of the electrodes that are in contact with the liquid crystal material
are treated so as to align the liquid crystal molecules in a particular direction.
This treatment typically consists of a thin polymer layer that is unidirectionally
rubbed using a cloth (the direction of the liquid crystal alignment is defined by
the direction of rubbing).
Before applying an electric field, the orientation of the liquid crystal molecules
is determined by the alignment at the surfaces. In a twisted nematic device (the
most common liquid crystal device), the surface alignment directions at the two
electrodes are perpendicular, and so the molecules arrange themselves in a
helical structure, or twist. Because the liquid crystal material is birefringent (i.e.
light of different polarizations travels at different speeds through the material),
light passing through one polarizing filter is rotated by the liquid crystal helix as
it passes through the liquid crystal layer, allowing it to pass through the second
polarized filter. Half of the light is absorbed by the first polarizing filter, but
otherwise the entire assembly is transparent.
When a voltage is applied across the electrodes, a torque acts to align the liquid
crystal molecules parallel to the electric field, distorting the helical structure
(this is resisted by elastic forces since the molecules are constrained at the
surfaces). This reduces the rotation of the polarization of the incident light, and
the device appears gray. If the applied voltage is large enough, the liquid crystal
molecules are completely untwisted and the polarization of the incident light is
not rotated at all as it passes through the liquid crystal layer. This light will then
be polarized perpendicular to the second filter, and thus be completely blocked
and the pixel will appear black. By controlling the voltage applied across the
liquid crystal layer in each pixel, light can be allowed to pass through in varying
amounts, correspondingly illuminating the pixel.
With a twisted nematic liquid crystal device it is usual to operate the device
between crossed polarizers, such that it appears bright with no applied voltage.
With this setup, the dark voltage-on state is uniform. The device can be operated
between parallel polarizers, in which case the bright and dark states are reversed
(in this configuration, the dark state appears blotchy).
Both the liquid crystal material and the alignment layer material contain ionic
compounds. If an electric field of one particular polarity is applied for a long
period of time, this ionic material is attracted to the surfaces and degrades the
device performance. This is avoided by applying either an alternating current, or
by reversing the polarity of the electric field as the device is addressed (the
response of the liquid crystal layer is identical, regardless of the polarity of the
applied field).
When a large number of pixels is required in a display, it is not feasible to drive
each directly since then each pixel would require independent electrodes.
Instead, the display is multiplexed. In a multiplexed display, electrodes on one
side of the display are grouped and wired together (typically in columns), and
each group gets its own voltage source. On the other side, the electrodes are also
grouped (typically in rows), with each group getting a voltage sink. The groups
are designed so each pixel has a unique, unshared combination of source and
sink. The electronics, or the software driving the electronics then turns on sinks
in sequence, and drives sources for the pixels of each sink.
Important factors to consider when evaluating an LCD monitor include
resolution, viewable size, response time (sync rate), matrix type (passive or
active), viewing angle, color support, brightness and contrast ratio, aspect ratio,
and input ports (e.g. DVI or VGA).
Color displays
In color LCDs each individual pixel is divided into three cells, or subpixels,
which are colored red, green, and blue, respectively, by additional filters
(pigment filters, dye filters and metal oxide filters). Each subpixel can be
controlled independently to yield thousands or millions of possible colors for
each pixel. Older CRT monitors employ a similar method.
Color components may be arrayed in various pixel geometries, depending on
the monitor's usage. If software knows which type of geometry is being used in
a given LCD, this can be used to increase the apparent resolution of the monitor
through subpixel rendering. This technique is especially useful for text antialiasing.
.
In-plane switching (IPS)
control
Some LCD panels have defective transistors, causing permanently lit or unlit
pixels which are commonly referred to as stuck pixels or dead pixels
respectively. Unlike integrated circuits, LCD panels with a few defective pixels
are usually still usable. It is also economically prohibitive to discard a panel
with just a few defective pixels because LCD panels are much larger than ICs.
Manufacturers have different standards for determining a maximum acceptable
number of defective pixels. The maximum acceptable number of defective
pixels for LCD varies a lot (such as zero-tolerance policy and 11-dead-pixel
policy) from one brand to another, often a hot debate between manufacturers
and customers. To regulate the acceptability of defects and to protect the end
user, ISO released the ISO 13406-2 standard. However, not every LCD
manufacturer conforms to the ISO standard and the ISO standard is quite often
interpreted in different ways.
LCD panels are more likely to have defects than most ICs due to their larger
size. In this example, a 12" SVGA LCD has 8 defects and a 6" wafer has only 3
defects. However, 134 of the 137 dies on the wafer will be acceptable, whereas
rejection of the LCD panel would be a 0% yield. The standard is much higher
now due to fierce competition between manufacturers and improved quality
Zero-power displays
The zenithal bistable device (ZBD), developed by QinetiQ (formerly DERA),
can retain an image without power. The crystals may exist in one of two stable
orientations (Black and "White") and power is only required to change the
image. ZBD Displays is a spin-off company from QinetiQ who manufacture
both grayscale and colour ZBD devices.
A French company, Nemoptic, has developed another zero-power, paper-like
LCD technology which has been mass-produced in Taiwan since July 2003.
This technology is intended for use in low-power mobile applications such as ebooks and wearable computers. Zero-power LCDs are in competition with
electronic paper.
Kent Displays has also developed a "no power" display that uses Polymer
Stabilized Cholesteric Liquid Crystals (ChLCD). The major drawback to the
ChLCD display is slow refresh rate, especially with low temperatures.
Drawbacks
LCD technology still has a few drawbacks in comparison to some other display
technologies:
Some light guns do not work with this type of display since
they do not have flexible lighting dynamics that CRTs have.
However, the field emission display will be a potential
replacement for LCD flat-panel displays since they emulate
CRTs in some technological ways.
erases the complete memory at one stroke, and not act on the
individual cells. This results in reducing the time for erasure.
PIC
One of the famous microcontrollers used in the industries. It
is based on RISC Architecture which makes the microcontroller process
faster than other microcontroller.
INTEL
These are the first to manufacture microcontrollers. These
are not as sophisticated other microcontrollers but still the easiest one to
learn.
ATMEL
Atmels AVR microcontrollers are one of the most powerful in
the embedded industry. This is the only microcontroller having 1kb of ram
even the entry stage. But it is unfortunate that in India we are unable to
find this kind of microcontroller.
Intel 8051
Intel 8051 is CISC architecture which is easy to program in assembly language
and also has a good support for High level languages.
The 8051 microcontroller is in the field for more than 20 years. There are lots of
books and study materials are readily available for 8051.
Derivatives
The best thing done by Intel is to give the designs of the 8051 microcontroller to
everyone. So it is not the fact that Intel is the only manufacture for the 8051
there more than 20 manufactures, with each of minimum 20 models. Literally
there are hundreds of models of 8051 microcontroller available in market to
choose. Some of the major manufactures of 8051 are
Atmel
Philips
Philips
The Philipss 8051 derivatives has more number of features than in any
microcontroller. The costs of the Philips microcontrollers are higher than the
Atmels which makes us to choose Atmel more often than Philips
Dallas
Dallas has made many revolutions in the semiconductor market. Dallass
8051 derivative is the fastest one in the market. It works 3 times as fast as a
8051 can process. But we are unable to get more in India.
Atmel
These people were the one to master the flash devices. They are the
cheapest microcontroller available in the market. Atmels even introduced a
20pin variant of 8051 named 2051. The Atmels 8051 derivatives can be got in
India less than 70 rupees. There are lots of cheap programmers available in India
for Atmel. So it is always good for students to stick with 8051 when you learn a
new microcontroller.
Architecture
The 8051 doesnt have any special feature than other microcontroller. The only
feature is that it is easy to learn. Architecture makes us to know about the
hardware features of the microcontroller. The features of the 8051 are
The 8051 has a 8-Bit CPU that means it is able to process 8 bit of data at a time.
8051 has 235 instructions. Some of the important registers and their functions
are
Thus port one would have 8 bits. There are a total of four ports
named p0, p1, p2, p3, giving a total of 32 lines. These lines can
be used both as input or output.
2
3
Supply
5.
6.
7.
PORT2.
pin no 1 to pin
no 8 because it is a 8 bit controller. All the main register and sfr all is
mainly 8 bit wide. Port 1 is also occupies a 8 pins. But there is no need
of pull up resistor in this port. Upon reset port 1 act as a input port.
Upon reset all the ports act as a input port
ALE
8031 multiplexes address and data through port 0 to save pins. The ALE pin is
used for demultiplexing the address and data by connecting to the ic 74ls373
chip.
PSEN.
EA. EA. In 89c51 8751 or any other family member of the ateml 89c51 series all
come with on-chip rom to store programs, in such cases the EA pin is connected
to the Vcc. For family member 8031 and 8032 is which there is no on chip rom,
code is stored in external memory and this is fetched by 8031. In that case EA
pin must be connected to GND pin to indicate that the code is stored externally.
ACC
ACCUMULATOR
0E0H
B REGISTER
0F0H
PSW
0D0H
SP
STACK POINTER
81H
DPTR
DPL
82H
DPH
83H
P0
PORT0
80H
P1
PORT1
90H
P2
PORT2
0A0H
P3
PORT3
0B0H
TMOD
89H
TCON
88H
TH0
8CH
TLO
8AH
TH1
TL1
8BH
SCON
SERIAL CONTROL
98H
SBUF
99H
PCON
POWER CONTROL
87H
8DH
INSTRUCTIONS
SETB BIT
CLR BIT
CPL BIT
JB BIT,TARGET
JBC BIT,TARGET
MOV INSTRUCTIONS
MOV instruction simply copy the data from one location to another location
MOV D,S
Copy the data from(S) source to D(destination)
MOV A,#23H
MOV R0,#12h
MOV R5,#0F9H
ADD INSTRUCTIONS.
ADD instructions adds the source byte to the accumulator ( A) and place the
result in the Accumulator.
MOV A, #25H
ADD A,#42H
ADDA,R3
ACALL,TARGET ADDRESS
By this instructions we call subroutines with a target address within 2k bytes
from the current program counter.
ACALL is a limit for the 2 k byte program counter, but for upto 64k byte we use
LCALL instructions.. Note that LCALL is a 3 byte instructions.
ACALL is a two byte instructions.
LJMP is also for absoltute jump. It tranfer program execution to the target
addres unconditionally. This is a 3 byte instructions LJMP
jump to any address within 64 k byte location.
JC TARGET
JUMP TO THE TARGET IF CY FLAG =1
JNC TARGET
JUMP TO THE TARGET ADDRESS IF CY FLAG IS = 0
JZ TARGET
JUMP TO TARGET IF A = 0
JNZ TARGET
JUMP IF ACCUMULATOR IS NOT ZERO
RL A
RR A
RRC A
RLC A
Same as above but but shift the data from MSB to carry and
carry to LSB
RET
RET1
PUSH.
This copies the indicated byte onto the stack and increments
SP by . This instructions supports only direct addressing mode.
POP.
DPTR INSTRUCTIONS.
MOV C A,@A+DPTR
MOVC A,@A+PC
This instructions moves a byte of data located in the program area to A. the address of the
desired byte of data is formed by adding the program counter ( PC) register to the original
value of the accumulator.
INC BYTE
INC A
INC Rn
INC DIRECT
DEC BYTE
DEC A
DEC Rn
DEC DIRECT
ARITHMATIC INSTRUCTIONS.
`
DIV AB
Both timer is the 89c51 share the one register TMOD. 4 LSB bit for the timer 0
and 4 MSB for the timer 1.
GATE:
Gating control when set. Timer/counter is enabled only while the
INTX pin is high and the TRx control pin is set. When cleared, the timer is
enabled whenever the TRx control bit is set
C/T :
Timer or counter selected cleared for timer operation ( input from
internal system clock)
M1
Mode bit 1
M0
Mode bit 0
M1
M0
MODE
OPERATING MODE
13 BIT TIMER/MODE
CY
PSW.7
CARRY FLAG
AC
PSW.6
AUXILIARY CARRY
F0
PSW.5
RS1
PSW.4
RS0
PSW.3
0V
PSW.2
OVERFLOW FLAG
--
PSW.1
PSW.0
TH1
CRYSTAL FREQUENCY
256----
____________________
There are two ways to increase the baud rate of data transfer in the 8051
1.
2.
PCON register is an 8 bit register . Of the 8 bits, some are unused, and some are
used for the power control capability of the 8051. the bit which is used for the
serial communication is D7, the SMOD bit. When the 8051 is powered up, D7
( SMOD BIT) OF PCON register is zero. We can set it to high by software and
thereby double the baud rate
( DECIMAL)
HEX
SMOD =0
SMOD =1
-3
FD
9600
19200
-6
FA
4800
9600
-12
F4
2400
4800
-24
E8
1200
2400
EA
IE.7
IE.6
NOT implemented
ET2
IE.5
ES
IE.4
ET1
IE.3
EX1
IE.2
ET0
IE.1
EX0
IE.0
If the bit is 0, the corresponding interrupt has a lower priority and if the bit is 1
the corresponding interrupt has a higher priority
IP.7
IP.6
PT2
IP.5
PS
IP.4
PT1
IP.3
PX1
IP.2
PT0
IP.1
PX0
IP.0
SCON
SM0
SM1
SM2
SCON.5
REN
TB8
:
SCON.3 The 9th bit that will be transmitted in modes 2 and 3,
Set/cleared
By software
RB8
:
SCON.2 In modes 2 &3, is the 9th data bit that was received. In
mode 1,
If SM2 = 0, RB8 is the stop bit that was received. In mode
0
RB8 is not used
T1
:
th
8 bit
R1
bit
TCON
TF1
TCON.7
Timer 1 overflow flag. Set by hardware when the
Timer/Counter 1
TR1
TCON.6
TF0 TCON.5
timer/counter 0
TR0
TCON.4
IE1
TCON.3
ITI
TCON.2
IE0
TCON.1
IT0
TCON.0
Arithmetic Operations
Mnemonic
Description
ADD A,Rn
Size
Cycles
ADD A,direct
ADD A,@Ri
ADD A,#data
ADDC A,direct
SUBB A,Rn
INC A
INC Rn
INC direct
Increment register.
Increment ACC.
SUBB A,#data
SUBB A,direct
ADDC A,#data
INC @Ri
DEC A
Decrement ACC.
DEC Rn
Decrement register.
DEC direct
DEC @Ri
INC DPTR
MUL AB
DIV AB
DA A
Logical Operations
Mnemonic
Description
ANL A,Rn
Size
Cycles
ANL A,@Ri
ANL A,#data
ANL direct,#data
ORL A,Rn
OR Register to ACC.
ORL A,#data
ORL direct,#data
2
XRL A,@Ri
XRL A,#data
XRL A,Rn
ORL A,@Ri
XRL direct,#data
CLR A
CPL A
Compliment ACC.
RL A
RLC A
RR A
RRC A
SWAP A
Data Transfer
Mnemonic
Description
Size
Cycles
MOV A,Rn
MOV A,direct
1
MOV A,@Ri
MOV A,#data
MOV Rn,A
MOV Rn,direct
MOV Rn,#data
MOV direct,A
MOV direct,Rn
MOV direct,direct
MOV direct,@Ri
MOV @Ri,A
MOV @Ri,direct
MOV @Ri,#data
MOV DPTR,#data16
3
2
MOVC A,@A+DPTR
address).
1
2
MOVC A,@A+PC
MOVX A,@Ri
MOVX A,@DPTR
MOVX @Ri,A
MOVX @DPTR,A
PUSH direct
POP direct
XCH A,Rn
XCH A,direct
XCH A,@Ri
XCHD A,@Ri
Mnemonic
Description
Size
Cycles
CLR C
CLR bit
SETB C
SETB
CPL C
CPL bit
ANL C,bit
ANL C,/bit
ORL C,bit
ORL C,/bit
MOV C,bit
MOV bit,C
JC rel
JNC rel
JB bit,rel
JNB bit,rel
JBC bit,rel
Program Branching
Mnemonic
ACALL
Description
addr11
LCALL
Size
addr16
Cycles
RET
RETI
Absolute jump.
AJMP addr11
SJMP rel
JMP @A+DPTR
JZ rel
JNZ rel
CJNE A,direct,rel
CJNE A,#data,rel
CJNE Rn,#data,rel Compare immediate byte to register and jump if not equal.3
2
CJNE @Ri,#data,rel
equal.3
2
DJNZ direct,rel
The RW line is the "Read/Write" control line. When RW is low (0), the information
on
PIC
One of the famous microcontrollers used in the
industries. It is based on RISC Architecture which makes
the microcontroller process faster than other
microcontroller.
INTEL
These are the first to manufacture
microcontrollers. These are not as sophisticated other
microcontrollers but still the easiest one to learn.
ATMEL
Atmels AVR microcontrollers are one of the
most powerful in the embedded industry. This is the only
microcontroller having 1kb of ram even the entry stage.
But it is unfortunate that in India we are unable to find this
kind of microcontroller.
Intel 8051
Intel 8051 is CISC architecture which is easy to program in
assembly language and also has a good support for High level
languages.
now assembler generate a ASM file and HEX file. This hex file is
useful for us to program the blank chip.
Now we transfer the hex code into the blank chip with the help
of serial programmer kit. In the programmer we insert a blank
chip 0f 89s51 series . these chips are multi time
programmable chip. This programming kit is seperatally
available in the market and we transfer the hex code into blank
chip with the help of the serial programmer kit
NOTES ON
LCD
LCD DETAIL .
Frequently, an 8051 program must interact with the outside world using input
and output devices that communicate directly with a human being. One of the
most common devices attached to an 8051 is an LCD display. Some of the most
common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means
16 characters per line by 2 lines and 20 characters per line by 2 lines,
respectively.
HD44780U, which refers to the controller chip which receives data from an external source
(in this case, the 8051) and communicates directly with the LCD.
44780 BACKGROUND
AN EXAMPLE HARDWARE CONFIGURATION
Programming Tip: The LCD interprets and executes our command at the
instant the EN line is brought low. If you never bring EN low, your
instruction will never be executed. Additionally, when you bring EN low
and the LCD executes your instruction, it requires a certain amount of time
to execute the command. The time it requires to execute an instruction
depends on the instruction and the speed of the crystal which is attached
to the 44780's oscillator input.
As previously mentioned, it takes a certain amount of time for each instruction to be executed
by the LCD. The delay varies depending on the frequency of the we will use this code every
time we send an instruction to
WAIT_LCD:
SETB EN ;Start LCD command
CLR RS ;It's a command
SETB RW ;It's a read command
MOV DATA,#0FFh ;Set all pins to FF initially
MOV A,DATA ;Read the return value
JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy
CLR EN ;Finish the command
CLR RW ;Turn off RW for future commands
RET
Thus, our standard practice will be to send an instruction to the LCD and then
call our WAIT_LCD routine to wait until the instruction is completely executed by
the LCD. This will assure that our program gives the LCD the time it needs to
execute instructions and also makes our program compatible with any LCD,
regardless of how fast or slow it is.
Programming Tip: The above routine does the job of waiting for the LCD,
but were it to be used in a real application a very definite improvement
would need to be made: as written, if the LCD never becomes "not busy"
the program will effectively "hang," waiting for DB7 to go low. If this never
happens, the program will freeze. Of course, this should never happen and
won't happen when the hardware is working properly. But in a real
application it would be wise to put some kind of time limit on the delay--for
example, a maximum of 256 attempts to wait for the busy signal to go
low. This would guarantee that even if the LCD hardware fails, the program
would not lock up.
SETB EN
CLR RS
MOV DATA,#38h
CLR EN
LCALL WAIT_LCD
Programming Tip: The LCD command 38h is really the sum of a number
of option bits. The instruction itself is the instruction 20h ("Function set").
However, to this we add the values 10h to indicate an 8-bit data bus plus
08h to indicate that the display is a two-line display.
We've now sent the first byte of the initialization sequence. The second byte of
the initialization sequence is the instruction 0Eh. Thus we must repeat the
initialization code from above, but now with the instruction. Thus the next code
segment is:
SETB EN
CLR RS
MOV DATA,#0Eh
CLR EN
LCALL WAIT_LCD
Programming Tip: The command 0Eh is really the instruction 08h plus
04h to turn the LCD on. To that an additional 02h is added in order to turn
the cursor on.
The last byte we need to send is used to configure additional operational
parameters of the LCD. We must send the value 06h.
SETB EN
CLR RS
MOV DATA,#06h
CLR EN
LCALL WAIT_LCD
Programming Tip: The command 06h is really the instruction 04h plus
02h to configure the LCD such that every time we send it a character, the
cursor position automatically moves to the right.
So, in all, our initialization code is as follows:
INIT_LCD:
SETB EN
CLR RS
MOV DATA,#38h
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#0Eh
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#06h
CLR EN
LCALL WAIT_LCD
RET
Having executed this code the LCD will be fully initialized and ready for us to
send display data to it.
Now we get to the real meat of what we're trying to do: All this effort is really so we can
display text on the LCD. Really, we're pretty much done.
Once again, writing text to the LCD is something we'll almost certainly want to do over and
over--so let's make it a subroutine.
WRITE_TEXT:
SETB EN
SETB RS
MOV DATA,A
CLR EN
LCALL WAIT_LCD
RET
The WRITE_TEXT routine that we just wrote will send the character in the
accumulator to the LCD which will, in turn, display it. Thus to display text on the
LCD all we need to do is load the accumulator with the byte to display and make
a call to this routine. Pretty easy, huh?
The above "Hello World" program should, when executed, initialize the LCD, clear
the LCD screen, and display "Hello World" in the upper left-hand corner of the
display.
CURSOR POSITIONING
The
Thus, the
SETB EN
CLR RS
MOV DATA,#0C4h
CLR EN
LCALL WAIT_LCD
The above code will position the cursor on line 2, character 10. To display "Hello"
in the upper left-hand corner with the word "World" on the second line at
character position 10 just requires us to insert the above code into our existing
"Hello World" program. This results in the following:
LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
SETB EN
CLR RS
MOV DATA,#0C4h
CLR EN
LCALL WAIT_LCD
MOV A,#'W'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT
1.
Vss
GROUND
2.
Vcc
+5VOLT SUPPLY
Vee
4.
RS
5.
R/W
ENABLE
DB0
DB1
$include (reg51.INC)
lcd_rs
bit
p0.0
lcd_en
bit
p0.1
lcd_d4
bit
p0.2
lcd_d5
bit
p0.3
lcd_d6
bit
p0.4
lcd_d7
bit
p0.5
AC_OUT
bit
EEPROM_DATA
equ
P2.1
EEPROM_CLOCK
equ
P2.0
LCD_DATA
equ
10h
TRANS_DATA
equ
11h
reg1
equ
12h
count
equ
13h
pulse_cont_lo
equ
1eh
pulse_cont_hi
equ
1fh
unit_cont_1
equ
21h
unit_cont_2
equ
22h
unit_cont_3
equ
23h
output_temp
equ
org
ljmp
0000h
main
org
ljmp
INTE_0
reti
org
0003h
000bh
24h
P2.7
reti
org
ljmp
0013h
INTE_1
reti
org
001bh
reti
org
0023h
reti
INTE_1:
reti
INTE_0:
push
psw
push
acc
clr
ex0
clr
mov
add
a,pulse_cont_lo
a,#1d
da
mov
pulse_cont_lo,a
mov
a,pulse_cont_hi
addc
a,#0d
da
mov
pulse_cont_hi,a
mov
a,pulse_cont_lo
cjne
a,#20h,inte1_end
mov
a,pulse_cont_hi
cjne
a,#03h,inte1_end
mov
a,unit_cont_2
addc
a,#0d
da
mov
unit_cont_2,a
mov
a,unit_cont_3
addc
a,#0d
da
LCALL write
mov
a,unit_cont_2
LCALL write
inte1_end:
mov
a,pulse_cont_lo
mov
1ah,a
mov
1bh,#3d
lcall DELAY_RM
LCALL write
mov
a,pulse_cont_hi
pop
acc
pop
psw
reti
main:
mov
psw,#00h
mov
sp,#75h
mov
p2,#0ffh
mov
p3,#0ffh
setb
tr1
lcall
INIT_LCD
lcall
CLR_LCD
lcall
data_cheke
setb
AC_OUT
mov
reg1,#60h
mov
mov
dptr,#AT_EN
lcall
SEND_MSG
lcall
DELAY11
mov
dptr,#AT_OK
lcall
SEND_MSG
lcall
DELAY11
mov
dptr,#AT_TEXT
lcall
SEND_MSG
lcall
DELAY11
mov
dptr,#AT_DELETE
lcall
SEND_MSG
lcall
DELAY11
lcall
count,#00h
data_read_eeprom
mov
a,output_temp
cjne
a,#01h,out_off
clr
AC_OUT
sjmp
main_lp1
setb
AC_OUT
out_off:
main_lp1:
lcall CLR_LCD
mov dptr,#MSG1
lcall LINE_1
mov dptr,#MSG2
lcall LINE_2
lcall display_cont
mov
r1,#2fh
mov
r4,#11h
r1
djnz
r4,clrram
mov
r1,#2fh
mov
r4,#11h
jb
p3.0,$
lcall data_recv
lcall DELAY11
lcall DELAY11
ljmp
main_lp1
jnb
ri,$
mov
a,sbuf
clr
ri
cjne
a,#00h,back
data_recv:
sjmp back_ret
back:
mov
@r1,a
inc
r1
mov
a,r1
cjne
a,#36h,nextback
mov
a,#'G'
cjne
a,35h,nextback
mov
a,#'N'
cjne
a,34h,nextback
mov
a,#'I'
cjne
a,33h,nextback
mov
a,#'R'
cjne
a,32h,nextback
mov dptr,#AT_ATH
lcall SEND_MSG
lcall DELAY11
lcall DELAY11
ret
nextback:
djnz
r4,data_recv
back_ret:
lcall CLR_LCD
mov dptr,#MSG3
lcall LINE_1
lcall DELAY1
mov LCD_DATA,#0c0h
lcall COMMAND_BYTE
mov
r1,#32h
mov
r4,#0dh
crxdn1:
mov
a,@r1
mov
LCD_DATA,a
cjne
a,#00h,cbrxdn
sjmp cbrxdn1
cbrxdn:
lcall
DATA_BYTE
inc
r1
lcall DELAY1
djnz
r4,crxdn1
cbrxdn1:
lcall DELAY11
lcall DELAY11
lcall DELAY11
lcall DELAY11
mov r4,#23d
mov dptr,#AT_READ
lcall SEND_MSG
recv4: jnb
jnb
ri,$
clr
ri
jnb
ri,$
clr
ri
ri,recv4
mov
a,sbuf
clr
ri
lcall
delay
djnz r4,recv4
;------------------------------mov
recvn: jnb
r1,#60h
ri,recvn
mov
a,sbuf
clr
ri
mov
@r1,a
mov
b,#'"'
cjne
a,b,nextn
sjmp recv14
nextn:inc
r1
sjmp recvn
;------------------------------recv14:
jnb
ri,recv14
mov
a,sbuf
mov
temp_data,a
clr
ri
mov
a,temp_data
cjne a,#10d,recv14
back_ret2:
mov
r1,#2fh
mov
r4,#10h
mov LCD_DATA,#0c0h
lcall COMMAND_BYTE
recv5: jnb
ri,recv5
mov
a,sbuf
clr
ri
mov
b,a
xch
a,cmd0
xch
a,cmd1
xch
a,cmd2
xch
a,cmd3
xch
a,cmd4
cjne
a,#13d,back1
mov
a,cmd4
cjne
a,#10d,back1
mov
a,cmd3
cjne
a,#'O',back1
mov
a,cmd2
cjne
a,#'K',back1
mov
a,cmd1
cjne
a,#13d,back1
mov
a,cmd0
cjne
a,#10d,back1
sjmp back_ret1
back1:
mov
a,b
mov
@r1,a
mov
b,r1
mov
a,#41h
clr
subb a,b
jc
inc
nextback1
r1
nextback1:
sjmp recv5
back_ret1:
lcall CLR_LCD
mov dptr,#MSG4
lcall LINE_1
lcall DELAY1
mov LCD_DATA,#0c0h
lcall COMMAND_BYTE
mov
a,r1
subb a,#007d
mov
temp,a
mov
r1,#2fh
crx11: mov
a,@r1
mov
LCD_DATA,a
lcall
DATA_BYTE
inc
r1
lcall DELAY1
mov
a,r1
cjne
a,temp,crx11
mov
mov
mov
mov
r1,#2fh
mov
a,@r1
mov
cmd0,a
r1,#30h
mov
a,@r1
mov
cmd1,a
r1,#31h
mov
a,@r1
mov
cmd2,a
r1,#32h
mov
a,@r1
mov
cmd3,a
clr
lcall DELAY11
lcall DELAY11
;
mov LCD_DATA,#080h
lcall COMMAND_BYTE
mov
r1,#60h
findn:
mov a,@r1
mov
b,#'"'
cjne
a,b,findn1
sjmp findn2
findn1:
inc r1
sjmp findn
findn2:
mov
r4,#10d
mov
r0,#0eah
dec
r1
dec
r0
mov
a,@r1
mov
@r0,a
findn3:
djnz r4,findn3
mov
r4,#10d
mov
r1,#0eah
mov
r0,#06ah
dec
r1
dec
r0
mov
a,@r1
mov
@r0,a
findn4:
djnz r4,findn4
;
mov
r4,#10d
mov
;crxn:
r1,#60h
mov
a,@r1
mov
LCD_DATA,a
lcall
DATA_BYTE
inc
r1
djnz
r4,crxn
lcall DELAY11
lcall DELAY11
mov dptr,#AT_DELETE
lcall SEND_MSG
lcall DELAY11
lcall
cmp_out
lcall DELAY11
lcall DELAY11
mov dptr,#MSG1
lcall LINE_1
mov dptr,#MSG2
lcall LINE_2
ret
display_cont:
mov
LCD_DATA,#087h
lcall COMMAND_BYTE
lcall DELAY41
mov
a,unit_cont_3
swap a
anl
ADD
a,#0fh
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,unit_cont_3
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,unit_cont_2
swap a
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,unit_cont_2
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,unit_cont_1
swap a
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
LCD_DATA,#'.'
lcall DATA_BYTE
lcall DELAY41
mov
a,unit_cont_1
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
LCD_DATA,#0cbh
lcall COMMAND_BYTE
lcall DELAY41
mov
a,pulse_cont_hi
swap a
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,pulse_cont_hi
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,pulse_cont_lo
swap a
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
mov
a,pulse_cont_lo
anl
a,#0fh
ADD
a,#30h
mov
LCD_DATA,a
lcall DATA_BYTE
lcall DELAY41
ret
cmp_out:
clr
mov
a,cmd0
cjne
a,#'4',cmp_out1
mov
a,cmd1
cjne
a,#'L',cmp_out1
mov
a,cmd2
cjne
a,#'N',cmp_out1
AC_OUT
mov
output_temp,#01h
mov a,output_temp
mov 1ah,a
mov 1bh,#5d
lcall DELAY_RM
LCALL write
lcall
sendmsg
mov dptr,#AT_MSG4
lcall SEND_MSG
mov TRANS_DATA,#026D
lcall TRANS
ljmp
cmp_out_end
mov
a,cmd0
cjne
a,#'4',cmp_out2
mov
a,cmd1
cjne
a,#'L',cmp_out2
mov
a,cmd2
cjne
a,#'F',cmp_out2
cmp_out1:
setb
AC_OUT
mov
output_temp,#02h
mov a,output_temp
mov 1ah,a
mov 1bh,#5d
lcall DELAY_RM
LCALL write
lcall
sendmsg
mov dptr,#AT_MSG5
lcall SEND_MSG
mov TRANS_DATA,#026D
lcall TRANS
ljmp
cmp_out_end
mov
a,cmd0
cmp_out2:
cjne
a,#'A',cmp_out_end
mov
a,cmd1
cjne
a,#'M',cmp_out_end
mov
a,cmd2
cjne
a,#'R',cmp_out_end
lcall
send_count
ljmp
cmp_out_end
cmp_out_end:
mov
cmd0,#00h
mov
cmd1,#00h
mov
cmd2,#00h
mov
cmd3,#00h
ret
send_count:
lcall
sendmsg
mov dptr,#AT_MSG1
lcall SEND_MSG
mov TRANS_DATA,#010D
lcall TRANS
mov dptr,#AT_MSG2
lcall SEND_MSG
mov TRANS_DATA,#010D
lcall TRANS
mov a,unit_cont_3
swap
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,unit_cont_3
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,unit_cont_2
swap
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,unit_cont_2
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,unit_cont_1
swap
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov TRANS_DATA,#'.'
lcall TRANS
mov a,unit_cont_1
lcall SEND_MSG
mov TRANS_DATA,#010D
lcall TRANS
mov a,pulse_cont_hi
swap
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,pulse_cont_hi
anl
a,#0fh
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov a,pulse_cont_lo
anl
a,#0fh
ADD a,#30h
mov TRANS_DATA,a
lcall TRANS
mov TRANS_DATA,#026D
lcall TRANS
ret
sendmsg:
mov dptr,#AT_EN
lcall SEND_MSG
lcall DELAY11
mov dptr,#AT_OK
lcall SEND_MSG
lcall DELAY11
mov dptr,#AT_TEXT
lcall SEND_MSG
lcall DELAY11
mov dptr,#AT_SEND
lcall SEND_MSG
mov
TRANS_DATA,#'"'
lcall
TRANS
mov
TRANS_DATA,#'0'
lcall
TRANS
mov
r0,#60h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#61h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#62h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#63h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#64h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#65h
mov
TRANS_DATA,@r0
mov
TRANS_DATA,@r0
lcall
TRANS
mov
r0,#69h
mov
TRANS_DATA,@r0
lcall
TRANS
mov
TRANS_DATA,#'"'
lcall
TRANS
mov
TRANS_DATA,#013d
lcall
TRANS
lcall DELAY11
ret
TRANS:
mov a,TRANS_DATA
mov
sbuf,a
jnb
ti,$
clr
ti
clr
ri
lcall
DELAY1
ret
SEND_MSG:
clr a
movc a,@a+dptr
cjne a,#0D,SEND_CONT
ret
SEND_CONT:
mov TRANS_DATA,a
lcall TRANS
inc dptr
ljmp SEND_MSG
wait:
ljmp
wait
LINE_1:
mov
LCD_DATA,#080h
lcall COMMAND_BYTE
lcall DELAY41
lcall WRITE_MSG
ret
LINE_2:
mov
LCD_DATA,#0c0h
lcall COMMAND_BYTE
lcall DELAY41
lcall WRITE_MSG
ret
LINE_2R:
mov
LCD_DATA,#0c0h
lcall COMMAND_BYTE
lcall DELAY41
lcall WRITE_MSG1
ret
INIT_LCD:
clr
lcd_rs
clr
lcd_en
clr
lcd_d7
clr
lcd_d6
setb
lcd_d5
setb
lcd_d4
nop
setb
lcd_en
nop
clr
lcall
setb
lcd_en
delay41
lcd_en
nop
clr
lcall
setb
lcd_en
delay1
lcd_en
nop
clr
lcall
clr
lcall
lcd_en
delay1
lcd_en
delay1
mov
LCD_DATA,#28h
lcall COMMAND_BYTE
mov
LCD_DATA,#08h
lcall COMMAND_BYTE
mov
LCD_DATA,#01h
lcall COMMAND_BYTE
mov
LCD_DATA,#06h
lcall COMMAND_BYTE
clr
lcd_rs
clr
lcd_en
mov
LCD_DATA,#28h
lcall COMMAND_BYTE
mov
LCD_DATA,#0ch
lcall COMMAND_BYTE
mov
LCD_DATA,#06h
lcall COMMAND_BYTE
mov
LCD_DATA,#01h
lcall COMMAND_BYTE
ret
CLR_LCD:
mov
LCD_DATA,#001h
lcall COMMAND_BYTE
lcall DELAY41
ret
WRITE_MSG:
mov
a,#00h
movc
a,@a+dptr
cjne
a,#'WRITE_CONT
ret
WRITE_CONT:
mov
LCD_DATA,a
lcall DATA_BYTE
inc
ljmp
dptr
WRITE_MSG
WRITE_MSG1:
mov
a,#00h
movc
cjne
ret
WRITE_CONT1:
mov
LCD_DATA,a
a,#'$',WRITE_CONT1
mov
@r1,a
lcall DATA_BYTE
inc
dptr
inc
r1
ljmp
WRITE_MSG1
COMMAND_BYTE:
ljmp
CMD10
DATA_BYTE:
clr
setb
lcd_en
lcd_rs
CMD10:
nop
push
acc
mov
a,LCD_DATA
mov
c,acc.4
mov
lcd_d4,c
mov
c,acc.5
mov
lcd_d5,c
mov
c,acc.6
mov
lcd_d6,c
mov
c,acc.7
mov
lcd_d7,c
nop
setb lcd_en
nop
clr
lcd_en
mov
c,acc.0
mov
lcd_d4,c
nop
setb lcd_en
nop
clr
lcall
lcd_en
delay41
pop
acc
ret
delay_2ms:
mov
r7,#10h
delay_2ms_1:
mov
r6,#0ffh
delay_2ms_2:
djnz
r6,delay_2ms_2
djnz
r7,delay_2ms_1
ret
DELAY:
mov
r6,#10d
DEL:
djnz
r6,DEL
ret
DELAY1:
mov
r6,#0d
mov
r7,#20d
DELAY10:
djnz
r6,DELAY10
djnz
r7,DELAY10
ret
DELAY_RM:
mov
r6,#0d
mov
r7,#5d
DEL_RM:
djnz
r6,DEL_RM
djnz
r7,DEL_RM
ret
DELAY5S:
mov
r5,#0d
mov
r6,#0d
mov
r7,#25d
DEL5S:
djnz
r5,DEL5S
djnz
r6,DEL5S
djnz
r7,DEL5S
ret
DELAY41:
mov
r6,#0d
mov
r7,#8d
DLP410:
djnz
r6,DLP410
djnz
r7,DLP410
ret
DELAY11:
mov
r6,#0d
mov
r7,#0d
mov
r5,#5d
DLP11:
djnz
r6,DLP11
djnz
r7,DLP11
djnz
r5,DLP11
ret
data_cheke:
mov 1bh,#6d
lcall DELAY_RM
lcall read
mov
a,19h
cjne
a,#0d,data_chanj
ljmp
data_load_eeprom
mov
1ah,#0d
mov
1bh,#0d
data_chanj:
lcall DELAY_RM
LCALL write
mov
1ah,#0d
mov
1bh,#1d
lcall DELAY_RM
LCALL write
lcall DELAY_RM
LCALL write
mov
1ah,#0d
mov
1bh,#3d
lcall DELAY_RM
LCALL write
mov
1ah,#0d
mov
1bh,#4d
lcall DELAY_RM
LCALL write
lcall DELAY_RM
LCALL write
mov
1ah,#0d
mov
1bh,#6d
lcall DELAY_RM
LCALL write
data_load_eeprom:
ret
data_read_eeprom:
mov 1bh,#0d
lcall DELAY_RM
lcall read
mov unit_cont_1,19h
lcall DELAY_RM
lcall read
mov unit_cont_2,19h
lcall DELAY_RM
lcall read
mov unit_cont_3,19h
mov 1bh,#3d
lcall DELAY_RM
lcall read
mov pulse_cont_lo,19h
mov 1bh,#4d
lcall DELAY_RM
lcall read
mov pulse_cont_hi,19h
mov 1bh,#5d
lcall DELAY_RM
lcall read
mov output_temp,19h
ret
;;;;;;;;;;;;; for 24c04 ;;;;;;;;;;;;;;;
read: PUSH B
MOV B, A
ACALL START
JC NOBUS
MOV A, #00H
ORL A, #0A0H
ACALL SHOUT
JC XR1
MOV A,1bh
ACALL SHOUT
JC XR1
MOV A, B
lCALL R_CRNT
lJMP XR2
XR1:
lCALL STOP
NOBUS: SETB 1
XR2:
MOV 19h, A
POP B
RET
CLR EEPROM_CLOCK
CLR C
AJMP X41
X40:
SETB C
X41:
RET
SETB EEPROM_CLOCK
NOP
SETB EEPROM_DATA
RET
SHOUT: PUSH B
MOV B, #8
X42:
RLC A
MOV EEPROM_DATA, C
SETB EEPROM_CLOCK
CLR EEPROM_CLOCK
DJNZ B, X42
SETB EEPROM_DATA
SETB EEPROM_CLOCK
NOP
MOV C, EEPROM_DATA
POP B
RET
MOV B, #8
X43:
NOP
NOP
NOP
NOP
NOP
SETB EEPROM_CLOCK
MOV C, EEPROM_DATA
CLR EEPROM_CLOCK
DJNZ B, X43
RET
ACK:
CLR EEPROM_DATA
NOP
NOP
SETB EEPROM_CLOCK
CLR EEPROM_CLOCK
RET
NAK:
SETB EEPROM_DATA
RET
lCALL STOP
XW2:
RET
lCALL SHIN
lCALL NAK
CLR C
XRC1: l STOP
XRC2: RET
MSG1:
MSG2:
MSG3:
MSG4:
AT_ATH:
AT_OK:
AT_EN:
DB
'ATH',013D,0
'AT',013D,0
'ATE1',013D,0
AT_READ 'AT+CMGR=1',013D,
AT_TEXT:
AT+CMGF=1',013D,0
AT_DELETE: 'AT+CMGD=1',013D,
AT_SEND:
'AT+CMGS=',0
AT_MSG1:
'MESSAGE RECEIVED',010D
AT_MSG2:
'UNIT COUNT',010D,0
AT_MSG3:
'PULSE COUNT',010D,0
AT_MSG4:
'OUTPUT ON',010D,0
AT_MSG5:
'OUTPUT OFF',010D,0