ebook img

Intelligent sensor design using the microchip dsPIC PDF

303 Pages·2007·5.405 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Intelligent sensor design using the microchip dsPIC

Intelligent Sensor Design Using the Microchip dsPIC® This Page Intentionally Left Blank Intelligent Sensor Design Using the Microchip dsPIC® by Creed Huddleston AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Newnes is an imprint of Elsevier Newnes is an imprint of Elsevier 30 Corporate Drive, Suite 400, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2007, Elsevier Inc. 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 written permission of the publisher. Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: [email protected]. You may also complete your request on-line via the Elsevier homepage (http://elsevier.com), by selecting “Support & Contact,” then “Copyright and Permission” and then “Obtaining Permissions.” Recognizing the importance of preserving what has been written, Elsevier prints its books on acid-free paper whenever possible. Library of Congress Cataloging-in-Publication Data Application submitted British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library. ISBN-13: 978-0-7506-7755-4 ISBN-10: 0-7506-7755-4 For information on all Newnes publications visit our website at www.books.elsevier.com 06 07 08 09 10 10 9 8 7 6 5 4 3 2 1 Printed in the United States of America Certain materials contained herein are reprinted with the permission of Microchip Technology, Inc. No further reprints or reproductions may be made of said materials without Microchip Technology Inc.’s prior written consent. dsPIC, MPLAB, Microchip, dsPICDEM, and dsPICworks are trademarks or registered trademarks of Microchip Technology, Inc. “Implementing Intelligent Sensors Using the Microchip dsPIC” is an inde- pendent book and is not affiliated with, nor has it been authorized, sponsored, or otherwise approved by Microchip. This book is lovingly dedicated to my incredible wife Lisa and my three wonderful children, Kate, Beth, and Dan. We are truly blessed to be a family, a fact I refl ect upon often. The book is also dedicated to my sister Sarah, whose tremendous laugh I’ll always remember and who probably would have been stunned (but hopefully pleased) to see her name here. This Page Intentionally Left Blank Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii What’s on the CD-ROM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xix Chapter 1: What Are Intelligent Sensors, and Why Should I Care about Them? . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Conventional Sensors Aren’t Perfect . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 First Things First—Digitizing the Sensor Signal . . . . . . . . . . . . . . . . . .7 1.3 Next Step—Add Some Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4 Finish Up with Quick and Reliable Communications . . . . . . . . . . . . 8 1.5 Put It All Together, and You’ve Got an Intelligent Sensor . . . . . . . . . . 9 1.6 Why Don’t We Make Everything Intelligent? . . . . . . . . . . . . . . . . . . 11 1.7 Real-world Examples of Intelligent Sensors . . . . . . . . . . . . . . . . . . . 13 1.8 Outline of the Remainder of the Book . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 2: Intuitive Digital Signal Processing . . . . . . . . . . . . . 21 2.1 Foundational Concepts for Signal Processing . . . . . . . . . . . . . . . . . . 21 2.2 Issues Related to Signal Sampling . . . . . . . . . . . . . . . . . . . . . . . . . .44 2.3 How to Analyze a Sensor Signal Application . . . . . . . . . . . . . . . . . .47 2.4 A General Sensor Signal-processing Framework . . . . . . . . . . . . . . . .48 2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Chapter 3: Underneath the Hood of the dsPIC DSC. . . . . . . . . 53 3.1 The dsPIC DSC’s Data Processing Architecture . . . . . . . . . . . . . . . . 55 3.2 Interrupt Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 vii viii Contents 3.3 The On-chip Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Chapter 4: Learning to be a Good Communicator . . . . . . . . . . 99 4.1 Types of Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 4.2 Communication Options Available on the dsPIC30F . . . . . . . . . . 106 4.3 High-level Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 4.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Chapter 5: A Basic Toolkit for the dsPIC DSC . . . . . . . . . . . . . 137 5.1 The Application Test Bed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 5.2 Overview of the Firmware Framework . . . . . . . . . . . . . . . . . . . . . 138 5.3 Implementation of the Framework Modules . . . . . . . . . . . . . . . . .149 5.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Chapter 6: Sensor Application—Temperature Sensor . . . . . . 161 6.1 Types of Temperature Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 6.2 Key Aspects of Temperature Measurement . . . . . . . . . . . . . . . . . . . 167 6.3 Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 6.4 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 6.5 Firmware Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 6.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 Chapter 7: Sensor Application—Pressure and Load Sensors . . 209 7.1 Types of Load and Pressure Sensors . . . . . . . . . . . . . . . . . . . . . . . . . .209 7.2 Key Aspects of Load Measurement . . . . . . . . . . . . . . . . . . . . . . . . 212 7.3 Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 7.4 Firmware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 7.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Chapter 8: Sensor Application—Flow Sensors . . . . . . . . . . . . 229 8.1 Types of Flow Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 8.2 Key Aspects of Flow Measurement . . . . . . . . . . . . . . . . . . . . . . . . 232 8.3 Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 8.4 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .243 8.5 Firmware Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 8.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Contents ix Chapter 9: Where Are We Headed? . . . . . . . . . . . . . . . . . . . . 253 9.1 Technology Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 9.2 Economic Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 9.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Appendix A: Software on the Included CD-ROM . . . . . . . . . . 265 A.1 On-disk Website of Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 A.2 Source Code for the Three Applications . . . . . . . . . . . . . . . . . . . . . . .266 Appendix B: Initialization of the dsPIC DSC and the System Start-up Code . . . . . . . . . . . . . . . . . . . . . 267 Appendix C: Buffered, Interrupt-driven Serial I/O . . . . . . . . . 271 C.1 Pseudo-code for the Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . .273 C.2 System Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .273 C.3 Reading Data From the Interface . . . . . . . . . . . . . . . . . . . . . . . . . . .273 C.4 Writing Data to the Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.