report of device controlchngd
Post on 04-Apr-2018
213 Views
Preview:
TRANSCRIPT
-
7/31/2019 Report of Device Controlchngd
1/57
1. INTRODUCTION TO AN EMBEDDED SYSTEM
An Embedded System employs a combination of hardware & software (a computational engine) to
perform a specific function; is part of a larger system that may not be a computer works in a
reactive and time-constrained environment. Software is used for providing features and flexibility.
Hardware is used for performance & sometimes security.
An embedded system is a special purpose system in which the computer is completely encapsulated
by the device it controls. Unlike a general purpose computer, such as a PC, an embedded system
performs predefined tasks usually with very specific tasks design engineers can optimize it reducing
the size and cost of the product. Embedded systems are often mass produced, so the cost savings may
be multiplied by million of items.The core of any embedded system is formed by one or several
microprocessor or micro controller programmed to perform a small number of tasks.
Microcontroller are widely used in Embedded System products. An Embedded product uses the
microprocessor(or microcontroller) to do one task & one task only. A printer is an example of
Embedded system since the processor inside it perform one task only namely getting the data and
printing it. Contrast this with Pentium based PC. A PC can be used for any no. of applications such
as word processor, print server, bank teller terminal, video game player, network server or internet
terminal. Software for variety of applications can be loaded and run. Of course the reason a PC can
perform multiple task is that it has RAM memory and an operating system that loads the application
software into RAM & lets the CPU run it. In and Embedded system there is only one application
software that is typically burn into ROM.
One of the most critical needs of the embedded system is to decrease power consumptions and space.
This can be achieved by integrating more functions into the CPU chips. All the embedded processors
have low power consumptions in additions to some forms of I/O,Serial Com port & ROM all on a
single chip. In higher performance Embedded system the trend is to integrate more & more function
on the CPU chip & let the designer decide which feature he/she wants to use.
Page | 1
-
7/31/2019 Report of Device Controlchngd
2/57
-
7/31/2019 Report of Device Controlchngd
3/57
2. LIST OF COMPONENTS USED
Printed Circuit Board
Microcontroller AT89S52
LCD
IN4007 diodes(4)
Step down transformer(12-0 V)
LEDs(2)
7805 Voltage Regulator
Crystal Oscillator - 11.0592MHz.
Capacitor - 33 uF (2), 10 uf (2), 1000 uf (1).
Resistor -470 ohm(6) ,10 kohm(2)
ON/OFF Switch.
Transistor- BC369 PNP.
Optocoupler 4N35(4)
RELAYS(4)
Ribbon Wire.
1738 TSOP
Remote
Soldering Material ( soldering iron,wire& stand)
Cutter
Cardboard
Page | 3
-
7/31/2019 Report of Device Controlchngd
4/57
3. TOOLS REQUIRED
KEIL MICROVISION3.0(COMPILER)
PCB WIZARD SOFTWARE
WINDOWS 7
SUPPLY
DIGITAL CAMERA
Page | 4
-
7/31/2019 Report of Device Controlchngd
5/57
4. PCB designing
A printed circuit board, or pcb is used to mechanically support and electrically connect electronics
componints using conductive paths ,tracks or signal traces etched from copper sheets laminated onto
a non-conductive substrate. It is also referred to as printed wiring board (PWB) or etched wiring
board. Printed circuit boards are used in virtually all but the simplest commercially produced
electronic devices.
A PCB populated with electronic components is called a printed circuit assembly (PCA), printed
circuit board assembly or PCB Assembly (PCBA).
Fig2.1.PCB Layout
Page | 5
http://en.wikipedia.org/wiki/Laminatedhttp://en.wikipedia.org/wiki/Substrate_(electronics)http://en.wikipedia.org/wiki/Laminatedhttp://en.wikipedia.org/wiki/Substrate_(electronics) -
7/31/2019 Report of Device Controlchngd
6/57
5REGULATED POWER SUPPLY
Power supplies are designed to convert high voltage AC mains to a suitable low voltage supply
for electronic circuits and other devices. A power supply can be broken down into a series of
blocks, each of which performs a particular function.
For example a 5V regulated supply:
Fig3.1.Block Diagram of Regulated Power Supply
Fig3.2.Power supply
Each of the blocks has its own function as described below
1. T ra ns f o r m er steps down high voltage AC mains to low voltage AC.
2. Rec ti f i er converts AC to DC, but the DC output is varying.
3. S m oo th i n g smoothes the DC from varying greatly to a small ripple.
4. Re g u la to r eliminates ripple by setting DC output to a fixed voltage.
5.1 TRANSFORMER
Page | 6
-
7/31/2019 Report of Device Controlchngd
7/57
Transformers convert AC electricity from one voltage to another with little loss of power.
Transformers work only with AC and this is one of the reasons why mains electricity is AC. The
two types of transformers
Step-up transformers increase voltage,
Step-down transformers reduce voltage.
Page | 7
-
7/31/2019 Report of Device Controlchngd
8/57
Most power supplies use a step-down transformer to reduce the dangerously high mainsvoltage to a safer low voltage. The input coil is called the primary and the output coil is
called the secondary. There is no electrical connection between the two coils,instead yjey are linked
by an alternaying magnetic field created in soft-iron core of the transformer. The two lines in the
middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in. Note
that as voltage is stepped down current is stepped up. The ratio of the number of turns on each
coil, called the turn ratio, determines the ratio of the voltages. A step-down transformer haslarge
number of turns on its primary (input) coil which is connected to the high voltage mains
supply, and a small number of turns on its secondary (output) coil to give a low output voltage.
Turns Ratio =
=
And Power Out = Power In
Where
Vs Is = Vp Ip
Vp = primary (input) voltage
Np = number of turns on primary coil
Ip = primary (input) current
Ns = number of turns on secondary coil
Page | 8
-
7/31/2019 Report of Device Controlchngd
9/57
Is = secondary (output) currenVs = secondary (output) voltage
Page | 9
-
7/31/2019 Report of Device Controlchngd
10/57
5.2 Bridge Rectifier
A bridge rectifier can be made using four individual diodes, but it is also available in special
packages containing the four diodes required.It is called a full-wave rectifier because it uses all
AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because
each diode uses 0.7V when conducting and there are always two diodes conducting, as shown in
the diagram below. Bridge rectifiers are rated by the maximum current they can pass and the
maximum reverse voltage they can withstand (this must be at least three times the supply
RMS voltage so the rectifier can withstand the peak voltages). In this alternate pairs of diodes
conduct, changing over the connections so the alternating directions of AC are converted to the one
direction of DC.
Fig3.3.Output Full-wave varying DC
5.3 SMOOTHING
Smoothing is performed by a large value e le c tr ol y ti c c a p a c ito r connected across the DC supply
to act as a reservoir, supplying current to the output when the varying DC voltagevarying DC
voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC
(dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the peak of
the varying DC, and then discharges as it supplies current to the output.
-
7/31/2019 Report of Device Controlchngd
11/57
Fig3.4.Smoothing circuit and waveform
Note that smoothing significantly increases the average DC voltage to almost the peak value
(1.4 RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS
(1.4V is lost in the bridge rectifier), with smoothing this increases to almost the peak value
giving 1.4 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small
ripple voltage.For many circuits a ripple which is 10% of the supply voltage is satisfactory and
the equation below gives the required value for the smoothing capacitor. A larger capacitor will
give fewer ripples. The capacitor value must be doubled when smoothing half-wave DC.
Smoothing capacitor for 10% ripple, C = 5 Io / Vs f
WhereC = smoothing capacitance in farads (F)
Io = output current from the supply in amps (A)
Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC
f = frequency of the AC supply in hertz (Hz)
-
7/31/2019 Report of Device Controlchngd
12/57
5.4 REGULATOR
Fig3.5.RegulatorVoltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output
voltages. They are also rated by the maximum current they can pass. Negative voltage
regulators are available, mainly for use in dual supplies. Most regulators include some
automatic protection from excessive current (overload protection') and overheating (thermal
protection'). Many of the fixed voltage regulator ICs has 3 leads and look like power
transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for
attaching a heat sink if necessary.
-
7/31/2019 Report of Device Controlchngd
13/57
5.5 Working of Power Supply
Transformer
Fig3.6.Transformer and its Waveform
The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for
electronic circuits unless they include a rectifier and a smoothing capacitor.
Transformer + Rectifier
Fig3.7.Transformer with rectifier and their waveform
The varying DC output it is not suitable for electronic circuits unless they include a smoothing
capacitor.
-
7/31/2019 Report of Device Controlchngd
14/57
Transformer + Rectifier + Smoothing
Fig3.8.Transformer with rectifier and smoothing and their waveform
The smooth DC output has a small ripple. It is suitable for most electronic circuits.
Transformer + Rectifier + Smoothing + Regulator
Fig3.9.Transformer with rectifier ,smoothing and regulator circuit with their
waveform
The regulated DC output is very smooth with no ripple. It is suitable for all electronic circuits.
-
7/31/2019 Report of Device Controlchngd
15/57
6. MICROCONTROLLER 8051/52
In our day to day life the role of micro-controllers has been immense. They are used in a variety
of applications ranging from home appliances, FAX machines, Video games, Camera, Exerciseequipment, Cellular phones musical Instruments to Computers, engine control, aeronautics,
security systems and the list goes on.
6.1 Microcontroller versus Microprocessors
What is the difference between a microprocessor and microcontroller? The microprocessors
(such as 8086, 80286, 68000 etc.) contain no RAM, no ROM and no I/O ports on the chip itself.
For this reason they are referred as general- purpose microprocessors. A system designer using
general- purpose microprocessor must add external RAM, ROM, I/O ports and timers to make
them functional. Although the addition of external RAM, ROM, and I/O ports make the system
bulkier and much more expensive, they have the advantage of versatility such that the designer
can decide on the amount of RAM, ROM and I/o ports needed to fit the task at hand. This is
the not the case with microcontrollers. A microcontroller has a CPU (a microprocessor) in
addition to the fixed amount of RAM, ROM, I/O ports, and timers are all embedded together on
the chip: therefore, the designer cannot add any external memory, I/O, or timer to it. The fixed
amount of on chip RAM, ROM, and number of I/O ports in microcontrollers make them ideal for
many applications in which cost and space are critical. In many applications, for example a
TV remote control, there is no need for the computing power of a 486 or even a 8086
microprocessor. In many applications, the space it takes, the power it consumes, and the price
per unit are much more critical considerations than the computing power. These applications
most often require some I/O operations to read signals and turn on and off
certainbits. It is interesting to know that somemicrocontrollers manufactures have gone as far as integrating an ADC and other peripherals
into the microcontrollers.
-
7/31/2019 Report of Device Controlchngd
16/57
6.2 A brief history of 8051 Family
In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051. This
microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port,
and four ports (8-bit) all on a single chip. The 8051 is an 8- bit processor, meaning the
the CPU can work on only 8 bit . The 8051 has a total of four I/O ports, each 8- bit wide.
Although 8051 can have a maximum of 64K bytes of on-chip ROM, many manufacturers put only
4K bytes on the chip.
The 8051 became widely popular after Intel allowed other manufacturers to make any flavor of
the 8051 they please with the condition that they remain code compatible with the 8051. This
has led to many versions of the 8051 with different speeds and amount of on-chip ROM
marketed by more than half a dozen manufacturers. It is important to know that although
there are different flavors of the 8051, they are all compatible with the original 8051 as far as
the instructions are concerned. This means that if you write your program for one, it will run on
any one of them regardless of the manufacturer. The major 8051 manufacturers are Intel, Atmel,
Dallas Semiconductors, Philips Corporation, Infineon.
6.3 8051 microcontroller
The 8051 is the original member of the 8051 family. Intel refers to it as MCS-51.
Other members of the 8051 family
There are two other members in the 8051 family of microcontrollers. They are the
8052 and the 8031.
-
7/31/2019 Report of Device Controlchngd
17/57
AT89C51 from ATMEL Corporation:
This popular 8051 chip has on-chip ROM in the form of flash memory. This is ideal for fast
development since flash memory can be erased in seconds compared to twenty minutes or more
needed for the earlier versions of the 8051. To use the AT89C51 to develop a microcontroller-
based system requires a ROM burner that supports flash memory: However, a ROM eraser is not
needed. Notice that in flash memory you must erase the entire contents of ROM in order to
program it again. The PROM burner does this erasing of flash itself and this is why a separate
burner is not needed. To eliminate the need for a PROM burner Atmel is working on a version
of the AT89C51 that can be programmed by the serial COM port of the PC.
Fig3.10. Atmel Microcontroller AT89C51
Hardware features
40 pin IC
4 Kbytes of Flash
128 Bytes of RAM
32 I/O lines
Two16-Bit Timer/Counters
Two-Level Interrupt Architecture
Full Duplex Serial Port
On Chip Oscillator and Clock Circuitry
Software features
-
7/31/2019 Report of Device Controlchngd
18/57
Bit Manipulations
Single Instruction Manipulation
Separate Program And Data Memory
4 Bank Of Temporary Registers
Direct, Indirect, Register and Relative Addressing.
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.
The Atmel Flash devices are ideal for developing, since they can be reprogrammed easy and fast.
If we need more code space for our application, particularly for developing 89Cxx projects
with C language. Atmel offers a broad range of microcontrollers based on the 8051
architecture, with on-chip Flash program memory.
-
7/31/2019 Report of Device Controlchngd
19/57
.
Fig3.11.Internal Architecture of AT89C51
-
7/31/2019 Report of Device Controlchngd
20/57
6.4 Pin description
The 89C51 have a total of 40 pins that are dedicated for various functions such as I/O, RD, WR,
address and interrupts. Out of 40 pins, a total of 32 pins are set aside for the four ports P0, P1, P2,
and P3, where each port takes 8 pins. The rest of the
pins are designated as Vcc, GND, XTAL1, XTAL, RST, EA, and PSEN. All these pins except
PSEN and ALE are used by all members of the 8051 and 8031 families. In other words,
they must be connected in order for the system to work, regardless of whether the
microcontroller is of the 8051 or the 8031 family. The other two pins, PSEN and ALE are used
mainly in 8031 based systems.
Fig3.12.MC 8051Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
-
7/31/2019 Report of Device Controlchngd
21/57
GND
Pin 20 is the ground.
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator, as shown in Figure. 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.
Fig3.13.OscillatorConnections
It must be noted that there are various speeds of the 8051 family. Speed refers to the maximum
oscillator frequency connected to the XTAL. For example, a 12 sMHz chip must be
connected to a crystal with 12 MHz frequency or less. Likewise, a 20 MHz microcontroller
requires a crystal frequency of no more than 20 MHZ. When the 8051 is connected to a crystal
oscillator and is powered up, we can observe the frequency on the XTAL2 pin using oscilloscope.
RST
Pin 9 is the reset pin. It is an input and is active high (normally low). Upon applying a high
-
7/31/2019 Report of Device Controlchngd
22/57
pulse to this pin, the microcontroller will reset and terminate all activities. This is often
referred to as a power on reset. Activating a power-on reset will cause all values in the
registers to be lost. Notice that the value of Program Counter is 0000 upon reset, forcing the
CPU to fetch the first code from ROM memory location 0000. This means that we must place the
first line of source code in ROM location 0000 that is where the CPU wakes up and expects to
find the first instruction. In order to RESET input to be effective, it must have a minimum
duration of 2 machine cycles. In other words, the high pulse must be high for a minimum of 2
machine cycles before it is allowed to go low.
EA
All the 8051 family members come with on-chip ROM to store programs. In such cases, the EA
pin is connected to the Vcc. For family members such as 8031 and
8032 in which there is no on-chip ROM, code is stored on an external ROM and is
fetched by the 8031/32. Therefore for the 8031 the EA pin must be connected to ground to
indicate that the code is stored externally. EA, which stands for external access, is pin number
31 in the DIP packages. It is input pin and must be connected to either Vcc or GND. In
other words, it cannot be left unconnected.
PSEN
This is an output pin. PSEN stands for program store enable. It is the read strobe to external
program memory. When the microcontroller is executing from external memory, PSEN is
activated twice each machine cycle.
ALE
ALE (Address latch enable) is an output pin and is active high. When connecting a microcontroller
to external memory, port 0 provides both address and data. In other words the microcontroller
multiplexes address and data through port 0 to save pins. The ALE pin is used for de-multiplexing
-
7/31/2019 Report of Device Controlchngd
23/57
the address and data by connecting to the G pin of the 74LS373 chip.
I/O port pins and their functions
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 output, ready to be used as output ports. To use any of these as input
port, it must be programmed.
Port 0
Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for input or output. To use the
pins of port 0 as both input and output ports, each pin must be connected externally to a
10K-ohm pull-up resistor. This is due to fact that port 0 is an open drain, unlike P1, P2 and P3.
With external pull-up resistors connected upon reset, port 0 is configured as output port. In
order to make port 0 an input port, the port must be programmed by writing 1 to all the bits of
it. Port 0 is also designated as AD0-AD7, allowing it to be used for both data and address.
When connecting a microcontroller to an external memory, port 0 provides both address and
data. The microcontroller multiplexes address and data through port 0 to save pins. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0- D7, but when ALE=1 ithas address A0-A7. Therefore, ALE is used for de- multiplexing address and data with the
help of latch 74LS373.
Port 1
Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used as input or output. In contrast to
port 0, this port does not require pull-up resistors since it has already pull-up resistors
internally. Upon reset, port 1 is configures as an output port. Similar to port 0, port 1 can be
used as an input port by writing 1 to all its bits.
Port 2
Port 2 occupies a total of 8 pins (pins 21 to 28). It can be used as input or output. Just like P1,
-
7/31/2019 Report of Device Controlchngd
24/57
-
7/31/2019 Report of Device Controlchngd
25/57
6.5 Memory Space Allocation
Internal ROM
The 89C51 has 4K bytes of on-chip ROM. This 4K bytes ROM memory has memory
addresses of 0000 to 0FFFh. Program addresses higher than 0FFFh, which exceed the internal
ROM capacity, will cause the microcontroller to automatically fetch code bytes from external
memory. Code bytes can also be fetched exclusively from an external memory, addresses 0000h
to FFFFh, by connecting the external access pin to ground. The program counter doesnt care
where the code is: the circuit designer decides whether the code is found totally in internal
ROM, totally in external ROM or in a combination of internal and external ROM.
Internal RAM
The 128 bytes of RAM inside the 8051 are assigned addresses 00 to 7Fh. These
128 bytes can be divided into three different groups as follows:
1. A total of 32 bytes from locations 00 to 1Fh are set aside for register banks and the
stack.2. A total of 16 bytes from locations 20h to 2Fh are set aside for bit addressable
read/write memory and instructions.
A total of 80 bytes from locations 30h to 7Fh are used for read and write storage, or what is
normally called a scratch pad. These 80 locations of RAM are widely used for the purpose of
storing data and parameters by 8051 programmers.
-
7/31/2019 Report of Device Controlchngd
26/57
7. LIQUID CRYSTAL DISPLAY
Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs. This is
due to the declining prices of LCD, the ability to display numbers, characters and graphics,
incorporation of a refreshing controller into the LCD, their by relieving the CPU of the task of
refreshing the LCD and also the ease of programming for characters and graphics. HD
44780 based LCDs are most commonly used.The LCD, which is used as a display in the system, is LMB162A. The main features of this
LCD are: 16 X 2 display, intelligent LCD, used for alphanumeric characters & based on ASCII
codes. This LCD contains 16 pins, in which 8 pins are used as 8-bit data I/O, which are
extended ASCII. Three pins are used as control lines these are Read/Write pin, Enable pin and
Register select pin. Two pins are used for Backlight and LCD voltage, another two pins are for
Backlight & LCD ground and one pin is used for contrast change.
Table3.3.LCDpin
description
Pin Symbol I/O Description
1 VSS - Ground
2 VCC - +5V power supply
3 VEE - Power supply to control contrast
4 RS I RS=0 to select command register, RS=1 to select data
5 R/W I R/W=0 for write, R/W=1 for read
6 E I/O Enable
7 DB0 I/O The 8 bit data bus
-
7/31/2019 Report of Device Controlchngd
27/57
1
8 DB1 I/O The 8 bit data bus
9 DB2 I/O The 8 bit data bus
10 DB3 I/O The 8 bit data bus
11 DB4 I/O The 8 bit data bus
12 DB5 I/O The 8 bit data bus
13 DB6 I/O The 8 bit data bus
14 DB7 I/O The 8 bit data bus
The LCD discuss in this section has the most common connector used for the Hitachi 44780
based LCD is 14 pins in a row and modes of operation and how to program and interface with
microcontroller is describes in this section.
VCC, VSS, VEE
The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for
controlling LCD contrast. Variable voltage between Ground and Vcc is used
to specify the contrast (or "darkness") of the characters on the LCD screen.
RS (register select)
There are two important registers inside the LCD. The RS pin is used for their selection as
follows. If RS=0, the instruction command code register is selected, then allowing to user to
send a command such as clear display, cursor at home etc.. If RS=1, the data register is selected,
allowing the user to send data to be displayed on the LCD.
R/W (read/write)
-
7/31/2019 Report of Device Controlchngd
28/57
The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and
R/W=0, when it writing.
EN (enable)
The enable pin is used by the LCD to latch information presented to its data pins. When data is
supplied to data pins, a high power, a high-to-low pulse must be applied to this pin in order to
for the LCD to latch in the data presented at the data pins.
D0-D7 (data lines)
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of
the LCDs internal registers. To displays the letters and numbers, we send ASCII codes for the
letters A-Z, a-z, and numbers 0-9 to these pins while making RS =1. There are also command
codes that can be sent to clear the display or force the cursor to the home position or blink the
cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the
information. The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W
=1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking care of internal operation and
will not accept any information, when D7=0 the LCD is ready to receive new information
-
7/31/2019 Report of Device Controlchngd
29/57
7.2 Interfacing of micro controller with LCD display
In most applications, the "R/W" line is grounded. This simplifies the application because when
data is read back, the microcontroller I/O pins have to be alternated between input and output
modes.
In this case, "R/W" to ground and just wait the maximum amount of time for each instruction
(4.1ms for clearing the display or moving the cursor/display to the "home position", 160s for
all other commands) and also the application software is simpler, it also frees up a
microcontroller pin for other uses. Different LCD execute instructions at different rates and to
avoid problems later on (such as if the LCD is changed to a slower unit). Before sending
commands or data to the LCD module, the Module must be initialized. Once the initialization is
complete, the LCD can be written to with data or instructions as required. Each character to
display is written like the control bytes, except that the "RS" line is set. During initialization, by
setting the "S/C" bit during the "Move Cursor/Shift Display" command, after each character is
sent to the LCD, the cursor built into the LCD will increment to the next position (either right
or left). Normally, the "S/C" bit is set (equal to "1")
Table 3.4.LCD Command Code
Commands and Instruction set
-
7/31/2019 Report of Device Controlchngd
30/57
Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by the
MCU. Before starting the internal operation of the LCD, control information is temporarily
stored into these registers to allow interfacing with various MCUs, which operate at different
speeds, or various peripheral control devices. The internal operation of the LCD is determined
by signals sent from the MCU.
Sending Commands to LCD
To send commands we simply need to select the command register. Everything is same as we
have done in the initialization routine. But we will summarize the common steps and put them in
a single subroutine.
Following are the steps:
1. Move data to LCD port
2. Select command register
3. Select write operation
4. Send enable signal5. Wait for LCD to process the command
Fig 3.14.LCD INTERFACING WITH MICROCONTROLLER
-
7/31/2019 Report of Device Controlchngd
31/57
Fig3.15.ircuit diagram of LCD interfacing
-
7/31/2019 Report of Device Controlchngd
32/57
8. Relay Driver using Optocoupler (Auto Electro Switching)
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 most have double throw (changeover) switch contacts as
shown in the diagram.
Fig3.16.Relay Driver
The relay's switch connections are usually labelled COM, NC and NO:
COM = Common, always connect to the moving part of the switch.
NC = Normally Closed, COM is connected to this when the relay coil is off.NO = Normally Open, COM is connected to this when the relay coil is on.
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.
Fig3.17.Relay Devices
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
32 | P a g e
-
7/31/2019 Report of Device Controlchngd
33/57
this current and a transistor is usually used to amplify the small IC current to the larger value required
for the relay coil.
33 | P a g e
-
7/31/2019 Report of Device Controlchngd
34/57
8.1 Pole and Throw
Since relays are switches, the terminology applied to switches is also applied to relays. A relay will
switch one or more poles, each of whose contacts can be thrown by energizing the coil in one of
three ways:
Normally-open (NO) contacts connect the circuit when the relay is activated; the circuit isdisconnected when the relay is inactive. It is also called a Form A contact or make contact.
Normally-closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is
connected when the relay is inactive. It is also called a Form B contact or break contact.
Change-over(CO), or double-throw (DT), contacts control two circuits: one normally-open contact
and one normally-closed contact with a common terminal. It is also called a Form C contact or
transfer contact (break before make). If this type of contact utilizes make before break
functionality, then it is called a Form D contact.
The following designations are commonly encountered:
SPST Single Pole Single Throw. These have two terminals which can be connected or
disconnected. Including two for the coil, such a relay has four terminals in total. It is ambiguous
whether the pole is normally open or normally closed. The terminology SPNO and SPNC is
sometimes used to resolve the ambiguity.
SPDT Single Pole Double Throw. A common terminal connects to either of two others. Including
two for the coil, such a relay has five terminals in total.
Fig3.18.Designations
34 | P a g e
-
7/31/2019 Report of Device Controlchngd
35/57
DPST Double Pole Single Throw. These have two pairs of terminals. Equivalent to two SPST
switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals
in total. The poles may be Form A or Form B (or one of each).
DPDT Double Pole Double Throw. These have two rows of change-over terminals. Equivalent to
two SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the
coil.
The "S" or "D" may be replaced with a number, indicating multiple switches connected to a single
actuator. For example 4PDT indicates a four pole double throw relay (with 14 terminals)
8.2 Choosing a relay
You need to consider several features when choosing a relay:
1. Physical size and pin arrangement
If you are choosing a relay for an existing PCB you will need to ensure that its dimensions and pin
arrangement are suitable. You should find this information in the supplier's catalogue.
2. Coil voltage
The relay's coil voltage rating and resistance must suit the circuit powering the relay coil. Many
relays have a coil rated for a 12V supply but 5V and 24V relays are also readily available. Some
relays operate perfectly well with a supply voltage which is a little lower than their rated value.
3. Coil resistance
The circuit must be able to supply the current required by the relay coil. You can use Ohm's law
to calculate the current:
35 | P a g e
-
7/31/2019 Report of Device Controlchngd
36/57
RELAY COIL CURRENT= SUPPLY VOLTAGE / COIL RESISTANCE
For example: A 12V supply relay with a coil resistance of 400 passes a current of 30mA. This is OK
for a 555 timer IC (maximum output current 200mA), but it is too much for most ICs and they will
require a transistor to amplify the current.
4. Switch ratings (voltage and current)
The relay's switch contacts must be suitable for the circuit they are to control. You will need to check
the voltage and current ratings. Note that the voltage rating is usually higher for AC, for example: "5A
at 24V DC or 125V AC".
5. Switch contact arrangement (SPDT, DPDT etc)
Most relays are SPDT or DPDT which are often described as "single pole changeover" (SPCO) or "doubl
pole changeover" (DPCO).
Protection diodes for relays
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.
Current flowing through a relay coil creates a magnetic field which collapses suddenly when the
current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across
the relay coil which is very likely to damage transistors and ICs. The protection diode allows the
induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away
quickly rather than instantly. This prevents the induced voltage becoming high enough to cause
damage to transistors and ICs
36 | P a g e
-
7/31/2019 Report of Device Controlchngd
37/57
.
Fig3.19.Protection Diodes
8.3 Relay and transistor comparison as switch
Like relays, transistors can be used as an electrically operated switch. For switching small DC currents
(< 1A) at low voltage they are usually a better choice than a relay. However, transistors cannot switch
AC (such as mains electricity) and in simple circuits they are not usually a good choice for switching
large currents (> 5A). In these cases a relay will be needed, but note that a low power transistor may
still be needed to switch the current for the relay's coil. The main advantages and disadvantages of
relays are listed below:
Advantages of relays:
Relays can switch AC and DC, transistors can only switch DC.
Relays can switch higher voltages than standard transistors.
Relays are often a better choice for switching large currents (> 5A).
Relays can switch many contacts at once.
Disadvantages of relays:
Relays are bulkier than transistors for switching small currents.
Relays cannot switch rapidly (except reed relays), transistors can switch many times per second.
Relays use more power due to the current flowing through their coil.
Relays require more current than many ICs can provide, so a low power transistor may be needed
to switch the current for the relay's coil.
37 | P a g e
-
7/31/2019 Report of Device Controlchngd
38/57
8.4 Relay Driver
For its interfacing with microcontrollers or other low current digital ICs, a power or current amplifier
circuit is required, known as relay driver circuits. Mainly two such driver circuits i.e. ULN2003 and
transistor/optocouplers are often used. An Auto Electro Switching/Relay Driver circuit comprises of
an optocoupler which will isolate the controller from the outer spikes or fluctuations or from theexternal hardware and at the same time it drives a power transistor i.e. make it on when a signal from
the controller pin is applied to it. Optocoupler actually comprises of a diode and a phototransistor. It
comes in a DIP IC package. Thus signal from the MCU is given to the LED part or the driving part.
When LED begins to glow then the phototransistor acts as on switch or short circuit. This output is
given to power transistor, which will amplify the current of the signal and then can be used to drive a
relay. The I/P signal is connected to the Relays common terminal and the O/P can be taken from
the relays NO terminal. When relay is ON then NO is connected to the common terminal of the
relay.
Fig3.20.Block diagram of Relay driver
Optocoupler
It has one IR LED and a photo- transistor. One pin of the LED is connected to the MCU to get a signal
38 | P a g e
-
7/31/2019 Report of Device Controlchngd
39/57
(0 or 1) and the pin is given ground. When the signal from the MCU is 0, then LED emits light. This
light will turn on the NPN transistor. Emitter of the transistor is grounded. Collector is connected to
the PNP transistor whose emitter is connected to Vcc and collector to the relay.
The purpose of using the optocouplers is to pass the supply from the PC/MCU to the appliances & is
for isolation of the port of the PC/MCU from an external hardware. The voltage signal from the
PC/MCU is being converted into light by the LED and then further converted into voltage by thephototransistor. This ensures that there is no physical connection between the PC and the appliances.
The signal from the PC/MCU is coupled only through light so that if in any case
the external hardware ( in this case :appliances) produces an error voltage it will not be passed over to
the port of the PC/MCU and will not damage the internal circuitry of the PC/MCU.
Fig3.21.Optocoupler (4N35) Pin Diagram
Table3.5Pin description
Pin no.
Function
1 Anode
2 Cathode
3 NC
4 Emitter5 Collector
6 Base
The 4N35 optoisolators consist of a gallium arsenide infrared emitting diode driving a silico
phototransistor in a 6-pin dual in-line package. There is no electrical connection between the two, just
39 | P a g e
-
7/31/2019 Report of Device Controlchngd
40/57
beam of light. The light emitter is nearly always an LED. The light sensitive device may be a photodiode
phototransistor, or more esoteric devices such as thyristors, triacs etc. To carry a signal across the isolatio
barrier, optocouplers are operated in linear mode.
Pin Description of 4N35
The IC package may also be called an IC or a chip. It is important to note that each type ofoptocoupler may use different pin assignments. For carrying a linear signal across isolation barrier
there are two types of optocouplers. Both types use an infrared light emitting diode (LED) to generate
and send a light signal across an isolation barrier. The difference is in the detection method. Some
optocouplers use a phototransistor detector while others use a photodiode detector which drives the
base of a transistor. The phototransistor detector uses the transistors collector base junction to detect
the light signal. This necessitates that the base area be relatively large compared to a standard
transistor. The result is a large collector to base capacitance which slows the collector rise time and
limits the effective frequency response of the device. In addition the amplified photocurrent flows in
the collector base junction and modulates the response of the transistor to the photons. This causes the
transistor to behave in a non-linear manner. Typical phototransistor gains range from 100 to 1000. The
photodiode/transistor detector combination on the other hand uses a diode to detect the photons and
convert them to a current to drive the transistor base. The transistor no longer has a large base area.
The response of this pair is not affected by amplified photocurrent and the photodiode capacitance
does not impair speed.
Optocoupler Operation
Optocouplers are good devices for conveying analog information across a power supply isolation
barrier, they operate over a wide temperature range and are often safety agency approved they do,
however, have many unique operating considerations.
Optocouplers are current input and current output devices. The input LED is excited by changes in
drive current and maintains a relatively constant forward voltage. The output is a current which is
proportional to the input current. The output current can easily be converted to a voltage through a
pull-up or load resistor.
Applications
AC mains detection
40 | P a g e
-
7/31/2019 Report of Device Controlchngd
41/57
Reed relay driving
Switch mode power supply feedback
Telephone ring detection
Logic ground isolation
Logic coupling with high frequency noise rejection.
Features
Interfaces with common logic families
Input-output coupling capacitance < 0.5 pF
Industry Standard Dual-in line 6-pin package
5300 VRMS isolation test voltage
Lead-free component
Transistor
A transistor is a semiconductor device used to amplify and switch electronic signals and power. It is
composed of a semiconductor material with at least three terminals for connection to an external
circuit. A voltage or current applied to one pair of the transistor's terminals changes the current
flowing through another pair of terminals. Because the controlled (output) power can be higher than
the controlling (input) power, a transistor can amplify a signal.
Transistor as a Current Amplifier
41 | P a g e
-
7/31/2019 Report of Device Controlchngd
42/57
A PNP transistor can be used as a current amplifier for driving the relay. Since approx 500-1000mA
current can be passed from emitter to collector in PNP transistor with a little base current (approx 1-
2mA).
Fig3.22.Transistor as a current amplifier
Here a circuit shows interfacing of relay with PNP transistor. Here Vin signal is given to transistor from
microcontroller or other low current digital devices. By using this driver circuit a relay can be derived from
microcontroller, but has a drawback i.e. whenever the relay gets off a back spike is generated in the base o
transistor which can harm the controller or other digital devices. This problem can be solved by using an
optocoupler between controller and transistor's base as shown:
42 | P a g e
-
7/31/2019 Report of Device Controlchngd
43/57
Fig3.23.Use of Optocoupler in current amplifier
In this circuit the MCU is connected to transistor through optocoupler, means there is an optical
connected between microcontroller and transistor not any physical connection, so the spike generated
by the transistor wouldn't be reach controller, so by using this circuit we've isolated the controller
from Power transistor. The PNP Power transistor used here is BC369.
Power Transistor (BC 369)
High current gain
High collector current
Low collector-emitter saturation voltage
Complementary type: BC 368 (NPN)
Fig3.24.Power Transistor BC369
Terminal 1: Emitter
Terminal 2: Collector
Terminal3: Base
43 | P a g e
-
7/31/2019 Report of Device Controlchngd
44/57
9. TSOP 1738
The TSOP 17XX series are miniaturized receivers for infrared remote control systems. PIN diode
and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. Thedemodulated output signal can directly be decoded by a microprocessor. TSOP 17XX is the standard
IR remote control receiver series, supporting all major transmission codes. Here XX refers to the
frequency of the infrared carrier signal on which the code is modulated, which is 38 KHz in our case.
It has three pins .GND and Vcc are connected to the power supply with VCC as 5V and Vout which
becomes 0V, or GND when the demodulated bit received is high i.e. 5V and vice versa.
Fig3.25.TSOP 1738
Features
44 | P a g e
-
7/31/2019 Report of Device Controlchngd
45/57
_ Photo detector and preamplifier in one package
_ Internal filter for PCM frequency
_ TTL and CMOS compatibility
_ Output active low
_ Low power consumption
_ High immunity against ambient light
_ Continuous data transmission possible (up to 2400 bps)
_ Suitable burst length .10 cycles/burst
_Available for carrier frequencies of 27 kHz up to 62 kHz
_ No external components necessary
_Output microcomputer-compatible
_High sensitivity for large transmitting range (120 ft/ 35 m)
_Maximum interference safety against optical and electrical disturbances
_High quality level ISO 9001
_Automated large-volume production
Typical applications
TV sets
Video recorders
Sat receivers
DVD (Digital Versatile Disk)
Slide projectors
45 | P a g e
-
7/31/2019 Report of Device Controlchngd
46/57
Hi-fi components
Fig3.26.RC5 Code transmission
12 CIRCUIT DIAGRAMS
46 | P a g e
-
7/31/2019 Report of Device Controlchngd
47/57
Fig4.4.Microcontroller with relay driver
47 | P a g e
-
7/31/2019 Report of Device Controlchngd
48/57
R ?
+T ?
T R A N S F O R M E R
1 5
4 8
R ?
D 1
L E D
V o l t a g e R e g u l a t o r 7 8 0 5
Q ?
P N P C B E
R ?
P
C ?
U ?
1 3V I N V O U T
K ?
R E L A Y S P D T
35
412
T s o p 1 7 3 8
Q ?
P N P C B E
U ?
4 N 3 5
1 6
2
5
4
R ?
2 0
D e v i c e
K ?
R E L A Y S P D T
35
412
2 2 0 V A
Y ?
C R Y S T A L
U ?
4 N 3 5
1 6
2
5
4
4 0
K ?
R E L A Y S P D T
35
412
- +
D I O D E B R I D G E
1
2
3
4
U ?
4 N 3 5
1 6
2
5
4
0 - 1 2 V
V C C
D e v i c e 1
Q ?
P N P C B E
N
2
2
0
V
A
C
C ?C A P N P
D e v i c e
U ?
A T 8 9 C 5 2
91 81 9 2 9
3 0
3 1
12345678
2 12 22 32 42 52 62 72 8
1 01 11 21 31 41 51 61 7
3 93 83 73 63 53 43 33 2
R S TX T A L 2X T A L 1 P S E N
A L E / P R O G
E A / V P P
P 1 . 0 / T 2P 1 . 1 / T 2 - E XP 1 . 2P 1 . 3P 1 . 4P 1 . 5P 1 . 6P 1 . 7
P 2 . 0 / A 8P 2 . 1 / A 9
P 2 . 2 / A 1 0P 2 . 3 / A 1 1P 2 . 4 / A 1 2P 2 . 5 / A 1 3P 2 . 6 / A 1 4P 2 . 7 / A 1 5
P 3 . 0 / R X DP 3 . 1 / T X D
P 3 . 2 / I N T OP 3 . 3 / I N T 1
P 3 . 4 / T OP 3 . 5 / T 1
P 3 . 6 / W RP 3 . 7 / R D
P 0 . 0 / A D 0P 0 . 1 / A D 1P 0 . 2 / A D 2P 0 . 3 / A D 3P 0 . 4 / A D 4P 0 . 5 / A D 5P 0 . 6 / A D 6P 0 . 7 / A D 7
-
K ?
R E L A Y S P D T
35
412
R e c . S e c t i
D e v i c e
O u t p u t 5 V D C
Q ?
P N P C B E
U ?
4 N 3 5
1 6
2
5
4
R 1R
Fig4.5. Microcontroller with TSOP and relay driver
48 | P a g e
-
7/31/2019 Report of Device Controlchngd
49/57
13. C CODE FOR PROJECT
#define f40k 1
#define DATA P1
#define RS P35
#define RW P36
#define E P37
#include
#define IRDet P32 //IR serial input stream
sbit IRLED = P3^3;//LED will blink on valid IR code
#define CH1 P20
#define CH2 P21
#define CH3 P22
#define CH4 P23
#define CH5 P24
#define CH6 P25
#define CH7 P26
#define CH8 P27
#define TRUE 1
#define FALSE 0
unsigned char RC5RxAddress, RC5RxCommand; // Last command received on RC5bit RC5Avail=FALSE; // And if the data are new...
unsigned char Repeating;
49 | P a g e
-
7/31/2019 Report of Device Controlchngd
50/57
TR0=TRUE; // Start timer 1
IRLED = 0;
IE0=0; // Clear any pending int's
EX0=TRUE; // Prepare for another startbit...
void main(void)
{
lcd_initialize();
P2=0xff;
ACC=0x83;
lcd_cmd();
lcd_display("IR REMOTE ",12);
ACC=0xC4;
lcd_cmd();
lcd_display("Control ",12);
secdelay(3);
ACC=0x80;
lcd_cmd();
lcd_display("RECEIVING...... ",12);
50 | P a g e
-
7/31/2019 Report of Device Controlchngd
51/57
ACC=0xC0;
lcd_cmd();
lcd_display("DEVICE CODE ",12);
EX0 = 1; // Enable EX0 Interrupt
EA = 1; // Enable Global Interrupt Flag
CH1 = 0; // Initial state, this output is low
P2=0xff;
while (1)
{
if(RC5Avail) {
RC5Avail = FALSE; // reset the variable for next check
switch(RC5RxCommand) {
case 0x01:
{
CH1 = ~CH1; // toggle the output
ACC='1';
lcd_datawrite();
}
break;
case 0x02:
{
CH2 = ~CH2;
ACC='2';
lcd_datawrite();
51 | P a g e
-
7/31/2019 Report of Device Controlchngd
52/57
}
break;
case 0x03:
{
CH3 = ~CH3;
ACC='3';lcd_datawrite();
}
break;
case 0x04:
{
CH4 = ~CH4;
ACC='4';
lcd_datawrite();
}
break;
case 0x05:
{
CH5 = ~CH5;
ACC='5';
lcd_datawrite();
}
break;
case 0x06:
{
CH6 = ~CH6;
ACC='6';
lcd_datawrite();
}
break;
case 0x07:
52 | P a g e
-
7/31/2019 Report of Device Controlchngd
53/57
{
CH7 = ~CH7;
ACC='7';
lcd_datawrite();
}
break;case 0x08:
{
CH8 = ~CH8;
ACC='8';
lcd_datawrite();
}
break;
}
}
}
}
}
53 | P a g e
-
7/31/2019 Report of Device Controlchngd
54/57
14. PROJECT PHOTOGRAPH
54 | P a g e
-
7/31/2019 Report of Device Controlchngd
55/57
55 | P a g e
-
7/31/2019 Report of Device Controlchngd
56/57
. REFERENCES
GOOGLE
www.alldatasheets.com
www.datasheets.com
www.electronicsforyou.com
www.projectguidance.com
8051 microcontroller and embedded systems by Ali Mazidi\
WIKIPEDIA
56 | P a g e
http://www.alldatasheets.com/http://www.datasheets.com/http://www.electronicsforyou.com/http://www.projectguidance.com/http://www.alldatasheets.com/http://www.datasheets.com/http://www.electronicsforyou.com/http://www.projectguidance.com/ -
7/31/2019 Report of Device Controlchngd
57/57
top related