1. Trang chủ
  2. » Công Nghệ Thông Tin

Newnes, PIC basic projects 30 projects using PIC BASIC and PIC BASIC PRO (2006) spy 0750668792

378 131 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Cover

  • Contents

  • 1 Microcontroller systems

  • 2 The PIC microcontroller family

  • 3 PIC microcontroller project development

  • 4 PicBasic and PicBasic Pro programming

  • 5 PicBasic and PicBasic Pro projects

  • Index

Nội dung

PIC BASIC Projects This page intentionally left blank PIC BASIC Projects 30 Projects Using PIC BASIC and PIC BASIC PRO By Dogan Ibrahim AMSTERDAM • BOSTON • HEIDELBERG • LONDON • NEW YORK • OXFORD PARIS • SAN DIEGO • SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO This eBook does not include ancillary media that was packaged with the printed version of the book Linacre House, Jordan Hill, Oxford OX2 8DP, UK 30 Corporate Drive, Suite 400, Burlington, MA 01803, USA Copyright © 2006 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 Notice No responsibility is assumed by the publisher for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions or ideas contained in the material herein Because of rapid advances in the medical sciences, in particular, independent verification of diagnoses and drug dosages should be made British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: 2006927674 ISBN-10: 0-75-066879-2 For information on all publications visit our web site at http://books.elsevier.com Trademarks/Registered Trademarks PIC is a registered trademark of Microchip Technology Inc All brand names mentioned in this book are protected by their respective trademarks and are acknowledged Typeset by Charon Tec Ltd, Chennai, India www.charontec.com Printed and bound in Great Britain, by MPG Books Ltd Contents Preface ix Microcontroller systems 1.1 Introduction 1.2 Microcontroller systems 1.2.1 RAM 1.2.2 ROM 1.2.3 EPROM 1.2.4 EEPROM 1.2.5 Flash EEPROM 1.3 Microcontroller features 1.3.1 Supply voltage 1.3.2 The clock 1.3.3 Timers 1.3.4 Watchdog 1.3.5 Reset input 1.3.6 Interrupts 1.3.7 Brown-out detector 1.3.8 Analogue-to-digital converter 1.3.9 Serial I/O 1.3.10 EEPROM data memory 1.3.11 LCD drivers 1.3.12 Analogue comparator 1.3.13 Real-time clock 1.3.14 Sleep mode 1.3.15 Power-on reset 1.3.16 Low power operation 1.3.17 Current sink/source capability 1.4 Microcontroller architectures 1.4.1 RISC and CISC 1.5 Exercises 1 6 6 7 7 8 8 9 10 10 10 10 10 10 11 11 11 The PIC microcontroller family 2.1 12-bit instruction word 2.2 14-bit instruction word 2.3 16-bit instruction word 2.4 Inside a PIC microcontroller 2.4.1 Program memory (Flash) 2.4.2 Data memory (RAM) 13 15 17 21 21 21 22 vi Contents 2.4.3 Register file map and special function registers 2.4.4 Oscillator circuits 2.4.5 Reset circuit 2.4.6 Interrupts 2.4.7 The configuration word 2.4.8 I/O interface 2.5 Exercises 22 34 40 41 42 42 47 PIC microcontroller project development 3.1 Required hardware tools 3.1.1 PC 3.1.2 PIC microcontroller programmer device 3.1.3 Solderless breadboard 3.1.4 PIC microcontroller and minimum support components 3.1.5 Power supply 3.2 Required software tools 3.2.1 Text editor 3.2.2 PicBasic and PicBasic Pro compilers 3.2.3 Programmer device software 3.3 Bundled development systems 3.4 Experimenter boards 3.5 Example project development 3.6 Other useful development tools 3.6.1 Simulators 3.6.2 In Circuit Emulators (ICE) 3.7 Exercises 3.8 Links to useful web sites 49 49 49 50 52 53 58 60 60 65 67 69 71 73 77 77 77 78 78 PicBasic and PicBasic Pro programming 4.1 PicBasic language 4.1.1 PicBasic variables 4.1.2 PicBasic mathematical and logical operations 4.1.3 PicBasic program flow control commands 4.1.4 Other PicBasic commands 4.1.5 Recommended PicBasic program structure 4.2 PicBasic Pro language 4.2.1 PicBasic Pro variables 4.2.2 Constants 4.2.3 Comments 4.2.4 Multi-statement lines 4.2.5 INCLUDE 4.2.6 DEFINE 4.2.7 Line extension 4.2.8 Accessing ports and other registers in PicBasic Pro 80 80 80 85 86 90 101 101 102 103 103 103 104 104 104 104 Contents 4.3 4.4 4.5 4.6 4.7 4.8 4.2.9 Arithmetic operators 4.2.10 PicBasic Pro commands Liquid crystal display (LCD) interface and commands 4.3.1 Parallel LCDs 4.3.2 Serial LCDs Interrupts Recommended PicBasic Pro program structure Using stepping motors Using servomotors Exercises PicBasic and PicBasic Pro projects Project – Simple flashing LED Project – Complex flashing LED Project – Flashing LED warning lights Project – Turning on odd numbered LEDs Project – Binary counting LEDs Project – Left scrolling LEDs Project – Right scrolling LEDs Project – Right-left scrolling LEDs Project – LED dice Project 10 – 7-segment LED display counter Project 11 – 7-segment LED dice Project 12 – Dual 7-segment LED display Project 13 – Dual 7-segment LED display counter Project 14 – Dual 7-segment LED event counter Project 15 – 4-digit display with serial driver – counter project Project 16 – 4-digit LED with serial driver – counter project with leading zeroes blanked Project 17 – 4-digit external interrupt-driven event counter Project 18 – 4-digit timer interrupt-driven chronograph Project 19 – Car park control system Project 20 – Seconds counter with LCD display Project 21 – LCD-based clock with hours–minutes–seconds display Project 22 – LCD-based chronometer Project 23 – LCD-based voltmeter using A/D converter Project 24 – LCD-based thermometer using A/D converter Project 25 – Serial LCD-based thermometer with external EEPROM memory Project 26 – Programmable thermometer with RS232 serial output Project 27 – Electronic organ Project 28 – Unipolar stepping motor control Project 29 – Unipolar stepping motor control using UCN5804B Project 30 – Servomotor-based mobile robot control About the CDROM Index vii 105 107 113 114 120 124 125 126 128 129 131 132 138 142 144 148 152 156 160 165 172 182 189 198 204 210 227 236 241 248 260 271 280 288 300 306 315 331 337 344 348 359 361 This page intentionally left blank Preface Microcontrollers are single-chip computers consisting of CPU (central processing unit), data and program memory, serial and parallel I/O (input/output), timers, external and internal interrupts, all integrated into a single chip that can be purchased for as little as $2.00 Microcontrollers are intelligent electronic devices used to control and monitor devices in the real world Today microcontrollers are used in most commercial and industrial equipment About 40% of microcontroller applications are in office automation, such as PCs, laser printers, fax machines, intelligent telephones, and so forth About one-third of microcontrollers are found in consumer electronics goods Products such as CD players, hi-f- equipment, video games, washing machines and cookers fall into this category The communications market, automotive market, and the military share the rest of the application areas Microcontrollers are programmed devices A program is a sequence of instructions that tell the microcontroller what to Microcontrollers have traditionally been programmed using the lowlevel assembly language of the target processor This consists of a series of instructions in the form of mnemonics The biggest disadvantage of assembly language is that microcontrollers from different manufacturers have different assembly languages and the user is forced to learn a new language every time a new processor is chosen Assembly language is also difficult to work with, especially during the development, testing, and maintenance of complex projects The solution to this problem has been to use a high-level language to program microcontrollers A high-level language consists of easy to understand, more meaningful series of instructions This approach makes the programs more readable and also portable The same high-level language can usually be used to program different types of microcontrollers Testing and the maintenance of microcontroller-based projects are also easier when high-level languages are used This book is about programming microcontrollers using a high-level language The PIC family of microcontrollers is chosen as the target microcontroller PIC is currently one of the most popular microcontrollers used by many engineers, technicians, students, and hobbyists PIC microcontrollers are manufactured in different sizes and in varying complexity These microcontrollers incorporate a RISC (reduced instruction set computer) architecture and there is only a small set of instructions that the user has to learn Also, the power consumption of PIC microcontrollers is very low and this is one of the reasons which make these microcontrollers popular in portable hand-held applications In this book, PicBasic and PicBasic Pro languages are used to program PIC microcontrollers BASIC is one of the oldest and widely known high-level programming languages Both PicBasic and PicBasic Pro have been developed by MicroEngineering Labs Inc PicBasic is a low-cost compiler and is aimed at the lower end of the market, mainly for students and the hobby market .. .PIC BASIC Projects This page intentionally left blank PIC BASIC Projects 30 Projects Using PIC BASIC and PIC BASIC PRO By Dogan Ibrahim AMSTERDAM • BOSTON... 77 78 78 PicBasic and PicBasic Pro programming 4.1 PicBasic language 4.1.1 PicBasic variables 4.1.2 PicBasic mathematical and logical operations 4.1.3 PicBasic program flow control commands 4.1.4... and commands 4.3.1 Parallel LCDs 4.3.2 Serial LCDs Interrupts Recommended PicBasic Pro program structure Using stepping motors Using servomotors Exercises PicBasic and PicBasic Pro projects Project

Ngày đăng: 19/06/2018, 14:45

TỪ KHÓA LIÊN QUAN

w