Assistant Professor Department of Electronics & communication Engineering Doon Valley Institute of Engineering & Technology Karnal, Haryana

Similar documents
Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

DIGITAL ELECTRONICS. Vayu Education of India

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

CHAPTER 1 MICROCOMPUTER SYSTEMS. 1.1 Introduction. 1.2 Microcontroller Evolution

Microprocessors/Microcontrollers

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Computer Hardware Requirements for Real-Time Applications

Basic computer principles

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

BASIC INTERFACING CONCEPTS

Microcontroller & Interfacing

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

8051 MICROCONTROLLERS

EMBEDDED SYSTEM BASICS AND APPLICATION

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

Microprocessor Theory

CREATED BY M BILAL & Arslan Ahmad Shaad Visit:

Embedded Systems Design (630414) Lecture 1 Introduction to Embedded Systems Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Lecture (01) Introducing Embedded Systems and the Microcontrollers By: Dr. Ahmed ElShafee

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

Embedded World Television, Radio, CD player, Washing Machine Microwave Oven Card readers, Palm devices

Lecture 2 Microcomputer Organization: Fig.1.1 Basic Components of Microcomputer

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD QUESTION BANK

Keywords: PLC, Three-Phase Induction Motor, AC Current Sensor, Proximity Sensor, AC Voltage Sensor.


Lecture 1. Course Overview and The 8051 Architecture

Sencer Yeralan and Helen Emery Gainesville, Florida January 2000

EMBEDDED SYSTEMS COURSE CURRICULUM

output devices. connected to the controller. data communications link. relay systems. user program. MECH1500Quiz1ReviewVersion2 Name: Class: Date:

THE MICROCOMPUTER SYSTEM CHAPTER - 2

Chapter One. Introduction to Computer System

ENE 334 Microprocessors

PROGRAMMING AND CUSTOMIZING

International Journal of Modern Trends in Engineering and Research e-issn No.: , Date: April, 2016

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD

Microprocessors And Microcontroller

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING MSC SYSTEMS ENGINEERING AND ENGINEERING MANAGEMENT SEMESTER 2 EXAMINATION 2016/2017

EE 308: Microcontrollers

PLC: introduction. PLC: introduction. PLC: application. PLC: application

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

Architecture of Computers and Parallel Systems Part 6: Microcomputers

OPERATIONAL UP TO. 300 c. Microcontrollers Memories Logic

HOURS SYLLABUS

Fig 1. Block diagram of a microcomputer

ECED3204: Microprocessor Part I--Introduction

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

Introduction to Microcontrollers

Basic Components of Digital Computer

Team 3. By: Miriel Garcia. Microcontrollers/ TI MSP430F5438A. ECE 480 senior Design. Application Note 4/3/15

MICROPROCESSOR BASED SYSTEM DESIGN

DIPLOMA COURSE IN ELECTRONICS AND COMMUNICATION ENGINEERING

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Automation of Conveyor System and Process Control with Power Reduction Using Efficient PLC Programming and SCADA


MICROCONTROLLERS 8051

HCS12 Microcontroller and Embedded Systems: Using Assembly and C with CodeWarrior 1 st Edition


MECE336 Microprocessors I

COMP2121: Microprocessors and Interfacing. Introduction to Microprocessors

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING YEAR : III SEM : VI

MN101E50 Series. 8-bit Single-chip Microcontroller

Pearson New International Edition. The 8051 Microcontroller and Embedded Systems Mazidi Mazidi McKinlay Second Edition


DERTS Design Requirements (1): Microcontroller Architecture & Programming

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.


Mechatronics MECH 1340 Digital Fundamentals & PLCs Introduction

Class: S.E. (Electrical) Course: 2012 PAT. Semester: IV : FUNDAMENTALS OF MICROPROCESSOR AND MICROCONTROLLER Textbooks:

Central Processing Unit - CPU

MICROPROCESSOR 8085 AND ITS INTERFACING SUNIL MATHUR. Second Edition A 1 ALE AD 0 - AD 7. Latch. Keyboard data V CC 8 P A D D 0 7 STB STB G G A

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Computer Organization and Microprocessors SYLLABUS CHAPTER - 1 : BASIC STRUCTURE OF COMPUTERS CHAPTER - 3 : THE MEMORY SYSTEM

plc operation Topics: The computer structure of a PLC The sanity check, input, output and logic scans Status and memory types 686 CPU

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

THE 8051 MICROCONTROLLER

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

Pretest Programmable Logic Controllers. Unit 1, Task 1

Lecture (02) PIC16F84 (I)

Components of a simple PC

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013)

PERFORMANCE ANALYSIS OF REAL-TIME EMBEDDED SOFTWARE

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Embedded Robotics. Software Development & Education Center

ARDUINO MEGA INTRODUCTION

Chapter TEN. Memory and Memory Interfacing

Parts of Computer hardware Software

WIZTECH AUTOMATION SOLUTIONS (P) LTD., An ISO 9001:2000 and IAO certified company

Robotic Systems ECE 401RB Fall 2006

Alcohol Detection using Pic Microcontroller

HARDWARE OF SUPERVISORY CONTROL & DATA ACQUISITION SYSTEM

8051 Microcontroller

Chapter 2 Sections 1 8 Dr. Iyad Jafar

Transcription:

8051 Microcontroller Embeded System Design and PLCs Arun Rana Assistant Professor Department of Electronics & communication Engineering Doon Valley Institute of Engineering & Technology Karnal, Haryana First Edition An ISO 9001:2008 Certified Company Vayu Education of India 2/25, Ansari Road, Darya Ganj, New Delhi-110 002

8051 Microcontroller Embeded System Design and PLCs Copyright VAYU EDUCATION OF INDIA ISBN: 978-93-82174-14-1 First Edition: 2013 290/- All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior permission of the Author and Publisher. Printed & bound in India Published by: AN ISO 9001:2008 Certified Company VAYU EDUCATION OF INDIA 2/25, Ansari Road, Darya Ganj, New Delhi-110 002 Ph.: 91-11-43526600, 41564445 Fax: 91-11-41564440 E-mail: vayueducation@rediffmail.com, vayueducation@gmail.com Website: www.veiindia.com

Preface Computers now form an integral part of most real-time control systems.with the advent of the microprocessors and microcontrollers in the last few decades the use of computers in control applications has been ever growing. Microcontrollers are single-chip computers which can be used to control real-time systems. Such controllers are also referred to as embedded real-time computers. These devices are low-cost, single-chip and easy to program. A microcontroller contains data and program memory, serial and parallel I/O, timers, and external and internal interrupts-all integrated into a single chip that can be purchased for as little as two dollars. About 40 percent of all microcontroller applications are found in office equipment, such as PCs, laser printers, fax machines, and intelligent telephones. About one third of all microcontrollers are found in consumer electronic goods. Products like CD players, hi-fi equipment, video games, washing machines, and cookers fall into this category. The communications market, the automotive market, and the military share the rest of the applications. A programmable logic controller (PLC) or programmable controller is a digital computer used for automation of electromechanical processes,such as control of machinery on factory assembly lines, amusement rides, or lighting fixtures. PLCs are used in many industries and machines. Unlike general-purpose computers, the PLC is designed for multiple inputs and output arrangements, extended temperature ranges, immunity to electrical noise, and resistance to vibration and impact. This book is written for advanced students, for practicing engineers, and for hobbyists who want to learn more about the programming and applications of 8051 microcontroller & PLCs. Knowledge of the Assembly programming language will be useful, and familiarity with at least one member of the 8051 microcontroller will be an advantage. Chapter 1: presents the basic features of microcontrollers, Microcontroller architectures Microcontroller packaging and appearance, criteria in Choosing a Microcontroller, Microcontrollers versus Microprocessors,Application of microcontrollers Chapter 2: reviews the Pinout Description 8051,block diagram of 8051, Oscillator Characteristics, TIMER/COUNTER,SFR,Interrupt Chapter 3: reviews the 8051 instruction set, Addressing modes,writing assembly language programming,lookup tables. Chapter 4: reviews the Interfacing of LEDs,Keyboard,LCD,ADCs & DACs. Chapter 5: reviews the basic idea of 8051 projects. Chapter 6: reviews the introduction of PLCs,working of PLCs,application of PLCs. Chapter 7: introduction of emsdded system and application Arun Rana

Acknowledgement God is omnipotent, omnipresent and omniscient. I bow before him for showing his blessing on me. The present book is an outcome of blessing of god and the good wishes of my parents, colleagues and friends. I express my deepest gratitude to my father Sh. Mahender Singh Rana and Brother Ajay Singh Rana for motivating me at all the stages while writing this book. I am indebted to Dr. Rajesh Malik,HOD of ECE dept. in NC College, Israna, Dr. J.P.Chauhan, Dr. N.K. Batra, Dr. Jagdish Chaudhary, Dr. K.K. Saini, Dr. A.K.Garg, Dr. Sharad Sharma, Dr. Ashish Chopra, Dr. Paras Chawala & Dr. Vinit Singla, for their kind co-operation and motivation for writing this book. I would like to extend my thanks to Dr. Mohit Agarwal, Project Director of DIET, for bringing out this book in such an excellent form. I would like to thanks to Dr. Rajeev Jain, Mr.Vijay Saini, Publisher of this book (VAYU EDUCATION OF INDIA), who Complete my dream Nicely. I also would like to thanks to Mr. Rajeev Gaba, Librarian Of DIET, Karnal, who give me direction to make book useful for the students. I express my gratefulness and appreciation to Er. Prabhdeep singh, Er. Ravinder Singh Bisht, Er. Sumit Rana, Er. Sanjeev Ohiman, Er. B.S. Saini, Er. Neha, Er. Satish, Er. Gorav, Er. Hitesh, Er. Gagan, Er. Dhurv, Er. Rajeev Kamboj,Er. Gurudev Sir,Er. Balvindr Singh, Mr. Susil Chauhan,Er. Swati Mittal, Er. Nidhi Mittal, Er. Nidhi Uppal, Er. Gitika Dua, Er. Dipti Chaudhary, Er. Ritu Chabra, Vijay Saini and All academic colleagues who gave me valuable suggestion during the course of preparation of this book. Suggestions and comments for further improvement of the book will be gratefully acknowleged Arun Rana

Contents 1. Introduction...1 1.1 Microcontroller systems...1 1.2 Microcontroller Memory...2 1.3 Microcontroller Features...3 1.4 Microcontroller Architectures...8 1.5 Microcontroller Packaging and Appearance...9 1.6 criteria in Choosing a Microcontroller...10 1.7 Microcontrollers Versus Microprocessors...11 1.8 Application of Microcontrollers...12 1.9 Survey of Microcontroller...15 1.11 Versions of 8051...18 1.12 Technological Trends in Microcontrollers Development...19 Questions...19 2. 8051 Architecture...21 2.1 Introduction...21 2.2 Pinout Description...21 2.3 Block Diagram of 8051...23 2.4 Internal RAM And ROM...31 2.5 What Are SFRs?...33 2.6 Input/Output Ports (I/O Ports)...38

x 8051 Microcontroller, Embedded System Design and PLCs 2.7 External Memory Connection...42 2.8 Stack Pointer...44 2.8 Oscillator...45 2.9 Clock...47 2.10 Timer/Counter...49 2.11 Interrupt...60 2.12 Reset...68 2.13 Serial Communication...69 2.14 Reset Sources...76 2.15 Introduction of Program Memory...78 2.16 Expanding I/O...81 2.17 Memory Mapped I/O...84 Questions...85 3. 8051 Instruction Set and Programming...89 3.1 Assembly Language...89 3.2 Writing Assembly Language Program...89 3.3 Elements of Assembly Language...90 3.4 Syntax of Assembly Language...90 3.5 Assembly Language Programming Example...96 3.6 Addressing Modes...114 3.7 Lookup Table...116 3.8 Arithmetic Operations...117 3.9 Logical Operations...119 3.10 Data Transfer Inst...121 3.11 Boolean Variable Instructions...124 3.12 Program Branching Instruction...128 3.13 Time Delays...132

Contents xi 3.14 Software Polled Timer...133 3.15 Serial Data Transmission...136 Questions...138 4. 8051 Applications...142 4.1 Keyboards...142 4.2 Displays...151 4.3 Interfacing an LCD to the 8051 Microcontroller...155 4.4 Serial Communication...170 4.5 Analog To Digital Converter (ADC0809)...181 4.6 Interfacing DAC to 8051...185 Questions...190 5. Basic Idea of 8051 Projects...192 5.1 Pick And Place Robot...192 5.2 Automatic Car Parking Indicator Using Microcontroller Description...195 5.3 Level Computing and Storage Device...196 5.4 Person counter and Password Detector...198 5.5 Temperature & Light Monitoring and Controlling...199 5.6 Electronic Voting Machine...200 5.7 Rolling display using Matrix LEDs...201 5.8 Remote Surveillance Vehicle Using AVR AT Mega16...202 5.9 Controller Area Network...203 5.10 Water Spy - A Submarine Robot...204 5.11 Greenhouse Robot...210 5.12 Landrover Robot Operated by Cellphone...211 5.13 Password Based Door Locking...212 5.14 Automatic Room light Controller with Visitor Counter...213 5.15 Automatic Bell For Colleges...214

xii 8051 Microcontroller, Embedded System Design and PLCs 5.16 Microcontroller Based Data Logger...215 5.17 Other Useful Project for Student...217 Questions...223 6. PLC history...224 6.1 Plc History...224 6.2 The Guts Inside...225 6.3 PLC Operation...226 6.4 Response Time...227 6.5 Response Time Concerns...227 6.6 Relays...229 6.7 Replacing Relays...230 6.8 Basic Instructions...231 6.9 PLC Registers...234 6.10 A Level Application...235 6.11 The Program Scan...236 6.12 Latch Instructions...237 6.13 Counters...239 6.14 Timers...242 6.15 Timer Accuracy...244 6.16 One-shots...246 6.17 Master Controls...247 6.18 Shift Registers...250 6.19 Getting and Moving Data...253 6.20 Math Instructions...256 6.21 Boolean Math...259 6.22 DC Inputs...261 6.23 AC Inputs...263

Contents xiii 6.24 Relay Outputs...265 4.25 Transistor Outputs...267 6.26 Using RS-232 with Ladder Logic...269 Questions...271 7. Embedded System Design...271 7.1 Introduction...271 7.2 Embedded Versus External Memory Devices...275 7.3 Microcontroller Features...276 7.4 Microcontroller and Embedded Processors...280 7.5 Basic of PIC Microcontrollers...284 7.6 Architecture and Pipelining...286 7.7 Program Memory Consideration...289 7.8 Addressing Modes...293 7.9 CPU Registers...297 7.10 Instruction Set...300 7.11 Embedded System Design Program...306 Questions...332 Appendix...333 Glossary...431 Index...435

Chapter - 1 Introduction 1.1 Microcontroller systems Microcontrollers are general purpose microprocessors which have additional parts that allow them to control external devices. Basically, a microcontroller executes a user program which is loaded in its program memory. Under the control of this program, data is received from external devices (inputs), manipulated and then data is sent to external output devices. A microcontroller is a very powerful tool that allows a designer to create sophisticated I/O data manipulation algorithms. Microcontrollers are classified by the number of bits in a data word. 8-bit microcontrollers are the most popular ones and are used in many applications. 16-bit and 32-bit microcontrollers are much more powerful, but usually more expensive and not required in many small to medium general purpose applications where microcontrollers are used. The simplest microcontroller architecture consists of a microprocessor, memory, and I/O as shown in fig.1.1. The microprocessor consists of a central processing unit (CPU) and the control unit (CU). The CPU is the brain of a microprocessor and is where all of the arithmetic and logical operations are performed. Fig. 1.1 The control unit controls the internal operations of the microprocessor and sends out control

2 8051 Microcontroller, Embedded System Design and PLCs signals to other parts of the microprocessor to carry out the required instructions. 1.2 MICROCONTROLLER MEMORY Memory is an important part of a microcomputer system. Depending upon the application, we can classify memories into two groups: program memory and data memory. Program memory stores all the program code and this memory is usually non-volatile, i.e. data is not lost after the removal of power. Data memory is where the temporary user data is stored during the various arithmetic and logical operations. Data memories are usually volatile. Simplified model of memory unit is shown in Fig. 1.2. Fig. 1.2 There are basically five types of memories as summarized below: 1.2.1 RAM RAM means Random Access Memory. It is a general purpose memory which usually stores user data. RAM is volatile, i.e. data is lost after the removal of power. Most microcontrollers have some amount of internal RAM. Generally, 256 bytes is a common amount, although some microcontrollers have more, some less. 1.2.2 ROM ROM is Read Only Memory. This type of memory usually holds program or fixed user data. ROM memories are programmed at the factory and their contents cannot be changed by the user. ROM memories are only useful if you have developed a program and wish to order several thousands copies of it. 1.2.3 EPROM EPROM is Erasable Programmable Read Only Memory. This is similar to ROM but the EPROM

Introduction 3 can be programmed using a suitable programming device. EPROM memories have a small clear window on the chip where the data can be erased under an UV light. Many development versions of microcontrollers are manufactured with EPROM memories where the user program is usually stored. These memories are erased and re-programmed until the user is satisfied with the program. Some versions of EPROMs, known as OTP (One Time Programmable), can be programmed using a suitable programmer device but these memories cannot be erased. OTP memories cost much less than the EPROMs. OTP is useful after a project has been developed completely and it is required to make hundreds of copies of the program memory. Most microcontrollers have some amount of built-in EPROM. 2k bytes is a typical capacity, although some may have more and some less. 1.2.4 EEPROM EEPROM is Electrically Erasable Programmable Read Only Memory. These memories can be erased and also be programmed under program control. EEPROMs are used to save configuration information, maximum and minimum values, identification data etc. Some microcontrollers have built-in EEPROM memories (e.g. PIC16F84 contains a 64-byte EEPROM memory where each byte can be programmed and erased directly by software). EEPROM memories are usually very slow compared to other types of semiconductor memories. 1.2.5 Flash EEPROM This is another version of EEPROM type memory. This type of memory is becoming popular recently and is used in many microcontrollers to store the program data. The data on a Flash EEPROM is erased and then re-programmed using a programming device. The entire contents of the memory should be erased and then re-programmed. Flash EEPROMs are usually very fast. One important distinction between a microcontroller and a microprocessor is that a microcontroller has special hardware in the form of input/output (I/O) ports for dealing with the outside world. I/O ports allow external signals and devices to be connected to the microcontroller. These ports are usually organized into groups of 8 bits and each group is given a name. For example, the PIC16F84 microcontroller contains two I/O ports named port A and port B. It is very common to have at least 8 I/O lines. Some microcontrollers have 32 or even 96 I/O lines, while some others may have only 6. On most microcontrollers the direction of the I/O port lines is programmable so that different bits can be programmed as inputs or outputs. Some microcontrollers provide bidirectional I/O ports where each port line can be used as either input or output. Some microcontrollers have open-drain outputs where the output transistors are left floating. External pull-up resistors are normally used with such output port lines. 1.3 Microcontroller features Microcontrollers from different manufacturers have different architectures and different capabilities. Some may suit to a particular application while some others may be totally unsuitable. The hardware features of microcontrollers in general are described in this section. 1.3.1 Supply Voltage Most microcontrollers operate with the standard +5 V supply. Some microcontrollers can operate at as low as +2.7 V and some will tolerate +6 V without any problems. You should check the

8051 Microcontroller Embedded System Design and PLCs Publisher : Vayu Education ISBN : 9789382174 14 1 Author : Arun Rana Type the URL : http://www.kopykitab.com/product/3185 Get this ebook