Top Banner
1.INTRODUCTION 1.1 INTRODUCTION TO EMBEDDED SYSTEMS An embedded system is a special- purpose computer system designed to perform one or a few dedicated functions, [1] often with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems control many of the common devices in use today. Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP4 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld share some elements with embedded systems — such as the operating systems and microprocessors which power them — but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected. 1.2 EXAMPLES OF EMBEDDED SYSTEMS Embedded systems span all aspects of modern life and there are many examples of their use. Telecommunications systems employ numerous embedded systems from telephone 1
65
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Documentation

1. INTRODUCTION

1.1 INTRODUCTION TO EMBEDDED SYSTEMS

An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, [1] often with real-time computing constraints. It is usually embedded as part of a complete device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems control many of the common devices in use today.

Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale.

Physically, embedded systems range from portable devices such as digital watches and MP4 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld share some elements with embedded systems — such as the operating systems and microprocessors which power them — but are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected.

1.2 EXAMPLES OF EMBEDDED SYSTEMS

Embedded systems span all aspects of modern life and there are many examples of their use. Telecommunications systems employ numerous embedded systems from telephone switches for the network to mobile phones at the end-user. Computer networking uses dedicated routers and network bridges to route data.

Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile phones, videogame consoles, digital cameras, DVD players, GPS receivers, and printers. Many household appliances, such as microwave ovens, washing machines and dishwashers, are including embedded systems; these are used to provide flexibility, effiency, accuracy and other features which made human life easier.

1

Page 2: Documentation

2. PROJECT DESCRIPTION

2.1 BACKGROUND OF INVENTION

A large variety of electrical appliances are found everywhere. While the presence of those appliances ensures that tasks are performed more safely and efficiently, the effectiveness of those appliances depends on controlling and indicating their operational status. For example, if an appliance is left turned on long after the user has finished with it, careless person may burn themselves on the exposed heated surfaces. Hence, an automatic control for shutting off the appliance as well as for indicating that the appliance has been shut off would avoid this and other safety risks. In addition, the controller/indicator would reduce additional wear and tear on the appliance, as well as save electricity.

Another problem created by the absence of indicators or controls stems from the fact that appliances often require a short period of time to reach a ready or operational state. In such instances, the user must periodically test the appliance to see if it is ready. By providing a control circuit for and indicator of a ready state, however, the user avoids losing the time spent testing the appliance.

Although some appliances are equipped with control and indicating circuitry that automatically turns the appliance off or indicates that the appliance is ready to use, such circuits have tended to involve relatively complex designs that have not fully solved the problems discussed above. Moreover, the appliances known in the prior art do not automatically shut off after a predetermined period of time regardless of any use during that period of time.

So in our project we use Real Time clock to control the appliances or to supply loads at different intervals of time. Power Saving Using Time Operated Electrical Appliance Controlling System is a reliable circuit that takes over the task of switch on/off the electrical devices with respect to time. This project replaces the Manual Switching. It has an Inbuilt Real Time Clock which tracks over the Real Time. When this time equals to the programmed time, then the corresponding Relay for the device is switched ON. The switching time can be edited at any Time using the keypad. The Real Time Clock is displayed on four 7-segment display. The programmed time can be predetermined by the user i.e. the user set time as he requires. He may also change the settings when ever wants to do so.

A time-based electrical appliance multi-mode control circuit and indicator arrangement which is connected to a power supply and an on and off switch. Upon turning the switch on, power is simultaneously supplied to the electrical appliance load and to a dual timer circuit. A first timer in the circuit is immediately energized causing a first indicator to represent an on state to the user

2

Page 3: Documentation

2.2 BLOCK DIAGRAM

Fig 2.2.1 Basic block diagram of “TIME BASED ELECTRICAL APPLIANCES CONTROL IN INDUSTRIES”.

3

+12V to Relay

P1^1-P1^7 (P0^0-P0^4)P3^5-P3^7

AT89S52

9 P2^3-P2^7

XTAL1, XTAL2

Relay

Crystal

Reset

LCD

+5V to all sectionsStep down T/F

Bridge Rectifier

Filter Circuit Regulator

Ds1307 RTC

Crystal

Loads

Back-upBattery

Page 4: Documentation

2.3 BLOCK DIAGRAM DESCRIPTION

Power supply

The type of power supply we use is the LINEAR POWER SUPPLY.

Linear power supply

An AC powered linear power supply usually uses a transformer to convert the voltage from the wall outlet (mains) to a different, usually a lower voltage. If it is used to produce DC, a rectifier is used. A capacitor is used to smooth the pulsating current from the rectifier. Some small periodic deviations from smooth direct current will remain, which is known as ripple. These pulsations occur at a frequency related to the AC power frequency (for example, a multiple of 50 or 60 Hz).

The voltage produced by an unregulated power supply will vary depending on the load and on variations in the AC supply voltage. For critical electronics applications a linear regulator will be used to stabilize and adjust the voltage. This regulator will also greatly reduce the ripple and noise in the output DC current. Linear regulators often provide current limiting, protecting the power supply and attached circuit from over current.

The simplest DC power supply circuit consists of a single diode and resistor in series with the AC supply.

The different blocks in power supply are

The Transformer

The Rectifier

The Filter

The voltage regulator

2.3.1 The Transformer

Usually steps up or step down the incoming line voltage depending on the needs of the power supply. This alternating voltage is then fed to the rectifier.

2.3.2 The Rectifier I s a diode circuit that converts the ac to pulsating dc. This pulsating dc is then applied to the filter.

4

Page 5: Documentation

2.3.3 The Filter

Filter is a circuit that reduces the variations of the in the dc voltage. It can include one or several passive

2.3.4 The voltage regulator

Voltage regulator is used to maintain a constant voltage at the power supply output. It also provides a further smoothing of the dc voltage. We will be using a zener diode as a voltage regulator. Modern day circuits have superseded the zener diode regulator with more modern integrated circuits. Since the zener diode is the simplest of these circuits to understand, we will study it as a prerequisite to the more modern circuits available.

2.3.5 AT89S52 micro-controller

In our project we are using the AT 89S52 micro-controller. The AT AT 89S52 micro-controller provides following standard features: 4k of flash memory, 128 bytes of ram, 32 I/O, two 16-bit timer/counters, five vector two-level interrupt architecture, a full duplex serial port, o chip oscillatorAnd clock circuitry. In addition , the AT AT 89S52 micro-controller 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, 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.

2.3.5 Real Time Clock DS 1307

The DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-directional 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 battery supply.

2.3.6 Back-up battery

The back-up used here is of 3v which is used provide back-up for RTC in times of power failure

2.3.7 Crystal A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated

5

Page 6: Documentation

circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them were called "crystal oscillators".

2.3.8 Reset circuit

A reset circuit is like a switch which is used reset the circuit. It is connected to pin 9 of the controller.

2.3.9 Liquid crystal display (LCD)

Frequently, a microcontroller 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 any microcontroller is an LCD (display). Some of the most common LCDs connected to the microcontroller are 16x2 displays, means 16 characters per line by 2 lines.

A standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in our project, AT89S52) and communicates directly with the LCD.

2.3.9 Relays

A relay is an electro-magnetic switch which is useful if you want to use a low voltage circuit to switch on and off a light bulb (or anything else) connected to the 220v mains supply.The current needed to operate the relay coil is more than can be supplied by most chips (op. amps, AT 89S52 etc).

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.

FIG 2.3.1 Basic relay

6

Page 7: Documentation

3. HARDWARE DESCRIPTION

3.1 POWER SUPPLY:

The type of power supply we use is the LINEAR POWER SUPPLY.

Linear power supply

An AC powered linear power supply usually uses a transformer to convert the voltage from the wall outlet (mains) to a different, usually a lower voltage. If it is used to produce DC, a rectifier is used. A capacitor is used to smooth the pulsating current from the rectifier. Some small periodic deviations from smooth direct current will remain, which is known as ripple. These pulsations occur at a frequency related to the AC power frequency (for example, a multiple of 50 or 60 Hz.

The voltage produced by an unregulated power supply will vary depending on the load and on variations in the AC supply voltage. For critical electronics applications a linear regulator will be used to stabilize and adjust the voltage. This regulator will also greatly reduce the ripple and noise in the output DC current. Linear regulators often provide current limiting, protecting the power supply and attached circuit from over current.

The simplest DC power supply circuit consists of a single diode and resistor in series with the AC supply.

The power supply consists of step-down transformer, bridge rectifier, voltage regulator and a filter to smoothen the o/p from bridge rectifier and voltage regulators.

Lastly we have a led to check if the supply is working or not.

AC/ DC supply

In the past, mains electricity was supplied as DC in some regions, AC in others. A simple, cheap linear power supply would run directly from either AC or DC mains, often without using a transformer. The power supply consisted of a rectifier and a capacitor filter. The rectifier was essentially a conductor, having no sudden effect when operating from DC.

Overload Protection

Power supplies should have some type of overload protection. Overload protection is important to protect the electronic equipment hooked up to the power supply and to also prevent overheating, which could potentially lead to an electrical fire. Fuses and Circuit Breakers are two of the more frequent mechanisms used for overload protection.

7

Page 8: Documentation

Block diagram of power supply

12v dc 12V

FIG 3.1.1 Block diagram of power supply

3.1.2 Transformers

The first component of the power supply is the transformer. Using magnetic coupling between windings, the transformer is used to isolate the rectifier from the mains voltage, and to reduce the voltage to something the regulator can tolerate. The primary winding will be rated at 220 0V AC and the secondary will be a more user friendly (or less user hostile) voltage to suit the application.

DC Output: The DC output is approximately equal to the secondary voltage multiplied by 1.414, but as we shall see, this is a rather simplistic calculation, and does not take the many variables into consideration. At light loading, this rule can be

8

230V AC Mains

Step Down Transformer

Filter

Regulator Filter

Rectifier

Page 9: Documentation

applied without fear, and it will be accurate enough for most applications. When an appreciable current is drawn, this simple approach falls flat on its face.

Mains variations: These occur in all situations, and the mains voltage at any point in time will usually be somewhat different from the nominal voltage quoted by the supplier. Any variation of 10% or less can be considered "normal", and greater variations are not at all uncommon.

Losses: Since all transformers have losses, these cannot be ignored in the design phase. Magnetizing loss (AKA iron loss) is the current that is required to maintain the design value of magnetic flux in the transformer core. There is nothing you can do to affect this loss, as it is dependent on the size of the core and the design criteria of the manufacturer. Large transformers will have a larger magnetising loss than small ones, but will be less affected by it due to the larger surface area which allows the transformer to remain cool at no load. Small transformers have a greater loss per VA than bigger ones, and this is one of the reasons that small transformers run quite warm even when unloaded.

The iron losses are greatest at no-load and fall as more current is drawn from the transformer. Copper losses are caused by the resistance of the winding, and are negligible at no load, and rise with increasing output current. There is a fine balance between iron and copper losses during transformer design. A relatively high iron loss means that copper losses will be reduced (thus improving regulation), but if too high, the transformer will overheat with no load. A full description of the magnetising current and its effect on regulation is outside the scope of this article, and since there is little you can do about it, it shall be discussed no further.

Mains noise: Noise can easily get through a transformer, both in transverse and common modes. Transverse noise is any noise or waveform distortion that is effectively superimposed on the incoming AC waveform, and this is coupled through the transformer along with the wanted signal - the mains.

Common mode noise is any noise signal that is common to both the active (hot) and neutral mains leads. This is not coupled through the transformer magnetically, but capacitive. The higher the capacitance between primary and secondary windings, the more common mode noise will get through to the amplifier. The much loved toroidal transformer is much worse than conventional "EI" (Ee-Eye) lamination transformers in this respect because of the large inter-winding capacitance. An electrostatic shield will help, but these are uncommon in mass produced toroidal transformers. The conventional transformer is usually better, and by using side-by-side windings instead of the more common (and cheaper) concentric windings, common mode noise can be reduced by an order of magnitude.

Input mains filters can remove either form of high frequency noise component to some degree, and large spikes can be removed using Metal Oxide Varsities (MOVs) that effectively short circuit the noise pulse, reducing it to a level that is (hopefully) inaudible. Contrary to the beliefs of some, there is no panacea for noise, and it is best attacked in the equipment, rather than the now popular (but mainly misconceived) notion that an expensive mains lead will cure all.

9

Page 10: Documentation

3.1.3 Rectifiers:

The second block of the power supply is the rectifier block. The most common rectifiers are...

Full wave rectifier Full Wave Dual Full Wave (Full Wave Centre Tap)

The full wave voltage doubler is still common in valve amplifier circuits and for preamp supplies.

The Full Wave Bridge Rectifier

The bridge rectifier is the most commonly used rectifier circuit for the following reasons:

No centre - tapped transformer is required. The bridge rectifier produces almost double the output voltage as a full wave

C-T transformer rectifier using the same secondary voltage

.

Fig 3.1.2 The Bridge rectifier

Basic Circuit Operation During the positive half cycle, both D1 and D3 are forward biased. At the same time, both D2 and D4 are reverse biased. Note the direction of current flow through the load. On the negative half cycle, D2 and D4 are forward biased and D1 and D3 are reverse biased. Again note that direction of current through the load is in the same direction although the secondary winding polarity has reversed.

10

Page 11: Documentation

In a bridge rectifier the diodes may be of variable types like 1N4001, 1N4002, 1N4003, 1N4004, 1N4005, 1N4006, 1N4007 etc……. can be used. But we use 1N4007 because it can with stand up to 1kv.

3.14 Regulators:

Very many devices need well regulated power. The most typical approach used electronics devices is to use a transformers that work directly from the domestic electricity supply at 60 Hz (in the U.S.A, 50 Hz in some other countries)and this is followed by rectifier + regulator circuitry that uses linear regulation. In this type of regulator a transistor, or a special IC, is used as a series resistor whose value of resistance is controlled so as to maintain the output voltage constant despite variations in load. This work well, is quite simple to make, but is quite inefficient as a lot of power is wasted as heat (wasted heat is define by formula: drop voltage over regulator (volts) * current taken (in amperes) = power loss (in watts)).Linear regulation works very well in low power applications where some lost heat is no problem (in higher power applications switched more power supplies are nowadays preferred because of less wasted power).

Here we use 7812 regulator and it supplies 12v to the controller.

3.1.5 Filters

In order to obtain DC voltage of 0 Hz, we have to use a low pass filter (LPF). So that capacitive filter circuit is used where a capacitor is connected at the rectifier output & dc is obtained across it. The filtered waveform is essentially a dc voltage with negligible ripples & it is ultimately fed to the load.

3.2 AT89S52 MICRO CONTROLLER

Features: • Compatible with MCS-51® Products

8K Bytes of In-System Programmable (ISP) Flash Memory– Endurance: 1000 Write/Erase Cycles

4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz

Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data PointerPower-off Flag

11

Page 12: Documentation

3.2.1 Description: The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes 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 instruction set and pinout. 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 in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller 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, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 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 interrupt or hardware reset.

AT 89S52 is a 40 –bit microcontroller which are divided into four ports namely P0,P1,P2,P3.

Fig 3.2.1 Microcontroller

12

Page 13: Documentation

3.2.2 AT 89S52 PIN DIAGRAM

Fig 3.2.2 AT 89S52 pin diagram

13

AT 89S52

Page 14: Documentation

3.2.3 Pin Description:

VCCSupply voltage.

GNDGround.

Port 0

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedanceInputs. Port 0 can also be configured to be the multiplexed low order 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 Pin

Alternate Functions

P1.0T2 (external count input to Timer/Counter 2),

clock-out

P1.1T2EX (Timer/Counter 2 capture/reload trigger

and direction control)

P1.5MOSI (used for In-System Programming)

P1.6MISO (used for In-System Programming)

P1.7SCK (used for In-System Programming)

Table 3.2.1 Pin configuration for port1

Port 1

14

Page 15: Documentation

Port 1 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups.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.

Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pullups. 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 pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 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 2 emits 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.

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.

Port 3 Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also 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

15

Page 16: Documentation

Table 3.2.2 Pin configuration for port3

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 of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

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.

16

Port Pin

Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5T1 (timer 1 external input)

P3.6WR (external data memory write strobe)

Page 17: Documentation

Fig 3.2.3 Architecture of AT 89S52

EA/VPP

17

Page 18: Documentation

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.

XTAL1

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

XTAL2

Output from the inverting oscillator amplifier.

Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 1. Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect.User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0.

Timer 2 Registers:

Control and status bits are contained in registers T2CON (shown in Table 2) and T2MOD (shown in Table 3) 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 Register

The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.

Memory Organization

MCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.

18

Page 19: Documentation

Program Memory

If the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory.

Data Memory

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. This means that the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access of the SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

TIMERS

The timers can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. The 89s52 has two timers; Timer0 and timer1.They can be used either as timers or as event counters.

Basic Registers of the Timer

Both Timer 0 and timer 1 are 16 bits wide. Since the 89s52 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte.

Timer 0 registers

The 16-bit register of timer 0 is accessed as low byte and high byte. The low byte register is called TLO(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These registers can be accessed like any other registers, such as A,B,R0,R1,R2,etc.For example, the instruction “MOV TLO,#4FH” moves the value 4FH into TLO, the low byte of timer 0.

Timer1 registers

Timer 1 is also 16 bits, and its 16-bit register is split into two bytes

Timer 2

19

Page 20: Documentation

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 the SFR T2CON (shown in Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 3. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected

Timer 2 Operating Modes

RCLK +TCLK CP/RL2 TR2 MODE

0 0 1 16-bit Auto-reload

0 1 1 16-bit Capture

1 X 1 Baud Rate Generator

X X 0 (Off)

Table 3.2.3 Timer 2 operating modes

Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle.

Baud Rate Generator

Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON (Table 2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 8.The baud rate generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are preset by software. The baud rates in Modes 1 and 3 are determined by Timer 2’s overflow rate according to the following equation.

20

Page 21: Documentation

Modes 1 and 3 Baud Rates = Timer2 Overflow Rate 16

The Timer can be configured for either timer or counter operation. In most applications, it is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2 the oscillator frequency).The baud rate formula is given below.

Modes 1 and 3 = Oscillator Frequency Baud Rate 32 x [65536-RCAP2H, RCAP2L)]

Where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer.

Interrupts

The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all shown in Figure 10. Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once. Note that Table 5 shows that bit position IE.6 is unimplemented.In the AT89S52, bit position IE.5 is also unimplemented. User software should not write 1s to these bit positions, since they may be used in future AT89 products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in thesame cycle in which the timer overflows the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.

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 11. 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 12. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

21

Page 22: Documentation

Idle Mode

In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled

Interrupt or by hardware reset. Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory.

Power-down Mode

In the Power-down mode, the oscillator is stopped, and the instruction that invokes Power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the Power-down mode is terminated. Exit from Power-down mode can be initiated either by a hardware reset or by an enabled external interrupt. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

Programming the Flash – Parallel Mode

The AT89S52 is shipped with the on-chip Flash memory array ready to be programmed.The programming interface needs a high-voltage (12-volt) program enable signal and is compatible with conventional third-party Flash or EPROM programmers. The AT89S52 code memory array is programmed byte by byte.

Programming Algorithm

Before programming the AT89S52, the address, data, and control signals should be set up according to the Flash programming mode table and Figures 13 and 14. To program the AT89S52, take the following

Stepso .Input the desired memory location on the address Lines.o Input the appropriate data byte on the data lines.o Activate the correct combination of control signals.o Raise EA/VPP to 12V.o Pulse ALE/PROG once to program a byte in the Flash array or the lock bits.

The byte-write cycle is self-timed and typically takes no more than 50 μs. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached

. Data Polling

22

Page 23: Documentation

The AT89S52 features Data Polling to indicate the end of a byte write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written data on P0.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

3.3 LIQUID CRYSTAL DISPLAY

3.3.1 LIQUID CRYSTAL DISPAY:

Frequently, a microcontroller 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 any microcontroller is an LCD (display). Some of the most common LCDs connected to the microcontroller are 16x2 displays, means 16 characters per line by 2 lines.

A standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in our project, AT89S52) and communicates directly with the LCD.

3.3.2 44780 BACKGROUNDS

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used, the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).

The three control lines are referred to as EN, RS, and RW.

The EN line is called "Enable." This control line is used to tell the LCD that we are sending data to the LCD. To send data to the LCD, our 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. When the other lines are completely ready, we bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The 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 we would set RS high.

The 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.Finally, the data bus consists of 4 or 8 lines (depending on the mode of

23

Page 24: Documentation

operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

3.3.3 HARDWARE CONFIGURATION

As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. In our project, we are going to use an 8-bit data bus, so we'll be using 11 of the AT89S52s I/O pins to interface with the LCD. In our project we use a 16- pin LCD in which 1st and 16th pins are connected to ground , 2nd and 15th pins are Vcc one for supply voltage to the LCD and other to the backlight, 3 rd pin is connected to the variable resistor 4th,5th & 6th pins are connected to the rd,wrand en pins of the controller. 7-14 pins are the data pins which are connected to the potts of the controller.

Fig 3.3.1 LCD pin diagram

Table 3.3.2 LCD pin configuration

24

AT89S52s

Page 25: Documentation

3.4 CRYSTAL

A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them were called "crystal oscillators".

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly ordered, repeating pattern extending in all three spatial dimensions

3.4.1 Crystal characteristics

3.5 RELAYS

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a

25

Page 26: Documentation

230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.

Fig 3.5.1 Basic Relay

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. For further information about switch contacts and the terms used to describe them please see the page on switches. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay.

The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil.

The animated picture shows a working relay with its coil and switch contacts. You can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them, making the relay DPDT. The relay's switch connections are usually labeled COM, NC and NO:

3.6 Real Time Clock DS 1307

The DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-directional 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 battery supply.

4. SOFTWARE DESIGN

26

Page 27: Documentation

4.1 OVERVIEW OF KIEL COMPILER\

It is possible to create the source files in a text editor such as Notepad, run the Compiler on each C source file, specifying a list of controls, run the Assembler on each Assembler source file, specifying another list of controls, run either the Library Manager or Linker (again specifying a list of controls) and finally running the Object-HEX Converter to convert the Linker output file to an Intel Hex File. Once that has been completed the Hex File can be downloaded to the target hardware and debugged. Alternatively KEIL can be used to create source files; automatically compile, link and covert using options set with an easy to use user interface and finally simulate or perform debugging on the hardware with access to C variables and memory. Unless you have to use the tolls on the command line, the choice is clear. KEIL Greatly simplifies the process of creating and testing an embedded application.

4.2 PROJECTS

The user of KEIL centers on “projects”. A project is a list of all the source files required to build a single application, all the tool options which specify exactly how to build the application, and – if required – how the application should be simulated. A project contains enough information to take a set of source files and generate exactly the binary code required for the application. Because of the high degree of flexibility required from the tools, there are many options that can be set to configure the tools to operate in a specific manner. It would be tedious to have to set these options up every time the application is being built; therefore they are stored in a project file. Loading the project file into KEIL informs KEIL which source files are required, where they are, and how to configure the tools in the correct way. KEIL can then execute each tool with the correct options. It is also possible to create new projects in KEIL. Source files are added to the project and the tool options are set as required. The project can then be saved to preserve the settings. The project also stores such things as which windows were left open in the simulator/debugger, so when a project is reloaded and the simulator or debugger started, all the desired windows are opened. KEIL project files have the extension

4.3 SIMULATOR AND DEBUGER

The simulator/ debugger in KEIL can perform a very detailed simulation of a micro controller along with external signals. It is possible to view the precise execution time of a single assembly instruction, or a single line of C code, all the way up to the entire application, simply by entering the crystal frequency. A window can be opened for each peripheral on the device, showing the state of the peripheral. This enables quick trouble shooting of mis-configured peripherals. Breakpoints may be set on either assembly instructions or lines of C code, and execution may be stepped through one instruction or C line at a time. The contents of all the memory areas may be viewed along with ability to find specific variables. In addition the registers may be viewed allowing a detailed view of what the microcontroller is doing at any point in time.

27

Page 28: Documentation

The Keil Software AT 89S52 development tools listed below are the programs you use to compile your C code, assemble your assembler source files, link your program together, create HEX files, and debug your target program. µVision2 for Windows™ Integrated Development Environment: combines Project Management, Source Code Editing, and Program Debugging in one powerful environment.C51 ANSI Optimizing C Cross Compiler: creates relocatable object modules from your C source code,

A51 Macro Assembler: creates relocatable object modules from your AT 89S52 assembler source code,

BL51 Linker/Locator: combines relocatable object modules created by the compiler and assembler into the final absolute object module,LIB51 Library Manager: combines object modules into a library, which may be used by the linker,OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules.

What is µVision3?µVision3 is an IDE (Integrated Development Environment) that helps you

write, compile, and debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

Editor.

A powerful debugger. To help you get started, several example programs (located in the \C51\Examples, C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.

HELLO is a simple program that prints the string "Hello World" using the Serial Interface.MEASURE is a data acquisition system for analog and digital systems. TRAFFIC is a traffic light controller with the RTX Tiny operating system.SIEVE is the SIEVE Benchmark.DHRY is the Dhrystone Benchmark

.

5. SOURCE CODE

28

Page 29: Documentation

#include<REG52.h>

#include<stdio.h>

sbit sda=P2^5;

sbit scl=P2^4;

sbit LED=P0^3;

sbit LED1=P0^4;

sbit LED2=P0^6;

sbit LED3=P0^7;

sbit FAN=P0^0;

void start(void);

void stop();

void writebyte(unsigned char);

unsigned char readbyte();

void writeack();

void readack();

void noack();

void hex2ascii(unsigned char);

void hex2ascii1(unsigned char);

void lcd_init();

void lcdcmd(unsigned char value);

void lcddata(unsigned char value);

void delay(unsigned int ti);

void voltage();

// sfr ldata =0x80;

sbit rs = P3^2;// rs pin

29

Page 30: Documentation

sbit rw = P3^1;// rw pin of lcd

sbit en = P3^0;// enable pin

void main()

{

unsigned char k[10],c=0,i;

unsigned char a[]={"TIME:"};

unsigned char b[]={"DATE:"};

unsigned char var=0;

LED=1;

LED1=1;

LED2=1;

LED3=1;

FAN=0;

lcd_init();

lcdcmd(0x80);

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

{

lcddata(a[i]);

}

start();

writebyte(0xd0); // write to RTC command

sda=1;

writeack();

writebyte(0x00); // memory location

sda=1;

30

Page 31: Documentation

writeack();

writebyte(0x00); // seconds

sda=1;

writeack();

writebyte(0x00); // minutes

sda=1;

writeack();

writebyte(0x10); // hours

sda=1;

writeack();

stop();

do{

c=0;

start();

writebyte(0xd0); // write to RTC

sda=1;

writeack();

writebyte(0x00); // 00 location

sda=1;

writeack();

delay(0);

start();

writebyte(0xD1); // read from RTC

writeack();

while(c<6)

31

Page 32: Documentation

{

k[c]=readbyte();

readack();

c++;

}

k[c]=readbyte();

noack();

stop();

lcdcmd(0x86);

hex2ascii(k[2]); // hours

lcddata(':');

hex2ascii(k[1]); // minutes

lcddata(':');

hex2ascii(k[0]); // seconds

if(k[2]==0x10 && k[1]==0x00 && k[0]==0x00)

{

LED=0;

voltage();

lcddata('0');

lcddata('2');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x00 && k[0]==0x10)

{

LED1=0;

32

Page 33: Documentation

voltage();

lcddata('0');

lcddata('4');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x00 && k[0]==0x20)

{

LED2=0;

voltage();

lcddata('0');

lcddata('6');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x00 && k[0]==0x30)

{

LED3=0;

voltage();

lcddata('0');

lcddata('8');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x00 && k[0]==0x40)

{

LED3=1;

voltage();

33

Page 34: Documentation

lcddata('0');

lcddata('6');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x00 && k[0]==0x50)

{

LED2=1;

voltage();

lcddata('0');

lcddata('4');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x01 && k[0]==0x00)

{

LED3=0;

voltage();

lcddata('0');

lcddata('6');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x01 && k[0]==0x10)

{

LED=1;

LED1=1;

LED3=1;

34

Page 35: Documentation

FAN=1;

voltage();

lcddata('1');

lcddata('0');

lcddata('V');

}

else if(k[2]==0x10 && k[1]==0x04 && k[0]==0x10)

{

FAN=0;

voltage();

lcddata('0');

lcddata('0');

lcddata('V');

}

} while(1);

}

void voltage()

{

unsigned char vol[]={"VOLTAGE: "};

unsigned char i;

lcdcmd(0xc0);

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

{

lcddata(vol[i]);

35

Page 36: Documentation

}

}

void start()

{

sda=1; // data lines fro transforing the bits

scl=1; // clock

sda=0;

delay(0);

scl=0;

}

void stop()

{

sda=0;

delay(0);

scl=1;

delay(0);

sda=1;

}

void writebyte(unsigned char i)

{

unsigned char j=0,k;

while(j<8)

{

k=i;

36

Page 37: Documentation

k=(k<<j)+0x80;

sda=CY;

scl=1;

scl=0;

++j;

}

}

unsigned char readbyte()

{

unsigned char j=0,i=0;

bit d1;

sda=1;

while(j<8)

{

scl=1;

delay(0);

d1=sda;

i=i<<1;

i=i|d1;

delay(0);

scl=0;

++j;

}

return i;

}

37

Page 38: Documentation

void writeack()

{

delay(0);

scl=1;

while(sda);

scl=0;

}

void readack()

{

sda=0;

scl=1;

delay(1);

scl=0;

}

void noack()

{

sda=1;

scl=1;

scl=0;

}

void lcd_init()

{

lcdcmd(0x38);

delay(50);

lcdcmd(0x0e);

38

Page 39: Documentation

delay(50);

lcdcmd(0x06);

delay(50);

lcdcmd(0x01);

delay(50);

}

void lcdcmd(unsigned char value)

{

P1 = value;

rs = 0;

rw = 0;

en = 1;

delay(1);

en = 0;

return;

}

void lcddata(unsigned char value)

{

P1 = value;

rs = 1;

rw = 0;

en = 1;

delay(1);

en = 0;

return;

39

Page 40: Documentation

}

void delay(unsigned int ti)

{

unsigned int i,j;

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

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

}

void hex2ascii(unsigned char i)

{

unsigned char k,j;

k=i;

k=k&0x0f;

j=k|0x30;

k=i;

i=0;

k=k&0xf0;

k=k>>4;

k=k|0x30;

delay(1);

lcddata(k);

delay(1);

lcddata(j);

}

6. RESULT ANALYSIS

40

Page 41: Documentation

A time based electrical appliance control system is used to switch on and off the electrical appliances automatically, i.e. after a predetermined time. This eliminates manual switching.

S.no. No. loads Load Volts Time

1. 1 LED1 2V 10:00:00

2 2 LED’s 1&2 4V 10:00:10

3 3 LED’s 1,2&3 6V 10:00:20

4 4 LED’s 1,2,3&4 8V 10:00:30

5 3 LED’s 1,2&3 6V 10:00:40

6 2 LED’s 1&2 4V 10:00:50

7 3 LED’s 1,2&3 6V 10:01:00

8 1 Fan 10V 10:01:10

Table 6.1 Result

When the power is turned on first electrical appliance is turned the display on the LCD is

Time 10:00:10voltage 2V

Table 6.2 LCD display in first instant of time

After a predetermined time i.e. as in our project second electrical is also turned on.then the display on the Lcd is

Time 10:00:20voltage 4V

Table 6.3 LCD display in second instant of time

After a predetermined time i.e. as in our project third electrical is also turned on. then the display on the LCD is

Time 10:00:30voltage 6V

41

Page 42: Documentation

Table LCD display in third instant of time

After a predetermined time i.e. as in our project fourth electrical is also turned on. Then the display on the LCD is

Time 10:00:40voltage 8V

Table 6.5 Result in fourth instant of time

After a predetermined time i.e. as in our project fourth electrical is turned off Then the display on the LCD is

Time 10:00:50voltage 6V

Table 6.6 LCD display in fifth instant of time

After a predetermined time i.e. as in our project third electrical is also turned off. Then the display on the LCD is

Time 10:01:00voltage 4V

Table 6.7 LCD display in sixth instant of time

After a predetermined time i.e. as in our project third electrical is also turned on. then the display on the LCD is

Time 10:01:10voltage 6V

Table 6.8 LCD display seventh instant of time

After a predetermined time i.e. as in our project fifth electrical is also turned on. then the display on the LCD is

Time 10:01:10voltage 10V

Table 6.9 LCD display in eighth instant of time

After a predetermined time all electrical appliances are turned off and time on LCD will be incrementing unless there is a power failure

7. APPLICATIONS

42

Page 43: Documentation

Power Saving Using Time based Electrical Appliance Controlling System is

used in industries where we require different loads to be supplied in different

intervals of time.

The time-based electrical appliances can be used in medical field to turnoff

equipments such as X-ray machines, scanners etc after a predefined time

where the patient should not be exposed to those machines more than that

predefined time.

This project can also be used to switch off the air condition (A.C) and again

switch on after a predefined time and this can be repeated number of times

The time-based electrical appliances can be used to control home appliances

like microwave ovens, washing-machines, computers, etc. i.e. after a pre-

defined timed the programmed appliances will switch off.

Time based circuits are also used in shopping malls to automatically switch

on lights in side the shop and on the signboard in night hours. in some cases

light in shopping malls will be glowing continuously so, they we can switch

on the alternately.

We have timer switches which are Programmable Time Switches manufactured by us are useful for automatic functioning of electric components like street lights, hoardings and glow signs etc. These switches can be programmed to supply required amount of output for any electrical devices. It can take load up to 3000 Amps.

In communications systems timers are used to know the status of the massage.

.Our time switch with LED display and accurate operation is widely used for

different applications. Our time switch can be operated at different voltage

range and can be mounted on the wall. Some of the salient features of our time

switch are as follows

8. ADVANTAGES AND DISADVANTAGES

8.1 ADVANTAGES

43

Page 44: Documentation

In industries, there will be various loads to be operated and these loads are to be operated at some specific intervals according to our requirements and also based on the device’s constraints. For these purposes, a person should be employed to monitor the status of the loads. But there may be chances that the person may forget to operate these loads at defined intervals. So, we use this project to automatically change loads according to the requirements.

It has an Inbuilt Real Time Clock which tracks over the Real Time. When this time equals to the programmed time, then the corresponding Relay for the device is switched ON.

A large variety of electrical appliances are found everywhere. While the presence of those appliances ensures that tasks are performed more safely and efficiently, the effectiveness of those appliances depends on controlling and indicating their operational status. our project improves performance of the appliances since they are automatically switched off after they finish work on it.

This project uses a time based controller which supplies power to appliances instead of manual operation thus resulting in reducing power wastage. This project also reduces the risk factor because it is not easy to operate such high loads in industries.

The Real Time clock is supported by a back up battery which avoids disturbances caused power failures.

8.2 DISADVANTAGES:

If the load requirements change than the pre-determined ones then the

controller has to be programmed again to the required timings. In order to

over this we need to have key pad to edit timings and load requirements

according to our future requirements.

9. FUTURE TRENDS

44

Page 45: Documentation

This project can be expanded to find applications in area like providing

security and denying access to the unauthenticated users.

This project in feature can be extended to the home automation systems.

Whre in if we want to switch on a water heater before retuning home from

a days work in\t can be automatically switched off.

The disadvantage we have in this project is that if load requirements differ

than the pre determined ones then we can have keypad in the circuit which

can inrease or decrease the load requirements as we require.

A time-based operation, as planned in the ATM future, is assumed to

affect the controllers’ Situation Awareness (SA) due to a higher priority of

meeting a time objective and increasing automation. This paper provides

SA requirements on the design of controller support tools in time-based

operations,

Clothes in a future are made from organic textiles and can repair

themselves, .... This means that an appliance that provide flexibility in terms

of time and space ... power mat at the top of the table brings energy to any

electrical appliance.... The new GE dishwasher with integrated control panel

offers a stylish...

In future we can extend this project to robots where human need not operate

the robot for the daily routine work it does.

This system in future can be used in vehchiles if the vehicle is un moved for

some-time it may automatically turn-off. This saves fuel. This usually

happens in large traffic jams.

This can be applied in future in many fields like communications, bio-

technology, bio-medical fields, and mechanical fields, electrical &

mechanical fields ……….. and so on.

10. CONCLUSION

45

Page 46: Documentation

Proper set of instructions that are suitable for a specific application always leads to a better system. As search never stops “Still better” never dies. Still better systems are always implemented with a small bit of intelligence

This project sets sights on replacing the conventional manual method of switching the loads by automatic time-based system for switching the loads i.e. this project is used to supply loads to different electrical appliance at different instants of time or to supply different loads to the same electrical appliance at different times.

A time-based electrical appliance multi-mode control circuit and indicator arrangement which is connected to a power supply and an on and off switch. Upon turning the switch on, power is simultaneously supplied to the electrical appliance load and to a dual timer circuit. The timer circuit is used to time according which the power is supplied to the different electrical appliances at the same time or it can supply different loads to different to electrical appliance at different instance of time.

This project can be extended to find applications in shopping malls, medical field even home appliances this can also be applicable in education and many other purposes.

The advantage of using this project is power Saving Using Time Operated Electrical Appliance Controlling System is a reliable circuit that takes over the task of switch on/off the electrical devices with respect to time. This project replaces the Manual Switching & there by it reduces the power consumption and it also the risk factor .The added advantage of this project is that it is cost effective when compared to different sensors applications

Finally we can conclude that by programming a device using some of the languages we can operate electrical appliances.

11. BIBLOGRAPHY

References

46

Page 47: Documentation

[1]. The AT 89S52 Microcontroller and Embedded Systems by M.A Mazidi & J.G

Mazidi, PHI, 2005.

[2]. The Microcontroller architecture, programming, interphasing and system design-

RAJ KAMAL, PEARSON EDUCATION, 2005.

[3]. The Microcontroller Application Cookbook by Matt Gilliland

[4]. Electronic devices and circuits by SHALIVAHANAN, TATAMACGRAW,

2005.

[5]. Electrical measurements, second edition by H.S.KALSI, TATA

MACGRAWHILL, 2004.

WEBSITES

[1]. www.atmel.com /dym/resources/prod_doccuments/doc0336.pdf

[2].www.atmel.com/dym/resources/prod_doccuments/doc1919.pdf

47