Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

Similar documents
Arduino Lesson 14. Servo Motors

Servo Info and Centering

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

INTRODUCTION TO SERIAL ARM

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Arduino Lesson 16. Stepper Motors

Introduction to Arduino

Arduino Motor Shield (L298) Manual

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD Six-servo Robot Arm

Arduino Lesson 13. DC Motors. Created by Simon Monk

Microcontroller Programming Beginning with Arduino. Charlie Mooney

Theory and Practice of Tangible User Interfaces. Thursday Week 2: Digital Input and Output. week. Digital Input and Output. RGB LEDs fade with PWM

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Pulse Width Modulation Applications

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

Selecting and Implementing H-Bridges in DC Motor Control. Daniel Phan A

Work with Arduino Hardware

IR Communication a learn.sparkfun.com tutorial

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

1602 LCD adopts standard 14 pins(no backlight) or 16pins(with backlight) interface, Instruction of each pin interface is as follows:

Basic Pulse Width Modulation

ECE 495 Project 3: Shocker Actuator Subsystem and Website Design. Group 1: One Awesome Engineering

Wireless Security Camera

How to Move Canon EF Lenses. Yosuke Bando

Electronic Brick of Current Sensor

Arduino Lesson 4. Eight LEDs and a Shift Register

Ocean Controls RC Servo Motor Controller

Arduino DUE + DAC MCP4922 (SPI)

Character LCDs. Created by Ladyada. Last updated on :45:29 PM EDT

DEPARTMENT OF ELECTRONICS ENGINEERING

Arduino Lesson 1. Blink

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Timer A (0 and 1) and PWM EE3376

HOBBY SERVO FUNDAMENTALS BY: DARREN SAWICZ

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

SYSTEM 45. C R H Electronics Design

EasyC. Programming Tips

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

Arduino Lesson 9. Sensing Light

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

2013 G Miller. 3 Axis Brushless Gimbal Controller Manual

FRC WPI Robotics Library Overview

Scripting Language Reference. SimpleBGC 32bit

Chapter 4: Pulse Width Modulation

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

CHAPTER 11: Flip Flops

Home Security System for Automatic Doors

C4DI Arduino tutorial 4 Things beginning with the letter i

AN2680 Application note

H-Bridge Motor Control

Lab Experiment 1: The LPC 2148 Education Board

Chapter 8. Digital and Analog Interfacing Methods

Application Note IMU Visualization Software

Motorising the Peco Turntable - a different approach

SD21-21 Channel Servo Driver Module Power Servo's

Accurate Measurement of the Mains Electricity Frequency

RGB LED Strips. Created by lady ada. Last updated on :00:18 PM EST

Application Note AN-SERV-006

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

Introduction to Arduino

Welcome to the tutorial for the MPLAB Starter Kit for dspic DSCs

Lab 6 Introduction to Serial and Wireless Communication

Hands On ECG. Sean Hubber and Crystal Lu

8 coil stator 11 coil stator

ABACOM - netpio.

Advanced LED Controller (LED Chaser)

ANDROID BASED FARM AUTOMATION USING GR-SAKURA

DC Motor control Reversing

EET272 Worksheet Week 9

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Pulse width modulation

Pololu DRV8835 Dual Motor Driver Shield for Arduino

Electronics 5: Arduino, PWM, Mosfetts and Motors

User manual DinaSys DTC/DTS and DTC/DTZ

The self-starting solar-powered Stirling engine

Adafruit's Raspberry Pi Lesson 9. Controlling a DC Motor

2.2" TFT Display. Created by Ladyada. Last updated on :15:09 PM EDT

DCDC-USB. 6-34V 10A, Intelligent DC-DC converter with USB interface. Quick Installation Guide Version 1.0c P/N DCDC-USB

Green House Monitoring and Controlling Using Android Mobile Application

Access Control Using Smartcard And Passcode

Basic DC Motor Circuits. Living with the Lab Gerald Recktenwald Portland State University

Basic DC Motor Circuits

Building a Basic Communication Network using XBee DigiMesh. Keywords: XBee, Networking, Zigbee, Digimesh, Mesh, Python, Smart Home

ezsystem elab16m Project 1F: Alarm System (Full Project description)

Interfacing Analog to Digital Data Converters

PWM IN AVR. Developed by: Krishna Nand Gupta Prashant Agrawal Mayur Agarwal

Arduino project. Arduino board. Serial transmission

CAN-Bus Shield Hookup Guide

ISP Engineering Kit Model 300

Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial)

AMZ-FX Guitar effects. (2007) Mosfet Body Diodes. Accessed 22/12/09.

Web Camera Mouse with Smart Base: An Electrical Engineering Design Project

ABB Drives. User s Manual HTL Encoder Interface FEN-31

Mobile Satellite Solutions. A WiWorld Partner SATELLITE TV ANTENNA CONTROLLER RFM-1000/1100 TECHNICAL MANUAL STOW SEARCH

Special Lecture. Basic Stamp 2 Programming. (Presented on popular demand)

MCP4725 Digital to Analog Converter Hookup Guide

Transcription:

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board Abstract This application note is a tutorial of how to use an Arduino UNO microcontroller to control an analog Servo motor through signals sent to the Servo motor s control line. This document will provide directions for wiring the Servo motor, the Arduino UNO and cover microcontroller programming techniques to control movement of the motor. Introduction Servo motors are small controllable motors that lend to implementation in many applications. There are Servos with many different speeds, sizes and torque capabilities, but all have 3 wires, power, ground and control. Servo motors are popular with hobbyists because they are inexpensive, $15-$100, and control of Servo motors with microcontrollers is universal for all models. Servo s receive pulse width modulated (PWM) signals to determine in which manner to move. There are many ways to send this signal to the motor; this application covers how to send the desired PWM signal to the Servo motor using the Arduino UNO microcontroller. The Arduino UNO is a popular microcontroller which comes on a development board to accelerate programming, provides simple interfacing with peripheral devices and connection with computers. The Arduino UNO chip is programmed with the Arduino programming language and Arduinio 1.0 software through a USB port on the board which plugs into a computer s USB port. The Arduino 1.0 software writes code from the software to the chip by uploading the file containing the desired code to the board. Once the chip has been programmed with the desired code, the chip can be removed from the development board and connected to any circuit. There

is much literature on this board and in the reference section of this document there are several places to find more information on this topic. Specifications Servo motors are controlled through the control line, usually a yellow or white wire. The pulse width of the signal sent to the Servo control wire determines how the motor will move, either clockwise or counter clockwise. The figure below shows how different pulse widths correspond with different position of the motor. When the Pulse Width is less than 1.5ms the motor will move to the 0 position and hold. When the Pulse Width is 1.5ms the motor will rotate to the 90 degree position and if the Pulse Width is greater than 1.5 ms the motor will rotate to the 180 position. When the motor reaches the desired position it will hold there until a signal is sent to move. This is done in this application using the Arduino 1.0 coding software to write to one of the Arduino UNO s 5 PWM output pins. The PWM output pins on the development board can be written to with different pulse widths which are used to control the motor. Hardware Configuration The simplicity of the Servo and Arduino UNO connections is one of the major reasons for their popularity. The Servo motor has 3 wires as shown in the picture below. The red wire is for power and must be connected to a power supply of 4.8-6 Volts. The black wire is the ground wire and is

connected to ground. The third wire, usually white or yellow, is the control wire. This must be connected to one of the PWM outputs of the Arduino UNO (Pins: 3, 5, 6, 10, 11). Pin 6 will be used for this application note. The Arduino UNO board, shown below, must be connected to power by either connecting the USB port on the board to a computer or wiring Vin to 3-5V and connecting GND to ground. VDD Servo Motor Pin 6 ~ Microcontroller Vin (PWM) GND

Software There are many ways to program the microcontroller to control the operation of a Servo motor. This application will discuss how to make the Servo motor sweep from the 0 to the 180 continuously. The above is a snapshot is from the Arduino 1.0 software and is the code used to perform the sweep operation. The comments on the code provide an explanation for each of the lines of code. This file is included in the reference section of this document. (1) The first step is to include the Servo.h library which contains commands for control of a Servo. The void setup() function is for attaching the servo to the Arduino board and also sets the Servo to its 90 position before

operation to set the Servo to a known position.. The void loop() statement controls the movement of the servo and runs continuously. The void loop contains two FOR loops, one for movement of the motor from 0 to 180 and the other from 180 to 0. The first loop sets the PWM signal output to 1ms which moves the Servo to 0. The pulse width is then incremented by 1us each time the loop is entered and the pulse width is written to port 6 until the pulse width reaches 2ms, the 180 position. There is also a delay of 15ms each time the pulse width is written to port 6 before sending the next signal to allow for the motor to move. The delay can be adjusted to shorten or lengthen the delay which corresponds to speeding up or slowing down the rotation. The second loops works similarly, but decrementing the pulse width from 2ms to 1ms which moves the motor from 180 to 0. Results A Servo motor can be controlled with an Arduino UNO development board using the hardware and the software approach outlined above. With the program described running, and connections properly made, the Servo motor will continuously rotate 180. The Servo motor can be coupled to a shaft which can be used for numerous applications. These methods can be modified slightly to move a motor in a variety of ways to fit another particular scenario. The ease of use of these 2 pieces of hardware offer a simple way to control a motor with a computer program.

#include <Servo.h> References 1. Sample Arduino code for continuous 180 degree rotation Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos; // variable to store the servo position void setup() { myservo.attach(6); // attaches the servo on pin 9 to the servo object //myservo.setminimumpulse(1000); //myservo.setmaximumpulse(2000); myservo.writemicroseconds(1500); //set to 0 delay(10); void loop() { for(pos = 1000; pos <2000 ; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.writemicroseconds(pos); // tell servo to go to position in variable 'pos' delay(5); // waits 15ms for the servo to reach the position for(pos =2000; pos > 1000; pos -= 1) // goes from 0 degrees to 180 degrees 4 { // in steps of 1 degree myservo.writemicroseconds(pos); // tell servo to go to position in variable 'pos' delay(3); // waits 15ms for the servo to reach the position 2. Arduino Website: http://arduino.cc/ 3. Arduino Servo Library: http://arduino.cc/playground/componentlib/servo 4. Servo Datasheet:

http://www.bizchip.com/servo.pdf