Vous êtes sur la page 1sur 42

RVR Institute of Engineering &Technology

1. INTRODUCTION

An embedded system is a combination of software and hardware to perform a


dedicated task.

Some of the main devices used in embedded products are Microprocessors and
Microcontrollers. Microprocessors are commonly referred to as general purpose
processors as they simply accept the inputs, process it and give the output.

In contrast, a microcontroller not only accepts the data as inputs but also
manipulates it, interfaces the data with various devices, controls the data and thus
finally gives the result.

As everyone in this competitive world prefer to make the things easy and
simple to handle, this project sets an example to some extent.

PC based Hi-tech Home Implementation is a simple project which enables the


user to control the electrical appliances at home just by sitting before the computer.
The project aims at controlling the electrical appliances based on the instructions
provided by the P.C. This project gives a brief outline of how to interface the personal
computer with the embedded systems.

In order to develop any project, the main requirements are hardware, software,
memory devices, protocols, interface media and display devices. The brief description
of these is explained in detail in later topics. This project provides three modes for the
user in which the control of the electrical appliances can be accessed.
1. Manual Mode
2. Auto load Mode
3. Auto fan Mode
The above three modes are discussed later in detail.

ECE Department 10
RVR Institute of Engineering &Technology

2. BLOCK DIAGRAM OF PC BASED INDUSTRIAL


AUTOMATON WITH AUTO/MANUAL MODES OF
OPERATION

LDR

LM35 ADC
\\\

Fig. 2.1: Block Diagram of PC based Industrial Automation with auto/manual


modes of operation

ECE Department 11
RVR Institute of Engineering &Technology

3.MICROCONTROLLERS

Microcontroller is a programmable device. A microcontroller has a CPU in


addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a
single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost and space are
critical.

The Intel 8051 is a Harvard architecture, single chip microcontroller (µC)


which was developed by Intel in 1980 for use in embedded systems. It was popular in
the 1980s and early 1990s, but today it has largely been superseded by a vast range of
enhanced devices with 8051-compatible processor cores that are manufactured by
more than 20 independent manufacturers including Atmel, Infineon Technologies and
Maxim Integrated Products.

8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of
data at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be
processed by the CPU. 8051 is available in different memory types such as UV-
EPROM, Flash and NV-RAM.

The microcontroller used in this project is AT89C51. Atmel Corporation


introduced this 89C51 microcontroller. This microcontroller belongs to 8051 family.
This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers,
one serial port and four ports (each 8-bits wide) all on a single chip. AT89C51 is
Flash type 8051.

The present project is implemented on Keil Uvision. In order to program the


device, Proload tool has been used to burn the program onto the microcontroller.

The features, pin description of the microcontroller and the software tools used
are discussed in the following sections.

ECE Department 12
RVR Institute of Engineering &Technology

3.1 Features of AT89C51:-

• 4Bytes of Re-programmable Flash Memory.


• RAM is 128 bytes.
• 2.7V to 6V Operating Range.
• Fully Static Operation: 0 Hz to 24 MHz.
• Two-level Program Memory Lock.
• 128x8-bit Internal RAM.
• 32 Programmable I/O Lines.
• Two 16-bit Timer/Counters.
• Six Interrupt Sources.
• Programmable Serial UART Channel.
• Low-power Idle and Power-down Modes.

3.2 Pin Description:-

The AT89C51 is a low-voltage, high-performance CMOS 8-bit


microcomputer with 4K bytes of Flash programmable memory. The device is
manufactured using Atmel’s high-density nonvolatile memory technology and is
compatible with the industry-standard MCS-51 instruction set. By combining a
versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a
powerful microcomputer, which provides a highly flexible and cost-effective solution
to many embedded control applications.

In addition, the AT89C51 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning. The power-down mode saves the RAM
contents but freezes the oscillator disabling all other chip functions until the next
hardware reset.

ECE Department 13
RVR Institute of Engineering &Technology

3.3 Pin Diagram of 8051:-

Fig. 3.1: Pin Diagram of 8051

3.3 Pin Description:-

VCC: - Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND:- Pin 20 is the ground.

XTAL1 and XTAL2:-

The 8051 has an on-chip oscillator but requires an external clock to run it.
Usually, a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2
(pin18). There are various speeds of 8051 family. Speed refers to the maximum

ECE Department 14
RVR Institute of Engineering &Technology

oscillator frequency connected to XTAL. When the 8051 is connected to a crystal


oscillator and is powered up, the frequency can be observed on the XTAL2 pin using
the oscilloscope.

Reset:-

Pin9 is the reset pin. It is an input and is active high. Upon applying a high
pulse to this pin, the microcontroller will reset and terminate all the activities. This is
often referred to as a power-on reset.

EA (External Access):-

Pin 31 is EA. It is an active low signal. It is an input pin and must be


connected to either Vcc or GND but it cannot be left unconnected.

The 8051 family members all come with on-chip ROM to store programs. In
such cases, the EA pin is connected to Vcc. If the code is stored on an external ROM,
the EA pin must be connected to GND to indicate that the code is stored externally.

PSEN (Program Store Enable):- This is an output pin.

ALE (Address Latch Enable):- This is an output pin and is active high.

Ports 0, 1, 2 AND 3:-

The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports.
All the ports upon RESET are configured as input, since P0-P3 have value FFH on
them.

Port 0(P0):-

Port 0 is also designated as AD0-AD7, allowing it to be used for both address


and data. ALE indicates if P0 has address or data. When ALE=0, it provides data D0-
D7, but when ALE=1, it has address A0-A7. Therefore, ALE is used for
demultiplexing address and data with the help of an internal latch.

ECE Department 15
RVR Institute of Engineering &Technology

When there is no external memory connection, the pins of P0 must be


connected to a 10K-ohm pull-up resistor. This is due to the fact that P0 is an open
drain. With external pull-up resistors connected to P0, it can be used as a simple I/O,
just like P1 and P2. But the ports P1, P2 and P3 do not need any pull-up resistors
since they already have pull-up resistors internally. Upon reset, ports P1, P2 and P3
are configured as input ports.

Port 1 and Port 2:-

With no external memory connection, both P1 and P2 are used as simple I/O.
With external memory connections, port 2 must be used along with P0 to provide the
16-bit address for the external memory. Port 2 is designated as A8-A15 indicating its
dual function. While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to
provide bits A8-A15 of the address.

Port 3:-

Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or
output. P3 does not need any pull-up resistors, the same as port 1 and port 2. Port 3
has an additional function of providing some extremely important signals such as
interrupts.

ECE Department 16
RVR Institute of Engineering &Technology

P3 Bit Function Pin

P3.0 RxD (serial input pin) 10

P3.1 TxD (serial output pin) 11

P3.2 INTO (active low) 12

P3.3 INT1 (active low) 13

P3.4 T0 (timer 0) 14

P3.5 T1 (timer 1) 15

P3.6 WR (active low) 16

P3.7 RD (active low) 17

Table 3.1: Port 3 Alternate Functions

3.4 Machine Cycle for the 8051:-

The CPU takes a certain number of clock cycles to execute an instruction. In


the 8051 family, these clock cycles are referred to as machine cycles. The length of
the machine cycle depends on the frequency of the crystal oscillator. The crystal
oscillator, along with on-chip circuitry, provides the clock source for the 8051 CPU.

The frequency can vary from 4 MHz to 30 MHz, depending upon the chip
rating and manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is
used to make the 8051 based system compatible with the serial port of the IBM PC.

ECE Department 17
RVR Institute of Engineering &Technology

In the original version of 8051, one machine cycle lasts 12 oscillator periods.
Therefore, to calculate the machine cycle for the 8051, the calculation is made as 1/12
of the crystal frequency and its inverse is taken.

3.5 Timers:-

The 8051 has two timers: Timer 0 and Timer 1. They can be used either as
timers to generate a time delay or as counters to count events happening outside the
microcontroller. Both Timer 0 and Timer 1 are 16-bit wide. Since the 8051 has an 8-
bit architecture, each 16-bit timer is accessed as two separate registers of low byte and
high byte. Lower byte register of Timer 0 is TL0 and higher byte is TH0. Similarly
lower byte register of Timer1 is TL1 and higher byte register is TH1.

TMOD (Timer Mode) Register:-

Both timers 0 and 1 use the same register TMOD to set the various operation
modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0
and the upper 4 bits for Timer 1. In each case, the lower 2 bits are used to set the timer
mode and the upper 2 bits to specify the operation.

(MSB) (LSB)

GATE C/T M1 M0 GATE C/T M1 M0

TIMER 1 TIMER 0

Gate:-

Every timer has a means of starting and stopping. Some timers do this by

software, some by hardware and some have both software and hardware controls. The

timers in the 8051 have both. The start and stop of the timer are controlled by the way

ECE Department 18
RVR Institute of Engineering &Technology

of software by the TR (timer start) bits TR0 and TR1. These instructions start and
stop the timers as long as GATE=0 in the TMOD register. The hardware way of
startingand stopping the timer by an external source is achieved by making GATE=1
in the TMOD register.

C/T:- Timer or counter selected. Cleared for timer operation and set for counter
operation.

M1 :- Mode bit 1

M0 :- Mode bit 0

M1 M0 Mode Operating Mode

13-bit timer mode

0 0 0 8-bit timer/counter THx with TLx as 5-bit

prescaler

0 1 1 16-bit timer mode

16-bit timer/counters THx and TLx are cascaded

8-bit auto reload timer/counter

1 0 2 THx holds a value that is to be reloaded into

TLx each time it overflows

1 1 3 Split timer mode

Table 3.2: Modes of TMOD Register

ECE Department 19
RVR Institute of Engineering &Technology

This mode 2 is an 8-bit timer and therefore it allows only values of 00H to
FFH to be loaded into the timer’s register TH. After TH is loaded with the 8-bit value,
the 8051 give a copy of it to TL. When the timer starts, it starts to count up by
incrementing the TL register. It counts up until it reaches its limit of FFH. When it
rolls over from FFH to 00H, it sets high the TF (timer flag). If Timer 0 is used, TF0
goes high and if Timer 1 is used, TF1 goes high. When the TL register rolls from FFH
to 0 and TF is set to 1, TL is reloaded automatically with the original value kept by
the TH register.

SCON (Serial Control) Register:- The SCON register is an 8-bit register used
to program the start bit, stop bit and data bits of data framing.

RI TI RB8 TB8 REN SM2 SM1 SM0

ECE Department 20
RVR Institute of Engineering &Technology

SM0 SCON.7 Serial port mode specifier

SM1 SCON.6 Serial port mode specifier

SM2 SCON.5 Used for multiprocessor communication

REN SCON.4 Set/cleared by software to enable/disable

Reception

TB8 SCON.3 Not widely used

RB8 SCON.2 Not widely used

Transmit interrupt flag. Set by hardware

TI SCON.1 at thebeginning of the stop bit in mode 1.

Must be cleared by software.

Receive interrupt flag. Set by hardware

RI SCON.0 at the beginning of the stop bit in mode 1

Must be cleared by software

Table 3.3: Functions of SCON Register

ECE Department 21
RVR Institute of Engineering &Technology

SM0 SM1 Mode

0 0 Serial Mode 0

0 1 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit

1 0 Serial Mode 2

1 1 Serial Mode 3

Table 3.4: Modes of SCON Register

Of the four serial modes, only mode 1 is widely used. In the SCON register,

when serial mode 1 is chosen, the data framing is 8 bits, 1 stop bit and 1 start bit,

which makes it compatible with the COM port of IBM/ compatible PC’s. And the

most important is serial mode 1 allows the baud rate to be variable and is set by Timer

1 of the 8051. In serial mode 1, for each character a total of 10 bits are transferred,

where the first bit is the start bit, followed by 8 bits of data and finally 1 stop bit.

ECE Department 22
RVR Institute of Engineering &Technology

4. SERIAL COMMUNICATION

The main requirements for serial communication are:

1. Microcontroller

2. PC

3. RS 232 cable

4. MAX 232 IC

5. HyperTerminal

When the pins P3.0 and P3.1 of microcontroller are set, UART which is
inbuilt in the microcontroller will be enabled to start the serial communication.

Synchronous communications allows faster data transfer rates than

asynchronous methods, because additional bits to mark the beginning and end of each

data byte are not required. The 8051 has a built-in UART.

The rate of data transfer in serial data communication is stated as bps (bits per

second). Another widely used terminology for bps is baud rate. The data transfer rate

of a given computer system depends on communication ports incorporated into that

system. And in asynchronous serial data communication, this baud rate is generally

limited to 100,000bps. The baud rate is fixed to 9600bps in order to interface with the

microcontroller using a crystal of 11.0592 MHz.

4.1 RS232 Cable:-

To allow compatibility among data communication equipment, an interfacing

standard called RS232 is used. Since the standard was set long before the advent of

ECE Department 23
RVR Institute of Engineering &Technology

the TTL logic family, its input and output voltage levels are not TTL compatible. For

this reason, to connect any RS232 to a microcontroller system, voltage converters

such as MAX232 are used to convert the TTL logic levels to the RS232 voltage levels

and vice versa.

4.2 MAX 232IC:-

Fig. 4.1: Pin Diagram of MAX 232 IC

Max232 IC is a specialized circuit which makes standard voltages as required

by RS232 standards. This IC provides best noise rejection and very reliable against

discharges and shortcircuits. MAX232 IC chips are commonly referred to as line

drivers.

To ensure data transfer between PC and microcontroller, the baud rate and

voltage levels of Microcontroller and PC should be the same. The voltage levels of

microcontroller are logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for

PC, RS232 voltage levels are considered and they are: logic 1 is taken as -3V to -25V

ECE Department 24
RVR Institute of Engineering &Technology

and logic 0 as +3V to +25V. So, in order to equal these voltage levels,

MAX232 IC is used. Thus this IC converts RS232 voltage levels to microcontroller

voltage levels and vice versa.

ECE Department 25
RVR Institute of Engineering &Technology

5. ANALOG TO DIGITAL CONVERTER

Analog-to-digital converters are among the most widely used devices for data
acquisition. Digital systems use binary values, but in the physical world everything is
continuous i.e., analog values. Temperature, pressure (wind or liquid), humidity and
velocity are the physical analog quantities.

These physical quantities are to be converted into digital values for further
processing. One such device to convert these physical quantities into electrical signals
is sensor. Sensors for temperature, pressure, humidity, light and many other natural
quantities produce an output that is voltage or current.

Thus, an analog-to-digital converter is needed to convert these electrical


signals into digital values so that the microcontroller can read and process them.

An ADC has an n-bit resolution where n can be 8,10,12,16 or even 24 bits.


The higher resolution ADC provides a smaller step size, where step size is the
smallest change that can be detected by an ADC. In addition to resolution, conversion
time is another major factor in judging an ADC. Conversion time is defined as the
time it takes the ADC to convert the analog input to a digital number.

5.1 ADC0804:-

The ADC chip that is used in this project is ADC0804. The ADC0804 IC is an
8-bit parallel ADC in the family of the ADC0800 series from National
Semiconductor. It works with +5 volts and has a resolution of 8 bits. In the ADC0804,
the conversion time varies depending on the clocking signals applied to the CLK IN
pin, but it cannot be faster than 110µs.

ECE Department 26
RVR Institute of Engineering &Technology

Fig. 5.1: Pin Diagram of ADC0804

5.2 Pin Description:-

CS (Chip Select):-

Chip select is an active low input used to activate the ADC0804 chip. To
access the ADC0804, this pin must be low.

RD (Read):-

This is an input signal and is active low. ADC converts the analog input to its
binary equivalent and holds it in an internal register. RD is used to get the data out of
ADC0804 chip. When CS=0, if a high-to-low pulse is applied to the RD pin, the 8-bit
digital output shows up at the D0-D7 data pins.

WR (Write):- This is an active low input used to inform the ADC0804 to start the
conversion process.

ECE Department 27
RVR Institute of Engineering &Technology

If CS=0 when WR makes a low-to-high transition, the ADC0804 starts


converting the analog input value Vin to an 8-bit digital value. The amount of time it
takes to convert varies depending on the CLK IN and CLK R values.

CLK IN and CLK R:-

CLK IN is an input pin connected to an external clock source when an external


clock is used for timing. However, the 804 has an internal clock generator. To use the
internal clock generator of the ADC0804, the CLK IN and CLK R are connected to a
capacitor and a resistor. In that case, the clock frequency is determined by the
equation: f = 1/ (1.1RC). Typical values are R=10K ohms and C= 150 pf. Substituting
in the above equation, the frequency is calculated as 606 kHz. Thus, the conversion
time is 110µs.

INTR:-

This is an output pin and is active low. It is a normally high pin and when the
conversion is finished, it goes low to signal the CPU that the converted data is ready
to be picked up. After INTR goes low, the CS pin is made low i.e., CS=0 and send a
high-to-low pulse to the RD pin to get the data out of the ADC0804 chip.

VIN(+) and VIN(-):-

These are the differential analog inputs where Vin=Vin(+) – Vin(-). The
Vin(-) pin is connected to ground and the Vin(+) pin is used as the analog input to be
converted to digital.

VCC:-
This is the +5 volt power supply. It is also used as a reference voltage when
the Vref/2 input (pin 9) is open.

ECE Department 28
RVR Institute of Engineering &Technology

VREF/2:-

Pin 9 is an input voltage used for the reference voltage. If this pin is open, the
analog input voltage for the ADC0804 is in the range of 0 to 5 volts.Vref/2 is used to
implement analog input voltages other than 0.5V. i.e., if the analog input range needs
to be 0 to 4 volts, Vref/2 is connected to 2 volts.

D0-D7:-

D0-D7 (D7 is the MSB) are the digital data output pins since ADC0804 is a
parallel ADC chip. To calculate the output voltage, the below equation is used:
Dout = Vin/ (step size)
where Dout = digital data output pins (in decimal) and Vin = analog input value
Step size is the smallest change and is given by (2 x Vref/2)/256 for ADC0804.

Clock Source for ADC0804:-

The speed at which an analog input is converted to the digital output depends
on the speed of the CLK input. According to the ADC0804 datasheets, the typical
operating frequency is approximately 640 kHz at 5 volts.

ECE Department 29
RVR Institute of Engineering &Technology

5.3 ADC Interface with Microcontroller:-

20
8 P2.5
P2.6
9 P2.7
P1.7
C P1.6
P1.5
5 P1.4
P1.3
1 P1.2
P1.1

Fig. 5.2: ADC Interfacing with 8051

ECE Department 30
RVR Institute of Engineering &Technology

6. TEMPERATURE SENSOR (LM35)

6.1 Precision Centigrade Temperature Sensor:-

In this project, in order to obtain the fan speed based on temperature, initially
this temperature value has to be read and fed to the microcontroller. This temperature
value has to be sensed. Thus a sensor has to be used and the sensor used in this project
is LM35. It converts temperature value into electrical signals.

LM35 series sensors are precision integrated-circuit temperature sensors


whose output voltage is linearly proportional to the Celsius temperature. The LM35
requires no external calibration since it is internally calibrated. . The LM35 does not
require any external calibration or trimming to provide typical accuracies of ±1⁄4°C at
room temperature and ±3⁄4°C over a full −55 to +150°C temperature range.

The LM35’s low output impedance, linear output, and precise inherent
calibration make interfacing to readout or control circuitry especially easy. It can be
used with single power supplies, or with plus and minus supplies. As it draws only 60
μA from its supply, it has very low self-heating, less than 0.1°C in still air.

6.2 Features:-

• Calibrated directly in ° Celsius (Centigrade)

• Linear + 10.0 mV/°C scale factor

• 0.5°C accuracy guaranteed (at +25°C)

ECE Department 31
RVR Institute of Engineering &Technology

• Rated for full −55° to +150°C range

• Suitable for remote applications

• Low cost due to wafer-level trimming

• Operates from 4 to 30 volts

• Less than 60 μA current drain

• Low self-heating, 0.08°C in still air

Fig. 6.1: LM35

The characteristic of this LM35 sensor is:

• For each degree of centigrade temperature it outputs 10milli volts.

ADC accepts the output from LM35 and converts that data into digital form
which is sent to microcontroller for further processing.

ECE Department 32
RVR Institute of Engineering &Technology

7. RELAYS

A relay is an electrically controllable switch widely used in industrial controls,


automobiles and appliances.

The relay allows the isolation of two separate sections of a system with two
different voltage sources i.e., a small amount of voltage/current on one side can
handle a large amount of voltage/current on the other side but there is no chance that
these two voltages mix up.

Fig. 7.1: Circuit Symbol of a Relay

7.1 Operation:-

When current flows through the coil, a magnetic field is created around the
coil i.e., the coil is energized. This causes the armature to be attracted to the coil. The
armature’s contact acts like a switch and closes or opens the circuit. When the coil is
not energized, aspring pulls the armature to its normal state of open or closed. There
are all types of relays for all kinds of applications.

ECE Department 33
RVR Institute of Engineering &Technology

7.2 Relay Operation and use of Protection Diodes:-

Fig. 7.2: Relay Operation and use of Protection Diodes

Transistors and ICs must be protected from the brief high voltage 'spike'
produced when the relay coil is switched off. The above diagram shows how a signal
diode (eg 1N4148) is connected across the relay coil to provide this protection. The
diode is connected 'backwards' so that it will normally not conduct. Conduction
occurs only when the relay coil is switched off, at this moment the current tries to
flow continuously through the coil and it is safely diverted through the diode. Without
the diode no current could flow and the coil would produce a damaging high voltage
'spike' in its attempt to keep the current flowing.

In choosing a relay, the following characteristics need to be considered:

ECE Department 34
RVR Institute of Engineering &Technology

1. The contacts can be normally open (NO) or normally closed (NC). In the NC type,
the contacts are closed when the coil is not energized. In the NO type, the contacts are
closed when the coil is energized.

2. There can be one or more contacts. i.e., different types like SPST (single pole
single throw), SPDT (single pole double throw) and DPDT (double pole double
throw) relays.

3. The voltage and current required to energize the coil. The voltage can vary from a
few volts to 50 volts, while the current can be from a few milliamps to 20milliamps.
The relay has a minimum voltage, below which the coil will not be energized. This
minimum voltage is called the “pull-in” voltage.

4. The minimum DC/AC voltage and current that can be handled by the contacts. This
is in the range of a few volts to hundreds of volts, while the current can be from a few
amps to 40A or more, depending on the relay.

7.3 Driving a Relay:-

An SPDT relay consists of five pins, two for the magnetic coil, one as the
common terminal and the last pins as normally connected pin and normally closed
pin.

When the current flows through this coil, the coil gets energized. Initially
when the coil is not energized, there will be a connection between the common
terminal and normally closed pin. But when the coil is energized, this connection
breaks and a new connection between the common terminal and normally open pin
will be established. Thus when there is an input from the microcontroller to the relay,
the relay will be switched on.
Thus when the relay is on, it can drive the loads connected between the
common terminal and normally open pin. Therefore, the relay takes 5V from the

ECE Department 35
RVR Institute of Engineering &Technology

microcontroller and drives the loads which consume high currents. Thus the relay acts
as an isolation device.
Digital systems and microcontroller pins lack sufficient current to drive the
relay. While the relay’s coil needs around 10milli amps to be energized, the
microcontroller’s pin can provide a maximum of 1-2milli amps current. For this
reason, a driver such as ULN2003 or a power transistor is placed in between the
microcontroller and the relay. In order to operate more than one relay, ULN2003 can
be connected between relay and microcontroller.

8. ULN 2003 DRIVER

Fig. 8.1: DIP 16 Package of ULN

The ULN2003 driver is a high voltage, high current Darlington arrays each
containing seven open collector Darlington pairs with common emitters. Each channel
is rated at 500mA and can withstand peak currents of 600mA. Suppression diodes are
included for inductive load driving and the inputs are pinned opposite the outputs to
simplify board layout.

These versatile devices are useful for driving a wide range of loads including
solenoids, relays DC motors, LED displays filament lamps, thermal print heads and
high power buffers. This chip is supplied in 16 pin plastic DIP packages with a copper
lead frame to reduce thermal resistance.

ECE Department 36
RVR Institute of Engineering &Technology

8.1 Pin Diagram of ULN2003:-

Fig. 8.2: Pin Diagram of ULN2003

ECE Department 37
RVR Institute of Engineering &Technology

This ULN2003 driver can drive seven relays at a time. The pins 8 and 9
provide ground and Vcc respectively. The working of ULN driver is as follows:
It can accept seven inputs at a time and produces seven corresponding outputs.
If the input to any one of the seven input pins is high, then the value at its
corresponding output pin will be low, for example if the input at pin 6 is high, then
the value at the corresponding output i.e., output at pin 11 will be low. Similarly if the
input at a particular pin is low, then the corresponding output will be high.

One of the coil terminals of the relay will be connected to the output pin of the
ULN driver. Thus in order to switch on the relay to operate any load, the output from
the ULN driver (any one of the 7 outputs) should be low. Thus for the output to be
low, the input applied at that corresponding input pin should be high. The input to the
ULN driver is provided by the microcontroller. Thus the instruction required to
operate the relay through the microcontroller is

SETB PX.Y
Where X is the port number (P0, P1, P2 and P3)
And Y is the pin number of Port X.

ECE Department 38
RVR Institute of Engineering &Technology

9. LIGHT DEPENDENT RESISTOR

LDRs or Light Dependent Resistors are very useful especially in light/dark


sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as
1,000,000 ohms, but when they are illuminated with light, the resistance drops
dramatically.
Thus in this project, LDR plays an important role in controlling the electrical
appliances based on the intensity of light i.e., if the intensity of light is more (during
daytime) the loads will be in off condition. And if the intensity of light is less (during
nights), the loads will be switched on.

Fig. 9.1: Circuit Symbol of LDR

ECE Department 39
RVR Institute of Engineering &Technology

9.1 LED Interfacing with the Microcontroller:-

Fig. 9.2: Led Interfacing with Microcontroller

LEDs are the most widely used input/output devices of the 8051.
Microcontroller port pins cannot drive these LEDs as these require high currents to
switch on. This current limiting resistor is connected to protect the port pins from
sudden flow of high currents from the power supply.

Thus in order to glow the LED, first there should be a current flow through the
LED. In order to have a current flow, a voltage difference should exist between the
LED terminals. To ensure the voltage difference between the terminals and as the
positive terminal of LED is connected to power supply Vcc, the negative terminal has
to be connected to ground. Thus this ground value is provided by the microcontroller
port pin. This can be achieved by writing an instruction “CLR P2.0”. With this, the
port pin P2.0 is initialized to zero and thus now a voltage difference is established
between the LED terminals and accordingly, current flows and therefore the LED
glows. LED and switches can be connected to any one of the four port pins.

ECE Department 40
RVR Institute of Engineering &Technology

9.2: Schematic Diagram:-

ECE Department 41
RVR Institute of Engineering &Technology

Fig. 9.3: Schematic Diagram

10. WORKING PROCEDURE

ECE Department 42
RVR Institute of Engineering &Technology

PC based industrial automation is a project which enables the user to control


the electrical appliances just by sitting before the p.c.

In this project, the user will be provided with three modes the user has the
choice to select the required mode.

The three modes are:


1. Normal Mode
2. Automatic Load Mode
3. Automatic Fan Mode.

To interface 8051 microcontroller with the PC, hyper terminal window is


used. When the system is switched on, the user can view the following menu in the
hyper terminal window.

Select the following modes


NM -> normal mode
AL -> auto load
AF -> auto fan

If the user wishes to enter into Normal Mode:


He has to press NM from the PC keyboard which is shown in the hyper
terminal window. After completion of entering any choice, he has to press ‘0’ to
indicate the termination of the process of entering the keys. That is, the key ‘0’ is
accessed as the enter key. If the entered option is valid, then the respective message
will be displayed and the control moves to the respective mode. If the entered option
is invalid, then the message “invalid operation” will be displayed in the hyper
terminal window.

Thus after entering the key ‘0’ in the hyper terminal window, user will get the
message “manual mode selected” in the hyper terminal window. After this message, a
list of options will be provided in the next line of the hyper terminal window.
ECE Department 43
RVR Institute of Engineering &Technology

Select the following options to operate the respective loads


F -> fan
1 -> load1
2 -> load2
3 -> load3
4 -> load4
5 -> load5
6 ->load6
7 ->load7
8 ->load8
User can choose any of the above options.

When the user presses the key ‘F’:-

User will get the message “operating fan…” in the hyper terminal window. the
present speed of the fan will be displayed in the next line. For example, if the speed of
the fan is 1, the message “fan speed at level 1” will be displayed in the hyper terminal
window. an other two options will be displayed in the next line and the options are:

Press ‘I’ to increment the speed


Press ‘D’ to decrement the speed

So, if the user wishes to increment the fan speed, he has to enter the key ‘I’
and enter key and he has to enter the key ‘D’ if he wishes to decrement the fan speed.
The user can increment the speed up to level4 and can decrement the speed to zero
level i.e., off condition.

When the user presses the key ‘1’:-

ECE Department 44
RVR Institute of Engineering &Technology

The message “load 1 is operating ….” will be displayed in the hyper terminal
window. The present status of the load1 will be displayed in the next line of the hyper
terminal window. That is, if the load is on, the message “load1 is on” will be
displayed in the hyper terminal window and if the load is off, the message “load1 is
off” will be displayed.

If the user wishes to change the status of the load, he has to press the same key
once again. the user has to press the key ’Q’ if he wishes to come out of the manual
mode at any moment or he can proceed with the next key if he wishes to stay in the
same mode.

When the user presses the key ‘2’:-

The message “load 2 is operating ….” will be displayed in the hyper terminal
window. The present status of the load2 will be displayed in the next line of the hyper
terminal window. That is, if the load is on, the message “load2 is on” will be
displayed in the hyper terminal window. If the user wishes to change the status of the
load, he has to press the same key once again.

When the user presses the key ‘3’:-

The message “load 3 is operating ….” will be displayed in the hyper terminal
window. The present status of the load3 will be displayed in the next line of the hyper
terminal window. That is, if the load is on, the message “load3 is on” will be
displayed in the hyper terminal window. If the user wishes to change the status of the
load, he has to press the same key once again. And so on until the key 8 the operation
will be the same.

If the user tries to give any key other than these, the message “Invalid
operation” will be displayed in the hyper terminal window.

ECE Department 45
RVR Institute of Engineering &Technology

The user has to press the key ’Q’ if he wishes to terminate from the manual
mode at any moment. Whenever the user presses the key ‘Q’, the main menu will be
displayed in the hyper terminal window.

If the user wishes to enter into Auto Load Mode:-

He has to enter AL from the PC keyboard. Then the message “Auto light
mode selected” will be displayed in the hyper terminal window. In this, the control of
the electrical appliances is controlled by light dependent resistor (LDR).

Light dependent resistor is nothing but a resistor whose resistance value


depends on the intensity of light. The resistance of LDR varies inversely with the
intensity of light. During the daytime, as the intensity of the light will be high, the
resistance of the LDR will be low and accordingly the load will be off. Similarly at
night times, as the intensity of light will be low, the resistance of the LDR will be
high and the load will be switched on accordingly. In this mode, the user has no
choice to select the load.

If the user wishes to enter into Auto Fan Mode:-

He has to enter AF from the keyboard then the message “Auto fan mode
selected” will be displayed in the hyper terminal window. The message “temperature
is:” will be displayed in the next line. The fan speed is controlled by monitoring the
temperature continuously. The temperature value is read from the temperature sensor
and this analog value is converted into digital value by analog to digital converter
(ADC) and fed to microcontroller. The room temperature value is displayed in the
hyper terminal window. The user has no choice to select the fan speed in this mode.

ECE Department 46
RVR Institute of Engineering &Technology

11. SOFTWARE REQUIREMENTS

11.1 Keil Compiler:-

Keil compiler is a software used where the machine language code is written
and compiled. After compilation, the machine source code is converted into hex code
which is to be dumped into the microcontroller for further processing. Keil compiler
also supports C language code.

11.2 Proload:-

Proload is a software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller and
this is done by the proload. Proload is a programmer which itself contains a
microcontroller in it other than the one which is to be programmed. This
microcontroller has a program in it written in such a way that it accepts the hex file
from the keil compiler and dumps this hex file into the microcontroller which is to be
programmed.

As the proload programmer kit requires power supply to be operated, this


power supply is given from the power supply circuit designed above. It should be
noted that this programmer kit contains a power supply section in the board itself but
in order to switch on that power supply, a source is required. Thus this is
accomplished from the power supply board with an output of 12volts.

ECE Department 47
RVR Institute of Engineering &Technology

11.3 Source Code:-


keycount equ 30h
relay1 equ p0.0
relay2 equ p0.1
relay3 equ p0.2
relay4 equ p0.3
relay5 equ p0.4
relay6 equ p0.5
relay7 equ p0.6
relay8 equ p0.7
rd1 equ p3.5
wr1 equ p3.6
intr equ p3.7
uln1 equ p2.0
uln2 equ p2.1
uln3 equ p2.2
uln4 equ p2.3
load equ p2.6
org 00h
mov p0,#0
mov p2,#0f0h
mov tmod,#20h
mov scon,#50h
mov th1,#0fdh
mov r1,#30h
mov 20h,#0
mov 21h,#0

start: mov dptr,#msg /*options */


acall repeat
jmp reception
transmit: setb tr1

ECE Department 48
RVR Institute of Engineering &Technology

mov sbuf, a /*transmiting to hyper tr window*/


jnb ti,$
clr ti
ret

ECE Department 49
RVR Institute of Engineering &Technology

12. CONCLUSION

In terms of complexity embedded systems can range from very simple with a
single microcontroller chip, to very complex with multiple units, peripherals and
networks mounted inside a large chassis or enclosure, but the project falls under the
former category making it very simple to analyze.

PC based Hi-tech Home Implementation is a simple project which enables the


user to control the electrical appliances at home just by sitting before the computer.
The project aims at controlling the electrical appliances based on the instructions
provided by the P.C. This project gives a brief outline of how to interface the personal
computer with the embedded systems. Hence by this project we can control various
electrical appliances by means of PC using PC’s hyper terminal window and can be
suitable for homes, hotels and showrooms etc. to control all the electrical appliances
and fan speed from centralized point.

This project provides three modes for the user in which the control of the
electrical appliances can be accessed. As this project is suitable for hotels and
showrooms the number of loads can be increased and can be used to control the
electrical appliances of large scale showrooms and hotels without any problem. But as
the number of loads increases the complexity also increases which may create a
problem in the system.

Therefore, the project is very much useful in hotels and large scale industries
were at a time many electrical appliances are to be controlled.

ECE Department 50
RVR Institute of Engineering &Technology

13. BIBLIOGRAPHY

“8051 Microcontrollers and embedded systems”


-M.A.Mazidi & J.G.Mazidi
“Microcontrollers based temperature monitoring and control.”
-Dogan Ibrahim
“Electronic Components”
-D.V.Prasad

Elecronics for You

www.atmel.com
www.datasheetcatalog.com
www.discovercircuits.com
www.kpsec.freeuk.com
www.datasheets.com
www.beyondlogic.com
www.natoinal.com

ECE Department 51

Vous aimerez peut-être aussi