Institution Timer
Institution Timer
Institution Timer
2013
INTRODUCTION
The technological advance in the field of electronics has brought more and more
sophistication in the domestic and industrial environment. Remotely controlled systems are the
demands of the day, which may, not only reduce unwanted human involvement, to switch on and
off various machines especially hazardous one. The Remotely Controlled Universal Institution
Timer is very attractive and useful system to each and every institution and offices that need to
keep time management in their daily routine. This system can control many receivers which are
remotely placed and the distance is around 100 Meters.
The system has two parts, one is a Transmitter and the other is a receiver. The Transmitter
holds a keyboard, a control unit, Display Unit an encoder and a Transmitting antenna. The
Receiver unit holds a Receiving antenna, a Decoder, a Central Processing Unit, a Display Unit, a
real time clock, power supply and a bell.
We are going to design this system in such a way that the transmitter can control as many
receivers in its range.
1
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
2
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
RF RECEIVER
Circuit
Operation
DECODER
REAL TIME
CLOCK
MICROCONTROLLER
DISPLAY
UNIT
ALARM SECTION
POWER SUPPLY
Microcontroller
The heart of this system microcontroller (C), which performs the arithmetical and
logical functions there by steering the performance of peripherals for a full proof and successful
performance. It is easy to use an eight bit microcontroller in this section as the system is to
handle a sequential operation and is supposed to do only one work at time.
Display
This section consists of a liquid crystal display. A liquid crystal display (LCD) is a flat
panel display electronic visual display, or video display that uses the light modulating properties
of liquid crystals. Liquid crystals do not emit light directly. The LCD display is interfacing with
a microcontroller.
3
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Bell Section
It consist of the bell driving circuit using MOFET or transistor. The bell section is
enabled by the Microcontroller.
Power supply
4
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The system requires a regulated voltage of +5v along with an unregulated 12v supply for
relay. These low voltages are obtained from the domestic supply with the help of this block.
KEYBOARD
MICROCONTROLLER
DISPLAY
UNIT
ENCODER
ASK TRANSMITTER
POWER SUPPLY
Microcontroller
5
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The heart of this system microcontroller (C), which performs the arithmetical and
logical functions there by steering the performance of peripherals for a full proof and successful
performance. It is easy to use an eight bit microcontroller in this section as the system is to
handle a sequential operation and is supposed to do only one work at time.
Display
This section consists of a liquid crystal display. A liquid crystal display (LCD) is a flat
panel display electronic visual display, or video display that uses the light modulating properties
of liquid crystals. Liquid crystals do not emit light directly. The LCD display is interfacing with
a microcontroller.
Keyboard
The keyboard section is used to read the inputs from the user .There are 5 switches for
controlling the remote section. The Microcontroller reads the switches directly and makes
corresponding HEX data. The Reset switch is used to reset the Microcontroller. There are two
switches to give input to the Microcontroller. There is a switch to give multiple inputs. There is a
SEND switch to send the whole data to the transmitter section.
Transmitter
These section converts the electrical signal from the microcontroller into radio frequency
wave and disperse into the air. The input of the transmitter is connected to decoder.
6
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
7
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
RECEIVER CIRCUIT
DIAGRAM
8
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
TRANSMITTER CIRCUIT
DIAGRAM
9
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
POWER SUPPLY
10
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
11
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
WORKING
Working of each circuit is explained in the circuit design section. The power supply unit
energizes the system as soon as the power is switched on. The power on reset circuit reset the
program counter in both microcontrollers. The microcontrollers start fetching opcodes from the
internal ROM whenever the reset voltage at the reset pin disappears.
Through I2C bus and displayed in the LED screen the RTC is backed up by a lithium ion
battery. The data is received using ASK module and HT12D decoder. We can set long or short
bell as our requirement using the transmitter module. The power supply has a 12 v dc output
with a 230 v ac input and it also have the ability to change over to battery when the ac input is
failed. When the ac fails a transistor is turned off and releases an EMR to its normally closed
position it connect the 12 V sealed lead acid battery to the output and the output is always stable.
The change over time is balanced by the capacitors in the circuit. The lead acid battery is
charged by receiving a signal from the microcontroller.
The signals drive a Darlington transistor pair and active an EMR. It connects the battery
to the 12 v dc and starts charging the battery. The charging time is set as 2 hrs in the program. At
a prefixed time the signal to charge the battery is generated and after 2 hrs de activated.
The regulated 5v is generated at the main circuit using 7805 regulator.
The transmitter module built around 89C51 mc. it have a LCD module and a 5 switches
to give input the entered data is temporarily stored inside the data memory of the mc. and when
we press the send switch the data is transmitted wirelessly using ASK transmitter module to
ensure security we use 12th generation encoder named HT 12E.
The transmitter (remote) is powered by 9V 6F22 type battery. Using a 7805 regulator IC
the 9v is converted in to 5 volts and is given to the MC. The remote have a reset switch that can
be also used as a range detector. When we press that it blinks a LED in the receiver only if the
receiver is in range.
12
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
MICROCONTROLLER
13
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
14
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Master Controller
The 8-bit microcontroller AT89C51 from ATMEL is selected to control the system. This
is a 40-pin chip, which contains four input/output ports, 256 bit RAM, and 8Kbyte of the
PROM. The power is applied across the Vcc(pin 40) and Gnd(20) pins. The external execution
is eliminated by connected to Vcc through a resistor.
The AT89C51 is a low-power, high performance CMOS 8-bit microcontroller with 8K
bytes of Flash programmable and erasable read only memory(PEROM).The device is
manufactured using Atmels high density nonvolatile memory technology and is compatible
with the industry standard 80C51 and 80C51 instruction set and pin out. The on-chip Flash
allows the program memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip,
Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost
effective solution to many embedded control applications.
The AT89C51 provides the following standard features: 8K bytes of Flash, 256 bytes of
RAM, 32 I/O lines, three 16-bit timer/counters, a sixvector two-level interrupt architecture, a
full duplex serial port, on-chip oscillator, and clock circuitry.In addition, the AT89C51 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.
15
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Pin Description
Port 1
In receiver circuit the Port 1 is directly connected to the LCD module (D0-D7).The
Microcontroller writes data to LCD through these pins. In transmitter circuit the Port 1 is used to
interface with the encoder circuits. In transmitter only five pins are used (P1.0-P1.4). The first
four pins are DATA pins and the last pin is the TA (Transmission Enable pin).
Port 2
16
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
In receiver circuit the Port 2 is used to interface the microcontroller with the RTC module
and to drive the bell circuit. P2.4 and P2.5 are used as SCL (Serial Clock) and SDA (Serial Data)
of the RTC respectively. P2.6 is used to drive the bell circuit and P2.7 is used as a range
indicator. In transmitter the Port 2 is used to read input from the keyboard circuit and also to
drive the LCD display.
Port 3
In receiver circuit Port 3 is used to drive the LCD display and to read the received
information from the decoder circuit. P3.4 to P3.7 is used to read data from the decoder and P3.3
is used as VT (Valid Transmission). In transmitter circuit the Port 3 is used to write data to the
LCD module.
Port Pin
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
Alternate Functions
RXD (serial input port)
TXD (serial output port)
INT0(external interrupt 0)
INT1(external interrupt 1)
TO(timer 0 external input)
T1(timer 1 external input)
WR(external data memory write strobe)
RD(external data memory read strobe)
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG
17
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Address Latch Enable is an output pulse for latching the low byte of the address during
access to external memory. This pin is also the program pulse input (PROG) during Flash
programming.
PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C51
is executing code from the external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activations are skipped during each access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be
strapped to VCC for internal program executions. This pin also receives the 12-volt
programming enable voltage (VPP) during Flash programming when 12-volt is selected.
XTAL1:- Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2:-Output from the inverting oscillator amplifier.
Clock Inputs
The X1 and X2 inputs are connected to the ends of a piezo electric crystal. We can choose
the crystal frequency from 1 MHz to 24MHz.Also both of the crystal inputs are connected to
ground through capacitors of value 33pF.
Reset Inputs
18
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The reset pin is connected to a power on circuit. The capacitor voltage at the time of
power on will be 1.This will reset microcontroller. The voltage drops to zero shortly after some
time. This will remove the reset condition and the microcontroller will start fetching now.
19
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal
(BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially
through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day,
date, month, and year information. The end of the month date is automatically adjusted for
months with fewer than 31 days, including corrections for leap year. The clock operates in either
the 24-hour or 12- hour format with AM/PM indicator. The DS1307 has a built-in power-sense
circuit that detects power failures and automatically switches to the backup supply. Timekeeping
operation continues while the part operates from the backup supply.
20
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
FEATURES
21
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
WORKING
The DS1307 is a low-power clock/calendar with 56 bytes of battery-backed SRAM. The
clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The
date at the end of the month is automatically adjusted for months with fewer than 31 days,
including corrections for leap year. The DS1307 operates as a slave device on the I2C bus.
Access is obtained by implementing a START condition and providing a device
identification code followed by a register address. Subsequent registers can be accessed
sequentially until a STOP condition is executed. When VCC falls below 1.25 x VBAT, the
device terminates an access in progress and resets the device address counter. Inputs to the
device will not be recognized at this time to prevent erroneous data from being written to the
device from an out-of-tolerance system. When VCC falls below VBAT, the device switches
into a low-current battery-backup mode. Upon power-up, the device switches from battery to
VCC when VCC is greater than VBAT +0.2V and recognizes inputs when VCC is greater
than 1.25 x VBAT. The block diagram in Figure 1 shows the main elements of the serial
RTC.
OSCILLATOR CIRCUIT
The DS1307 uses an external 32.768kHz crystal. The oscillator circuit does not require
any external resistors or capacitors to operate. Table 1 specifies several crystal parameters for
the external crystal. Figure 1 shows a functional schematic of the oscillator circuit. If using a
crystal with the specified characteristics, the startup time is usually less than one second.
CLOCK ACCURACY
The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy
of the match between the capacitive load of the oscillator circuit and the capacitive load for
22
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
which the crystal was trimmed. Additional error will be added by crystal frequency drift
caused by temperature shifts. External circuit noise coupled into the oscillator circuit may
result in the clock running fast. Refer to Application Note 58: Crystal Considerations with
Dallas Real-Time Clocks for detailed information.
RTC AND RAM ADDRESS MAP
Table 2 shows the address map for the DS1307 RTC and RAM registers. The RTC
registers are located in address locations 00h to 07h. The RAM registers are located in
address locations 08h to 3Fh. During a multi-byte access, when the address pointer reaches
3Fh, the end of RAM space, it wraps around to location 00h, the beginning of the clock
space.
CLOCK AND CALENDAR
The time and calendar information is obtained by reading the appropriate register bytes.
Table 2 shows the RTC registers. The time and calendar are set or initialized by writing the
appropriate register bytes. The contents of the time and calendar registers are in the BCD
format. The day-of-week register increments at midnight. Values that correspond to the day
of week are user-defined but must be sequential (i.e., if 1 equals Sunday, then 2 equals
Monday, and so on.) Illogical time and date entries result in undefined operation. Bit 7 of
Register 0 is the clock halt (CH) bit. When this bit is set to 1, the oscillator is disabled. When
cleared to 0, the oscillator is enabled. On first application of power to the device the time and
date registers are typically reset to 01/01/00 01 00:00:00 (MM/DD/YY DOW HH:MM:SS).
The CH bit in the seconds register will be set to a 1. The clock can be halted whenever the
timekeeping functions are not required, which minimizes current (IBATDR).
The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is
defined as the 12-hour or 24-hour mode-select bit. When high, the 12-hour mode is selected.
In the 12-hour mode, bit 5 is the AM/PM bit with logic high being PM. In the 24-hour mode,
23
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
bit 5 is the second 10-hour bit (20 to 23 hours). The hours value must be re-entered
whenever the 12/24-hour mode bit is changed.
When reading or writing the time and date registers, secondary (user) buffers are used to
prevent errors when the internal registers update. When reading the time and date registers,
the user buffers are synchronized to the internal registers on any I2C START. The time
information is read from these secondary registers while the clock continues to run. This
eliminates the need to re-read the registers in case the internal registers update during a read.
The divider chain is reset whenever the seconds register is written. Write transfers occur on
the I2C acknowledge from the DS1307. Once the divider chain is reset, to avoid rollover
issues, the remaining time and date registers must be written within one second.
Timekeeper Registers
24
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
is called a master. The devices that are controlled by the master are referred to as slaves. The
bus must be controlled by a master device that generates the serial clock (SCL), controls the
bus access, and generates the START and STOP conditions. The DS1307 operates as a slave
on the I2C bus.
Data transfer can be initiated only when the bus is not busy.
During data transfer, the data line must remain stable whenever the clock line is HIGH.
Changes in the data line while the clock line is high will be interpreted as control signals.
25
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
26
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
2. Slave Transmitter Mode (Read Mode): The first byte is received and handled as in
the slave receiver mode. However, in this mode, the direction bit will indicate that the
transfer direction is reversed. The DS1307 transmits serial data on SDA while the serial
clock is input on SCL. START and STOP conditions are recognized as the beginning and end
of a serial transfer (see Figure 5). The slave address byte is the first byte received after the
START condition is generated by the master. The slave address byte contains the 7-bit
DS1307 address, which is 1101000, followed by the direction bit (R/W), which is 1 for a
read. After receiving and decoding the slave address the DS1307 outputs an acknowledge on
SDA. The DS1307 then begins to transmit data starting with the register address pointed to
by the register pointer. If the register pointer is not written to before the initiation of a read
mode the first address that is read is the last one stored in the register pointer. The register
pointer automatically increments after each byte are read. The DS1307 must receive a Not
Acknowledge to end a read.
27
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
28
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
29
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
BLOCK DIAGRAM
PIN DIAGRAM
PIN DESCRIPTION
30
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Pin Name
I/O
Internal connection
CMOS IN
Pull-high
(HT12A)
A0~A7
AD8~AD11
NMOS
TRANSMISSION
GATE
PROTECTION
DIODE
(HT12E)
NMOS
TRANSMISSION
GATE
PROTECTION
DIODE
(HT12E)
CMOS IN
Pull-high
D8~D11
O
DOUT
open
CMOS OUT
I
CMOS IN
Pull-high
L/MB
TE
Description
CMOS IN
Pull-high
I
I
OSC1
OSCILLATOR 1
O
OSC2
I
X1
O
X2
I
VSS
31
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
___
VDD
32
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
FUNCTIONAL DESCRIPTION
OPERATION
The 212 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 theTransmission enable (TE or D8~D11) is held low. Once the
transmissions enable returns high the encoder output completes its final cycle and then stops as
shown below.
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 (for use with the momentary type of data decoders). 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.
33
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Address/data waveform
Each programmable address/data pin can be externally set to one of the following two logic states asshown
below.
34
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
BLOCK DIAGRAM
35
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
PIN DISCRIPTION
36
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
FUNCTIONAL DESCRIPTION
Operation
The 212 series of decoders provides various combinations of addresses and data pins in
different packages so as to pair with the 2 12 series of encoders. The decoders receive data that are
transmitted by an encoder and interpret the first N bits of code period as addresses and the last
2_N bits as data, where N is the address code number. A signal on the DIN pin activates the
oscillator which in turn decodes the incoming address and data. The decoders will then check
the received address three times continuously. If the received address codes all match the
contents of the decoders local address, the 12_N bits of data are decoded to activate the output
pins and the VT pin is set high to indicate a valid transmission. This will last unless the address
37
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
code is incorrect or no signal is received. The output of the VT pin is high only when the
transmission is valid. Otherwise it is always low. Output type of the 212 series of decoders, the
HT12F has no data output pin but its VT pin can be used as a momentary data output. The
HT12D, on the other hand, provides 4 latch type data pins whose data remain unchanged until
new data are received.
38
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
39
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The transmitter module is crystal locked in frequency, ensuring a stable and more reliable
transmitting function. All external components are fixed in value. Nothing can be accidentally
detuned.
Frequency Range: 433.92 MHZ
Modulate Mode: ASK
Circuit Shape: LC
Date Rate: 4800 bps
Selectivity: -106 dB
Channel Spacing: 1MHZ
Supply Voltage: 5V
High Sensitivity Passive Design.
Simple To Apply with Low External Count.
DC CHARECTERISTICS
INTERFACE PORT P1
40
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
The transmitter module component layout. A stranded core insulated wire cut to 17cm in length
can be used as an antenna.
41
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
the number of bytes to transmit, and the data stream itself. Transmission is concludedwith a 4
byte CRC that must be used by the host controller to validate the data. All data after the start
marker are encoded in 4b/6b format in order not the upset the DC bias of the ATA3741 receiver
PLL circuit. Any undesired C bias within the PLL control loop will almost guarantee a data lost.
Fortunately for Arduino and gizDuino programmers, you need not worry about these details.
Every complicated thing just mentioned had already been taken cared of by the VirtualWire
library, so that you dont have to. It is a free Arduino IDE add-onlibrary that can work with RX433A1 wireless hardware. If you havent done so, now is the good time to download this library.
Users of non-Arduino compatible platform/MCUs are not as lucky, and may have to do the dirty
work themselves.
42
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
P1 INTERFACE PORT
43
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
LCD CONTROLLER/DRIVER
The HD44780U dot-matrix liquid crystal display controller and driver LSI displays
alphanumerics, Japanese kana characters, and symbols. It can be configured to drive a dotmatrix liquid crystal display under the control of a 4- or 8-bit microprocessor. Since all the
functions such as display RAM, character generator, and liquid crystal driver, required for
driving a dot-matrix liquid crystal display are internally provided on one chip, a minimal system
can be interfaced with this controller/driver. A single HD44780U can display up to one 8character line or two 8-character lines.
The HD44780U has pin function compatibility with the HD44780S which allows the user
to easily replace an LCD-II with an HD44780U. The HD44780U character generator ROM is
extended to generate 208 5 8 dot character fonts and 32 5 10 dot character fonts for a total of
240 different character fonts. The low power supply (2.7V to 5.5V) of the HD44780U is suitable
for any portable battery-driven product requiring low power dissipation.
Features
5 8 and 5 10 dot matrix possible
Low power operation support:
2.7 to 5.5V
Wide range of liquid crystal display driver power
3.0 to 11V
Liquid crystal drive waveform
A (One line frequency AC waveform)
Correspond to high speed MPU bus interface
2 MHz (when VCC = 5V)
4-bit or 8-bit MPU interface enabled
80 8-bit display RAM (80 characters max.)
9,920-bit character generator ROM for a total of 240 character fonts
208 character fonts (5x8 dot)
32 character fonts (5x10 dot)
64x8-bit character generator RAM
44
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
45
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
HD44780U-PIN FUNCTIONS
46
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
No: of
Lines
I/O
Signal
Device
Interfaced
with
MPU
MPU
MPU
RS
R/W
E
MPU
DB4 TO DB7
I/O
MPU
DB0 to DB3
I/O
O
CL1
LCD
Segment Signals
Power Supply
Power Supply
Oscillation
resistor clock
1
O
1
O
D
COM1
COM16
SEG1
SEG40
V1 to V5
VCC, GND
OSC1, OSC2
1
to
Selects registers.
0: Instruction register (for write) Busy flag:
address counter (for read)
1: Data register (for write and read)
Selects read or write.
0: Write
1: Read
Starts data read/write
Extension
driver
Extension
driver
Extension
driver
Extension
driver
LCD
CL2
Function
16
to 40
5
2
2
47
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Instructions
48
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
Clear Display
Clear display writes space code 20H (character pattern for character code 20H must be a
blank pattern) into all DDRAM addresses. It then sets DDRAM address 0 into the address
counter, and returns the display to its original status if it was shifted. In other words, the display
disappears and the cursor or blinking goes to the left edge of the display (in the first line if 2
lines are displayed). It also sets I/D to 1 (increment mode) in entry mode. S of entry mode does
not change.
Return Home
Return home sets DDRAM address 0 into the address counter, and returns the display to
its original status if it was shifted. The DDRAM contents do not change.The cursor or blinking
go to the left edge of the display (in the first line if 2 lines are displayed).
49
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
S: Shifts the entire display either to the right (I/D = 0) or to the left (I/D = 1) when S is 1.
The display does not shift if S is 0.
If S is 1, it will seem as if the cursor does not move but the display does. The display
does not shift when reading from DDRAM.Also, writing into or reading out from CGRAM does
not shift the display.
Function Set
50
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
DL: Sets the interface data length. Data is sent or received in 8-bit lengths (DB7 to DB0)
when DL is 1,and in 4-bit lengths (DB7 to DB4) when DL is 0.When 4-bit length is selected,
data must be sent orreceived twice.
N: Sets the number of display lines.
F: Sets the character font.
51
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
instructions need not be executed just before this read instruction when shifting the cursor by the
cursor shift instruction (when reading out DDRAM). The operation of the cursor shift
instruction is the same as the set DDRAM address instruction. After a read, the entry mode
automatically increases or decreases the address by 1. However, display shift is not executed
regardless of the entry mode.
PCB Fabrication
The first step of assembling is to procure a printed circuit board. The fabrication of the
program counter plays a crucial role in the electronic field. We are using a microcontroller-based
system that handles high frequencies. In the high frequency circuit the data may easily be
violated in the PCB due to the physical parameters. That is the track capacitance and inductance
can cause the cross talk in the buses. Also, unwanted noise can be induced to supply rails and
from there it can affect the total response. Hence, the PCB design has a major role in the system
performance.
The board is designed using a personal computer. The layout is drawn using the software
Proteus. The layout is printed in a butter sheet using a laser printer. The layout is transferred
52
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
to the copper clad sheet using the screen print procedure. First, a negative screen of the layout is
prepared with the help of a professional screen printer. Then the copper clad sheet is kept under
this screen. The screen printing ink is pored on the screen and brushed through the top of the
screen. The printed board is kept under shade for few hours till the ink become dry.
The etching medium is prepared with the un-hydrous ferric chloride and water. The
printed board is kept in this solution till the exposed copper dissolves in the solution fully. After
that the board is taken out and rinsed in the flowing water under a tap. The ink is removed with
the help of NC thinner. The board is coated with solder in order prevent oxidation. Another
screen, which contains component side layout, is prepared and the same is printed on the
component side of the board. A paper epoxy laminate is used as the board. Both component and
the track layout of the peripheral PCB is given below.
53
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
54
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
55
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
56
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
57
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
LCD Initialization
While(1)
yes
YesReset Key==1 No
Hour Key==1 No
Min Key==1 No
yes
Next key==1
No
Hour++
Minute++
58
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
No
Send key
Yes
Sending message
Send DATA to
transmitter
59
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
//TRANSMITTER PROGRAM
#include<reg51.h>
#define LCD P3
#define DATA P1
sbit RS=P2^5; //connect p2.5 to rs pin of lcd
sbit EN=P2^7; //connect p2.7 to en pin of lcd
sbit RW=P2^6; //connect p2.6 to en pin of lcd
sbit TE=P1^4; //transmission enable
char DecimalToBCD(unsigned char);
void init_lcd(void);
void cmd_lcd(unsigned char);
void write_lcd(unsigned char);
void display_lcd(unsigned char *);
void delay_ms(unsigned int);
void alarm();
void settime();
void process();
void send(unsigned char);
void longbell();
void hr(int);
void mn(int,unsigned char);
void hrmn();
void disp(unsigned char);
void keys(int,int,unsigned char);
void aa();
void reset();
unsigned char *s[];
unsigned char c,a1,a2,h,m,d;
unsigned int j=0,i=0,mode=0,a=0,b=1,f=1,e=0;
unsigned char arr[40];
60
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
void main(void)
{
start:
DATA=0xFF;
TE=1;
e=0;
a1=0x00,a2=0x00;
init_lcd();
//MAIN MENU
cmd_lcd(0x01);
display_lcd(" *REALTRONICS*");
delay_ms(300);
cmd_lcd(0x01);
display_lcd("1 CLOCK 2 ALARM");
cmd_lcd(0xc0);
display_lcd("3 LONGBELL");
while(1)
{
while((P2&0x10)==0) //Reset Key 1
{
TE=0;
DATA=0x0D;
delay_ms(100);
goto start;
}
while((P2&0x02)==0) //Key 2
{
e=1;
}
while((P2&0x04)==0) //Key 3
{
e=2;
}
while((P2&0x01)==0) //Key 4
{
61
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
e=3;
}
switch(e)
{
case 1:settime();break;
case 2: alarm();break;
case 3: longbell();break;
}
}
}//
END OF MAIN
62
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
}
void write_lcd(unsigned char c) //write Data to LCD
{
EN=1; //set enable pin
RW=0;
RS=1; //set register select pin
LCD=c; //load 8 bit data
EN=0; //clear enable pin
delay_ms(2); //delay 2 milliseconds
}
void display_lcd(unsigned char *s) //write string to LCD
{
while(*s)
write_lcd(*s++);
}
63
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
64
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
a=2;
b=1;
hrmn();
}
if(mode==1)
{
a=4;
b=3;
aa();
cmd_lcd(0x01);
display_lcd(" DATE DAY");
cmd_lcd(0xc0);
display_lcd(" 00 00");
}
if(mode==2)
{
a=5;
b=6;
aa();
cmd_lcd(0x01);
display_lcd(" MONTH YEAR");
cmd_lcd(0xc0);
display_lcd(" 00 2000");
}
while(1)
{
reset();
while((P2 & 0x01)==0)//mode key P2.0
{
mode++;
goto start;
while((P2 & 0x01)==0);
}
while((P2 & 0x08)==0)//send key P2.3
{
65
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
send(0x0B);
while((P2 & 0x08)==0);
}
if(mode>2)
mode=0;
if(mode==0)
{
keys(23,1,59);
}
if(mode==1)
{
keys(31,1,6);
}
if(mode==2)
{
keys(12,1,99);
}
}
}
void process() //Process Function
{
while((P2 & 0x01)==0)//mode key P2.0
{
cmd_lcd(0x01);
disp(arr[a]);
write_lcd(' ');
disp(arr[b]);
cmd_lcd(0xc0);
for(j=1;j<=3;j++)
{
write_lcd(' ');
66
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
}
disp(h);
cmd_lcd(0xc8);
for(j=1;j<=3;j++)
{
write_lcd(' ');
}
disp(m);
a+=2;
b+=2;
while((P2 & 0x01)==0);
}
while((P2 & 0x02)==0)//hour key P2.1
{
hr(23);
while((P2 & 0x02)==0);
}
while((P2 & 0x04)==0)//min key P2.2
{
cmd_lcd(0xc8);
mn(5,55);
while((P2 & 0x04)==0);
}
}
void send(unsigned char word) //Send data to ASK
{
TE=0;
DATA=word;
delay_ms(100);
cmd_lcd(0x01);
display_lcd(" SENDING");
67
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
cmd_lcd(0xC0);
for(d=0;d<=b;d++)
{
DATA=arr[d]/16;
delay_ms(200);
write_lcd('.');
DATA=arr[d]%16;
delay_ms(200);
}
if(d>b)
{
delay_ms(200);
main();
}
}
void longbell() //Long bell function
{
hrmn();
a=0;
b=1;
a1=0x00;
a2=0x00;
while(1)
{
reset();
while((P2 & 0x08)==0)//send key P2.3
{
send(0x0C);
while((P2 & 0x08)==0);
}
process();
}
}
68
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
//Hour Function
cmd_lcd(0xc0);
for(j=1;j<=3;j++)
{
write_lcd(' ');
}
if(a1<lm1)
a1++;
else
a1=0x00;
h =DecimalToBCD(a1);
arr[a]=h;
disp(h);
}
void mn(int i,unsigned char lm2) //Minute Function
{
for(j=1;j<=3;j++)
{
write_lcd(' ');
}
if(a2<lm2)
a2=a2+i;
else
a2=0x00;
if(m==a2)
{
69
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
a1=0x00;
}
m =DecimalToBCD(a2);
arr[b]=m;
if(lm2>70)
{
disp(32);
}
disp(m);
}
void hrmn() //Hour Minute Display
{
cmd_lcd(0x01);
display_lcd(" HR MN");
cmd_lcd(0xc0);
display_lcd(" 00 00");
}
void disp(unsigned char val)
{
write_lcd((val/16)+48);
write_lcd((val%16)+48);
}
void keys(int k1,int k2,unsigned char k3)
{
while((P2 &0x02)==0)
{
hr(k1);
while((P2 & 0x02)==0);
}
70
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
LCD INITIALIZATION
71
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
While(1)
YES
NO
IF VT==1
IF CLK == ALARM
NO
READ DATA FROM RTC
YES
YES
ENABLES THE ALARM
SECTION
//RECIEVER PROGRAM
#include<reg51.h>
72
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
void _nop_(void);
#define delay_us _nop_(); //generates 1 microsecond
#define LCD P1
sbit flag1=P2^6;
//BELL
//BELL LOW
sbit flag2=P2^7;
//LED
#define f3 flag2=0;
//LED HIGH
#define f4 flag2=1;
//LED LOW
73
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
//Process Function
void battery();
void init_lcd(void);
//Battery function
//LCD initialization
//Command LCD
//Delay function
void start(void);
void stop(void);
74
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
void main()
{
f1;
f3;
BAT=0;
init_lcd();
for(j=0;j<8;j++)
write_i2c(0xd0,j,0x00);
for(j=8;j<64;j++)
{
write_i2c(0xd0,j,0xFF);
}
start:
while(1)
{
battery();
shortbell(0x08,0x09,0x2F,300);
shortbell(0x30,0x31,0x3F,900);
75
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
while(TA==1)
{
while((P3 & 0xF0)!=0xF0)
{
time0=P3 & 0xF0;
while(time0==0xA0)
{
delay_ms(200);
for(a=0x08;a<=0x2F;a++)
{
process();
if(time0!=0xF0)
write_i2c(0xd0,a,time);
else
goto start;
}
while(time0==0xA0);
}
while(time0==0xB0)
{
delay_ms(200);
for(a=0x00;a<=0x07;a++)
76
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
{
process();
if(time0!=0xF0)
write_i2c(0xd0,a,time);
else
goto start;
}
while(time0==0xB0);
}
while(time0==0xC0)
{
delay_ms(200);
for(a=0x30;a<=0x3F;a++)
{
process();
if(time0!=0xF0)
write_i2c(0xd0,a,time);
else
goto start;
}
while(time0==0xC0);
}
77
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
while(time0==0xD0)
{
f4;
delay_ms(200);
f3;
goto start;
while(time0==0xD0);
}
while((P3 & 0xF0)!=0xF0);
}
}
cmd_lcd(0x02);
for(q=0;q<2;q++)
write_lcd(' ');
c=read_i2c(0xd0,0x02);//read hours register and display on LCD
write_lcd((c/16)+48);
write_lcd((c%16)+48);
write_lcd(':');
78
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
delay_ms(10);
c=read_i2c(0xd0,0x00);//read seconds register and display on LCD
write_lcd((c/16)+48);
write_lcd((c%16)+48);
write_lcd(' ');
}
}
79
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
80
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
delay_us
SCKLOW //clock low
delay_us
mask/=2; //shift mask
}while(mask>0);
81
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
{
unsigned mask=0x80;
do //transmits 8 bits
{
if(!c&mask) //set data line accordingly(0 or 1)
SDAHIGH //data high
82
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
else
SDALOW //data low
SCKHIGH //clock high
delay_us
SCKLOW //clock low
delay_us
mask/=2; //shift mask
}while(mask>0);
SDAHIGH //release data line for acknowledge
SCKHIGH //send clock for acknowledge
delay_us;
slave_ack=SDA; //read data pin for acknowledge
SCKLOW //clock low
delay_us
83
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
{
;
}
}
}
84
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
85
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
{
unsigned char c=0,mask=0x80;
do //receive 8 bits
{
SCKHIGH //clock high
delay_us
if(SDA==1) //read data
c|=mask; //store data
SCKLOW //clock low
delay_us
mask/=2; //shift mask
}while(mask>0);
if(master_ack==1)
SDAHIGH //don't acknowledge
else
SDALOW //acknowledge
SCKHIGH //clock high
delay_us
SCKLOW //clock low
delay_us
SDAHIGH //data high
return c;
}
86
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
void init_lcd(void)
{
delay_ms(10); //delay 10 milliseconds
cmd_lcd(0x0e); //lcd on, cursor on
delay_ms(10);
cmd_lcd(0x38); //8 bit initialize, 5x7 character font, 16x2 display
delay_ms(10);
cmd_lcd(0x06); //right shift cursor automatically after each character is displayed
delay_ms(10);
cmd_lcd(0x01); //clear lcd
delay_ms(10);
cmd_lcd (0x80);
}
87
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
88
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
void process()
{
time1=P3&0xF0;
delay_ms(200);
time2=P3&0xF0;
temp=time2/16;
time=time1+temp;
delay_ms(200);
time0=P3 & 0xF0;
}
void battery()
{
e1 = read_i2c(0xd0,0x02);
if((e1>=0x02)&&(e1<=0x03))
{
BAT = 1;
}
else
89
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
BAT = 0;
}
//End Program
90
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
91
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
CONCLUSION
92
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
93
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
DATASHEET
94
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
95
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
96
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
97
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
98
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
99
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
100
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
101
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
102
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
103
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
104
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
105
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
106
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
107
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
108
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
109
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
110
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
111
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
112
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
113
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
114
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
115
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
116
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
117
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
118
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
119
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
120
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
121
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
122
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
123
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
124
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
125
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
126
GOVT
POLYTECHNIC COLLEGE KOTTAYAM
127
GOVT
POLYTECHNIC COLLEGE KOTTAYAM