We started off using a lot of excel and doing classwork through It.
The second program we used was MatLab and we did more of the same.
The third segment was Hand drafting.
From hand drafting we went into solidworks
Lastly, we ended the year with our final "block sorting" project.
As a team, design, build, and test a microcontroller-based machine to address the challenge described below. Document all activities and details chronologically in an engineering notebook and provide progress reports as requested by the instructor. Present the results to the class in a formal presentation that includes a demonstration of your team’s machine. Document the overall project in a final report.
Company X produces 2-inch colored wood cubes used in various industries. Their current quality assurance process includes manual inspection of the size and color of each cube. Cubes that meet both the size and color specifications are separated by hand from those that do not meet both specifications. The company’s management wants to automate the quality assurance and separation processes and has identified the need for a machine which does the following with no human intervention:
1) Identifies and bins cubes that do not meet the size specification
2) Identifies and bins cubes that meet the size specification but not the color specification
3) Sorts and bins cubes that meet both specifications by color Cube specifications:
1) Cube measures 2.00” ± 0.10”
2) Cube color is green, yellow, or orange
Cubes may be pre-loaded and/or fed into the machine by hand, but no energy may be imparted to a cube when doing so. The machine must be able to accept a cube as large as 2.30” and as small as 1.70”.
1. System shall use an Arduino Uno as the microcontroller.
2. Power within the system “boundary” shall be no greater than 12VDC. 120VAC power, if used, shall be converted to no greater than 12VDC prior to crossing the system “boundary”.
3. System shall correctly bin ten random cubes within four minutes. The set of cubes includes: a. Cubes that meet the size specification and the color specification b. Cubes that do not meet the size specification that are as large as 2.30” or as small as 1.70” c. Cubes that meet the size specification but do not meet the color specification
4. The bins are part of the system and therefore part of the design. Separate bins are required for the cubes that meet the size and color specifications – i.e., one bin for green, one bin for yellow, one bin for orange. One or more bins can be used for cubes that do not meet the size and/or color specifications. Each bin shall be capable of holding a minimum of four cubes.
5. The system, including the bins, shall occupy a volume no larger than 8 cubic feet. System volume is calculated by:
System Volume = Maximum Length ⨯ Maximum Width ⨯ Maximum Height
#include <Servo.h>
// ---------------- SERVOS ----------------
Servo binServo;
Servo gateServo;
const int binPin = 9;
const int gatePin = 10;
const int HOME = 90;
// bin angles
const int YELLOW_ANGLE = 60;
const int ORANGE_ANGLE = 90;
const int GREEN_ANGLE = 135;
const int WASTE_ANGLE = 0;
// ---------------- ULTRASONIC ----------------
#define TRIG_PIN 7
#define ECHO_PIN 8
const float minDist = 2.35;
const float maxDist = 3.10;
// ---------------- COLOR SENSOR ----------------
const int S0 = 4;
const int S1 = 5;
const int S2 = 6;
const int S3 = 11;
const int sensorOut = 12;
const int LED = 13;
int redValue, greenValue, blueValue;
// ---------------- SYSTEM ----------------
bool systemLocked = false;
unsigned long lastActionTime = 0;
const int cooldownTime = 2500;
// Bin tracking
int currentBinAngle = HOME;
// NEW: detection delay system
unsigned long detectStartTime = 0;
bool objectDetected = false;
const int readDelay = 1500;
// ---------------- SETUP ----------------
void setup() {
Serial.begin(9600);
binServo.attach(binPin);
gateServo.attach(gatePin);
binServo.write(HOME);
gateServo.write(110);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
}
// ---------------- DISTANCE ----------------
float readDistance() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(5);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
long duration = pulseIn(ECHO_PIN, HIGH, 30000);
if (duration == 0) return -1;
float distance = duration * 0.034 / 2;
if (distance <= 0 || distance > 400) return -1;
return distance;
}
// ---------------- COLOR ----------------
void readColor() {
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
redValue = pulseIn(sensorOut, LOW, 30000);
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
greenValue = pulseIn(sensorOut, LOW, 30000);
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
blueValue = pulseIn(sensorOut, LOW, 30000);
Serial.print("R: "); Serial.print(redValue);
Serial.print(" G: "); Serial.print(greenValue);
Serial.print(" B: "); Serial.println(blueValue);
}
// ---------------- COLOR MATCH ----------------
int getColorBin() {
if ((abs(redValue - 9) <= 3 && abs(greenValue - 12) <= 3 && abs(blueValue - 15) <= 3) ||
(abs(redValue - 10) <= 3 && abs(greenValue - 15) <= 3 && abs(blueValue - 18) <= 3))
return 1;
if ((abs(redValue - 12) <= 3 && abs(greenValue - 22) <= 3 && abs(blueValue - 18) <= 3) ||
(abs(redValue - 12) <= 3 && abs(greenValue - 26) <= 3 && abs(blueValue - 21) <= 3))
return 2;
if (abs(redValue - 22) <= 3 &&
abs(greenValue - 22) <= 3 &&
abs(blueValue - 20) <= 3)
return 3;
return -1;
}
// ---------------- SORT ----------------
void goToBin(int bin) {
int targetAngle;
if (bin == 1) targetAngle = YELLOW_ANGLE;
else if (bin == 2) targetAngle = ORANGE_ANGLE;
else if (bin == 3) targetAngle = GREEN_ANGLE;
else targetAngle = WASTE_ANGLE;
if (targetAngle != currentBinAngle) {
Serial.println("BIN SERVO MOVE");
binServo.write(targetAngle);
delay(900);
currentBinAngle = targetAngle;
}
gateServo.write(180);
Serial.println("GATE OPEN");
delay(2500);
gateServo.write(110);
Serial.println("GATE CLOSED");
}
// ---------------- LOOP ----------------
void loop() {
if (systemLocked && millis() - lastActionTime < cooldownTime) return;
float distance = readDistance();
Serial.print("Distance: ");
Serial.println(distance);
if (distance == -1) {
Serial.println("NO ECHO");
delay(200);
return;
}
if (distance > 7.0) {
Serial.println("TOO FAR");
delay(300);
return;
}
// Detect object and start delay
if (!objectDetected) {
objectDetected = true;
detectStartTime = millis();
Serial.println("OBJECT DETECTED - WAITING");
return;
}
// Wait 1.5 seconds before reading
if (millis() - detectStartTime < readDelay) {
return;
}
Serial.println("READING NOW");
readColor();
bool validSize = (distance >= minDist && distance <= maxDist);
int bin = getColorBin();
if (!validSize) {
Serial.println("WASTE SIZE");
goToBin(4);
}
else if (bin != -1) {
Serial.print("SORT BIN ");
Serial.println(bin);
goToBin(bin);
}
else {
Serial.println("UNKNOWN COLOR");
goToBin(4);
}
objectDetected = false;
systemLocked = true;
lastActionTime = millis();
delay(1000);
}
This is a full arduino electrical schematic for our wiring. Above that is all the code for our project seperated by function.
These are the sensors I made for the project and the "arduino board".
These are replica blocks I added.
These are The servos I replicated witha pointed attachment and a wheel attachment.
This is a gif of the fully assembled project assembly in SolidWorks.
This is the shorter vertical base part.
this is the slide platform wall that holds the color sensor.
This is the big cardboard "container" that holds and sorets all of the blocks at the end.
This is the longer vertical base.
This is the shorter horizontal base.
this is the longer horizontal base.
This is the slide platform wall that holds the distance sensor.
These are cardboard wheels we added to take weight stress of of the servo motor.
This is the slide platform that has a little hole in it for the pointed motor so the blocks have time and something to rest on for the color and size readings.
Full Exploded Drawing of the solidworks assembly.
Full 2D and isometric drawing of the final assembly.
This is another Drawing with everything colored, the blocks in the box, and an exploded view all in one.
This is a SolidWorks screenshot of the assembly moddled in the above image.
This is a gif from test day displaying the porject working perfectly.