ebook img

Controlling Motors: Book 3 of the Arduino Short Reads Series PDF

81 Pages·4.388 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 Controlling Motors: Book 3 of the Arduino Short Reads Series

Controlling Motors Book 3 of the Arduino Short Reads Series Gary Hallberg North Border Tech Training First Edition Copyright © 2020 Gary Hallberg and North Border Tech Training All reserved. This book or any portion thereof may not be reproduced or used in any manner whatsoever without the express written permission of the publisher except for the use of brief quotations in a book review. First Published, 2020 Contents About the Arduino Short Reads Series ..................................................................................................... 5 Foreword.................................................................................................................................................... 6 Prerequisites for this Book ........................................................................................................................ 7 Download the Code ................................................................................................................................... 8 Chapter 1: DC Motors ................................................................................................................................ 9 Parts needed for this Chapter ................................................................................................................ 9 How a DC Motor Works ........................................................................................................................ 9 Controlling A DC Motor with a Transistor ........................................................................................... 11 Transistors ........................................................................................................................................... 12 General Purpose Diodes ...................................................................................................................... 14 Capacitors ............................................................................................................................................. 15 Experiment 1: Interfacing a DC Motor using a Transistor ................................................................. 16 Pulse Width Modulation ...................................................................................................................... 19 Experiment 2: Speed Control Using PWM ......................................................................................... 20 Summary .............................................................................................................................................. 22 Chapter 2: The H-Bridge ......................................................................................................................... 23 Parts needed for this Chapter .............................................................................................................. 23 The Principles of H-Bridge Operation ................................................................................................ 23 The L293D H-Bridge ........................................................................................................................... 24 Experiment 3: Direction and Speed Control using a H-Bridge .......................................................... 26 The HX1838 Infrared Remote Control and Receiver ......................................................................... 30 Experiment 4: IR Controlled Vehicle ...................................................................................................31 Troubleshooting Experiment 4 ........................................................................................................... 44 Summary .............................................................................................................................................. 44 Chapter 3: Servo Motors ......................................................................................................................... 46 Parts needed for this Chapter .............................................................................................................. 46 What are Servos? ................................................................................................................................. 46 Servo Operation ................................................................................................................................... 47 The SG90 9G Servo .............................................................................................................................. 48 The Servo Power Supply ...................................................................................................................... 49 Experiment 5: Servo Control using a Potentiometer .......................................................................... 50 The DHT11 Temperature and Humidity Sensor ................................................................................. 52 Experiment 6: A Servo based Thermometer ....................................................................................... 53 Summary .............................................................................................................................................. 57 Chapter 4: Stepper Motors ...................................................................................................................... 58 Parts needed for this Chapter .............................................................................................................. 58 Stepper Motor Operation .................................................................................................................... 58 The NEMA-17 Bipolar Stepper Motor ................................................................................................. 60 The L298N Dual H-bridge DC Stepper Motor Controller .................................................................. 61 The 28BYJ-48 Unipolar Stepper Motor and ULN2003 Driver Board ............................................... 63 Experiment 7: Basic Control of the NEMA-17..................................................................................... 65 Experiment 8: Basic Control of the 28BYJ-48 .................................................................................... 68 Rotary Encoders ................................................................................................................................... 71 The KY-040 Rotary Encoder Module .................................................................................................. 72 Experiment 9: Controlling the 28BYJ-48 with a Rotary Encoder ...................................................... 73 Summary .............................................................................................................................................. 79 Epilogue ................................................................................................................................................... 80 About the Author ..................................................................................................................................... 81 About the Arduino Short Reads Series The idea underpinning the Arduino short reads series is to provide a comprehensive, easy to follow tutorial set and reference guide for anybody wanting to learn about Arduino and basic electronics. Having a short reads series means that students and hobbyists can select key topics of interest in the field with minimal outlay. The series aims to provide an easy introduction to all topics of interest and expand on these topics to provide a broader and deeper understanding of that focus area. The books are currently only available in Kindle format to provide a very inexpensive package backed up by video content and interactive social media. The series is aimed at youngsters and adults interested in getting into electronics and it takes a modern approach combining the use of the inexpensive software driven Arduino controller board with a multitude of sensors and discreet electronic components. The experiments in this series of books are easy to follow, inexpensive to implement and compelling for all interested in STEM education. I hope to inspire anybody looking for a future career in technology or to simply to have fun. The first book of this series looks at the Arduino microcontroller and explains its operation and purpose. Experiments look to show you how to set up the programming environment and drive LEDs as well as read input from switches, thermistors and photocells. Book 1 will give you a solid foundation of how some basic electronic components work and how to use them to make simple designs. Books 4 and 5 in this Arduino short read series are still being written but the series focuses on the following: • Book 1 – First Steps with Arduino (published) • Book 2 – Working with Displays (published) • Book 4 – Range Finding, Object Detection and Object Avoidance • Book 5 – Building a Simple Rover There will be more books to follow the first 5 covering a wide range of focus topics so watch this space! If you find this series of books useful then please leave your review and rating on Amazon. Follow North Border Tech Training on Facebook and Twitter for the latest news and insights as to how this series will develop. Foreword Book 1 of this series sets out to provide a basic understanding of the Arduino platform, how to program it and how to interface simple electronics. In this book we build on those skills in the focus area of controlling the many types of motor. I have been looking forward to writing this book. Motors and other actuators such as solenoids are an essential component in any control system and using the Arduino to control these devices is a natural marriage. Controlling motors from the Arduino does present us with some challenges in that the Arduino cannot provide the power to drive a motor directly. Therefore, we need more in the way of interfacing electronics. Furthermore, if you cut off the power from a spinning motor, its inductive properties, and the fact that it will act as a generator, will necessitate extra electronics to protect the Arduino and the interfacing circuitry. Therefore, there will be much more emphasis on the electronic engineering aspects around the Arduino and this is a positive deviation from the other books in the series. I have no doubt the skills learnt here will allow you to develop more engaging and useful projects. Without further delay let us get into the content. Prerequisites for this Book This book assumes you have read Book 1 of the series (’First Steps with Arduino’) or you already have some experience of the Arduino platform, how to set up the IDE and undertake some basic Arduino programming tasks. Basic functions such as ‘digitalRead’ and ‘digitalWrite’ are not covered here but are explained in Book 1. We will revisit Pulse Width Modulation as it is an essential technology for speed control of DC motors. Transistors too are an essential device and although they were covered in book 2, they will be covered again here as the books in this series are intended be standalone, but with the basics covered in book 1. We will introduce capacitors to readers who are new to electronics and are following this series of books sequentially. Download the Code You can download the Arduino Code for the experiments in this book from GitHub using the link below. https://github.com/ghallberg-nbtt/cautious-spoon I recommend that you do this as I have removed some of the comments from the code in the book listings to aid readability in print form. I strongly recommend that you comment your code heavily to facilitate understanding and to become familiar with best engineering practice. Chapter 1: DC Motors Direct Current or DC motors are by far the easiest type of motor to work with and at the same time they allow us to address all the issues of driving the motors from an Arduino board. They are common devices in all sorts of equipment such as toys, radio-controlled cars and DVD players. As a result, they are cheap. Therefore, they are a great place the start. Parts needed for this Chapter • Arduino Uno or clone board • Full or half size breadboard • 1 x 3-6V DC motor (<250mA power draw) • 6V battery box (4 x AA) or main adapter • 1 x PN2222 NPN Transistor • 1 x 1N4001 diode (or similar 1A general purpose diode) • 1 x 0.1uF capacitor • 1 x 1KΩ resistor • 1 x 10KΩ potentiometer • Jumper wires How a DC Motor Works We will not go too much into the science behind the operation of the motor, but we will look at the principle of operation. If you hold the thumb of your left hand straight up, then hold you index finger straight out and then hold you middle finger perpendicular to those, you will be able to visualize the physics behind the motor operation. Refer to Figure 1-1. Figure 1-1: Electromagnetic Forces Image source: The author If you place a conductor such as a copper wire in magnetic field and then pass a current through that wire a force will be asserted that will try and push the wire out of the field as depicted in Figure 1-1. We can engineer a device (a DC motor) to utilize that force and create a rotary motion. Figure 1-2 shows a simplified DC motor.

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.