batch 8 documentation

55
“AUTOMATIC STREET LIGHT CONTROLLER USING RTC” 1. ABSTRACT 1.1 Title: AUTIMATIC STREET LIGHT CONTROLLER UISNG RTC Aim: The main aim of the project is to build an Automatic Street Light Controller using RTC Scope: We can control the street lights through manually, but it is a time taken and also time lagging chances are there so, the process was lagging due to this. So this project i.e. The Electronic Street Light Control System has the provision to control the street lighting/yard lighting/quarry lighting system automatically as per the timings programmed in the system and the programs can be modified automatically throughout the year as per the seasonal changes which is an already programmed in the system by using RTC (Real Time Clock). RTC is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time. RTCs often have an alternate source of power, so they can continue to keep time while the primary source of power is off or unavailable. i.e. A clock that keeps track of the time even when the computer is turned off. Real-time clocks run on a special battery that is not connected to the normal power supply. In contrast, clocks that are not real-time do not function when the computer is off. Every IBM PC compatible computer features a battery- backed RTC chip. This contains a 32768 Hz crystal oscillator that drives a date/time counter. It also contains 114 bytes of battery-backed CMOS RAM that are reserved for BIOS use. The chip typically used is compatible to the Dallas Semiconductor DS1287 and Motorola MC146818B RTCs. Department Of Electrical & Electronics Engineering, ANU BOSE INSTITUTE OF TECHNOLOGY. Page 1 of 55

Upload: marakala-sagarreddy

Post on 05-Mar-2015

353 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

1. ABSTRACT

1.1 Title: AUTIMATIC STREET LIGHT CONTROLLER UISNG

RTC

Aim: The main aim of the project is to build an Automatic Street Light Controller using RTC Scope: We can control the street lights through manually, but it is a time taken and also time lagging chances are there so, the process was lagging due to this. So this project i.e. The Electronic Street Light Control System has the provision to control the street lighting/yard lighting/quarry lighting system automatically as per the timings programmed in the system and the programs can be modified automatically throughout the year as per the seasonal changes which is an already programmed in the system by using RTC (Real Time Clock).

RTC is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time. RTCs often have an alternate source of power, so they can continue to keep time while the primary source of power is off or unavailable. i.e. A clock that keeps track of the time even when the computer is turned off. Real-time clocks run on a special battery that is not connected to the normal power supply. In contrast, clocks that are not real-time do not function when the computer is off.

Every IBM PC compatible computer features a battery-backed RTC chip. This contains a 32768 Hz crystal oscillator that drives a date/time counter. It also contains 114 bytes of battery-backed CMOS RAM that are reserved for BIOS use. The chip typically used is compatible to the Dallas Semiconductor DS1287 and Motorola MC146818B RTCs.

In this project we have a control (on/off) on street lights belongs to certain areas, depending up on the time setting in RTC programming with time display through micro controller. Some relays are connected to the loads (lights) to make a contact when our desired time is obtained; otherwise they are all in off state.

We may use this RTC for some other real time applications like data logging, time and attendance, time stamping, system synchronous & service remainder.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 1 of 41

Page 2: Batch 8 Documentation

MICRO CONTROLLER

POWER SUPPLY

RTC

LCD

RELAY

RELAY

RELAY

Street light 2

Street light 1

Street light 3

BC 547

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

1.2 BLOCK DIAGRAM

1.3 EXPLENATION

The above block diagram refers to the AUTOMATIC STREET LIGHT

CONTROLLER USING RTC. Initially we give the power supply to the micro controller. To

that micro controller as an input the supply of power will initiates the circuit functioning.

As an interconnectors we will use the relays in the circuit functioning which will

detects the fault locationing and will make the device get protected from the disasters of the

fault currents and will make the automation used here by improving the flexibility and make

the system a good efficient and a flexible one. The control of the system is done

automatically with respect to time,is already programmed in the micro controller.Here a rtc

(real time clock) is used for accurate time.

All other descriptions are explained here below in a brief method in a sequential

method.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 2 of 41

Page 3: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

2. POWER SUPPLY

Power supply is a reference to a source of electrical power. A device or system that

supplies electrical or other types of energy to an output load or group of loads is called a

power supply unit or PSU.

This power supply section is required to convert AC signal to DC signal and also to

reduce the amplitude of the signal. The available voltage signal from the mains is

230V/50Hz which is an AC voltage, but the required is DC voltage(no frequency) with the

amplitude of +5V and +12V for various applications.

In this section we have Transformer, Bridge rectifier, are connected serially and

voltage regulators for +5V and +12V (7805 and 7812) via a capacitor (1000µF) in parallel

are connected parallel as shown in the circuit diagram below. Each voltage regulator output

is again is connected to the capacitors of values (100µF, 10µF, 1 µF, 0.1 µF) are connected

parallel through which the corresponding output(+5V or +12V) are taken into consideration.

2.1 CIRCUIT EXPLANATION

2.1.1 TRANSFORMER

A transformer is a static device that transfers electrical energy from one circuit to

another without changing frequence, through inductively coupled electrical conductors. A

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 3 of 41

Page 4: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

changing current in the first circuit (the primary) creates a changing magnetic field; in turn,

this magnetic field induces a changing voltage in the second circuit (the secondary). By

adding a load to the secondary circuit, one can make current flow in the transformer, thus

transferring energy from one circuit to the other.

The secondary induced voltage VS, of an ideal transformer, is scaled from the

primary VP by a factor equal to the ratio of the number of turns of wire in their respective

windings:

2.1.2 BASIC PRINCIPLE

The transformer is based on two principles: firstly, that an electric current can

produce a magnetic field (electromagnetism) and secondly that a changing magnetic field

within a coil of wire induces a voltage across the ends of the coil (electromagnetic

induction). By changing the current in the primary coil, it changes the strength of its

magnetic field; since the changing magnetic field extends into the secondary coil, a voltage

is induced across the secondary.

A simplified transformer design is shown below. A current passing through the

primary coil creates a magnetic field. The primary and secondary coils are wrapped around a

core of very high magnetic permeability, such as iron; this ensures that most of the magnetic

field lines produced by the primary current are within the iron and pass through the

secondary coil as well as the primary coil.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 4 of 41

Page 5: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

An ideal step-down transformer showing magnetic flux in the core

INDUCTION LAW

The voltage induced across the secondary coil may be calculated from Faraday's law

of induction, which states that:

Where VS is the instantaneous voltage, NS is the number of turns in the secondary coil

and Φ equals the magnetic flux through one turn of the coil. If the turns of the coil are

oriented perpendicular to the magnetic field lines, the flux is the product of the magnetic

field strength B and the area A through which it cuts. The area is constant, being equal to the

cross-sectional area of the transformer core, whereas the magnetic field varies with time

according to the excitation of the primary. Since the same magnetic flux passes through both

the primary and secondary coils in an ideal transformer, the instantaneous voltage across the

primary winding equals

Taking the ratio of the two equations for VS and VP gives the basic equation for

stepping up or stepping down the voltage

IDEAL POWER EQUATION

If the secondary coil is attached to a load that allows current to flow, electrical power

is transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is

perfectly efficient; all the incoming energy is transformed from the primary circuit to the

magnetic field and into the secondary circuit. If this condition is met, the incoming electric

power must equal the outgoing power.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 5 of 41

Page 6: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

Pincoming = IPVP = Poutgoing = ISVS

giving the ideal transformer equation

Pin-coming = IPVP = Pout-going = ISVS

giving the ideal transformer equation

If the voltage is increased (stepped up) (VS > VP), then the current is decreased

(stepped down) (IS < IP) by the same factor. Transformers are efficient so this formula is a

reasonable approximation.

If the voltage is increased (stepped up) (VS > VP), then the current is decreased

(stepped down) (IS < IP) by the same factor. Transformers are efficient so this formula is a

reasonable approximation.

The impedance in one circuit is transformed by the square of the turns ratio. For

example, if an impedance ZS is attached across the terminals of the secondary coil, it appears

to the primary circuit to have an impedance of

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 6 of 41

Page 7: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

This relationship is reciprocal, so that the impedance ZP of the primary circuit appears

to the secondary to be

2.1.3 DETAILED OPERATION

The simplified description above neglects several practical factors, in particular the

primary current required to establish a magnetic field in the core, and the contribution to the

field due to current in the secondary circuit.

Models of an ideal transformer typically assume a core of negligible reluctance with

two windings of zero resistance. When a voltage is applied to the primary winding, a small

current flows, driving flux around the magnetic circuit of the core. The current required to

create the flux is termed the magnetizing current; since the ideal core has been assumed to

have near-zero reluctance, the magnetizing current is negligible, although still required to

create the magnetic field.

The changing magnetic field induces an electromotive force (EMF) across each

winding. Since the ideal windings have no impedance, they have no associated voltage drop,

and so the voltages VP and VS measured at the terminals of the transformer, are equal to the

corresponding EMFs. The primary EMF, acting as it does in opposition to the primary

voltage, is sometimes termed the "back EMF". This is due to Lenz's law which states that the

induction of EMF would always be such that it will oppose development of any such change

in magnetic field.

2.2 BRIDGE RECTIFIER

A diode bridge or bridge rectifier is an arrangement of four diodes in a bridge

configuration that provides the same polarity of output voltage for any polarity of input

voltage. When used in its most common application, for conversion of alternating current

(AC) input into direct current (DC) output, it is known as a bridge rectifier. A bridge rectifier

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 7 of 41

Page 8: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

provides full-wave rectification from a two-wire AC input, resulting in lower cost and weight

as compared to a center-tapped transformer design, but has two diode drops rather than one,

thus exhibiting reduced efficiency over a center-tapped design for the same output

voltage.

2.2.1 BASIC OPERATION

When the input connected at the left corner of the diamond is positive with respect to

the one connected at the right hand corner, current flows to the right along the upper colored

path to the output, and returns to the input supply via the lower one.

When the right hand corner is positive relative to the left hand corner, current flows

along the upper colored path and returns to the supply via the lower colored path.

In each case, the upper right output remains positive with respect to the lower right

one. Since this is true whether the input is AC or DC, this circuit not only produces DC

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 8 of 41

Page 9: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

power when supplied with AC power: it also can provide what is sometimes called "reverse

polarity protection". That is, it permits normal functioning when batteries are installed

backwards or DC input-power supply wiring "has its wires crossed" (and protects the

circuitry it powers against damage that might occur without this circuit in place).

Output smoothing (Using Capacitor)

For many applications, especially with single phase AC where the full-wave bridge

serves to convert an AC input into a DC output, the addition of a capacitor may be important

because the bridge alone supplies an output voltage of fixed polarity but pulsating magnitude

The function of this capacitor, known as a reservoir capacitor (aka smoothing

capacitor) is to lessen the variation in (or 'smooth') the rectified AC output voltage waveform

from the bridge. One explanation of 'smoothing' is that the capacitor provides a low

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 9 of 41

Page 10: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

impedance path to the AC component of the output, reducing the AC voltage across, and AC

current through, the resistive load. In less technical terms, any drop in the output voltage and

current of the bridge tends to be cancelled by loss of charge in the capacitor.

The idealized waveforms shown above are seen for both voltage and current when

the load on the bridge is resistive. When the load includes a smoothing capacitor, both the

voltage and the current waveforms will be greatly changed. While the voltage is smoothed,

as described above, current will flow through the bridge only during the time when the input

voltage is greater than the capacitor voltage. For example, if the load draws an average

current of n Amps, and the diodes conduct for 10% of the time, the average diode current

during conduction must be 10n Amps. This non-sinusoidal current leads to harmonic

distortion and a poor power factor in the AC supply.

In a practical circuit, when a capacitor is directly connected to the output of a bridge,

the bridge diodes must be sized to withstand the current surge that occurs when the power is

turned on at the peak of the AC voltage and the capacitor is fully discharged. Sometimes a

small series resistor is included before the capacitor to limit this current, though in most

applications the power supply transformer's resistance is already sufficient.

2.2.2 VOLTAGE REGULATOR

A voltage regulator is an electrical regulator designed to automatically maintain a

constant voltage level.

The 78xx (also sometimes known as LM78xx) series of devices is a family of self-

contained fixed linear voltage regulator integrated circuits. When specifying individual ICs

within this family, the xx is replaced with a two-digit number, which indicates the output

voltage the particular device is designed to provide (for example, the 7805 has a 5 volt

output, while the 7812 produces 12 volts).

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 10 of 41

Page 11: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

3. RTC (REAL TIME CLOCK)

A RTC is a computer clock (most often in the form of an integrated circuit) that keeps

track of the current time. Although the term often refers to the devices in personal

computers, servers and embedded systems, RTCs are present in almost any electronic device

which needs to keep accurate time.

We are using DS1307 64x8, Serial, Real Time Clock.

3.1 FEATURES:

Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the week, and Year with Leap-Year Compensation Valid Up to 2100.

Battery-Backed, General-Purpose RAM with Unlimited Writes.

Address and data transferred serially through I2C bidirectional Serial bus Interface.

Automatic Power-Fail Detect and Switch to the battery back-up Circuitry.

Optional Industrial Temperature Range: -40°C to +85°C.

Available in 8-Pin Plastic DIP or SO.

RTC DS1307

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 11 of 41

Page 12: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

3.2 PIN DIAGRAM

3.3 PIN DESCRIPTION:

X1 and X2

Connections for Standard 32.768 kHz Quartz Crystal. The internal oscillator circuitry is

designed for operation with a crystal having a specified load capacitance (CL) of 12.5Pf.

Vbat

Backup Supply Input for Any Standard 3V Lithium Cell or Other Energy Source. If a

backup supply is not required, VBAT must be grounded. The nominal power-fail trip point

(VPF) voltage at which access to the RTC and user RAM is denied is set by the internal

circuitry as 1.25 x VBAT nominal.

GND

Ground.

SDA

Serial Data Input/Output. SDA is the data input/output for the I2C serial interface. The

SDA pin is open drain and requires an external pull-up resistor. The pull-up voltage can be

up to 5.5V regardless of the voltage on VCC.

SCL

Serial Clock Input. SCL is the clock input for the I2C interface and is used to synchronize

data movement on the serial interface. The pull-up voltage can be up to 5.5V regardless of

the voltage on VCC.

SQW/OUT

Square Wave/Output Driver. The SQWE bit set to 1, the SQW/OUT pin outputs one of

four square-wave frequencies. SQW/OUT operates with either VCC or VBAT applied. If

not used, this pin can be left floating.

VCC

Primary Power Supply. When a backup supply is connected to the device and VCC is

below VTP, read and writes are inhibited.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 12 of 41

Page 13: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

3.4 APPLICATIONS:

Data logging.

Time and Attendance.

Time Stamping.

System Synchronous and Service Remainder.

4. MICRO CONTROLLERS

4.1 MICROPROCESSORS VS. MICROCONTROLLERS:

• Microprocessors are single-chip CPUs used in microcomputers.

• Microcontrollers and microprocessors are different in three main aspects: hardware

architecture, applications, and instruction set features.

• Hardware architecture: A microprocessor is a single chip CPU while a microcontroller is a

single IC contains a CPU and much of remaining circuitry of a complete computer (e.g.,

RAM, ROM, serial interface, parallel interface, timer, interrupt handling circuit).

• Applications: Microprocessors are commonly used as a CPU in computers while

microcontrollers are found in small, minimum component designs performing control

oriented activities.

• Microprocessor instruction sets are processing Intensive.

• Their instructions operate on nibbles, bytes, words, or even double words.

• Addressing modes provide access to large arrays of data using pointers and offsets.

• They have instructions to set and clear individual bits and perform bit operations.

• They have instructions for input/output operations, event timing, enabling and setting

priority levels for interrupts caused by external stimuli.

• Processing power of a microcontroller is much less than a microprocessor.

4.2 DIFFERENCE BETWEEN 8051 AND 8052:

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 13 of 41

Page 14: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful

microcontroller, sporting a number of additional features which the developer may make use

of:

bytes of Internal RAM (compared to 128 in the standard 8051).

A third 16-bit timer, capable of a number of new operation modes and 16-bit reloads.

Additional SFRs to support the functionality offered by the third timer.

AT89S52:

4.3 FEATURES:

• 8K Bytes of In-System Programmable (ISP) Flash Memory

• 4.0V to 5.5V Operating Range

• Fully Static Operation: 0 Hz to 33 MHz

• 256K Internal RAM

• 32 Programmable I/O Lines

• 3 16-bit Timer/Counters

• Full Duplex UART Serial Channel

• Low-power Idle and Power-down Modes

• Interrupt Recovery from Power-down Mode

• Watchdog Timer

• Dual Data Pointer

• Power-off Flag

4.4 DESCRIPTION OF MICROCONTROLLER 89S52:

The AT89S52 is a low-power, high-performance CMOS 8-bit micro

controller with 8Kbytes of in-system programmable Flash memory. The device

is manufactured

Using Atmel’s high-density nonvolatile memory technology and is

compatible with the industry-standard 80C51 micro controller. 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

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 14 of 41

Page 15: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

CPU with in-system programmable flash one monolithic chip; the Atmel

AT89S52 is a powerful micro controller, which provides a highly flexible and

cost-effective solution to many embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of Flash,

256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit

timer/counters, full duplex serial port, on-chip oscillator, and clock circuitry. In addition,

the AT89S52 is designed with static logic for perationdown to zero frequency and

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 15 of 41

Page 16: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

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 interrupt Or hardware reset.

4.5 PIN DESCRIPTION OF MICROCONTROLLER 89S52

VCC

Supply voltage.

GND

Ground.

Port 0

Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can

sink eight TTL inputs. When 1sare written to port 0 pins, the pins can be used as high

impedance inputs. Port 0 can also be configured to be the multiplexed low order

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 16 of 41

Page 17: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

address/data bus during accesses to external program and data memory. In this mode, P0

has internal pull-ups. Port 0 also receives the code bytes during Flash programming and

outputs the code bytes during program verification. External pull-ups are required

during program verification

Port 1

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 Output buffers

can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by

the internal pull-ups and can be used as inputs. In addition, P1.0 and P1.1 can be configured

to be the timer/counter 2 external count input

(P1.0/T2) and the timer/counter 2 trigger input P1.1/T2EX), respectively, as shown in

the following table. Port 1 also receives the low-order address bytes during Flash

programming and verification.

Port2

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output

buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are

pulled high by the internal pull-ups and can be used as inputs. Port2 emits the high-order

address byte during fetches from external program memory and during accesses to

external data memory that use 16-bit addresses (MOVX @DPTR). In this application,

Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data

memory that use 8-bit addresses (MOVX @ RI), Port 2emits the contents of the P2

Special Function Register. Port 2 also receives the high-order address bits and some

control signals during Flash programming and verification.

Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers

can sink/source four TTL inputs. When 1s are writt 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. Port 3 also

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 17 of 41

Page 18: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

serves the functions of various special features of the AT89S52, as shown in the following

table.

Port 3 also receives some control signals for Flash programming

And verification.

RST

Reset input. A high on this pin for two machine cycles while the oscillator is

running resets the device.

ALE/PROG

Address Latch Enable (ALE) is an output pulse for latching the low byte of the address

during accesses to external memory. This pin is also the program pulse input (PROG) during

Flash programming. In normal operation, ALE is emitted at a constant rate of1/6 the

oscillator frequency and may be used for external timing or clocking purposes.

PSEN

Program Store Enable (PSEN) is the read strobe to external program memory.

When the AT89S52 is executing code from 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. A should be strapped to VCC for internal program executions. This pin also

receives the 12-voltProgramming enables voltage (VPP) during Flash programming.

XTAL1

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

circuit.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 18 of 41

Page 19: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

XTAL2

Output from the inverting oscillator amplifier.

OSCILLATOR CHARACTERISTICS

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

amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 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 2.

Figure 1. Oscillator Connections

SPECIAL FUNCTION REGISTER (SFR) MEMORY: -

Special Function Registers (SFR s) are areas of memory that control specific

functionality of the 8051 processor. For example, four SFRs permit access to the 8051’s

32 input/output lines. Another SFR allows the user to set the serial baud rate, control and

access timers, and configure the 8051’s interrupt system.

The Accumulator:

The Accumulator, as its name suggests is used as a general register to accumulate the

results of a large number of instructions. It can hold 8-bit (1-byte) value and is the most

versatile register.

The “R” registers:

The “R” registers are a set of eight registers that are named R0, R1. Etc

up to R7. These registers are used as auxiliary registers in many operations.

The “B” registers:

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 19 of 41

Page 20: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

The “B” register is very similar to the accumulator in the sense that it

may hold an 8-bit (1-byte) value. Two only uses the “B” register 8051 instructions:

MUL AB and DIV AB.

The Data Pointer:

The Data pointer (DPTR) is the 8051’s only user accessible 16-bit

(2Bytes) register. The accumulator, “R” registers are all 1-Byte values. DPTR, as the

name suggests, is used to point to data. It is used by a number of commands, which

allow the 8051 to access external memory.

THE PROGRAM COUNTER AND STACK POINTER:

The program counter (PC) is a 2-byte address, which tells the 8051 where

the next instruction to execute is found in memory. The stack pointer like all registers except

DPTR and PC may hold an 8-bit (1-Byte) value

ADDRESSING MODES:

An “addressing mode” refers that you are addressing a given memory location.

In summary, the addressing modes are as follows, with an example of each:

Each of these addressing modes provides important flexibility.

Immediate Addressing MOV A, #20 H

Direct Addressing MOV A, 30 H

Indirect Addressing MOV A, @R0

Indexed Addressing

a. External Direct MOVX A, @DPTR

b. Code In direct MOVC A, @A+DPTR

IMMEDIATE ADDRESSING:

Immediate addressing is so named because the value to be stored in

memory immediately follows the operation code in memory. That is to say, the

instruction itself dictates what value will be stored in memory. For example, the

instruction:

MOV A, #20H:

This instruction uses immediate Addressing because the accumulator will be

loaded with the value that immediately follows in this case 20(hexadecimal). Immediate

addressing is very fast since the value to be loaded is included in the instruction.

However, since the value to be loaded is fixed at compile-time it is not very flexible.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 20 of 41

Page 21: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

DIRECT ADDRESSING:

Direct addressing is so named because the value to be stored in memory is

obtained by directly retrieving it from another memory location.

For example:

MOV A, 30h

This instruction will read the data out of internal RAM address 30(hexadecimal)

and store it in the Accumulator.

INDIRECT ADDRESSING:

Indirect addressing is a very powerful addressing mode, which in many cases

provides an exceptional level of flexibility. Indirect addressing is also the only way to

access the extra 128 bytes of internal RAM found on the 8052. Indirect addressing

appears as follows:

MOV A, @R0:

This instruction causes the 8051 to analyze Special Function Register (SFR) Memory:

TIMER 2 REGISTERS:

Control and status bits are contained in registers T2CON and T2MOD

for Timer 2 . The register pair (RCAP2H , RCAP2L) are the Capture / Reload

registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode .Interrupt

Registers:

The individual interrupt enable bits are in the IE registe . Two priorities can be

set for each of the six interrupt sources in the IP register.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 21 of 41

Page 22: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

Timer 2

Timer 2 is a 16-bit Timer / Counter that can operate as either a timer or an

event counter. The type of operation is selected by bit C/T2 in

Capture Mode

In the capture mode , two options are selected by bit EXEN2 in T2CON .

If EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets

bit TF2 in T2CON . This bit can then be used to generate an interrupt . If

EXEN2 = 1 , Timer 2 performs the same operation , but a 1-to-0 transition at

external input T2EX also causes the current value in TH2 and TL2 to be

captured into RCAP2H and RCAP2L , respectively

Auto-reload (Up or Down Counter)

Timer 2 can be programmed to count up or down when configured in its

16-bit auto-reload mode. This feature is invoked by the DCEN (Down Counter

Enable) bit located in the SFR T2MOD . Upon reset , the DCEN bit is set to 0

so that timer 2 will default to count up

Baud Rate Generator

Timer 2 is selected as the baud rate generator by setting TCLK and/or

RCLK in T2CON ..The baud rates in Modes 1 and 3 aredetermined by Timer 2’s

overflow rate according to the following equation .

Modes 1 and 3 Baud Rates =Timer 2 Overflow Rate

Timer 0

Timer 0 functions as either a timer or event counter in four modes of operation .

Timer 0 is controlled by the four lower bits of the TMOD register and bits 0, 1, 4

and 5 of the TCON register

Mode 0 ( 13-bit Timer)

Mode 0 configures timer 0 as a 13-bit timer which is set up as an 8-bit

timer (TH0 register) with a modulo 32 prescaler implemented with the lower five

bits of the TL0 register . The upper three bits of TL0 register are indeterminate and

should be ignored . Prescaler overflow increments the TH0 register.

Mode 1 ( 16-bit Timer )

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 22 of 41

Page 23: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

Mode 1 is the same as Mode 0, except that the Timer register is being

run with all 16 bits . Mode 1 configures timer 0 as a 16-bit timer with the

TH0 and TL0 registers connected in cascade . The selected input increments the

TL0 register .

Mode 2 (8-bit Timer with Auto-Reload)

Mode 2 configures timer 0 as an 8-bit timer ( TL0 register ) that

automatically reloads from the TH0 register . TL0 overflow sets TF0 flag in the

TCON register and reloads TL0 with the contents of TH0 , which is preset by

software .

Mode 3 ( Two 8-bit Timers )

Mode 3 configures timer 0 so that registers TL0 and TH0 operate as separate

8-bit timers. This mode is provided for applications requiring an additional 8-bit

timer or counter .

Timer 1

Timer 1 is identical to timer 0 , except for mode 3 , which is a hold-

count mode . Functio Register PCON. If SMOD = 0 (which is its value on reset), the

baud rate

Mode 3 ( Halt ):

Placing Timer 1 in mode 3 causes it to halt and hold its count . This

can be used to halt Timer 1 when TR1 run control bit is not available i.e. ,

when Timer 0 is in mode 3

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 23 of 41

Page 24: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

5. LCD (LIQUID CRISTAL DISPLAY)

5.1 INTRODUCTION:

A liquid crystal display (LCD) is a thin, flat display device made up of any

number of color or monochrome pixels arrayed in front of a light source or reflector. Each

pixel consists of a column of liquid crystal molecules suspended between two transparent

electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to each

other. Without the liquid crystals between them, light passing through one would be blocked

by the other. The liquid crystal twists the polarization of light entering one filter to allow it to

pass through the other.

Many microcontroller devices use 'smart LCD' displays to output visual information.

LCD displays designed around LCD NT-C1611 module, are inexpensive, easy to use, and it

is even possible to produce a readout using the 5X7 dots plus cursor of the display. They

have a standard ASCII set of characters and mathematical symbols. For an 8-bit data bus,

the display requires a +5V supply plus 10 I/O lines (RS RW D7 D6 D5 D4 D3 D2 D1 D0).

For a 4-bit data bus it only requires the supply lines plus 6 extra lines(RS RW D7 D6 D5

D4). When the LCD display is not enabled, data lines are tri-state and they do not interfere

with the operation of the microcontroller.

5.2 FEACHERS:

(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM

(3) 80x8 bits (80 characters).

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 24 of 41

Page 25: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

(4) Character generator ROM

(5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM

(7).Display data RAM and character generator RAM may be

Accessed by the microprocessor.

(8) Numerous instructions

(9) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,

Blink Character, Cursor Shift, Display Shift.

(10). Built-in reset circuit is triggered at power ON.

(11). Built-in oscillator.

Data can be placed at any location on the LCD. For 16×1 LCD, the address locations are:

Fig : Address locations for a 1x16 line LCD

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 25 of 41

Page 26: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

5.3 SHAPES AND SIZES:

Even limited to character based modules,there is still a wide variety of shapes and sizes

available. Line lenghs of 8,16,20,24,32 and 40 charecters are all standard, in one, two and

four line versions.

5.4 PIN DESCRIPTION:

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins

(two pins are extra in both for back-light LED connections).

Fig: pin diagram of 1x16 lines lcd

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 26 of 41

Page 27: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

CONTROL LINES:

EN: Line is called "Enable." This control line is used to tell the LCD that you are sending it

data. To send data to the LCD, your program should make sure this line is low (0) and then

set the other two control lines and/or put data on the data bus.

RS:

Line is the "Register Select" line. When RS is low (0), the data is to be treated as a

command or special instruction (such as clear screen, position cursor, etc.). When RS is high

(1), the data being sent is text data which sould be displayed on the screen. For example, to

display the letter "T" on the screen you would set RS high.

RW:

Line is the "Read/Write" control line. When RW is low (0), the information on the

data bus is being written to the LCD. When RW is high (1), the program is effectively

querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command.

All others are write commands, so RW will almost always be low.

LOGIC STATUS ON CONTROL LINES:

• E - 0 Access to LCD disabled

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 27 of 41

Page 28: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instructions

-1 Character

Writing data to the LCD:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

READ DATA FROM DATA LINES (IF IT IS READING)ON LCD:

1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 28 of 41

Page 29: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

INITIALIZATION BY INSTRUCTIONS:

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 29 of 41

Page 30: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

If the power conditions for the normal operation of the internal reset circuit are

not satisfied, then executing a series of instructions must initialize LCD unit. The

procedure for this initialization process is as follows:

LCD COMMANDS:

FLOW CHART:

We won’t replace every routine in the LCD library, but we will try to cover all the

major functions. Our program, then, must initialize the LCD, display a simple message on

the LCD, display a message that requires controlling the position we place letters on the

LCD, in this way we will cover all the major LCD operati

6. RELAYS

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 30 of 41

Page 31: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

6.1 INTRODUCTION:

A relay is an electrical switch that opens and closes under the control of another

electrical circuit. In the original form, the switch is operated by an electromagnet to open or

close one or many sets of contacts. A relay is able to control an output circuit of higher

power than the input circuit, it can be considered to be, in a broad sense, a form of an

electrical amplifier.

Relays are usuallly SPDT (single pole double through switch)or DPDT (double pole

double through switch) but they can have many more sets of switch contacts, for example

relays with 4 sets of changeover contacts are readily available.

6.2 BASIC OPERATION OF A RELAY:

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 31 of 41

Page 32: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

An electric current through a conductor will produce a magnetic field at right angles to

the direction of electron flow. If that conductor is wrapped into a coil shape, the magnetic

field produced will be oriented along the length of the coil. The greater the current, the

greater the strength of the magnetic field, all other factors being equal.

RELAYS CAN BE CATEGORIZED ACCORDING TO THE MAGNETIC SYSTEM AND OPERATION:

NEUTRAL RELAYS:

This is the most elementary type of relay. The neutral relays have a magnetic coil,

which operates the relay at a specified current, regardless of the polarity of the voltage

applied.

BIASED RELAYS:

Biased relays have a permanent magnet above the armature. The relay operates if the

current through the coil winding establishes a magneto-motive force that opposes the flux by

the permanent magnet. If the fluxes are in the same direction, the relay will not operate, even

for a greater current through the coil.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 32 of 41

Page 33: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

POLARIZED RELAYS:

Like the biased relays, the polarized relays operate only when the current through the

coil in one direction. But there the principle is different. The relay coil has a diode connected

in series with it. This blocks the current in the reverse direction.

The major difference between biased relays and polarized relays is that the former

allows the current to pass through in the reverse direction, but does the not operate the relay

and the later blocks the current in reverse direction.  You can imagine how critical these

properties when relays are connected in series to form logic circuits.

MAGNETIC STICK RELAYS OR PERM POLARIZED RELAYS:

These relays have a magnetic circuit with high permanence.  Two coils, one to

operate (pick up) and one to release (drop) are present.  The relay is activated by a current in

the operate coil. On the interruption of the current the armature remains in picked up position

by the residual magnetism. The relay is released by a current through the release coil.

SLOW RELEASE RELAYS:

These relays have a capacitor connected in parallel to their coil. When the operating

current is interrupted the release of relay is delayed by the stored charge in the capacitor. The

relay releases as the capacitor discharges through the coil.

RELAYS FOR AC:

These are neutral relays and picked up for A.C. current through their coil. These are

very fast in action and used on power circuits of the point motors, where high current flows

through the contacts. A normal relay would be slow and make sparks which in turn may

weld the contacts together.

6.3 APPLICATIONS:

To control a high-voltage circuit with a low-voltage signal, as in some types of

modems or audio amplifiers,

To control a high-current circuit with a low-current signal, as in the starter solenoid

of an automobile,

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 33 of 41

Page 34: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

7. KEIL SOFTWARE

INSTALLING THE KEIL SOFTWARE ON A WINDOWS PC

Insert the CD-ROM in your computer’s CD drive On most computers, the CD will “auto run”, and you will see the Keil installation

menu. If the menu does not appear, manually double click on the Setup icon, in the root directory: you will then see the Keil menu.

On the Keil menu, please select “Install Evaluation Software”. (You will not require a license number to install this software).

Follow the installation instructions as they appear.

LOADING THE PROJECTS

The example projects for this book are NOT loaded automatically when you install the Keil compiler.These files are stored on the CD in a directory “/Pont”. The files are arranged by chapter: for example, the project discussed in Chapter 3 is in the directory “/Pont/Ch03_00-Hello”.Rather than using the projects on the CD (where changes cannot be saved), please copy the files from CD onto an appropriate directory on your hard disk. Note: you will need to change the file properties after copying: file transferred from the CD will be ‘read only’.

Configuring the Simulator

Open the Keil mVision2

Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open it.

Go to Project – Select Device for Target ‘Target1’

Select 8052(all variants) and click OK

Now we need to check the oscillator frequency: Go to project – Options for Target ‘Target1’

Make sure that the oscillator frequency is 12MHz.

Building the Target

Running the Simulation

Having successfully built the target, we are now ready to start the debug session and run the simulator.

First start a debug session The flashing LED we will view will be connected to Port 1. We therefore want to

observe the activity on this port

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 34 of 41

Page 35: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

To ensure that the port activity is visible, we need to start the ‘periodic window update’ flag

Go to Debug - Go

While the simulation is running, view the performance analyzer to check the delay durations.

Go to Debug – Performance Analyzer and click on it

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

8.PROGRAM

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 35 of 41

Page 36: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

#include <REGX51.H>

#include <lcd.h>

sbit st1 = P2^0;

sbit st2 = P2^1;

sbit st3 = P2^2;

sbit light = P0^0;

void main()

{

light=0;

init_lcd();

display_lcd("automatic steetlight controller");

while(1)

{

if(st3==0 && st2==0 && st1==1)

{

cmd_lcd(0x80);

display_lcd("press sw1to set");

cmd_lcd(0xC0);

display_lcd("the timings");

}

if(st3==0 && st2==1 && st1==0)

{

cmd_lcd(0x80);

display_lcd("time is set as");

cmd_lcd(0xC0);

display_lcd("prev values ");

}

if(st3==0 && st2==1 && st1==1)

{

cmd_lcd(0x80);

display_lcd("streetlight");

cmd_lcd(0xC0);

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 36 of 41

Page 37: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

display_lcd("on");

}

if(st3==1 && st2==0 && st1==0)

{

cmd_lcd(0x80);

display_lcd("sw-2 to new value");

cmd_lcd(0xC0);

display_lcd("sw-3 to old value");

}

if(st3==1 && st2==0 && st1==1)

{

cmd_lcd(0x80);

display_lcd("street light");

cmd_lcd(0xC0);

display_lcd("off");

}

if(st3==1 && st2==1 && st1==0)

{

light=1;

}

if(st3==1 && st2==1 && st1==1)

{

light=0;

}

}

}

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 37 of 41

Page 38: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

9. APPLICATIONS

Accurate on & off street lights.

The manual operation of street light controlling is a time taking process.with this

project the manual operation completely eliminated.

Muncipality and public lighting systems are controlled automaticallu.

Power and time saved by accurate on & off.

Applicable for all kinds of lighting systems.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 38 of 41

Page 39: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

10.RESULT

We made a project on automatic on/off streetlight.which controls the lighting

system automatically and reduces the efforts,which is applicable in all kinds of lighting

system applications. Hence by using this project we can observe the automatic on-off street

light.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 39 of 41

Page 40: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

11.CONCLUSION

Our aim is to control the street lights automatically according time.

By using this project the manual operation of the lighting system is completely elemineted.

This project gives the best solution for electrical power wastage.

Because saving of 1 unit power will save 5 kg’s of primary fuel coal.

So by using this project we can get the automatic on/off street lights and also save the power.

which is applicable for all kinds of lighting system.

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 40 of 41

Page 41: Batch 8 Documentation

“AUTOMATIC STREET LIGHT CONTROLLER USING RTC”

12. BIBLIOGRAPHY

12.1 REFERENCE BOOKS

8051 MICRO EMBEDDED BY CONTROLLER AND STEMS-MAZIDI &MAZIDI ADVANCED MICRO-PROCESSERS AND PERIPHERALS-RAY AND

BHURCHANDI

12.2 REFERENCE SITES

www.keil.com

www.wisegeek/microcontroller.com

www.wikipedia.com

www.mytutorialcafe.com

www.softpedia.com

www.electronics4u.com

www.electronics.howstuffworks.com

www.direction.com

www.remotecontroltechnology.com

www.atmel.com

www.zilog.com

Department Of Electrical & Electronics Engineering,ANU BOSE INSTITUTE OF TECHNOLOGY. Page 41 of 41