Pin Picker Upper Robot
Simon Schinella
EnTech
Miami Dade College
Nimson50@hotmail.com
1.
Introduction
The purpose of this
robot is to pickup sharp metal pins off of the floor so that people don’t step
on them and sustain injuries. Metal pins can be hard to sweep or vacuum up; it
is even more difficult to pick them up by hand. This robot has an electromagnet
that is ideal for picking up pins and needles.
The robot will drive
around a room with an electromagnet that will pick up the pins off the floor
and keep them in a safe holding tray.
2. Background and/or Related Work
I have had experience
with most of the components used on this project, but what was new for me was
integrating them to all be used together. My first experience with an Arduino
was in a Advanced Digital Circuits class. My final project in that class
required me to build an H-bridge and use the Arduino to turn a motor in one
direction and then the other at different speeds using pulse width modulation (PDW).
The stages of the motor speed also had to be displayed on an LCD screen. This
experience with these components helped with building this robot.
3.3. Additional Information
The
robot is a three wheel design with two of the wheels being drive/turn wheels
and one being a balance/stability swiveling caster wheel. The total structure
is 13 x 7 x 5 inches, making it ideal for going under tables and staying out of
the way of passersby. It weighs 16oz with the batteries making it fast and efficient
on power.
The brain of the robot is an Arduino UNO. The body is a
three wheel chassis and it has an arm that pivots in one place actuated by a
servo motor. At the end of the arm there is a metal touch sensor that activates
the pin pick up sequence. The head is a
sonic proximity detector mounted on the front. There is a tray to hold the
pins and a bump sensor in front of the robot. The tray that the pins are held
in will have a sensor that will indicate when the tray is full. The fourth and
final sensor is a photo diode sensor used to power up and power down the robot
remotely.
This robot can go forward or spin in place. It can also avoid obstacles
and stop if it hits something. It can pickup metal objects with an electromagnet
and it can drop the metal objects into a holding tray. The robot has an LED
screen that displays the distances output by the sonic detector, if it detects
a collision, if the robot detects a metal object, and if the bump switch is hit.
4. Results
Figure 1
This is an over
view of the body of the robot. As you can see, the LCD screen is at the back of
the robot seen to the right of figure 1. To the left of the LCD is the Arduino
UNO. In the center of the image are the two drive motors and there yellow
mechanisms that provide a 1/48 gear ratio. In between them is the H-bridge motor
driver circuit. Beside it is the 9V battery that powers the electromagnet and
in the lower left hand corner is a bread board with the sonic detector.
In figure 2 is the
Arduino UNO and all of it’s conections. The 5V from the Arduino goes to the
bread board so more components can use it and the same thing goes for the
ground so that all of the grounds can be common to the Arduino. You can also
see the photo diod that is used to power on and off the robot and pin 13 is the
indicator LED.
This is an image
of the H-bridge motor driver circuit. This circuit is getting 5V from the
Arduino and it is also grounded. The orange and black wires on the top and
bottom are going to the motors and the four red wires coming out of the midle
are the inputs from the Arduino. The H-bridge IC is to the left of the circuit
board and has the heat sink attached to it.
Figure4 is an image
of the bread board used. The top line on the bread board is used for the 5V
from the Arduino and the third line down is used for the Common ground. The
five rows in the middle are used for the sonic detector connections and at the
bottom of the board is the transistor circuit used to engage and dissengage
the electromagnet. The two blue wires are the electromagnet wires. You can
also see the bump switch in the upper left hand corner of the image.
In figure5 is the
metal detector touch sensor circuit and the electromagnet. As I mentioned
before, the blue wires go to the electromagnet and the orange, green, and black
are for the metal detector. The metal detector is adjustable so that it can get
low enough to the ground to touch any small metal objects.
Figure6 is to show
a front view that highlights the sonic detector, bump switch,servo motor, and
picker arm.
5. Conclusion
There were a lot of ups and downs with this
project and some of them were very frustrating, but I was able to learn a lot
from all of them. The first set back didn’t have anything to do with the actual
build of the robot, but had to do with getting the parts. I ordered all of the
parts from China and some of them took almost a month to get so I would recommend
any one that is going to try anything like this to take that in to serious
consideration. The next problem was with the obstacle avoidance. The robot
would turn farther that was desired and to fix this I applied a type of PWM by
turning on and off the motors so that it would only turn a little at a time
until it was in the desired position. I also had some trouble implementing the
I2C circuit on the LCD. First I had to find the right library and then I had to
learn that sense you can set up multiple I2C components in series you have to
give each component its own address. I tested all of the components used with
the Arduino being powered by my computer so that I would be able to save on
batteries, but after getting everything going the current from the computer was
no longer enough so I knew the Arduino would not have enough current to run
everything. To correct this problem I integrated a 9V battery that is dedicated
to powering the electromagnet and another one just for the Arduino. This
solution worked perfectly and everything had enough current.
This project was very enjoyable because of
the way I was able to apply everything that I had learned in other classes
leading up to this one and because I was able to use the integrated circuits like
the H-bridge motor driver circuit and the I2C circuit instead of having to build
them from scratch.
6. References
http://pinpickerupperrobot.blogspot.com
5.1 Code
//Arduino/Energia Obstacle Avoidance Robot
Code, Callum King-Underwood, 17/10/2013, do whatever the hell you want with it
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
//These are the pins used for the HCSR04
int echo = 4;
int trigger = 3;
//metal detector
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
//const int ledPin = 13;
// the number of the LED pin
// variables will change:
int buttonState = 1; // variable for reading the pushbutton
status
//Bump
switch
const int bumpPin = A3; // the number of the pushbutton pin
const int ledPin = 13;
// the number of the LED pin
int bumpState = 0; // variable for reading the pushbutton
status
//full
level
const
int levelPin = 12; // the number of
the pushbutton pin
//const int ledPin = 13; // the number of the LED pin
// variables will change:
int
levelState = 0;
void stop2();
void bump();
//ElectroMagnet
int MAG = 11;
//ServoMotor
#include <Servo.h>
Servo myservo;
// create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0;
// variable to store the servo position
//These are the pins for the motor driver, I
used an L9110S
int AIA = 10;
//Motor A, input A
int AIB = 9;
//Motor A, input B
int BIA = 8;
//Motor B, input A
int BIB = 7;
//Motor B, input B
//Variables for the distance measurements
int distance;
//This you leave alone, the program will fill it as required.
int dangerLevel = 50;//this is in cm, the
distance at which to avoid an obstacle.
void setup()
{
//Level
full
//
initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
//
initialize the pushbutton pin as an input:
pinMode(levelPin, INPUT);
//bump
switch
pinMode(ledPin, OUTPUT);
pinMode(bumpPin, INPUT);
//metal detector
//
initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
//
initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
//pick
up interupt
attachInterrupt(0, stop2, FALLING);
//bump
interupt
//attachInterrupt(2, bump, HIGH);
//ServoMotor
myservo.attach(5); // attaches
the servo on pin 5 to the servo object
// set
the motor driver pins to output
pinMode(AIA, OUTPUT);
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);
//set
the motor driver pins high to start with.
//both
pins being high results in the motor not spinning, as does both low, I don't
think it matters which you use.
digitalWrite(AIA, HIGH);
digitalWrite(AIB, HIGH);
digitalWrite(BIA, HIGH);
digitalWrite(BIB, HIGH);
//set
the ultrasound pins up too
pinMode(echo, INPUT);
pinMode(trigger, OUTPUT);
digitalWrite(trigger, LOW);
Serial.begin(9600);
}
void loop()
{
//bump
switch
bumpState = digitalRead(bumpPin);
//
check if the pushbutton is pressed.
// if
it is, the buttonState is HIGH:
if
(bumpState == HIGH) {
//
turn LED on:
digitalWrite(ledPin, HIGH);
digitalWrite(AIA,
LOW); //stop
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
Serial.println("bump if statment");
delay(100*40);
digitalWrite(AIA, HIGH);
digitalWrite(AIB, LOW);
digitalWrite(BIA, HIGH);
digitalWrite(BIB, LOW);
}
//level
full
//
read the state of the pushbutton value:
//levelState = digitalRead(levelPin);
//
check if the pushbutton is pressed.
// if
it is, the buttonState is HIGH:
//if
(levelState == HIGH) {
//
turn LED on:
//digitalWrite(ledPin, HIGH);
//}
//else
{
//
turn LED off:
//digitalWrite(ledPin, LOW);
//}
//Send
a short pulse on HCSR04 trigger
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(5);
digitalWrite(trigger, LOW);
//record the pulse from the echo pin
distance = pulseIn(echo, HIGH);
//dividing it by 58 roughly converts to cm, tweak this value if you
wish.
distance = distance / 58;
//debug
feature: print out the distance over serial.
lcd.init();
// initialize the lcd
lcd.backlight();
Serial.println(distance);
lcd.print(distance);
// if
(digitalRead(2) == LOW){
//
stop2();}
if
((distance > dangerLevel)||(distance == 0)){
myservo.write(180);
// tell servo to go to position in variable 'pos'
//delay(1000); // waits 15ms for the
servo to reach the position
//there is no obstacle too close to the robot. We will go forwards.
digitalWrite(AIA, LOW);
digitalWrite(AIB, HIGH);
digitalWrite(BIA, LOW);
digitalWrite(BIB, HIGH);
}
else{
//delay(100);
myservo.write(180);
// tell servo to go to position in variable 'pos'
//there is an obstacle, so one motor will go forwards and the other
backwards.
digitalWrite(AIA, LOW);
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
delay(500);
//delayMicroseconds(1000000000);
digitalWrite(AIA, LOW);
digitalWrite(AIB, HIGH);
digitalWrite(BIA, HIGH);
digitalWrite(BIB, LOW);
delay(500);
digitalWrite(AIA, LOW);
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
//delayMicroseconds(1000000000);
//Confirm that we are avoiding an obstacle over serial.
Serial.println("Danger Hit");
lcd.print("Danger Hit!");
}
}
void stop2()
{
//long time = millis();
delay(250*10); //role forward one inch
digitalWrite(AIA, LOW); //stop
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
delay(100*10);
//while ( millis() - time < 3000){}
//time = millis();
//ElectroMag
digitalWrite(MAG, HIGH);
//while ( millis() - time < 1000){}
//time = millis();
//ServoMotor
delay(100*10);
myservo.write(30); // tell
servo to go to position in variable 'pos'
//while ( millis() - time < 000){}
delay(100*10);
digitalWrite(MAG, LOW);
//delay(10000);
//myservo.write(0);
// tell servo to go to position in variable 'pos'
//delay(100000);
//
Serial.println("METAL!!!!!!!!!!");
//lcd.print("METAL!!!!");
}
void bump(){
digitalWrite(AIA, LOW); //stop
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
delay(100*60);
}
/*
if
(buttonState == 0){
Serial.println("if stop");
digitalWrite(AIA, HIGH);
digitalWrite(AIB, LOW);
digitalWrite(BIA, LOW);
digitalWrite(BIB, LOW);
//delay(100000); )*/
No comments:
Post a Comment