CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures...
Transcript of CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures...
![Page 1: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/1.jpg)
Human Computer Interaction Laboratory
@jonfroehlich Assistant Professor Computer Science
CMSC838 Tangible Interactive Computing
Week 11 | Lecture 20 | April 9, 2015 Motors
![Page 2: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/2.jpg)
TODAY’S LEARNING GOALS
1. Learn about the three most common motor types:
DC hobby motors, servo motors, and stepper
motors
2. Learn how to interface with said motors using
Arduino
3. Learn about common motor drivers like H-Bridges
and the Arduino motor shields
![Page 3: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/3.jpg)
One More Inspiration for MP4
![Page 4: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/4.jpg)
ATMOSPHERE Created by CMSC838f Spring2014 Students Ruofei Du, Kent Wills, and Max Potasznik
[source: https://youtu.be/W6fZNOhm72c]
![Page 5: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/5.jpg)
MOTOR OVERVIEW
![Page 6: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/6.jpg)
MEET THE MOTORS Created by Jeff Feddersen of NYU ITP
[source: https://vimeo.com/84274150]
![Page 7: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/7.jpg)
Pulse Width Modulation (PWM): A Quick Refresher
![Page 8: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/8.jpg)
WHAT IS PULSE WIDTH MODULATION? Afrotechmods
[source: https://youtu.be/YmPziPfaByw]
![Page 9: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/9.jpg)
ARDUINO: ANALOG OUT
[sources: https://learn.sparkfun.com/tutorials/what-is-an-arduino; http://arduino.cc/en/Main/arduinoBoardUno; http://www.gammon.com.au/forum/?id=11473;
https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-uno-faq]
The Arduino UNO has 14 digital pins that can be used either as input or output (using the pinMode, digitalWrite, and digitalRead
functions). The pins operate at 5 volts. Each pin can provide or receive a maximum of 40mA and has an internal pull-up resistor,
which is disconnected by default, of 20-50kOhms.
14 digital I/O pins: these pins can be used for either input or output (set the mode using the pinMode function). Some pins have special functions. For example, pins with the ‘~’ symbol can be used to simulate analog output using pulse-width modulation (PWM). Other special functions are marked on this slide.
Six of the Digital I/O pins can be configured for analog out (pins 3, 5, 6, 9, 10, & 11 on the Uno): Any pin with a ‘~’ prefix can simulate analog output using 8-bit PWM with the analogWrite() function
![Page 10: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/10.jpg)
ARDUINO ANALOGWRITE USES PULSE WIDTH MODULATION (PWM) The Arduino simulates analog output using PWM, which is very useful for controlling motors! Assume we are
controlling analog pin 3.
Approximately approximately every 1/490 of a second (490Hz), the Arduino generates a PWM pulse. The length of this pulse is controlled by the ‘analogWrite’ function. So, analogWrite(0) will not produce a pulse, analogWrite(128) creates a pulse that lasts half of the cycle, and analogWrite(255) creates a pulse that lasts all the way until the next pulse (i.e., the output is on all the time)
analogWrite(3, 13)
5% duty cycle
Mean output: ~0.25V
analogWrite(3, 128)
50% duty cycle
Mean output: ~2.5V
analogWrite(3, 225)
90% duty cycle
Mean output: ~4.5V
[sources: http://arduino.cc/en/Reference/analogWrite; http://arduino.cc/en/Tutorial/PWM; https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds/theory-pwm]
![Page 11: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/11.jpg)
In-Class Exercises
![Page 12: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/12.jpg)
IN-CLASS EXERCISES Today, we are going to walk through multiple motor exercises in class to familiarize ourselves with different types of
motors and motor driver circuitry (e.g., H-Bridges and motor shields).
DC Motors and H-Bridges Learn about the simplest type of motor—the DC hobby motor—and how to use an H-Bridge to control the motor’s direction. http://goo.gl/DShDLJ
Servo Motors Servo motors use PWM for precise control of angular position, velocity, and acceleration. Servo’s also contain additional sensor circuity to sense position. http://goo.gl/aNJeKm
Stepper Motors Stepper motors divide a motor’s full rotation into “steps”—the motors position can be precisely controlled with these steps (assuming the maximum load is not exceeded). Unlike servor motors, typical steppers do not have built-in position feedback circuitry. http://goo.gl/TqxDsI
[sources: https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors; https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/parts; https://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors]
![Page 13: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/13.jpg)
Motor Drivers
![Page 14: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/14.jpg)
ADAFRUIT EXERCISES USE A L293D H-BRIDGE, WHICH IS EQUIVALENT TO THE SN754410
[source: https://www.sparkfun.com/products/315]
![Page 15: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/15.jpg)
SPARKFUN EASYDRIVER: STEPPER MOTOR DRIVER
![Page 16: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/16.jpg)
ARDUINO MOTOR SHIELDS Because many motors have high current requirements (higher than individual ports can support on the arduino)
and can cause problems with voltage spikes when a motor turns on and off, motor shields have become popular,
easy-to-use boards for working with motors.
Sparkfun Ardumoto Motor Shield: $24.95 Uses a L298 H-Bridge IC to control two DC motors up to 2A per channel https://www.sparkfun.com/products/9815
Adafruit Motor Shield v2: $19.95 Drives up to 4 DC motors or 2 stepper motors using transistor-based drivers with 1.2A per channel and 3A peak current and a fully dedicated PWM driver chip http://www.adafruit.com/product/1438
![Page 17: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/17.jpg)
ADAFRUIT MOTOR SHIELD V2 TUTORIAL
[source: https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/overview]
![Page 18: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/18.jpg)
Slip Rings
![Page 19: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/19.jpg)
FLASHGEAR Created by CMSC838f Students Jonggi Hong and Karthik Badam
[source: http://cmsc838f-s15.wikispaces.com/FlashGear]
![Page 20: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/20.jpg)
At first glance, it may seem like the same long wires go from the
Arduino to the LEDs
![Page 21: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/21.jpg)
It’s actually two sets of wires connected through a special device called a
slip ring
These wires rotate freely
![Page 22: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/22.jpg)
HOW DO SLIP RINGS WORK?
Output
[source: http://www.bgbinnovation.com/engineeringAnimation.html]
![Page 23: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/23.jpg)
SLIP RING WITH FLANGE Sold by Adafruit: http://adafru.it/736
[source: https://vimeo.com/38377598]
![Page 24: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/24.jpg)
ADAFRUIT SLIP RING EXAMPLES You can purchase slip rings in all sorts of varieties/configurations—a few different examples are listed below.
[source: adafruit.com]
6-Wire Slip Ring: $14.95 22mm diameter, 6 wires, max 240V @ 2A http://www.adafruit.com/products/736
12-Wire Slip Ring: $19.95 22mm diameter, 12 wires, max 240V @ 2A http://www.adafruit.com/products/1196
12-Wire Miniature Slip Ring: $24.95 12mm diameter, 12 wires, max 240V @ 2A http://www.adafruit.com/products/1195
![Page 25: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/25.jpg)
![Page 26: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/26.jpg)
A BIT MORE ON SLIP RINGS The ITP Vimeo Channel has a quick 3 minute video on slip rings including using a barrel audio jacks or barrel
power connectors for simple slip rings that only need a few connections
[source: http://www.bgbinnovation.com/engineeringAnimation.html]
![Page 27: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/27.jpg)
More Great Resources
![Page 28: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/28.jpg)
NYU ITP PHYSICAL COMPUTING VIDEO SERIES The NYU ITP Video series is now up to 74 videos (all short, ~5 min high-quality videos). The following are related
to motors, which I encourage you to watch. The images/thumbnails are clickable.
[source: https://vimeo.com/channels/pcomp/103165443]
![Page 29: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/29.jpg)
NYU ITP VIDEO SERIES: BASIC CIRCUITS TO DRIVE MOTORS These videos cover basic ICs, like transistors and H-Bridges, that are commonly used to drive motors. The
thumbnails are clickable.
Intro to Using Transistors for Motors (3:53) Using a transistor and an external power supply to control a ‘high load’ motor
H-Bridges (4:27) An H-Bridge is an IC that enables you to reverse your supply voltage (and thus dynamically control a motor’s direction).
High Current Loads (5:12) How to use relays and transistors to control ‘high loads’ like motors
![Page 30: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/30.jpg)
Servo Motor (10:54) Basic introduction to servo motors
NYU ITP VIDEO SERIES: SERVO MOTORS A servo motor allows for precise control of angular position, velocity, and acceleration. A servo consists of a motor coupled
to a sensor for position feedback.
![Page 31: CMSC838 Week 11 | Lecture 20 | April 9, 2015 › class › spring2015 › cmsc838f-sp15 › lectures › C… · Human Computer Interaction Laboratory @jonfroehlich Assistant Professor](https://reader033.fdocuments.in/reader033/viewer/2022060412/5f11188167aa9a7a70707859/html5/thumbnails/31.jpg)
NYU ITP VIDEO SERIES: STEPPER MOTORS A stepper motor is a brushless DC electric motor that divides a rotation into equal steps. The motor ’s position can be
commanded to move and hold at any of these steps without a feedback sensor. The thumbnails below are clickable.
[source: https://vimeo.com/channels/pcomp/103165443; http://en.wikipedia.org/wiki/Stepper_motor]
Stepper Motors: Types (3:01) Covers different types of stepper motors (5-wire stepper, 8-wire stepper, etc.)
Stepper Motors: Unipolar Steppers (5:34) Covers different types of stepper motors (5-wire stepper, 8-wire stepper, etc.)
Stepper Motors: Bipolar w/H-Bridge (3:14) Using an H-Bridge with Bipolar (4-wire) stepper motors.
Stepper Motors: Dedicated IC Drivers (6:54) To get the most out of a stepper motor, you will want to use a dedicated stepper motor IC.