28-08-2014, 11:48 AM
I undertook the module of 6 months industrial training at Sebiz Finishing School, Embedded systems. I have studied about various micro-controllers like AT89C51, PIC16F877A etc.
CONTENTS
· Acknowledgement
• Introduction
• Definition of Embedded Systems
• Examples
• Computer Essentials
• Microprocessors and Microcontrollers
• PIC Microcontrollers
• 12 Series PIC
• Applications
• Timers
• Interrupts
• DMA
• 8051
• Basic Components
• Block Diagram
• Features of 8051
• 8051 family comparison
• Introduction to PLC
• Switches
• Ladder Logic
ACKNOWLEDGEMENT
First of all I would like to thank the Almighty, who has always guided me to work on the right path of the life. I acknowledge with deep sense of gratitude and most sincere appreciation, the valuable guidance and unfailing encouragement rendered to me by “Mr. VINAY RATHI”, “CORPORATE TRAINER” for their proficient and enthusiastic guidance, useful encouragement and immense help. I have been deep sense of admiration for them inmate goodness and inexhaustible enthusiasm.
My heartfelt gratitude goes to all teachers and guidance group who with their encouraging, caring words, constructive criticism and segmentation have contributed directly or indirectly in a significant way towards completion of this training. My special thanks go to my friends whose support and encouragement have been a constant source of assurance, guidance, strength, and inspection to me.
I am immensely grateful to my parents, my family. They have always supported me and taught me the things that matter most in life. I am proudly grateful to all of them.
Chapter 1
Introduction to Embedded System
Embedded system:
· It is a system whose principal function is not computational, but which is controlled by a computer embedded within it.
· An embedded system is closely integrated with the main system
· It may not interact directly with the environment
· An embedded product uses a microprocessor or microcontroller to do one task only
1.1 Examples
Fig 1.1 Embedded in Refrigrator
Fig 1.2 Car Door
Fig 1.3 Electronic Ping Pong
Criteria in Choosing the Micro-controller
· Meeting the computing needs of the task efficiently and cost effectively
· Speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption
· Easy to upgrade
· Cost per unit
· Availability of software development tools
· Assemblers, debuggers, C compilers, emulator, simulator, technical support
· Wide availability and reliable sources of the microcontrollers
Features of Microcontrollers
One of the most useful features of the 8051 is that it contains four I/O ports (P0 - P3)
· Port 0 (pins 32-39):P0(P0.0~P0.7)
· 8-bit R/W - General Purpose I/O
· Or acts as a multiplexed low byte address and data bus for external memory design
· Port 1 (pins 1-8) :P1(P1.0~P1.7)
· Only 8-bit R/W - General Purpose I/O
· Port 2 (pins 21-28):P2(P2.0~P2.7)
· 8-bit R/W - General Purpose I/O
· Or high byte of the address bus for external memory design
· Port 3 (pins 10-17):P3(P3.0~P3.7)
· General Purpose I/O
COMPUTER ESSENTIALS
fig. 1.4 Basic computing
Fig 1.5 Von Neumann & Harvard Computers
· PSEN (out): Program Store Enable, the read signal for external program memory (active low).
· ALE (out): Address Latch Enable, to latch address outputs at Port0 and Port2
· EA (in): External Access Enable, active low to access external program memory locations 0 to 4K
· RXD,TXD: UART pins for serial I/O on Port 3
· XTAL1 & XTAL2: Crystal inputs for internal oscillator.
Fig. 1.7 8051 PIN Config.
Fig. 1.9 Microcontroller Interfacing
Description about Microcontrollers
a) Processor
(1) Usually general-purpose but can be app-specific
b) On-chip memory
(1) Often RAM for data, EEPROM/Flash for code
c) Integrated peripherals
(1) Common peripherals
(i) Parallel I/O port(s)
(ii) Clock generator(s)
(iii)Timers/event counters
(2) Special-purpose devices such as:
(i) Analog-to-digital converter (sensor inputs)
(ii) Mixed signal components
(iii)Serial port + other serial interfaces (SPI, USB)
(iv) Ethernet
• Benefits
o Typically low-power/low-cost
§ Target for embedded applications
o Easily programmable
§ Simple ISAs (RISC processors)
§ Use of development kits simplifies process
• Limitations
o Small storage space (registers, memory)
o Restricted instruction set
o May be required to multiplex pins
o Not typically used for high performance
• High performance, low cost, for embedded applications
o Only 35 different instructions
o Interrupt capability
o Direct, indirect, relative addressing mode
• Low Power
o 8.5uA @ 32KHz, 2.0V
• Peripheral Features
o 12 I/O pins with individual direction control
o 10-bit A/D converter
o 8/16-bit timer/counter
• Special Microcontroller Features
o Internal/external oscillator
o Power saving sleep mode
Fig. PIC Circuit Diagram
PROGRAM MEMORY SIZE
· 13-bit program counter to address 8K locations
· Each location is 14-bit wide (instructions are 14 bits long)
· RESET vector is 0000h
· When the CPU is reset, its PC is automatically cleared to zero.
· Interrupt Vector is 0004h
· 0004h is automatically loaded into the program counter when an interrupt occurs
· Vector à address of code to be executed for given interrupt
STATUS REGISTER
STACK
· 8-level deep x 13-bit wide hardware stack
· The stack space is not part of either program or data space and the stackpointer is not readable or writable.
· The PC is “PUSHed” onto the stack when a CALL instruction is executed, or an interrupt causes a branch.
· The stack is “POPed” in the event of a RETURN, RETLW or a RETFIE instruction execution.
· However, NO PUSH or POP instructions !
· PCLATH is not affected by a “PUSH” or “POP” operation.
· The stack operates as a circular buffer:
· After the stack has been PUSHed eight times, the ninth push overwrites the value that was stored from the first push.
PIC
• Peripheral Interface Controller (PIC) was originally designed by General Instruments
• In the late 1970s, GI introduced PIC® 1650 and 1655 – RISC with 30 instructions.
• PIC was sold to Microchip
• Features: low-cost, self-contained, 8-bit, Harvard structure, pipelined, RISC, single accumulator, with fixed reset and interrupt vectors.
Fig. 12 series PIC
12F508
PIN CONFIG. OF PIC 12F508/509
PIC Family
Stack Size
Instruction Word Size
No. of Instructions
Interrupt Vectors
12CX/FX
2
12-14 bit
33
None
16C5X/F5X
2
12 bit
33
None
16CX/FX
8
14 bit
35
1
17CX/FX
16
16 bit
58
4
18CX/FX
32
16 bit
75
2
APPLICATIONS
· TV
• stereo
• remote control
• phone / mobile phone
• refrigerator
• microwave
• washing machine
• electric tooth brush
• oven / rice or bread cooker
• watch
• alarm clock
• electronic musical instruments
• electronic toys (stuffed animals,handheld toys, pinballs, etc.)
• medical home equipment (e.g. blood
pressure, thermometer)
• Medical Systems
– pace maker, patient monitoring systems, injection systems, intensive care units, …
• Office Equipment
– printer, copier, fax, …
• Tools
– multimeter, oscilloscope, line tester, GPS, …
• Banking
– ATMs, statement printers, …
• Transportation
– Planes/Trains/[Automobiles] and Boats)
• radar, traffic lights, signalling systems, …
• Automobiles
– engine management, trip computer, cruise control, immobilizer, car alarm,
– airbag, ABS, ESP, …
• Building Systems
– elevator, heater, air conditioning, lighting, key card entries, locks, alarm systems, …
• Agriculture
– feeding systems, milking systems, …
• Space
– satellite systems, …
TIMERS
• Base 8051 has 2 timers
• we have 3 in the Atmel 89C55
• Timer mode
• Increments every machine cycle (12 clock cycles)
• Counter mode
• Increments when T0/T1 go from 1 - 0 (external signal)
• Access timer value directly
• Timer can cause an interrupt
• Timer 1 can be used to provide programmable baud rate for serial communications
• Timer/Counter operation
• Mode control register (TMOD)
• Control register (TCON)
INTERRUPTS
q Original 8051 has 5 sources of interrupts
v Timer 0 overflow
v Timer 1 overflow
v External Interrupt 0
v External Interrupt 1
v Serial Port events (buffer full, buffer empty, etc)
q Enhanced version has 22 sources
v More timers, programmable counter array, ADC, more external interrupts, another serial port (UART)
If interrupt event occurs AND interrupt flag for that event is enabled, AND interrupts are enabled, then:
1. Current PC is pushed on stack.
2. Program execution continues at the interrupt vector address for that interrupt.
3. When a RETI instruction is encountered, the PC is popped from the stack and program execution resumes where it left off.
INTERRUPT PRIORITIES
q What if two interrupt sources interrupt at the same time?
q The interrupt with the highest PRIORITY gets serviced first.
q All interrupts have a default priority order.
q Priority can also be set to “high” or “low”.
Each interrupt has a specific place in code memory where program execution (interrupt service routine) begins.
External Interrupt 0: 0003h
Timer 0 overflow: 000Bh
External Interrupt 1: 0013h
Timer 1 overflow: 001Bh
Serial : 0023h
Timer 2 overflow(8052+) 002bh
The 8051 Microcontroller
8051 Basic Component
RAM
I/O Port
Timer
Serial COM Port
CPU
ROM
Microcontroller
A single chip
4K bytes internal ROM
128 bytes internal RAM
Four 8-bit I/O ports (P0 - P3).
Two 16-bit timers/counters
One serial interface
Block Diagram
CPU
Interrupt
Control
OSC
Bus
Control
4k
ROM
Timer 1
Timer 2
Serial
128 bytes
RAM
4 I/O Ports
TXD
RXD
External Interrupts
P0 P2 P1 P3
Addr/Data
Other 8051 featurs
1. only 1 On chip oscillator (external crystal)
2. 6 interrupt sources (2 external , 3 internal, Reset)
3. 64K external code (program) memory(only read)PSEN
4. 64K external data memory(can be read and write) by RD,WR
5. Code memory is selectable by EA (internal or external)
6. We may have External memory as data and code
Comparison of the 8051 Family Members
WD: Watch Dog Timer
AC: Analog Comparator
ISP: In System Programable
Programmable Logical Controller
1.1 History of PLC
PLC were first created to serve the automobile industry, and the first PLC project was developed in 1968 for general motors to replace hard wired relay systems by Dick Morley
1.2 Evolution of PLC
The evolution of PLC control system has been achieved by going through a lot of phase of control systems every time trying to make it more effective & efficient. First of all manual control system was developed. That is all the actions related to process control or machine control was perform by the operators .but due to the human errors and its effect in the quality & quantity in the production, some alternatives forced the engineers to think of the hard wired control system with relays, timers & controls. this was the first step towards the automation. This control method is very popular and still a lot of people use this method. But due to the limitations of this method a more effective & efficient method was developed that the microprocessor base controller .
PLC development began in 1968 in response to a request from GM Hydramatic. At that time GM frequently spent days or weeks replacing inflexible relay-based