Motors for Makers: a Guide to Steppers, Servos, And
Total Page:16
File Type:pdf, Size:1020Kb
ptg16386157 MOTORS for MAKERS A Guide to Steppers, Servos, and Other Electrical Machines ptg16386157 Matthew Scarpino 800 East 96th Street Indianapolis, Indiana 46240 MOTORS FOR MAKERS: A GUIDE Editor-in-Chief TO STEPPERS, SERVOS, AND OTHER Greg Wiegand ELECTRICAL MACHINES Executive Editors Rick Kughen Copyright © 2016 by Pearson Education Bernard Goodwin All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, Development Editor photocopying, recording, or otherwise, without written permission from Greg Kettell the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the Managing Editor preparation of this book, the publisher and author assume no responsibility for Kristy Hart errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. Senior Project Editor ISBN-13: 978-0-13-403283-2 Betsy Gratner ISBN-10: 0-13-403283-7 Copy Editor Library of Congress Control Number: 2015951266 Bart Reed Printed in the United States of America Indexer First Printing: December 2015 Lisa Stumpf Trademarks All terms mentioned in this book that are known to be trademarks or service Proofreader marks have been appropriately capitalized. Que Publishing cannot attest to the Leslie Joseph ptg16386157 accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Reviewers John Baichtal Warning and Disclaimer Bryan Bergeron Every effort has been made to make this book as complete and as accurate Rich Blum as possible, but no warranty or fitness is implied. The information provided is Stephen Hobley on an “as is” basis. The author and the publisher shall have neither liability James Floyd Kelly nor responsibility to any person or entity with respect to any loss or damages Pete Prodoehl arising from the information contained in this book. Paul Tan Special Sales Publishing Coordinators For information about buying this title in bulk quantities, or for special sales Michelle Housely opportunities (which may include electronic versions; custom cover designs; Cindy Teeters and content particular to your business, training goals, marketing focus, Kristen Watterson or branding interests), please contact our corporate sales department at Cover Designer [email protected] or (800) 382-3419. Mark Shirar For government sales inquiries, please contact [email protected] . Compositor For questions about sales outside the U.S., please contact Nonie Ratcliff [email protected] . CONTENTS AT A GLANCE Introduction 1 I Introduction 1 Introduction to Electric Motors 5 2 Preliminary Concepts 13 II Exploring Electric Motors 3 DC Motors 27 4 Stepper Motors 55 5 Servomotors 73 6 AC Motors 89 7 Gears and Gearmotors 113 8 Linear Motors 127 III Electrical Motors in Practice 9 Motor Control with the Arduino Mega 145 10 Motor Control with the Raspberry Pi 171 11 Controlling Motors with the BeagleBone Black 195 12 Designing an Arduino-Based Electronic Speed Control (ESC) 215 ptg16386157 13 Designing a Quadcopter 241 14 Electric Vehicles 263 IV Appendixes A Electric Generators 279 B Glossary 287 Index 293 CONTENTS Introduction 1 4 Stepper Motors 55 Who This Book Is For 2 4.1 Permanent Magnet (PM) Steppers 56 How This Book Is Organized 2 4.2 Variable Reluctance (VR) Steppers 59 Let Me Know What You Think 3 4.3 Hybrid (HY) Steppers 61 4.4 Stepper Control 63 I Introduction 4.5 Summary 71 1 Introduction to Electric 5 Servomotors 73 Motors 5 5.1 Hobbyist Servos 74 1.1 Brief History 6 5.2 Overview of Servo Control 78 1.2 Anatomy of a Motor 7 5.3 PID Control 85 1.3 Overview of Electric Motors 9 5.4 Summary 87 1.4 Goals and Structure 11 1.5 Summary 11 6 AC Motors 89 ptg16386157 6.1 Alternating Current (AC) 90 2 Preliminary Concepts 13 6.2 Overview of Polyphase Motors 91 2.1 Torque and Angular Speed 13 6.3 Asynchronous Polyphase Motors 96 2.2 Magnets 18 6.4 Synchronous Polyphase Motors 100 2.3 Equivalent Circuit Element 21 6.5 Single-Phase Motors 103 2.4 Power and Efficiency 23 6.6 AC Motor Control 106 2.5 Summary 25 6.7 Universal Motors 109 6.8 Summary 110 II Exploring Electric Motors 7 Gears and Gearmotors 113 3 DC Motors 27 7.1 Overview of Gears 113 3.1 DC Motor Fundamentals 28 7.2 Types of Gears 117 3.2 Brushed Motors 34 7.3 Gearmotors 124 3.3 Brushless Motors 42 7.4 Summary 125 3.4 Electronic Speed Control (ESC) Systems 49 8 Linear Motors 127 3.5 Batteries 51 8.1 Linear Actuators 128 3.6 Summary 53 8.2 Linear Synchronous Motors 131 8.3 Linear Induction Motors 137 Contents v 8.4 Homopolar Motors 140 12.3 Zero-Crossing Detection 225 8.5 Summary 143 12.4 Designing the Schematic 229 12.5 Board Layout 232 12.6 Controlling the BLDC 234 III Electrical Motors in Practice 12.7 Summary 239 9 Motor Control with the Arduino Mega 145 13 Designing a Quadcopter 241 9.1 The Arduino Mega 146 13.1 Frame 242 9.2 Programming the Arduino Mega 149 13.2 Propellers 243 9.3 The Arduino Motor Shield 158 13.3 Motors 248 9.4 Stepper Motor Control 162 13.4 Electronics 250 9.5 Servomotor Control 166 13.5 Construction 259 9.6 Summary 168 13.6 Summary 260 10 Motor Control with the 14 Electric Vehicles 263 Raspberry Pi 171 14.1 Electric Vehicle Conversion 264 10.1 The Raspberry Pi 172 14.2 Modern Electric Vehicles 267 ptg16386157 10.2 Programming the Raspberry Pi 174 14.3 Patents from Tesla Motors 272 10.3 Controlling a Servomotor 182 14.4 Summary 278 10.4 The RaspiRobot Board 186 10.5 Summary 192 IV Appendixes 11 Controlling Motors with the A Electric Generators 279 BeagleBone Black 195 A.1 Overview 280 11.1 The BeagleBone Black (BBB) 196 A.2 DC Generators 281 11.2 Programming the BBB 198 A.3 AC Generators 283 11.3 PWM Generation 205 A.4 Summary 286 11.4 The Dual Motor Controller Cape (DMCC) 207 11.5 Summary 213 B Glossary 287 12 Designing an Arduino-Based Index 293 Electronic Speed Control (ESC) 215 12.1 Overview of the ESC Design 216 12.2 Switching Circuitry 218 ABOUT THE AUTHOR Matthew Scarpino is an engineer with more than 12 years of experience designing hardware and software. He has a master’s degree in electrical engineering and is an Advanced Certified Interconnect Designer (CID+). He is the author of Designing Circuit Boards with EAGLE: Make High-Quality PCBS at Low Cost. WE WANT TO HEAR FROM YOU! As the reader of this book, you are our most important critic and commentator. We value your opin- ion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way. We welcome your comments. You can email or write to let us know what you did or didn’t like about this book—as well as what we can do to make our books better. Please note that we cannot help you with technical problems related to the topic of this book. When you write, please be sure to include this book’s title and author as well as your name and email address. We will carefully review your comments and share them with the author and editors who worked on the book. Email: [email protected] Mail: Que Publishing ptg16386157 ATTN: Reader Feedback 800 East 96th Street Indianapolis, IN 46240 USA READER SERVICES Register your copy of Motors for Makers at informit.com for convenient access to downloads, updates, and corrections as they become available. To start the registration process, go to informit.com/register and log in or create an account.* Enter the product ISBN, 9780134032832, and click Submit. Once the process is complete, you will find any available bonus content under “Registered Products.” *Be sure to check the box that you would like to hear from us in order to receive exclusive discounts on future editions of this product. INTRODUCTION When I received my master’s degree in electrical engineering in 2002, I couldn’t help but feel a little disappointed. I knew all about analog circuit theory, but I knew next to nothing about practical circuit boards. I could compute the Lorentz force in an electric motor, but I had no idea how motor controllers worked in the real world. Put simply, I could write pro- ptg16386157 grams and solve equations, but I couldn’t make anything. Shortly after I received my degree, the first Arduino boards appeared in the marketplace. Their simplicity and low cost sparked a worldwide interest in electronics, and within a few years, the Maker Movement was born. Makers aren’t interested in heavy mathematics and physics. Makers are concerned with what they can build. Whether it involves 3D print- ers or the Raspberry Pi, makers care about cool hardware, especially if it involves electronics. But makers get nervous when it comes to motors. Pre-built quadcopters are growing in popularity, but I don’t see many makers designing their own electronic speed controls (ESCs) or programming their own robotic arms. This is perfectly understandable. Motors are more complicated than other circuit elements. With motors, you don’t just have to be concerned with electrical quantities such as voltage and current; you have to think about mechanical quantities such as torque and angular speed.