Interfacing PIC MicrocontrollersEmbedded Design by Interactive Simulation... Alternatively you can submit your request online by visiting the Elsevier web site at http://elsevier.com/loc
Trang 2Interfacing PIC Microcontrollers
Embedded Design by Interactive Simulation
Trang 4Interfacing PIC Microcontrollers
Embedded Design by Interactive Simulation
Martin Bates
Trang 5Newnes is an imprint of Elsevier
Linacre House, Jordan Hill, Oxford OX2 8DP, UK
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, UK
84 Theobald's Road, London WC1X 8RR, UK
Radarweg 29, PO Box 211, 1000 AE Amsterdam, The Netherlands
30 Corporate Drive, Suite 400, Burlington, MA 01803, USA
525 B Street, Suite 1900, San Diego, CA 92101-4495, USA
Copyright © 2006, Martin Bates Published by Elsevier 2006 All rights reserved The right of Author Name to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988
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 written permission of the publisher
Permissions may be sought directly from Elsevier's Science & Technology Rights Department in Oxford, UK: phone (+44) (0) 1865 843830; fax (+44) (0) 1865 853333; email: permissions@elsevier.com Alternatively you can submit your request online by visiting the Elsevier web site at http://elsevier.com/locate/permissions, and selecting
Obtaining permission to use Elsevier material
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress
For information on all Newnes publications
visit our web site at books.elsevier.com
Printed and bound in Great Britain
06 07 08 09 10 10 9 8 7 6 5 4 3 2 1
ISBN-13: 978-0-7506-8028-8
ISBN-10: 0-7506-80288-8
Trang 6Preface
I have my students to thank for this book Regardless of ability, each has had
a role to play The more able students have always helped, through their proj-ect work, to develop new ideas and solutions in elproj-ectronic design Some have displayed an astonishing instinctive understanding of engineering ideas, and some have been so keen to learn as to make teaching easy and rewarding There is never enough time to give each individual student the time and help they deserve So, one has to start writing to make sure that the essential tech-nical information is at least accessible, and hope that students are able to make best use of it
Another spur to writing this book has been the development of the interac-tive design software which has made the job of learning and teaching elec-tronics that much more enjoyable The Proteus software used in this book has been developed by a talented team at Labcenter Electronics in the UK, led by John Jameson and Iain Cliffe They have a world beating product, and I wanted
to make a small contribution to encouraging students and engineers to use it
It allows us to bring electronic circuits to life on the computer screen instantly
It has always been a problem in electronics that you cannot see a circuit working in the same way that a mechanical engineer can see a steam engine pumping up and down Sure, we can see the screen flickering on a television,
or an electric motor spinning, but you cannot see electrons or volts As a re-sult, it has always been that much more difficult to teach electronics Proteus
is a big step towards bringing electronics alive, as such it helps us to partici-pate more effectively in the communications and information revolution that is all around us
Trang 8This book is a sequel to my first effort ‘PIC Microcontrollers, an Introduction
to Microelectronics’ This attempted to provide a comprehensive introduction
to the subject via a single type of microcontroller, which is essentially a com-plete computer on a chip The PIC was the first widely available device to use flash memory, which makes it ideal for experimental work Flash memory al-lows the program to be replaced quickly and easily with a new version It is now commonplace, not least in our USB memory sticks, but also in a wide range of electronic systems where user data need to be retained during power down Cheap flash memory microcontrollers have transformed the teaching of microelectronics – they are re-usable and the internal architecture is fixed, making them easier to explain On the other hand, beginners can ignore the innards and treat them as a black box, and get on with the programming! The small instruction set of the PIC is also a major advantage – only 35 instruc-tions to learn Compare that with a complex processor such as the Pentium, which is quite terrifying compared with the PIC! The quality of the PIC tech-nical documentation is also a major factor
For these reasons, I set out to introduce the PIC into my teaching as widely as possible At the same time, schools, universities and hobbyists were starting to use
it, so continuity of learning was possible Since there is never enough time to teach all the detail, I decided to set out a full description of the basic PIC device, the 16F84, and some representative applications Although this particular chip is now redundant in terms of new products, the basic architecture is unchanged in current chips, so it is still a useful starting point
My students and I soon graduated to the more powerful PIC 16F877 This is now used widely as a more advanced teaching device, because it has a full complement of interfaces: analogue input, serial ports, slave port and so on, plus a good range of hardware timers A full description of this chip covers
Trang 9the inexperienced designer to create a working system relatively quickly As a result, my next step was to document the 16F877 and its applications, through the medium of interactive simulation
Proteus©from Labcenter Electronics© consists of two main parts, ISIS and ARES ARES is a layout package, which is used to create a PCB when the cir-cuit has been designed ISIS is the schematic capture and interactive simula-tion software used to create the circuit drawing and to test the circuit prior to building the real hardware SPICE is a mathematical circuit modelling system which has been developed over many years – these models can now be used to bring the drawing to life Onscreen buttons and virtual signal sources, for example, provide inputs to the circuit Output can be displayed on a voltage probe or on a virtual oscilloscope Now that we have microcontroller simula-tion as well, we really are in business The MCU can be dropped on the screen,
a program attached and debugged instantly Electronic design has never been
so easy!
It is assumed that the reader is familiar with the basics of microcontroller sys-tems, as covered in the first book This one follows on, and is divided into three main parts In the first part, the 16F877 hardware and programming and the simulation system are introduced In the second part, a range of interfacing techniques are covered; switches, keypads, displays, digital and analogue facing, data conversion and so on In the third part, power outputs, serial inter-faces, sensors, and system design examples culminate in a design for a general purpose board which provides a platform for further development
Each topic is illustrated by designs based on the 16F877, so that the reader can concentrate on the interfacing and not have to deal with different micro-controllers All the circuits are available on the associated website (see links below) All schematics were produced using ISIS – and you can produce them
to the same standard in your own reports The designs can be downloaded and run along side the book ISIS Lite, the introductory design package, can be downloaded free, with extra features available for a small registration fee The 16F877 will simulate fully, and the software changed, but the hardware cannot
be modified unless a licence is purchased for this device The microcontroller models can be purchased for institution or professional use in packages – see the Labcenter website
Get PICing!
Introduction
Trang 10Links, References and Acknowledgements
Support Website
www.picmicros.org.uk This book is supported by the above website created by the author to provide
• application examples for downloading, listed by chapter
• applications to be displayed on screen for teaching purposes
• easy access to relevant data sheets
• links to relevant manufacturers websites, Microchip and Labcenter
• links to 'PIC Microcontrollers - an Introduction to Microelectronic Systems'
If you have Proteus Professional installed and a licence for the PIC 16 series microcontrollers, you will be able to modify the hardware and application pro-gram to your own requirements
If not, Labcenter have agreed a special offer for readers of this book: a special
low cost edition of ISIS Lite schematic capture, with PROSPICE Lite simula-tion tools and PIC 16F877 licence A key will be e-mailed to you which will allow the demo programs to be fully tested and modified
If you do not have a licensed copy of Proteus, you can download the demo ver-sion and run the applications and modify the code, but not the hardware Please log on to www.picmicros.org.uk for details; also visit www.labcenter.co.uk and www.proteuslite.com for Proteus/ISIS information and downloads