Ajay 2
Ajay 2
Ajay 2
EMBEDDED SYSTEM
Combination of Software and hardware, designed to perform a particular task. Examples : Printer, Timers, Remote controls, Digital locks, Lighting control, Key-
board.
COMPONENTS:
Embedded system is a combination of hardware and software. Hardware may be a linear or digital integrated circuit. Software part consists of any the languages that is may be machine level or assembly
CHARACTERISTICS:
Perform a single set of functions. Works in a time constrained environment. Provides high performance and reliability. Mostly embedded systems have low cost because they are mass produced in millions. Some embedded systems have mechanical moving parts like disk drives as they are
HARDWARE
Digital Circuits Digital Circuits Decoder, latches Decoder, latches etc. etc. Passive Passive components components Resistance, Resistance, Capacitance, Capacitance, Transistors etc. Transistors etc. Hardware Hardware
Analog Circuits Analog Circuits OPAMP, ADC, OPAMP, ADC, DAC DAC etc. etc.
Fig 1.1
SOFTWARE
Java/J2EE Java/J2EE
Software Software
Fig 1.2
1.3 GOAL OF STUDY: To study the various components of Embedded Systems, their implementation, architecture and applications, was the main goal of this training. 1.4 APPLICATIONS OF EMBEDDED SYSTEMS:
Automatic teller machines (ATM). Avionics, such as inertial guidance systems, flight control hardware/software and othCellular telephones and telephone switches. Engine controllers and antilock brake controllers for automobiles. Home automation products, such as thermostats, air conditioners, sprinklers, and seHousehold appliances, including microwave ovens, washing machines, television Handheld computers.
Video game consoles. Even computer peripherals themselves such as routers and printers have embed-
ded processors.
Fig. 1.3
the most reliable infrastructure where system down time is never issue are just some of hurdles the telecommunications sector is facing today.
INDUSTRIAL AUTOMATION:
Fig 1.4
Fig 1.5
ROBOTICS:
Fig 1.6
OTHER APPLICATIONS:
Fig 1.7
10
CHAPTER 2
MICROCONTROLLER BASED DESIGN Introduction Architecture Assembly Based Designs Interfacing with Devices Tools
11
single package . 8-bit data bus - It can access 8 bits of data in one operation (hence it is an 8-bit
microcontroller). 16-bit address bus - It can access 216 memory locations - 64 kB each of RAM and
ROM . On-chip RAM - 128 bytes ("Data Memory") On-chip ROM - 4 kB ("Program Memory"). Four byte bi-directional input/output port. UART (serial port). Two 16-bit Counter/timers. Two-level interrupt priority.
12
Fig. 3.1
13
MICRCONTROLLER
1. Contains on chip RAM, ROM, I/O, TIMER, Serial port . 2. Used in Specific Purpose applications 3. Provides data storage facility. 4. The structure of uC is as given below
CPU RAM ROM
I/O
TIMER
SERIAL
COM PORT
Address Bus
Table 3.1 In short microcontroller can be defined as: True computer on a chip. Specific-purpose digital computers. Design incorporates all the features of a microprocessor like ALU, PC, SP and regis-
ters along with RAM ROM, parallel I/O, serial I/O,, timers, clock circuits ADC etc.
3.4 TYPES OF MICROCONTROLLER: 4 BIT MICROCONTROLLERS: It is the most popular microcontroller made in terms
of production. It is most economical and cheaper. It is mainly applicable to toys and small appliances.
14
word size adequate for many computing tasks and control or monitoring applications it is applicable to simple appliances control, high speed machine control, data collection etc.
16 BIT MICROCONTROLLERS: It provides faster and more sophisticated calculations. It is applicable to control of servomechanisms like robot arms.
32 BIT MICROCONTROLLERS: The design emphasis is more on high speed computation features and not on chip features like RAM, ROM, and Timers etc. it is applicable to robotics, highly intelligent instrumentation, avionics, image, processing, telecommunications, automobiles Example: Intel 80960, ARM
15
EXTERNAL INTERRUP TS INTERRU PT CONTRO L ONCHI P FLA SH ETC. ON CHIP RAM TIMER1 TIMER0 COUNTER INPUT
CPU
BUS CONTRO L SERIAL PORT
OSC
4 I/O PORTS
P0
P2 P1 P3
TXD RXD
ADDRESS/DA TA
Fig 3.2
16
P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD) P3.0 (TXD) P3.1 (INT0) P3.2 (INT1) P3.3 (T0) P3.4 (T1) P3.5 (WR) P3.6 (RD) P3.7 XTAL2 XTAL1 GND
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
Vcc P0.0 (AD0) P0.1 (AD1) P0.2 (AD2) P0.3 (AD3) P0.4 (AD4) P0.5 (AD5) P0.6 (AD6) P0.7 (AD7) EA/VPP ALE/PROG PSEN P2.7 (A15) P2.6 (A14) P2.5 (A13) P2.4 (A12) P2.3 (A11) P2.2 (A10) P2.1 (A9) P2.0 (A8)
Fig 3.3
17
Contains internal pull-ups. Used both as I/O port and higher address byte.
Fig 3.4
18
Active high. Used for de-multiplexing the address and data by connecting G pin of the 74LS373.
EA - (pin 31):
Active low input. To access external ROM, it must be GND.
VCC - (pin 40). GND (pin 20). 3.8 GENERAL PURPOSE REGISTERS : Registers (R0-R7) Set of 8 auxiliary registers, namely R0, R1, and R7. Data Pointer (DPTR): Made of two 8-bit registers, namely DPH and DPL, Used to
furnish memory address for internal and external code access and external data access.
Program Counter (PC): 16-bit register holds the address of the next program instruction to
be executed, automatically Incremented after each instruction fetch.
19
Branching Instruction. Data movement Instruction. Variety of addressing modes. 6 interrupt sources.
INTERRUPT CONTROL:
IE IP : Interrupt Enable. : Interrupt Priority.
I/O PORT:
P0 P1 P2 P3 : Port 0. : Port 1. : Port 2. : Port 3.
TIMERS:
TMOD : Timer mode. TCON : Timer control. TH0 TL0 TH1 TL1 : Timer 0 high byte. : Timer 0 low byte. : Timer 1 high byte. : Timer 1 low byte.
SERIAL I/O:
SCON : Serial port control. SBUF : Serial data registers.
OTHER:
PCON : Power control & misc.
A, B registers:
A (Accumulator):
8-bit register & used as working register.
20
B registers:
8-bit register and can be used as general purpose Register. Necessary for the instructions MUL and DIV.
RS1
RS0
: : :
OV
---- P
Register Select 1. Register Select 0. : : Arithmetic Overflow Flag. Accumulator Parity Flag.
21
01:16-bit counter/timer. 10: 8-bit auto-reload mode 11: Timer 0 = two 8-bit timers. Timer 1 Counting disabled. Timing function allowed. It can be used as Baud Rate generator.
TIMER MODE
Timer Mode 0: Emulates 8048 counter/timer (13-bits). 8-bit counter (TL0 or TL1). 5-bit presales (TH0 or TH1).
Timer Mode 2:
3.11 TCON: Timer Control Register TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
TF1, TF0: Overflow flags for Timer 1 and Timer 0. TR1, TR0: Run control bits for Timer 1 and Timer 0. Set to run Reset to hold. IE1, IE0 : Edge flag for external interrupts 1 and 0. Set by interrupt edge, cleared when interrupt is processed. IT1, IT0 : Type bit for external interrupts. Set for falling edge interrupts, reset for 0 level interrupts.
3.12 SCON: Serial Control Register SMO SM1 SM2 REN TB8 RB8 TI RI
SM0, SM1 = Serial Mode: 00 = Mode 0 : Shift register I/O expansion. 01 = Mode 1 : 8-bit UART with variable baud rate. 10 = Mode 2 : 9-bit UART with fixed baud rate. 11 = Mode 3 : 9-bit UART with variable baud rate. SM2 : Mode 0 : Not used. Mode 1 : 1 = Ignore bytes with no stop bit. Mode 2,3: 0 = Set receive interrupt (RI) on all bytes.
22
REN = Enables receiver. TB8 = Ninth bit transmitted (in modes 2 and 3). RB8 = Ninth bit received: Mode 0 : Not used. Mode 1 : Stop bit. Mode 2, 3: Ninth data bit. TI = Transmit interrupt flag. RI = Receive interrupt flag.
EA
----
----
ES
ET1
EX1
ET0
EX0
EA: Global interrupt enable. ES: Serial interface. ET1: Timer 1. EX1: External interrupts 1. ET0: Timer 0. EX0: External interrupts 0. 0 = Disabled. 1 = Enabled.
23
Interrupt Enables
Each interrupt source can be individually enabled or disabled by setting or clearing a bit in the SFR named IE (Interrupt Enable). This register also contains a global disable bit, which can be cleared to disable all interrupts at once.
24
The hardware-generated LCALL causes the contents of the Program Counter to be pushed into the stack, and reloads the PC with the beginning address of the service routine. As previously noted, the service routine for each interrupt begins at a fixed location. Only the Program Counter is automatically pushed onto the stack, not the PSW or any other register. Having only the PC automatically saved allows the programmer to decide how much time should be spent saving other registers. This enhances the interrupt response time, albeit at the expense of increasing the programmers burden responsibility. As a result, many interrupt functions that are typical control applications toggling a port pin for example, or reloading a timer, or unloading a serial buffer can often be completed in less time than it takes other architectures to complete.
25
26
27
28
BLOCK DIAGRAM
Alarm
LCD
Motor driver
Microcontroller Relays
Fig 6.1
29
Circuit Description
The system consists of five sections namely power supply section, microcontroller circuit, relay section, motor driver circuit and alarm circuitry.
2. Microcontroller circuit
Here we have used microcontroller AT89S52. All the ports of controller is configured as an output ports. The microcontroller controls all the relays and the motor driver and LCD. The LCD is used to display the time at which an event will occur such as switching ON the lights, opening the gates, etc. Relays will be activated/ deactivated to switch on/off the lights or the pump. The relays are connected to P0.0 pin of the microcontroller through relay driver.
4. Alarm Section
The alarm section consists of a piezoelectric buzzer. The buzzer will produce sound to give indication that gate is to be closed shortly.
30
5.Relay: It is used to control the flow of water in the garden just like any simple valve and is
driven by a relay driver.
Source Code
The source code for the microcontroller is written in C language and is compiled using the popular C compiler keil uvision3.
31
CIRCUIT DIAGRAMS
1. Main Circuit
VCC 6V C3 U2 R2 8 .2 k J1 U1
V C C4 0 P0B0A30 D8 P0B1A31 D9 P0B2A32 D7 P0B3A33 D6 P0B4A34 D5 P0B5A35 D4 P0B6A36 D3 P0B7A37 D2 E A V P3 1 P ALEPR3G O0 29 PSEN P2B7A25 18 P2B6A24 17 P2B5A23 16 P2B4A22 15 P2B3A21 14 P2B2A20 13 P 2 B 1 A292 P 2 B 0 A281 2 3 4 5 6 7 8 9
R1 1 X 8 S IP 10k X1
IO1 O1 I IO2 O2 I
1 0 u FK e y = S p a c e
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
B U ZZER 200 Hz
P1B0T2 P1B1T2EX P1B2 P1B3 P1B4 P1B5MOSI P1B6MISO P1B7SCK RST P3B0RXD P3B1TXD P3B2INT0 P3B3INT1 P3B4T0 P3B5T1 P3B6WR P3B7RD XTAL2 XTAL1 GND
MOTOR SECTION X2
IO1 O1 I IO2 O2 I IO3 O3 I
8052
AC INTERFACE X3
IO1 O1 I IO2 O2 I IO3 O3 I IO4 O4 I IO5 O5 I IO6 O6 I IO7 O7 I IO8 O8 I IO9 O9 I IO10 10 IO IO11 11 IO
C1 22pF C2 22pF X1 H C -4 9 /U _ 1 1 M H z
LCD module
Fig 6.2
32
Fig 6.3
33
L293D
Fig 6.4
34
4. Relay circuit
VCC 12V
K2
IO3
K3
K
Fig 6.5
35
5. Power supply
Fig 6.6
36
Fig 6.7
Fig 6.8
36