robotic arm 2 wilmer arellano © 2013. hardware next slide shows sensor connection to analog pin 0...

31
ROBOTIC ARM 2 Wilmer Arellano © 2013

Upload: gregory-taylor

Post on 19-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

ROBOTIC ARM 2

Wilmer Arellano © 2013

Page 2: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Hardware

Next slide shows sensor connection to analog pin 0 and Motor 1 connection.

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 3: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Next motors use adjacent pins to the left

Page 4: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Let's use the same control numbering

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 5: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

H-Bridge http://www.robotroom.com/HBridge.htmlbotroom.com/HBridge.html

This is just an example, we prefer to use the TC4422 in the T0-220 package which has higher Current capability but is single channel. You can order free samples from microchip

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 6: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Let’s try one motor (use the one in the Arduino kit)

Find operation of instruction analogWrite() in arduino.cc

Pseudo Code Move motor at speed 1 Wait a certain amount of time Move motor at speed 2 Wait a certain amount of time Change direction Move motor at speed 3 Wait a certain amount of time

Hints: set speed2 > speed1 = 150. And Speed3 = 255 – speed2 Test it, if it does not work invert motor cables

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 7: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Let's use the same motor numbering

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Motor

1

Page 8: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Precautions

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 9: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Precautions

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Motor 2 may not have enough power to lift the fully extended arm

Page 10: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Precautions

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Lifting with motor 3 first helps to solve the problem

Page 11: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Positioning the sensor

Sensor must have at least 4 cm from object. For that reason is placed near the center

You may need to use some little rotation for best results

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 12: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Avoid extreme rotations

Avoid rotating motors to the extreme positions (left or right)

They may click and lock

Ask your instructor if this happens

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 13: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

H-Bridge

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 14: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

H-Bridge http://www.robotroom.com/HBridge.htmlbotroom.com/HBridge.html

This is just an example, we prefer to use the TC4422 in the T0-220 package which has higher Current capability but is single channel. You can order free samples from microchip

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 15: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Precautions

The Robotic Arm is a delicate device that may be damaged if operated beyond the mechanic limits

If while you program the arm operation you observe a motion behavior that may compromise the robot integrity disconnect power immediately. Center the arm with the manual remote and make any corrections necessary to your program

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 16: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Installation

Download Library from: http://web.eng.fiu.edu/~arellano/1002/Microcontroller/Arm.zip

Unzip library and drop it in: The libraries folder of your arduino

installation. In my case: C:\arduino-1.0.1-windows\arduino-1.0.1\

libraries

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 17: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Include in your final report: An explanation of a gear box operation.

Particularize for the gear boxes you are using

How to measure power in a DC motor. Include several power measurements on the arm’s motors under different operating conditions

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 18: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

#include <Arm.h>// Create an instancve of ArmArm arm(0);// Backward direction, Left and Downint LEFT = 0, DOWN = 0;// Forward direction, Right and Upint RIGHT = 1, UP = 1;int control = 1, temp;

void setup() { Serial.begin(9600); Serial.println("Hello");}

void loop() { arm.checkData(); while(control > 0){ arm.moveMotor(1, LEFT, 5, 10); arm.moveMotor(1, RIGHT, 5, 10); control = control - 1; temp = arm.distance(); Serial.print("Distance: "); Serial.println(temp); }}

•Example, just to test motor 1•Change the motor ID number and test motors one by one

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 19: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Constructor

Include the library: #include <Arm.h>

Create an instance of the class: Arm arm(int); “int” tells the library where the distance

sensor is connected. #include <Arm.h> // Create an instancve of Arm Arm arm(0);

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 20: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Create Mnemonics

// Backward direction, Left and Down int LEFT = 0, DOWN = 0; // Forward direction, Right and Up int RIGHT = 1, UP = 1;

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 21: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Initialize

int control = 1, temp;

void setup() { Serial.begin(9600); Serial.println("Hello"); }

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 22: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Execute

void loop() { arm.checkData(); while(control > 0){ arm.moveMotor(1, LEFT, 5, 10); arm.moveMotor(1, RIGHT, 5, 10); control = control - 1; temp = arm.distance(); Serial.print("Distance: "); Serial.println(temp); } }

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 23: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Motor Control 1

arm.moveMotor(int motorID, int Direction, int Speed, int time)

Motor ID = 1, 2, 3, 4, 5 Direction = RIGHT, LLEFT 0 < Speed < 11 0 < time < 40 You may need to invert your motor

connection for proper operation

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 24: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Motor Control 2

arm.checkData() This function with no arguments checks

for serial data from the computer Use the serial monitor of the Arduino IDE

to control the arm Type one or more commands and hit

enter

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 25: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Motor Control 2

Commands Selection

a or A moves motor towards left Motion

s or S moves motor towards right w or W moves motor up z or Z moves motor down a, z and s, w are interchangeable

A single motion command will produce a small movement a sequence of several motion commands of the same type will produce an ampler motion

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 26: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Motor Control 3

arm.initialize(time) This function allows you to adjust the

arm position for “time” seconds, using the commands on the previous slide.

This function internally uses arm.checkData()

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 27: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Motor Control 3

#include <Arm.h>Arm arm(0); // Creates an instance of Armint LEFT = 0, DOWN = 0; // Backward direction, Left and Downint RIGHT = 1, UP = 1; // Forward direction, Right and Upint temp;

void setup() { // We use this loop only as we want a single execution of the programSerial.begin(9600);Serial.println("Hello");arm.initialize(20); // The argument Determines how many second you have to manually position the arm}void loop() { }

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 28: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Distance measurement

temp = arm.distance(); When this function is called an integer is

returned with approximate distance between the sensor and an object

Limitations Max distance 80 cm Object with a distance less than 10 cm will

appear to be farther away

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 29: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

Functions

Next we will modify the original code to: Include functions Add some delay to manually position the

griper Lines highlighted in red have change

please read the comments.

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 30: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

#include <Arm.h>Arm arm(0); // Creates an instance of Armint LEFT = 0, DOWN = 0; // Backward direction, Left and Downint RIGHT = 1, UP = 1; // Forward direction, Right and Upint temp;

void setup() { // We use this loop only as we want a single execution of the programSerial.begin(9600);Serial.println("Hello");arm.initialize(20); // The argument Determines how many second you have to manually position the armhome(); // "home()" is a function call. It will execute the code between the braces of "void home()“ Program // Execution will return here after executing the code of spin()}void loop() { }void home(){ temp = arm.distance(); while(temp > 10){ // When the sensor detects an object within 20 cm of distance , the function will stop// Replace the next comment line with appropriated code // Move motor #1 so the arm moves towards home. //Try different combinations of speed and time to see which one works best. temp = arm.distance(); Serial.print("Distance: "); // This line is optional if you want to monitor distance in the computer Serial.println(temp); // This line is optional if you want to monitor distance in the computer }}

Lecture is licensed under a Creative Commons Attribution 2.0 License.

Page 31: ROBOTIC ARM 2 Wilmer Arellano © 2013. Hardware  Next slide shows sensor connection to analog pin 0 and Motor 1 connection. Lecture is licensed under

#include <Arm.h>Arm arm(0); // Creates an instance of Armint LEFT = 0, DOWN = 0; // Backward direction, Left and Downint RIGHT = 1, UP = 1; // Forward direction, Right and Upint temp;void setup() { // We use this loop only as we want a single execution of the programSerial.begin(9600);Serial.println("Hello");arm.initialize(20); // The argument Determines how many second you have to manually position the armhome(); // "home()" is a function call. It will execute the code between the braces of "void home()“ Program // Execution will return here after executing the code in home() // add more functions, like find(); // Move arm to find the object}void loop() { }void home(){ temp = arm.distance(); while(temp > 10){ // When the sensor detects an object within 20 cm of distance , the function will stop// Replace the next comment line with appropriated code // Move motor #1 so the arm moves towards home. //Try different combinations of speed and time to see which one works best. temp = arm.distance(); Serial.print("Distance: "); // This line is optional if you want to monitor distance in the computer Serial.println(temp); // This line is optional if you want to monitor distance in the computer }}void find(){ temp = arm.distance(); while(temp > 25){// Replace the next comment lines with appropriated code // Move motor #1 so the arm moves towards the object. //Try different combinations of speed and time to see which one works best.// May need to move back a little bit after finding home (Overshoot) temp = arm.distance(); Serial.print("Distance: "); // This line is optional if you want to monitor distance in the computer Serial.println(temp); // This line is optional if you want to monitor distance in the computer }}

Lecture is licensed under a Creative Commons Attribution 2.0 License.