EMBEDDED SYSTEM INDIVIDUAL MODULES 1. Embedded System 2. Microcontroller unit 3. Power Supply 4. Liquid crystal display(LCD) 5. Motor driver 6. Seven segment display 7. Ultrasonic sensor 8. Bluetooth 9. Relay 10. Light emitting diode 11. IR reflector sensor 12. DC motors 13. RFID
56
Embed
d2automation.ind2automation.in/embedded/Embedde System Project Mo… · Web viewProgram status word register is an 8 bit register. ... In automobile alternators and central power
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
EMBEDDED SYSTEM
INDIVIDUAL MODULES
1. Embedded System
2. Microcontroller unit
3. Power Supply
4. Liquid crystal display(LCD)
5. Motor driver
6. Seven segment display
7. Ultrasonic sensor
8. Bluetooth
9. Relay
10. Light emitting diode
11. IR reflector sensor
12. DC motors
13. RFID
1. EMBEDDED SYSTEM
1.1IntroductionMicrocontroller 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. Although microcontroller are preferred choice for many Embedded
systems, There are times that a microcontroller is inadequate for the task. For this reason in
recent years many manufactures of general purpose microprocessors such as INTEL,
Motorolla, AMD & Cyrix have targeted their microprocessors for the high end of Embedded
market.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,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.
1.2Embedded SystemAn Embedded System employs a combination of hardware & software to perform a specific
function. Software is used for providing features and flexibility hardware(Processors,
Memory...) 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
task’s 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 millions
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. In contrast to a general
purpose computer, which can run any software application, the user chooses, the software on
an embedded system is semi-permanent, so it is often called firmware.
1.3 Examples 1) Automated tiller machines (ATMS).
2) Integrated system in aircraft and missile.
3) Cellular telephones and telephonic switches.
4) Computer network equipment, including routers timeservers and firewalls
5) Computer printers, Copiers.
6) Disk drives (floppy disk drive and hard disk drive)
7) Engine controllers and antilock brake controllers for automobiles.
8) Home automation products like thermostat, air conditioners sprinkles and security
monitoring system.
9) House hold appliances including microwave ovens, washing machines, TV sets DVD
players/recorders.
10) Medical equipment.
11) Measurement equipment such as digital storage oscilloscopes, logic analyzers and
spectrum analyzers.
12) Multimedia appliances: internet radio receivers, TV set top boxes.
13) Small hand held computer with P1M5 and other applications.
14) Programmable logic controllers (PLC’s) for industrial automation and monitoring.
15) Stationary video game controllers.
1.4Microprocessor (MPU) A microprocessor is a general-purpose digital computer central processing unit(CPU).
Although popularly known as a “computer on a chip” is in no sense a complete digital
computer. The block diagram of a microprocessor CPU is shown, which contains an
arithmetic and logical unit (ALU), a program counter (PC), a stack pointer (SP),some
working registers, a clock timing circuit, and interrupt circuits.
Figure 1.1: Block Diagram of Microprocessor.
1.5Microcontroller (MCU)Figure shows the block diagram of a typical microcontroller. The design incorporates all of
the features found in micro-processor CPU: ALU, PC, SP, and registers. It also added the
other features needed to make a complete computer: ROM, RAM, parallel I/O, serial I/O,
counters, and clock circuit.
Figure 1.2: Block Diagram of Microcontroller.
1.6 Comparision Between Microprocessor And MicrocontrollerThe microprocessor must have many additional parts to be operational as a computer whereas
microcontroller requires no additional external digital parts.
1) The prime use of microprocessor is to read data, perform extensive calculations on that data
and store them in the mass storage device or display it. The prime functions of
microcontroller is to read data, perform limited calculations on it, control its environment
based on these data. Thus the microprocessor is said to be general-purpose digital
computers whereas the microcontroller are intend to be special purpose digital controller.
2) Microprocessor need many opcodes for moving data from the external memory to the CPU,
microcontroller may require just one or two, also microprocessor may have one or two
types of bit handling instructions whereas microcontrollers have many.
3) Thus microprocessor is concerned with the rapid movement of the code and data from the
external addresses to the chip, microcontroller is concerned with the rapid movement of the
bits within the chip.
4) Lastly, the microprocessor design accomplishes the goal of flexibility in the hardware
configuration by enabling large amounts of memory and I/O that could be connected to the
address and data pins on the IC package. The microcontroller design uses much more
limited.
2. THE 8051 ARCHITECTURE
2.1 IntroductionThe Intel 8051 is an 8-bit microcontroller which means that most available operations are
limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard, and Extended. The
Short and Standard chips are often available in DIP (dual in-line package) form, but the
Extended 8051 models often have a different form factor, and are not "drop-in compatible".
Figure 2.1: Block Diagram of 8051.
All these things are called 8051 because they can all be programmed using 8051 assembly
language, and they all share certain features (although the different models all have their own
special features).Some of the features that have made the 8051 popular are:
4KB on chip program memory.
128 bytes on chip data memory (RAM).
4 register banks.
8-bit data bus.
16-bit address bus.
32 general purpose registers each of 8 bits.
16 bit timers (usually 2, but may have more, or less).
3 Internal and 2 external interrupts.
Bit as well as byte addressable RAM area of 16 bytes.
Four 8-bit ports, (short models have two 8-bit ports).
16-bit program counter and data pointer.
1 Microsecond instruction cycle with 12 MHz Crystal.
8051 models may also have a number of special, model-specific features, such as UARTs,
ADC, OpAmps, etc.
2.2 Typical applications8051 chips are used in a wide variety of control systems, telecom applications, and robotics as
well as in the automotive industry. By some estimation, 8051 family chips make up over 50%
of the embedded chip market. The 8051 has been in use in a wide number of devices, mainly
because it is easy to integrate into a project or build a device around. The following are the
main areas of focus:
2.2.1 Energy Management: Efficient metering systems help in controlling energy usage
in homes and industrial applications. These metering systems are made capable by
incorporating microcontrollers.
2.2.2 Touch screens: A high number of microcontroller providers incorporate touch-
sensing capabilities in their designs. Portable electronics such as cell phones, media
players and gaming devices are examples of microcontroller-based touch screens.
2.2.3 Automobiles: The 8051 finds wide acceptance in providing automobile solutions.
They are widely used in hybrid vehicles to manage engine variants. Additionally,
functions such as cruise control and anti-brake system have been made more
efficient with the use of microcontrollers. So the microcontroller 8051 has great
advantage in the field of the automobiles.
2.2.4 Medical Devices: Portable medical devices such as blood pressure and glucose
monitors use microcontrollers will to display data, thus providing higher reliability
in providing medical results.
2.3 Pin out DescriptionPin 1-8 (Port 1): Each of these pins can be configured as an input or an output.
Pin 9(RST): A logic one on this pin disables the microcontroller and clears the contents of
most registers. In other words, the positive voltage on this pin resets the microcontroller.
Figure 2.2: Pin diagram of the 8051 DIP.
By applying logic zero to this pin, the program starts execution from the beginning. Pin 9 is
the RESET pin. It is an input and is active high. Upon applying a high pulse to this pin the
microcontroller well reset and terminate all activities. This is often referred to as a power on
reset .Activating a power on reset will cause all values the registers to be lost. It will set
program counter to all 0s.In order for the RESET input to be effective it must have a minimum
duration of two machine cycles. In other words the high pulse must be high for a minimum of
two machine cycles before it is allowed to go low.
Pin 10-17(Port 3): Similar to port 1, each of these pins can serve as general input or output.
Besides, all of them have alternative functions:
Pin 10(RXD): Serial asynchronous communication input or Serial synchronous
communication output.
Pin 11(TXD): Serial asynchronous communication output or Serial synchronous
communication clock output.
Pin 12(INT0): Interrupt 0 input.
Pin 13(INT1): Interrupt 1 input.
Pin 14(T0): Counter 0 clock input.
Pin 15(T1): Counter 1 clock input.
Pin 16(WR): Write to external (additional) RAM.
Pin 17(RD): Read from external RAM.
Pin 18, 19(X2, X1): Internal oscillator input and output. The 8051 has an on chip oscillator
but requires an external clock to run it. Most often a quartz crystal oscillator is connected to
inputs XTAL1 (pin 19) and XTAL2 (pin 18). The quartz crystal oscillator connected to
XTAL1 and XTAL2 also needs two capacitors of 30PF value. One side of each capacitor is
connected to the ground. Speed refers to the maximum oscillator frequency connected to
XTAL.
Figure 2.3: Oscillator Circuit and Timing.
Pin 20(GND): Ground.
Pin 21-28(Port 2): If there is no intention to use external memory then these port pins are
configured as general inputs/outputs. In case external memory is used, the higher address byte,
i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is
not used, which means that not all eight port bits are used for its addressing, the rest of them
are not available as inputs/outputs.
Pin 29(PSEN): This is an output pin. PSEN stands for “program store enable”. If external
ROM is used for storing program then a logic zero (0) appears on it every time the
microcontroller reads a byte from memory.
Pin 30(ALE): ALE stands for “address latch enable. It is an output pin and is active high.
When connecting an 8031 to external memory, port 0 provides both address and data. In other
words the 8031 multiplexes address and data through port 0 to save pins. The ALE pin is used
for de-multiplexing the address and data. Prior to reading from external memory, the
microcontroller puts the lower address byte (A0-A7) on P0. In other words, this port is used
for both data and address transmission.
Pin 31(EA): EA which stands for “external access” is pin number 31 in the DIP packages. It
is an input pin and must be connected to either VCC or GND. In other words it cannot be
unconnected. By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that even
there is a program written to the microcontroller, it will not be executed. Instead, the program
written to external ROM will be executed. By applying logic one to the EA pin, the
microcontroller will use both memories, first internal then external (if exists).
Pin 32-39(Port 0): Similar to P2, if external memory is not used, these pins can be used as
general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE
pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0).
Pin 40(VCC):+5V power supply.
2.4 PORTS P0-P3All the ports upon RESET are configured as input, since P0-P3 have value FFH on them. The
following is a summary of features of P0-P3.
2.4.1 PORT 0:
Port 0 is also designated as AD0-AD7 allowing it to be used for both address and data. When
connecting an 8051/31 to an external memory, port 0 provides both address and data. The
8051 multiplexes address and data through port 0 to save pins. ALE indicates if p0 has address
A0-A7.in the 8051 based systems where there is no external memory connection the pins of
P0 must be connected externally to 10k-ohm pull-up resistor. This is due to the fact that P0 is
an open drain, unlike P1, P2 and P3. Open drain is a term used for MOS chips in the same way
that open collector is used for TTL chips. In many systems using the 8751, 89c51 or
DS89c4*0 chips we normally connect P0 to pull up resistors.
2.4.2 PORT 1, PORT 2:
In 8051 based systems with no external memory connection both P1 and P2 are used as simple
I/O. however in 8031/51 based systems with external memory connections P2 must be used
along with P0 to provide the 16-bit address for the external memory. P2 is also designated as
A8-A15 indicating its dual function. Since an 8031/51 is capable of accessing 64k bytes of
external memory it needs a path for the 16 bits of address. While P0 provides the lower 8 bits
via A0-a7 it is the job P2 to provide bits A8-A15 of the address. In other words when the
8031/51 is connected to external memory P2 is used for the upper 8 bits of the 16 bit address
and it cannot be used for I/O.
2.4.3 PORT 3:
Port 3 occupies a total of 8 pins 10 through 17. It can be used as input or output. P3 does not
need any pull-up resistors the same as P1 and P2 did not. Although port 3 is configured as
input port upon reset this is not the way it is most commonly used. Port 3 has the additional
function of providing some extremely important signals such as interrupts.
Port 3 Bit Function Pin
P3.0 RXD 10
P3.1 TXD 11
P3.2 INT0 12
P3.3 INT1 13
P3.4 T0 14
P3.5 T1 15
P3.6 WR 16
P3.7 RD 17
Table 2.1: Port 3 Alternate function
2.5 Programming Model of 8051In programming model of 8051 we have different types of registers are available and these
registers are used to store temporarily data is then the information could be a byte of data to be
processed or an address pointing to the data to be fetched the majority of registers is 8051 are
8-bikt registers.
2.6 Accumulator (Register A)Accumulator is a mathematical register where all the arithmetic and logical operations are
done is this register and after execution of instructions the outpour data is stored in the register
is bit addressable near. We can access any of the single bit of this register.A register is a
general-purpose register used for storing intermediate results obtained during operation. Prior
to executing an instruction upon any number or operand it is necessary to store it in the
accumulator first. All results obtained from arithmetical operations performed by the ALU are
stored in the accumulator. Data to be moved from one register to another must go through the
accumulator. In other words, the A register is the most commonly used register and it is
impossible to imagine a microcontroller without it. More than half instructions used by the
8051 microcontroller use somehow the accumulator.
Figure 2.4: Accumulator Register.
2.7 B RegisterB register is same as that of accumulator of. It is also an 8 bit register and every bit of this is
accessible. This is also a mathematical register B which is used mostly for multiplication and
division.
Figure 2.5: B Register.
2.8 PSW (Program Status Word) RegisterProgram status word register is an 8 bit register. It is also referred to as the flag register.
Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051. The unused
bits are user-definable flags. Four of the flags are called conditional flags, meaning that they
Indicate some conditions that result after an instruction is executed. These four are CY (carry),
AC (auxiliary carry), P (parity) and OV (overflow).
Figure 2.6: Program Status Word Register
PSW register is one of the most important SFRs. It contains several status bits that reflect the
current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two
register bank select bits, Overflow flag, parity bit and user-definable status flag.
BANK RS1 (PSW.4) RS0 (PSW.3)
Bank 0 0 0
Bank 1 0 1
Bank 2 1 0
Bank 3 1 1
Table 2.2: PSW Bit Bank selection.
P (Parity bit): If a number stored in the accumulator is even then this bit will be automatically
set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via
serial communication.
Bit 1: This bit is intended to be used in the future versions of microcontrollers.
OV ( Overflow): Occurs when the result of an arithmetical operation is larger than 255 and
cannot be stored in one register. Overflow condition causes the OV bit to be set (1).
Otherwise, it will be cleared (0).
1RS0, RS1 (Register bank select bits): These two bits are used to select one of four register
banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four
banks of RAM.
F0 (Flag 0): This is a general-purpose bit available for use.
AC (Auxiliary Carry Flag): This is used for BCD operations only.
CY (Carry Flag): This is the (ninth) auxiliary bit used for all arithmetical operations and shift
instructions.
2.9 Data Pointer Register (DPTR)DPTR register is not a true one because it doesn't physically exist. It consists of two separate
registers: DPH (Data Pointer High) and (Data Pointer Low). For this reason it may be treated
as a 16-bit register or as two independent 8-bit registers. Their 16 bits are primarily used for
external memory addressing. Besides, the DPTR Register is usually used for storing data and
intermediate results.
Figure 2.7: Data Pointer Register.
2.10 Stack Pointer (SP) Register
Figure 2.8: Stack Pointer Register.
A value stored in the Stack Pointer points to the first free stack address and permits stack
availability. Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops
decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack
Pointer, which means that the space of RAM reserved for the stack starts at this location. If
another value is written to this register, the entire Stack is moved to the new memory location.
2.11 Internal MemoryThe 8051 has two types of memory and these are Program Memory and Data Memory.
Program Memory (ROM) is used to permanently save the program being executed, while Data
Memory (RAM) is used for temporarily storing data and intermediate results created and used
during the operation of the microcontroller. 128 or 256 bytes of RAM is used.
2.11.1 Internal RAM
As already mentioned, Data Memory is used for temporarily storing data and intermediate
results created and used during the operation of the microcontroller. Besides, RAM memory
built in the 8051 family includes many registers such as hardware counters and timers,
input/output ports, serial data buffers etc. The previous models had 256 RAM locations, while
for the later models this number was incremented by additional 128 registers. However, the
first 256 memory locations (addresses 0-FFh) are the heart of memory common to all the
models belonging to the 8051 family. Locations available to the user occupy memory space
with addresses 0-7Fh, i.e. first 128 registers. This part of RAM is divided in several blocks.
The first block consists of 4 banks each including 8 registers denoted by R0-R7. Prior to
accessing any of these registers, it is necessary to select the bank containing it. The next
memory block (address 20h-2Fh) is bit- addressable, which means that each bit has its own
address (0-7Fh). Since there are 16 such registers, this block contains in total of 128 bits with
separate addresses (address of bit 0 of the 20h byte is 0, while address of bit 7 of the 2Fh byte
is 7Fh). The third group of registers occupy addresses 2Fh-7Fh, i.e. 80 locations, and does not
have any special functions or features.
Figure 2.9: RAM Memory Space Allocation.
2.11.2 Additional RAM
In order to satisfy the programmers’ constant hunger for Data Memory, the manufacturers
decided to embed an additional memory block of 128 locations into the latest versions of the
8051 microcontrollers. However, it’s not as simple as it seems to be… The problem is that
electronics performing addressing has 1 byte (8 bits) on disposal and is capable of reaching
only the first 256 locations, therefore. In order to keep already existing 8-bit architecture and
compatibility with other existing models a small trick was done. What does it mean? It means
that additional memory block shares the same addresses with locations intended for the SFRs
(80h- FFH). In order to differentiate between these two physically separated memory spaces,
different ways of addressing are used. The SFRs memory locations are accessed by direct
addressing, while additional RAM memory locations are accessed by indirect addressing.
2.11.3 Internal ROM
The first models of the 8051 microcontroller family did not have internal program memory. It
was added as an external separate chip. These models are recognizable by their label
beginning with 803 (for example 8031 or 8032). All later models have a few Kbyte ROM
embedded. Even though such an amount of memory is sufficient for writing most of the
programs, there are situations when it is necessary to use additional memory as well. A typical
example are so called lookup tables. They are used in cases when equations describing some
processes are too complicated or when there is no time for solving them. In such cases all
necessary estimates and approximates are executed in advance and the final results are put in
the tables (similar to logarithmic tables).EA=0In this case, the microcontroller completely
ignores internal program memory and executes only the program stored in external memory.
EA=1In this case, the microcontroller executes first the program from built-in ROM, then the
program stored in external memory. In both cases, P0 and P2 are not available for use since
being used for data and address transmission. Besides, the ALE and PSEN pins are also used.
2.11.4 Memory Expansion
In case memory (RAM or ROM) built in the microcontroller is not sufficient, it is possible to
add two external memory chips with capacity of 64Kb each. P2 and P3 I/O ports are used for
their addressing and data transmission. From the user’s point of view, everything works quite
simply when properly connected because most operations are performed by the
microcontroller itself. The 8051 microcontroller has two pins for data read RD(P3.7) and
PSEN. The first one is used for reading data from external data memory (RAM), while the
other is used for reading data from external program memory (ROM). Both pins are active
low. Even though additional memory is rarely used with the latest versions of the
microcontrollers, we will describe in short what happens when memory chips are connected
according to the previous schematic. The whole process described below is performed
automatically. Similar occurs when it is necessary to read location from external RAM.
Addressing is performed in the same way, while read and write are performed via signals
appearing on the control outputs RD (is short for read) or WR (is short for write).
2.12 Special Function Registers (SFRs)Special Function Registers (SFRs) are a sort of control table used for running and monitoring
the operation of the microcontroller. Each of these registers as well as each bit they include,
has its name, address in the scope of RAM and precisely defined purpose such as timer
control, interrupt control, serial communication control etc. Even though there are 128
memory locations intended to be occupied by them, the basic core, shared by all types of 8051
microcontrollers, has only 21 such registers. Rests of locations are intentionally left
unoccupied in order to enable the manufacturers to further develop microcontrollers keeping
them compatible with the previous versions.
3. POWER SUPPLY
3.1 IntroductionIn most of our electronic products or projects we need a power supply for converting mains
AC voltage to a regulated DC voltage. For making a power supply designing of each and
every component is essential. Here to discuss the designing of regulated 5V Power Supply.
3.2 Block Diagram of Power SupplyFigure 3.1 show the block diagram of power supply. It can be divided into following stages:
Stage1: Transformer
Stage 2: Rectifier
Stage 3: Filter
Stage 4: Regulator
Figure 3.1: Block Diagram of Power Supply.
Figure 3.2: Circuit Diagram of Power Supply.
3.2.1 Transformer
A transformer is a static electrical device that transfers energy by inductive coupling between
its winding circuits. A varying current in the primary winding creates a varying magnetic flux
in the transformer's core and thus a varying magnetic flux through the secondary winding.
This varying magnetic flux induces a varying electromotive force (EMF) or voltage in the
secondary winding. Commonly, transformers are used to increase or decrease the voltages of
alternating current in electric power applications.
A wide range of transformer designs are used in electronic and electric power applications.
Transformers are essential for the transmission, distribution, and utilization of electrical
energy.
Figure 3.3: Centre Tapped Transformer.
3.2.2 Rectifier
A rectifier is an electrical device that converts alternating current (AC), which periodically
reverses direction, to direct current (DC), which flows in only one direction. The process is
known as rectification. Physically, rectifiers take a number of forms, including vacuum tube