ebook img

Fast and Effective Embedded Systems Design. Applying the ARM mbed PDF

479 Pages·2012·31.075 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 Fast and Effective Embedded Systems Design. Applying the ARM mbed

Please visit the Companion Website to Fast and Effective Embedded Systems Design www.embedded-knowhow.co.uk Elsevier book site The companion website contains instructor support, program examples, errata, updates on parts and answers to frequently asked questions. Fast and Effective Embedded Systems Design Applying the ARM mbed Second Edition Rob Toulson Tim Wilmshurst Amsterdam(cid:129)Boston(cid:129)Heidelberg(cid:129)London(cid:129)NewYork(cid:129)Oxford(cid:129)Paris SanDiego(cid:129)SanFrancisco(cid:129)Singapore(cid:129)Sydney(cid:129)Tokyo NewnesisanimprintofElsevier NewnesisanimprintofElsevier The Boulevard,LangfordLane,Kidlington,OxfordOX51GB,UnitedKingdom 50HampshireStreet,5thFloor,Cambridge,MA02139,UnitedStates Copyright©2017RTSixtyLtd.andTimWilmshurst. PublishedbyElsevierLtd.Allrightsreserved. Nopart ofthispublicationmaybereproduced ortransmittedinanyformorbyanymeans,electronic or mechanical, includingphotocopying,recording,oranyinformationstorageand retrievalsystem,without permission inwriting fromthepublisher.Detailsonhowtoseekpermission,furtherinformationaboutthe Publisher’spermissionspolicies andourarrangementswithorganizationssuchastheCopyrightClearance Center andtheCopyrightLicensingAgency,canbefoundatourwebsite:www.elsevier.com/permissions. Thisbookandtheindividualcontributionscontainedinitare protected undercopyrightbythePublisher(other thanasmaybenotedherein). Notices Knowledgeandbestpracticeinthisfieldareconstantly changing.Asnewresearchandexperiencebroadenour understanding, changesinresearchmethods,professionalpractices, ormedicaltreatment maybecome necessary. Practitioners andresearchersmust alwaysrelyontheirownexperience andknowledgeinevaluatingandusing anyinformation,methods,compounds,orexperimentsdescribedherein.Inusingsuchinformationormethods theyshouldbemindfuloftheirownsafetyand thesafetyofothers,includingpartiesforwhomtheyhavea professional responsibility. Tothefullestextentofthelaw,neitherthePublishernortheauthors,contributors,oreditors,assumeany liabilityforanyinjuryand/ordamagetopersonsorpropertyasamatterofproductsliability,negligenceor otherwise,orfromanyuseoroperationofanymethods,products,instructions,orideascontainedinthe material herein. LibraryofCongressCataloging-in-Publication Data Acatalogrecordforthisbookisavailablefrom theLibraryofCongress British LibraryCataloguing-in-PublicationData Acatalogue recordforthisbookisavailablefrom theBritishLibrary ISBN:978-0-08-100880-5 ForinformationonallNewnespublications visitourwebsite athttps://www.elsevier.com/ Publisher:Jonathan Simpson Acquisition Editor:TimPitts Editorial ProjectManager:CharlieKent ProductionProjectManager:Susan Li Designer: MarkRogers TypesetbyTNQBooksandJournals Introduction It’s now just 4years since the first edition of this book was published. Microprocessors are of course still everywhere, providing “intelligence” in cars, mobile phones, household and office equipment, TVs and entertainment systems, medical products, aircraftdthe list seems endless. Those everyday products, where a microprocessor is hidden inside to add intelligence, are called embedded systems. It is still not so long ago when designers of embedded systems had to be electronics experts, or software experts, or both. Nowadays, with user-friendly and sophisticated building blocks available for our use, both the specialist and the beginner can quickly engage in successful embedded system design. One such building block is the mbed, launched in 2009 by the renowned computer giant ARM. The mbed is the central theme of this book; through it, all the main topics of embedded system design are introduced. Technology has continued its onward gallop since the first edition of this book was published in 2012, and there is already much in that edition which needs updating, rewriting, or replacing. The single mbed device that we based the first book around has spawned an extended family of “mbed-enabled” devices, an “ecosystem” of products, development tools, community support has emerged, and the phrase “Internet of Things” (IoT) is on everyone’s lips. The company who created the mbed, ARM, has meanwhile repositioned the mbed concept, notably by placing it at the heart of their IoT developments. The original mbed device is, however, still there, well-used and well- established, in industry, among hobbyists, and in colleges and universities worldwide. Its concept and ecosystem are, however, changing and developing very fast. In light of this exciting but rapidly changing field, we as authors made a number of decisions regarding this second edition. We decided that it should still be based around the original mbed, now more commonly called the LPC1768 mbed. This clever device is after all well-established and has much life left in it. We further recognized that the first edition may have tried to cover too many things, with too little depth. Therefore in this edition, we remove a few topics, but aim to ensure that each remaining one gets fuller treatment. Overall it has grown by one chapter, and is a bigger book; we hope that the increased depth will be appreciated by the reader. In retaining the focus just described, we are xv Introduction deliberately choosing to exclude some important mbed-related topics, notably around IoT developments. We anticipate making these the subject of further writing projects. Broadly, the book divides into two parts, as it did with the first edition. Chapters 1 to 10 provide a wide-ranging introduction to embedded systems, using the mbed and demonstrating how it can be applied to rapidly produce successful embedded designs. These chapters aim to give full support to a reader, moving you through a carefully constructed series of concepts and exercises. These start from basic principles and simple projects, to more advanced system design. The final six chapters cover more advanced or specialist topics, building on the foundations laid in the early chapters. The pace here may be a little faster, and you may need to contribute more background research. All this book asks of you at the very beginning is a basic grasp of electrical/electronic theory. The book adopts a “learning through doing” approach. To make best use of it, you will need an mbed, an internet-connected computer, and the various additional electronic components identified through the book. You won’t need every single one of these if you choose not to do a certain experiment or book section. You’ll also need a digital voltmeter, and ideally access to an oscilloscope. Each chapter is based around a major topic in embedded systems. Each has some theoretical introduction and may have more theory within the chapter. The chapter then proceeds as a series of practical experiments. Have your mbed ready to hook up the next circuit, and download and compile the next example program. Run the program, and aim to understand what’s going on. As your mbed confidence grows, so will your creativity and originality; start to turn your own ideas into working projects. You will find that this book rapidly helps you to: (cid:129) understand and apply the key aspects of embedded systems, (cid:129) understand and apply the key aspects of the ARM mbed, (cid:129) learn from scratch, or develop your skills in embedded C/C++ programming, (cid:129) develop your understanding of electronic components and configurations, (cid:129) understand how the mbed can be applied in some of the most exciting and innovative intelligent products emerging today, (cid:129) produce designs and innovations you never thought you were capable of! If you get stuck, or have questions, support is available for all readers through the book website, the mbed website, or by email discussion with the authors. If you are a university or college instructor, then this book offers a “complete solution” to your embedded systems course. Both authors are experienced university lecturers, and had your students in mind when writing this book. The book contains a structured sequence of practical and theoretical learning activity. Ideally you should equip every student or xvi Introduction student pair with an mbed, prototyping breadboard and component kit. These are highly portable; so development work is not confined to the college or university lab. Later in the course, students will start networking their mbeds together. Complete Microsoft PowerPoint presentations for each chapter are available to instructors via the book website, as well as answers to Quiz questions, and example solution code for the exercises and mini projects. This book is appropriate for any course or module which wants to introduce the concepts of embedded systems, in a hands-on and interesting way. Because the need for electronic theory is limited, the book is accessible to those disciplines which would not normally aim to take embedded systems. The book is meant to be accessible to Year 1 undergraduates, though we expect it will more often be used in the years which follow. Students are likely to be studying one of the branches of engineering, physics, or computer science. The book will also be of interest to the practicing professional and the hobbyist. This book is written by Rob Toulson, Professor of Creative Industries at the University of Westminster, and Tim Wilmshurst, Head of Electronics at the University of Derby. After completing his PhD, Rob spent a number of years in industry, where he worked on digital signal processing and control systems engineering projects, predominantly in audio and automotive fields. He then moved to an academic career, where his main focus is now in developing collaborative research between the technical and creative industries. Tim led the Electronics Development Group in the Engineering Department of Cambridge University for a number of years, before moving to Derby. His design career has spanned much of the history of microcontrollers and embedded systems. Aside from our shared interest in embedded systems, we both share an interest in music and music technology. The book brings together our wide range of experiences. Having planned the general layout of the book, and after some initial work, we divided the chapters between us. Tim took responsibility for most of the early ones and issues relating to electronic and computing hardware. Rob worked on programming aspects, and Internet and Audio applications. This division of labor was mainly for convenience, and at publication we both take responsibility for all the chapters! Because Tim has written several books on embedded systems in the past, a few background sections and diagrams have been taken from these and adapted, for inclusion in this book. There seemed no point in “reinventing the wheel” where background explanations were needed. xvii CHAPTER 1 Embedded Systems, Microcontrollers, and ARM 1.1 Introducing Embedded Systems 1.1.1 What Is an Embedded System? We’re all familiar with the idea of a desktop or laptop computer, and the amazing processing that they can do. These computers are general purpose; we can get them to do different things at different times, depending on the application or program we run on them. At the very heart of such computers we would find a microprocessor, a tiny and fantastically complicated electronic circuit which contains the core features of a computer. All of this is fabricated on a single slice of silicon, called an integrated circuit (IC). Some people, particularly those who are not engineers themselves, call these circuits microchips, or just chips. What is less familiar to many people is the idea that instead of putting a microprocessor in a general-purpose computer, it can also be placed inside a product which has nothing to do with computing, like a washing machine, toaster, or camera. The microprocessor is then customized to control that product. The computer is there, inside the product; but it can’t be seen, and the user probably doesn’t even know it’s there. Moreover, those add- ons which we normally associate with a computer, like a keyboard, screen, or mouse, are also nowhere to be seen. We call such products embedded systems, because the microprocessor that controls them is embedded right inside. Because such a microprocessor is developed to control the device, in many cases, those used in embedded systems have different characteristics from the ones used in more general- purpose computing machines. We end up calling these embedded ones microcontrollers. Though much less visible than their microprocessor cousins, microcontrollers sell in far greater volume, and their impact has been enormous. To the electronic and system designer they offer huge opportunities. Embedded systems come in many forms and guises. They are extremely common in the home, the motor vehicle, and the workplace. Most modern domestic appliances, like a washing machine, dishwasher, oven, central heating, and burglar alarm, are embedded systems. The motor car is full of them, in engine management, security (for example, locking and antitheft devices), air-conditioning, brakes, radio, and so on. They are found FastandEffectiveEmbeddedSystemsDesign.http://dx.doi.org/10.1016/B978-0-08-100880-5.00001-3 Copyright©2017RTSixtyLtd.andTimWilmshurst.PublishedbyElsevierLtd.Allrightsreserved. 3 4 Chapter 1 across industry and commerce, in machine control, factory automation, robotics, electronic commerce, and office equipment. The list has almost no end, and it continues to grow. Fig. 1.1 expresses the embedded system as a simple block diagram. There is a set of inputs from the controlled system. The embedded computer, usually a microcontroller, runs a program dedicated to this application, permanently stored in its memory. Unlike the general-purpose desktop computer, which runs many programs, this is the only program it ever runs. Based on information supplied from the inputs, the microcontroller computes certain outputs, which are connected to actuators and other devices within the system. The actual electronic circuit, along with any electromechanical components, is often called the hardware; the program running on it is often called the software. Aside from all of this, there may also be interaction with a user, for example via a keypad and display, and there may be interaction with other subsystems elsewhere, though neither of these is essential to the general concept. One other variable will affect all that we do in embedded systems, and this is time, represented therefore as a dominating arrow which cuts across the figure. We will need to be able to measure time, make things happen at precisely predetermined times, generate data streams or other signals with a strong time dependence, and respond to unexpected things in a timely fashion. This chapter introduces and reviews many concepts relating to computers, microprocessors, microcontrollers, and embedded systems. It does this in overview form, to give a platform for further learning. We return to most concepts in later chapters, building on them and adding detail. More details can also be found in Ref. [1]. (User Interface) TIME EEmmbbeeddddeedd CCoommpuptuetrer Input Output SSooffttwwaarree Variables Variables HHaarrddwwaarree (Link to other Systems) Figure 1.1 The embedded system. Embedded Systems, Microcontrollers, and ARM 5 1.1.2 An Example Embedded System A snack vending machine is a good example of an embedded system. One is represented in Fig. 1.2, in block diagram form. At its heart is a single microcontroller. As the diagram shows, this accepts a number of input signals, from the user keypad, the coin counting module, and from the dispensing mechanism itself. It generates output signals dependent on those inputs. A hungry customer may approach the machine and start jabbing at the buttons, or feeding in coins. In the first case, the keypad sends signals back to the microcontroller, so that it can recognize individual keys pressed and then hook these key values together to decipher a more complex message. The coin counting module will also send information telling the amount of money paid. The microcontroller will attempt to make deductions from the information it’s receiving, and will output status information on the display. Has a valid product been selected? Has enough money been paid? If yes, then it will energize an actuator to dispense the product. If no, it will display a message asking for more money, or a reentry of the product code. A good machine will be ready to give change. If it does dispense, there will be sensors on the mechanism to ensure that the chosen product is available, and finally that the action is complete. These are shown in the diagram as gate position sensors. A bad machine (and haven’t we all met these?) will give annoying or useless messages on its display, demand more money when you know you’ve given the Inputs Outputs gate actuators keypad gate position microcontroller liquid sensors crystal display mobile coin comms. counter module module Figure 1.2 Vending machine embedded system. 6 Chapter 1 right amount, or leave that chocolate bar you desperately want teetering on a knife-edge, not dropping down into the dispensing tray. What’s been described so far is a fairly conventional machine. We can, however, take it further. In modernvending systems, there might be a mobile communications feature which allows the vending machine to report directly to the maintenance team if a fault is diagnosed; they will then come and fix the fault. Similarly, the machine might report stock levels through mobile or internet communications to allow the service team to visit and replenish whenever supplies run low. This simple example reflects exactly the diagram of Fig. 1.1. The microcontroller accepts input variables, makes calculations and decisions with this, and generates outputs in response. It does this in a timely manner, and correct use of time is implicit in these actions. There is in this case a user interface, and in a modern machine there is a network interface. While the above paragraphs seem to be describing the physical hardware of the system, in fact it’s all controlled by the software that the designer has written. This runs in the microcontroller and determines what the system actually does. 1.1.3 A Second Example System: A Word on Control Systems and the Segway In this book we will see a number of control systems. Such systems are very common and range from home to office equipment, industrial machinery to cars, autonomous vehicles, robotics, toys, flying drones, and aerospace. Think of how much control there must be in a humble inkjet printer: drawing in and guiding the paper, shooting the print cartridges backward and forward with extraordinary precision, and squirting just the right amount of ink, of the right color, in just the right place. The accuracy of a control system is a very important aspect as errors and inaccuracy can have huge impact on performance, wear, and safety. Closed loop control systems employ internal error analysis to achieve accurate control of actuators, given continuous sensor input readings. Usually, this means that the system measures the position of an actuator, compares it with a signal representing the position it’s meant to be at (called the setpoint), and from this information tries to move the actuator to the correct position. The fundamental components of a closed loop system are therefore an actuator which causes some form of action, a sensor which measures the effect of the action, and a controller to compute the difference between the setpoint and the actual position. Although we say position, any physical variable can be controlled. For example, a heater element might be used to heat an oven to a specified temperature, and a temperature sensor used to measure the actual heat of the oven. If the closed loop (cid:1) controller tells the oven to be at 200 C, then the heater will provide heat until the sensor (cid:1) signals to the controller that 200 C has been achieved. If the sensor measurement shows

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.