robotic arm 2 wilmer arellano © 2013. hardware next slide shows sensor connection to analog pin 0...
TRANSCRIPT
ROBOTIC ARM 2
Wilmer Arellano © 2013
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.
Lecture is licensed under a Creative Commons Attribution 2.0 License.
Next motors use adjacent pins to the left
Let's use the same control numbering
Lecture is licensed under a Creative Commons Attribution 2.0 License.
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.
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.
Let's use the same motor numbering
Lecture is licensed under a Creative Commons Attribution 2.0 License.
Motor
1
Precautions
Lecture is licensed under a Creative Commons Attribution 2.0 License.
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
Precautions
Lecture is licensed under a Creative Commons Attribution 2.0 License.
Lifting with motor 3 first helps to solve the problem
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.
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.
H-Bridge
Lecture is licensed under a Creative Commons Attribution 2.0 License.
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.
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.
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.
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.
#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.
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.
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.
Initialize
int control = 1, temp;
void setup() { Serial.begin(9600); Serial.println("Hello"); }
Lecture is licensed under a Creative Commons Attribution 2.0 License.
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.
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.
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.
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.
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.
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.
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.
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.
#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.
#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.