Finishing the assembly was an easy process. The team purchased Epoxy adhesive to attach the servo horn to the gear. The adhesive was spread over the gear, the servo horn was placed on the gear, and pressure was put on the servo horn for about 30 minuets. To ensure that the servo horn and gear would have as little independent movement as possible, electrical tape was placed over the servo horn on the gear after the adhesive dried. Here is a close-up view of the attachment between the two parts:
The team also made a slight change in the mechanism's assembly from its initial assembly that was created in SolidWorks (shown in Week 3 Design Update). Instead of placing the Arduino Uno board on the side of the base, the bread board was placed on the side of the base. This adjustment allowed the Arduino board to connect to a computer without the USB cable possibly getting in the mechanism's way. The bread board is designed with adhesive on the bottom, so it was simply placed on the mechanism's base. Some electrical tape was also put on the launching arm to make it a bit sturdier. Here are some pictures of the completed mechanism:
Side 1 |
Side 2 |
Once testing began, the team noticed a clear problem. The mechanism could support one rubber band, but once two, three, and four rubber bands were placed onto the mechanism, the servo motor began to rotate on its own due the force from the rubber bands. Also, the force of the rubber bands caused the gear's position on the servo horn to shift slightly. After initial testing, it was clear that this specific mechanism should launch one rubber band at a time.
In order to allow the mechanism to launch one rubber band at a time, the Arduino code needed to be adjusted. The code was changed so that the servo motor alternated between two different positions: its initial "reload" position, and its position after launch. The difference between these two positions was made very large, so that servo motor can make a large rotation, and the rubber band is guaranteed to launch every time. If the servo motor does not rotate enough, then the rubber band will most likely remain on the gear. Here is the updated code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Arduino code - Code is used to: | |
* control servo motor with push button | |
* display LED at all times | |
* display LCD at servo's initial position | |
*/ | |
// introduce servo motor and LCD | |
#include <Servo.h> | |
#include <LiquidCrystal.h> | |
Servo Servo1; | |
LiquidCrystal lcd(12,11,5,4,3,2); | |
// global variables | |
const int buttonPin = 6; | |
boolean currentState = LOW; | |
boolean lastState = LOW; | |
boolean stateChange = false; | |
int currentButton = 0; | |
int lastButton = 1; | |
int pos = 0; | |
int led = 13; | |
// setup button, sevo, LED, and LCD | |
void setup() { | |
pinMode(buttonPin, INPUT); | |
Serial.begin(9600); | |
Servo1.attach(9); | |
while (pos==lastButton);{ | |
pinMode(led, OUTPUT); | |
lcd.begin(16, 2); | |
lcd.clear(); | |
} | |
} | |
// main loop | |
// call functions and keep LED on at all times | |
void loop(){ | |
currentState = debounceButton(); | |
stateChange = checkForChange(currentState, lastState); | |
currentButton = getButtonNumber(lastButton, currentState, stateChange); | |
servoControl(currentButton); | |
lastState = currentState; | |
lastButton = currentButton; | |
digitalWrite(led, HIGH); | |
printfunction(currentButton); | |
} | |
// function debounceButton | |
boolean debounceButton() | |
{ | |
boolean firstCheck = LOW; | |
boolean secondCheck = LOW; | |
boolean current = LOW; | |
firstCheck = digitalRead(buttonPin); | |
delay(50); | |
secondCheck = digitalRead(buttonPin); | |
if (firstCheck == secondCheck){ | |
current = firstCheck; | |
} | |
return current; | |
} | |
// function checkForChange | |
boolean checkForChange(boolean current, boolean last) | |
{ | |
boolean change; | |
if (current != last){ | |
change = true; | |
} | |
else { | |
change = false; | |
} | |
return change; | |
} | |
// function getButtonNumber | |
int getButtonNumber(int button, boolean state, boolean change) | |
{ | |
if (change == true && state == LOW){ | |
button++; | |
if (button > 1){ | |
button = 0; | |
} | |
Serial.println(button); | |
} | |
return button; | |
} | |
// function servoControl | |
// base servo position off of button state | |
// make sure that first position is intended initial position | |
void servoControl(int button) | |
{ | |
if(button == 1) {Servo1.write(160);} | |
if(button == 0) {Servo1.write(70);} | |
} | |
// function printfunction | |
// base LCD display off of button state | |
void printfunction (int button) | |
{ | |
if(button == 1) { | |
lcd.setCursor(0,0); | |
lcd.print ("!!!! RELOAD !!!!!"); | |
} | |
else{lcd.clear(); | |
} | |
} |
And here is a video of the mechanism in action:
Overall, the mechanism performs what it is intended to do, which is launch rubber bands and indicate when it needs to be reloaded. However, it does not perform to its fullest extent because it is unable to hold multiple rubber bands.
After completing this project, there are a few changes that would be made if the team were to do it again. First, some simple changes would be made to the gear that was 3D printed. The center hole would be cut to fit directly on the servo motor, so that a servo horn or any adhesive would not be needed. Also, the edges of the gear would be rounded to make sure that rubber bands would not get caught on pointed edges while launching (a problem that doesn't occur often, but occasionally). Here is what the re-designed gear would look like:
A close-up of the center hole, cut to fit a servo motor |
No comments:
Post a Comment