Servomotor Control with Arduino Integrated Development Environment. Application Notes. Bingyang Wu Mar 27, Introduction

Similar documents
LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

Coding with Arduino to operate the prosthetic arm

FABO ACADEMY X ELECTRONIC DESIGN

Programming 2 Servos. Learn to connect and write code to control two servos.

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

LC-10 Chipless TagReader v 2.0 August 2006

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

Megamark Arduino Library Documentation

Lesson 13. The Big Idea: Lesson 13: Infrared Transmitters

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Using the S5U13781R01C100 Shield Graphics Library with Atmel Studio

Lesson 3: Arduino. Goals

Saturday Academy Program

Arduino Digital Out_QUICK RECAP

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

Arduino and Servo Motor

DFRduino Romeo All in one Controller V1.1(SKU:DFR0004)

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Total Hours Registration through Website or for further details please visit (Refer Upcoming Events Section)

TWEAK THE ARDUINO LOGO

Application Note. Communication between arduino and IMU Software capturing the data

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

User Manual of Alpha 1s for Mac

Internet of Things Student STEM Project Jackson High School. Lesson 2: Arduino and LED

stored on the micro SD card supplied with the product and accessed when you come back to your computer.

AN ARDUINO CONTROLLED CHAOTIC PENDULUM FOR A REMOTE PHYSICS LABORATORY

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

1Getting Started SIK BINDER //3

EARTH PEOPLE TECHNOLOGY. EPT-200TMP-TS-U2 Temperature Sensor Docking Board User Manual

Figure 1. Digilent DC Motor

iphoto Getting Started Get to know iphoto and learn how to import and organize your photos, and create a photo slideshow and book.

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Progeny Imaging. User Guide V x and Higher. Part Number: ECN: P1808 REV. F

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

Module: Arduino as Signal Generator

DragonLink Advanced Transmitter

UNIT 4 VOCABULARY SKILLS WORK FUNCTIONS QUIZ. A detailed explanation about Arduino. What is Arduino? Listening

Arduino Lesson 1. Blink. Created by Simon Monk

Welcome to Arduino Day 2016

ServoDMX OPERATING MANUAL. Check your firmware version. This manual will always refer to the most recent version.

smraza Getting Start Guide Contents Arduino IDE (Integrated Development Environment)... 1 Introduction... 1 Install the Arduino Software (IDE)...

Lab 2: Blinkie Lab. Objectives. Materials. Theory

LAUNCHPAD. Getting Started Guide

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

XT-1 Configuration Manager User Manual EN

Application Note AN 157: Arduino UART Interface to TelAire T6613 CO2 Sensor

ZX Distance and Gesture Sensor Hookup Guide

VBRC 5. Radio Communicator. Installer Manual

9/2/2013 Excellent ID. Operational Manual eskan SADL handheld scanner

MIDLAND PROGRAMING G14

On the front of the board there are a number of components that are pretty visible right off the bat!

Tarocco Closed Loop Motor Controller

HC-SR501 Passive Infrared (PIR) Motion Sensor

Arduino Hacking Village THOTCON 0x9

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

Index. n A. n B. n C. Base biasing transistor driver circuit, BCD-to-Decode IC, 44 46

Studuino Icon Programming Environment Guide

Endurance R/C Wi-Fi Servo Controller 2 Instructions

Interfacing Clockaudio microphones with the Logic Box

Quick Start Guide for the PULSE PROFILING APPLICATION

Veyron Servo Driver (24 Channel) (SKU:DRI0029)

The µbotino Microcontroller Board

Arduino Setup & Flexing the ExBow

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

RESTAURANT MANAGEMENT for WINDOWS. GIFT CARD Version

URM37 V3.2 Ultrasonic Sensor (SKU:SEN0001)

Using the SparkFun PicoBoard and Scratch

APDS-9960 RGB and Gesture Sensor Hookup Guide

Preface. If you have any TECHNICAL questions, add a topic under FORUM section on our website and we'll reply as soon as possible.

RPG CREATOR QUICKSTART

VOICE CONTROLLED ROBOT WITH REAL TIME BARRIER DETECTION AND AVERTING

HAND GESTURE CONTROLLED ROBOT USING ARDUINO

Lab 06: Ohm s Law and Servo Motor Control

Progeny Imaging Veterinary

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

2D Floor-Mapping Car

Industrial Automation Training Academy. Arduino, LabVIEW & PLC Training Programs Duration: 6 Months (180 ~ 240 Hours)

Omniverse Setup Instructions

Arduino Control of Tetrix Prizm Robotics. Motors and Servos Introduction to Robotics and Engineering Marist School

Welcome to Weebly. Setting up Your Website. Write your username here:

Getting Started with the micro:bit

VISSIM Vehicle Actuated Programming (VAP) Tutorial

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Analog Discovery Arbitrary Function Generator for Windows 7 by Mr. David Fritz and Ms. Ellen Robertson

Operating Mode: Serial; (PWM) passive control mode; Autonomous Mode; On/OFF Mode

1 ImageBrowser Software User Guide 5.1

VMA205 WIFI ESP8266 SHIELD

Lab 12: Timing sequencer (Version 1.3)

NAME DESCRIPTION OF ACTIVITY LEARNING GOALS PRE-REQUISITE KNOWLEDGE/SKILL MATERIALS NEEDED EDUCATION PROJECT IMAGE. Animated Character

Creating Retinotopic Mapping Stimuli - 1

Advanced Mechatronics 1 st Mini Project. Remote Control Car. Jose Antonio De Gracia Gómez, Amartya Barua March, 25 th 2014

The Robot Builder's Shield for Arduino

Serial Control Hardware (RS-485)

MADEinUSA OPERATOR S MANUAL. RS232 Interface Rev. A

A Model Based Approach for Human Recognition and Reception by Robot

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Peek-a-BOO Kit JAMECO PART NO / / Experience Level: Beginner Time Required: 1+ hour

USB Multifunction Arbitrary Waveform Generator AWG2300. User Guide

Programming a Servo. Servo. Red Wire. Black Wire. White Wire

Transcription:

Servomotor Control with Arduino Integrated Development Environment Application Notes Bingyang Wu Mar 27, 2015 Introduction Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open- source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be stand- alone, or they can communicate with software running on your computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled. The open- source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open- source software. This software can be used with any Arduino board.

Objectives The Application Notes is a user guide introducing the Arduino Integrated Development Environment (IDE) and its application in controlling the servomotor. The servomotor is to be used for lifting and lowering the arm in the gate security system designed by the team. The following parts will take you through the setup and functionality of different components of the Arduino IDE. The programming code regarding controlling of the servomotor will also be explained in detail. Arduino IDE Setup When the Arduino IDE is opened up, the following window will pop up. The window may look slightly different for different Operating Systems (OS); they are generally identical in terms of layout and functionality. For general purposes, this tutorial uses Mac OS X as example.

Figure 1. Arduino IDE Interface The interface is fairly clear and straightforward, which is divided into three sections, with a toolbar at the top; the code editing area in the middle; and the notification/status area at the bottom. For the latest version of Arduino IDE (Arduino IDE 1.6.2), the toolbar consists of six buttons as shown in Table 1 below. The tab with a file name is located between the toolbar and the code editing area. Button Icons Functionalities Verify- Check the errors from the code Upload- Write the current code into the microcontroller New- Open a new blank window for coding Open- Open an existing sketch Save- Save current program Serial Monitor- Send and receive data to and from Arduino Table 1. Toolbar Buttons and Their Corresponding Functionalities Among the introduced buttons and their corresponding functionalities above, serial monitor is one of the most useful components, which is of a great importance as testing the program. Serial monitor displays the serial data received from the output of the microcontroller. One can also input data to the microcontroller via serial monitor. In other words, serial monitor provides a way for the users to interact with the microcontroller by immediate data exchange. Clicking on the serial monitor icon opens up a window as shown below. One can select the baud rate at which the data is sent to or received from the Arduino. Baud rate stands for the rate of change per second at which the status (or bit data) is sent to or received from the Arduino microcontroller. The default baud rate is 9600, meaning the user is sending 1200 characters per second via the serial connector (USB cable in the case of the team) for sending a character record (9600 bit/8 bit per character = 1200 characters). A textbox is located at the top of the serial monitor window; one can input data by clicking the send button. The blank area below the textbox is where the serial data output is displayed.

Figure 2. Serial Monitor Window Servomotor Setup Once you are confident with manipulating the Ardunio IDE, you are well prepared to move on to the next stage and work on the projects in a variety of scopes. For the gate security system project for ArcelorMittal, an RFID reader and a servomotor are connected to the microcontroller (Arduino Yun for this project). Once an RFID tag/card is put near to the RFID reader, a character string corresponding to the specific tag/card is displayed in the serial monitor window. If the character string matches one of the preset strings in the database, the motor is triggered and it lifts the arm allowing vehicles to pass through. Then the motor runs reversely to put the arm to its original position. The Arduino IDE implements C/C++ programming language. Following is the code segments that program the servomotor. The logic and functionality of the essential parts of the code will be explained in paragraphs following each of the code segments.

#include <Servo.h> Servo servo; int pinservostart = 9; int pinservostop = 7; int servolockedrotation = 150; int servounlockedrotation = 30; int unlocktime = 3500; int pinled = 13; The top line of the code is #include directive followed by a header file. The effect of #include <Servo.h> is the same as if one has typed the entre contents of the Servo.h file into the file at the point where #include line appears. The Servo.h file is supplied as part of all C complier packages. It contains information about input and output functions that are needed for programming the servomotor. The third and forth lines assign the corresponding microcontroller pins on which the servomotor will attach. Please be noticed that only one servomotor is used in the design, instead two pins are assigned. The reason for this will be discussed in later paragraphs in a more detailed manner. For now just keep in mind that the servomotor is only attached on pin 9. The next two lines determine the position of the servomotor for lifting and lowering the arm, respectively. unlocktime determines the duration of the lifting and lowering process for the arm. The last line assigns pin 13 to the LED, which works as an indication when the access is granted. servo.attach(pinservostop); This line initializes the servomotor at rest position because as mentioned above that the servomotor is attached only on pin 9, not pin 7. pinmode(pinled, OUTPUT); digitalwrite(pinled, LOW); These two lines define the pin for the LED as an output pin, and initialize the LED as off. val = Serial.read(); if(val == 'G') { digitalwrite(pinled, HIGH); servo.attach(pinservostart); servo.write(servounlockedrotation); // Access Granted

} delay(unlocktime); servo.attach(pinservostop); delay(3500); servo.attach(pinservostart); servo.write(servolockedrotation); delay(unlocktime); servo.attach(pinservostop); digitalwrite(pinled, LOW); else if(val == 'D') { } delay(1000); // Access Denied // Wait a moment to scan the next card The code segment is for the control of the servomotor. val = Serial.read(); at the first line reads whatever inputted by the user via serial monitor. A reading of G represents access granted, similarly a D for access denied. This is only for the purpose of testing the proper working of the servomotor. If the access is granted, digitalwrite(pinled, HIGH); makes the indication LED on. The next two lines attach the servomotor on pin 9 and run the motor in the direction of lifting the arm. The duration of the lifting process is determined by the following delay code. Then the servo.attach(pinservostop); stops the servomotor by switching the effective pin from 9 to 7, which detaches the servomotor that is originally attached on pin 9. The following delay holds the servomotor at its lifted position for a specified time period. After that, the servomotor is reattached to pin 9 and servo.write(servolockedrotation); indicates that it is to be run in the direction of lowering the arm. The following delay assures same duration for the lowering process as it is for the lifting process. Once the servomotor goes back to its original position, it stops running again for being detached from pin 9. For the access denied situation, there will be only a delay code in place that gives a short break to the reader before the next card can be scanned. If you find that attaching the servomotor to an unused pin is a waste, an alternative way to achieving the same result is to replace the lines of servo.attach(pinservostop); with servo.detach();. It detaches the servomotor from the pin it was attached and stops the motor immediately. The character strings corresponding to the cards read are as shown below in Fig.3.

Figure 3. Character Strings of Cards Conclusion The Arduino IDE is a powerful development tool that allows the users to take advantage of its user- friendly interface and achieve a complex design goal in an easy manner at both the prototype and manufacturing stage. For the motor part of the project, the Arduino IDE did an exceptionally good job in terms of conciseness and efficiency. There are, of course, many ways in which the project can be improved in some aspects if time is not that much of a constraint. An obvious example could be adding a sensor that replaces, or possibly works with, the delay implemented that holds the arm in its lifting position to allow passing of the vehicles. In this case, the arm will not go down unless the clear path under it is confirmed by the system. Thus the design would be much more applicable in real life regarding its higher safety standard and more efficient implementation, especially for the always busy traffic flows in front of the gate. Also, another sensor could be added to distinguish passengers from vehicles to prevent people from taking advantage of the ease of getting a new ticket if the parking lot is charging by hours. Therefore, the point is that the Arduino IDE along with the Arduino microcontroller provides the users with unlimited ways to bringing to reality whatever is in their mind, and there are always various methods available for a single task. It is always a good idea to try different blueprints to find the best one for the targeted product.

Reference http://arduino.cc/ Stephen Prata, C primer Plus Sixth Edition