0% found this document useful (0 votes)
43 views21 pages

Final Project Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views21 pages

Final Project Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

MSE Department – Faculty of Engineering – MSA University

Spring 2024
Course ID: MSE 365
Course Name: Introduction to Mechatronics

Final Project Report

Color Sorting Machine

Student Name ID
Eslam Wael Hussien 223243
Ahmed Ibrahim 222647
Marwan Amr 224293
Ziad Mohamed 221599
Lama Alaa 225213

Supervisor: Dr. Amgad M. Bayoumy

TA: Eng. Mariam Amro & Nour Essam


Table of contents
Chapter 1: Introduction (done)
1.1 Background
1.2 Problem definition
1.3 Function requirement
1.4 Project specification
1.5 Current technology

Chapter 2: System Design


2.1 Discussion of design
2.2 Design specification
2.3 System outline

Chapter 3: Mechanical Design


3.1 Mechanical design calculation
3.2 Mathematical modeling

Chapter 4: Electrical Design (Done)


4.1 Power supply calculations

Chapter 5: Control Design (done)


5.1 Simulation of mathematical modelling (SIMULINK)
5.2 Mechatronics Simulation (PROTEUS)

Chapter 6: Result and Discussion (done)

Chapter 7: Conclusions and Future Work (done)


7.1 Conclusions

Appendix A: Project Outline details (Done)


Appendix B: Mechanical Drawings (done)
Appendix C: Electric Drawings (Done)
Appendix D: Programming Code Listing (done)
Appendix E: Main Datasheets (done)

2
List of Figures

3
Chapter 1: Introduction

1.1Background

The Arduino Color Sorting Machine is a fascinating project that combines electronics,
programming, and mechanical design. It demonstrates how microcontrollers can be used in
automation and robotics to perform specific tasks, in this case, sorting objects based on their
color. This type of project is commonly undertaken by hobbyists, students, and educators to
explore principles of automation, sensors, and control systems.

Components and Materials


1. Arduino Microcontroller: The central brain of the project, typically an Arduino Uno
or similar board, which handles the logic and control signals.
2. Color Sensor: A TCS3200 color sensor is used to detect the color of the objects.
These sensors are capable of identifying different colors based on the RGB color
model.
3. Servo Motors: Used for actuating the sorting mechanism. Servos are precise and can
be controlled easily using PWM signals from the Arduino.
4. Sorting Mechanism: This can be a set of gates or arms controlled by servo motors to
divert objects into different bins based on their color.
5. Power Supply: Appropriate power supply to drive the motors and Arduino.

Working Principle:
1. Feeding Mechanism: Objects are fed into the machine, one at a time or along a
conveyor belt.
2. Color Detection: The color sensor reads the color of the object as it passes by.
3. Processing and Sorting: The Arduino code interprets the sensor data and determines
the object’s color.
4. Servo Actuation: Based on the color, the Arduino sends signals to the servo motors,
which then move the object to the designated bin.

Project Applications:
 Sorting M&Ms by color (popular beginner project)
 Separating different colored parts in a manufacturing process (industrial application)
 Recycling colored objects (educational project on sustainability)

Applications and Benefits


 Educational Tool: This project serves as an excellent educational tool for learning
about sensors, microcontroller programming, and automation.
 Industrial Relevance: Similar principles are used in industrial automation for sorting
and quality control in manufacturing processes.
 DIY Projects: Hobbyists can use this project as a stepping stone for more complex
automation and robotics projects.

4
Learning Outcomes:
 Electronics and programming: Gain hands-on experience with sensors, motors, and
Arduino coding.
 Automation concepts: Understand the principles of automated sorting and control
systems.
 Problem-solving and design: Develop skills in designing, building, and
troubleshooting a project.

1.2Problem definition
The specific problem addressed by this project is the development of an automated color
sorting machine capable of:
1. Identifying the color of various objects.
2. Sorting these objects into predefined categories based on their color.
3. Operating efficiently and accurately in a controlled environment.

Constraints
1. Environmental Conditions: The system should operate correctly under typical
indoor lighting conditions.
2. Object Specifications: Objects to be sorted should be within a certain size and shape
range for consistent handling.
3. Power Supply: The machine should operate within the power limits of standard
Arduino-compatible components.

Expected Outcomes
1. Prototype Development: Build and test a functional prototype of the Arduino color
sorting machine.
2. Performance Evaluation: Assess the machine’s accuracy, speed, and reliability in
sorting objects by color.
3. Documentation: Provide comprehensive documentation, including design
schematics, code, and a user manual for replication and educational purposes.

Potential Challenges
1. Sensor Calibration: Ensuring the color sensor is properly calibrated to work under
various lighting conditions.
2. Mechanical Design: Designing a robust and efficient mechanical sorting mechanism.
3. System Integration: Seamlessly integrating all components (sensors, motors,
conveyor) with the Arduino.

5
1.3Function requirement
1. Color Sensor Integration: Utilize a color sensor (TCS3200) to detect the color of
objects.
2. Control System: Program the Arduino to process color sensor data and control sorting
mechanisms.
3. Sorting Mechanism: Use servo motors or other actuators to direct objects into the
correct bins based on color.
4. User Interface: Provide a simple interface for users to start, stop, and possibly
calibrate the machine.

1.4Project specification
This report outlines the specifications for an Arduino-based color sorting machine.
4. System Functionality
1. The machine will automatically sort objects based on their color.
2. It will be able to differentiate between a minimum of [X] distinct colors (specify the
desired number of colors).
3. The sorted objects will be directed to separate bins or compartments.

2. Hardware Requirements
1. Microcontroller: Arduino Nano
2. Color Sensor: Suitable for the chosen color range (TCS3200)
3. Servo Motors: Minimum of [2] servos required for the sorting mechanism.
4. Frame or structure to hold everything together (wood)

1.5Current technology
The current technology used in developing an Arduino color sorting machine involves
integrating various electronic components and sensors with mechanical parts to create an
automated system capable of sorting objects by color. This technology leverages
advancements in microcontroller capabilities, sensor accuracy, and motor control to achieve
efficient and reliable sorting.

1. Arduino Microcontroller
 Arduino Nano: One of the most popular choices due to its simplicity,
affordability, and extensive community support. It features an ATmega328
microcontroller, 14 digital I/O pins, 8 analog inputs, and operates at 16 MHz.
 Other Variants: Depending on the complexity and scale, other Arduino boards
like the Mega (with more I/O pins) or Nano (more compact) may be used.
2. Color Sensors
 TCS3200: A programmable color light-to-frequency converter that can detect a
wide range of colors. It consists of an array of photodiodes with filters for red,
green, blue, and no filter.

6
1. Servo Motors
 SG90 Servo Motors: Commonly used for their affordability and ease of
control using PWM signals from the Arduino. They are suitable for actuating
sorting mechanisms due to their precision and range of motion.
Software and Programming
1. Arduino IDE
The primary environment for writing, compiling, and uploading code to the Arduino. The
IDE supports C/C++ programming and provides libraries for interfacing with sensors and
motors.
2. Libraries
 Servo.h: Arduino library for controlling servo motors.
 Wire.h: For I2C communication with sensors like the TCS3200.

3. Algorithm and Workflow


 Calibration: Initial setup to calibrate the color sensor under specific lighting
conditions.
 Color Detection: Reading sensor data to determine the RGB values of objects.
 Decision Making: Comparing RGB values with predefined thresholds to
classify the object’s color.
 Actuation: Controlling servo motors to sort objects into respective bins.

Chapter 2: System Design

7
Chapter 3: Mechanical Design

8
Chapter 4: Electrical Design

4.1 Power supply calculation


electing the Power Supply
 Choose a power supply that can provide the required voltage and current.
 Ensure that the power supply is stable and can handle the peak power requirements of
the system.
 Consider using a power supply with some margin of safety to accommodate for
fluctuations in power consumption.
Let's assume the following:
 Arduino Nano: 50 mA
 Color sensor: 10 mA
 Two servo motors: 200 mA each
 Conveyor belt motor: 500 mA
 Total current: 50 mA+10 mA+(2×200 mA)
+500 mA=960 mA50 mA+10 mA+(2×200 mA)+500 mA=960 mA
If all components operate at 5V, then the power supply should provide
5 V×0.96 A=4.8 W5 V×0.96 A=4.8 W.

Chapter 5: Control Design


9
5.1 Simulation of mathematical modelling (SIMULINK)

Creating a mathematical model and a SIMULINK simulation for an Arduino-based color


sorting machine involves several steps, including defining the system's components, deriving
the equations governing the system's behavior, and implementing the control logic. Here's a
detailed guide on how to approach this project:

1. Define the System Components


The color sorting machine typically consists of the following components:
 Sensors: To detect the color of the objects.
 Actuators: To move the objects to the appropriate bins.
 Microcontroller: An Arduino board to process the sensor data and control the
actuators.

2. Derive the Mathematical Model


The mathematical model will include:
 Sensor Model: The relationship between the sensor readings and the actual color of
the object.
 Actuator Dynamics: The behavior of the motors or servos used to sort the objects.
 Control Logic: The algorithm that decides which bin the object should go to based on
sensor data.

Assume the color sensor outputs a value 𝐶C that corresponds to a specific color. This can be
Sensor Model

modeled as: 𝐶=𝑓(color)C=f(color) where 𝑓f is a function mapping the color to sensor


output.
Actuator Dynamics

The actuator can be modeled as a first-order system τ +θ=Ku Where:

 𝜃 is the actuator position.


dt

 τ is the time constant.


 K is the gain.
 u is the control input.
Control Logic

input: 𝑢=𝑔(𝐶)
The control logic can be represented as a set of rules or a decision matrix based on the sensor

where 𝑔 is the control law that maps the sensor reading to actuator commands.

3. Implementing the Model in SIMULINK


In SIMULINK, you can create a block diagram to simulate the color sorting machine. Here's
a step-by-step outline:

10
a. Sensor Block
Create a block that simulates the sensor output based on the color of the object. Use a lookup
table or a mathematical function to represent the sensor model.
b. Actuator Block
Model the actuator as a transfer function or a state-space model. Use the transfer function:
K
G ( s )=
τs+1
c. Control Logic Block
Implement the control logic using a combination of logical operators, lookup tables, or a state
machine. This block will take the sensor output and generate the control signal for the
actuator.
d. System Integration
Connect all the blocks together to form the complete system. The sensor block outputs a
signal based on the object's color, the control logic block decides the appropriate bin, and the
actuator block moves the object accordingly.
4. Simulate the Model
Run the simulation in SIMULINK to test the behavior of the color sorting machine. Adjust
parameters and refine the model as needed to achieve the desired performance.
5. Implementing on Arduino
Once the SIMULINK model is validated, you can implement the control algorithm on an
Arduino. Here’s an outline of the Arduino implementation:
a. Setup the Hardware
 Connect the color sensor to the Arduino.
 Connect the actuators (servos or motors) to the Arduino.
 Set up the conveyor belt system.

11
5.2 Mechatronics Simulation (PROTEUS)

12
Chapter 6: Result and discussion

13
An Arduino color sorting machine is a practical and educational project that demonstrates the
power of automation using microcontrollers. Here's a breakdown of the key results and
discussion points:

Results:
 Successful Sorting: The machine can effectively separate objects based on their color
with a specified degree of accuracy.
 Automation Achieved: The repetitive task of color sorting is automated, saving time
and effort.
 Educational Value: The project provides hands-on learning in electronics,
programming, and automation principles.
Discussion:
 Accuracy: The achieved accuracy depends on various factors like sensor calibration,
color range complexity, and object variations. Fine-tuning the color thresholds and
potentially using more advanced color sensors can improve accuracy.
 Sorting Speed: The throughput depends on the chosen sorting mechanism and the
processing power of the Arduino board. Optimizing the code and using faster servo
motors can enhance speed.
 Scalability: The basic design can be adapted to handle different object sizes and
shapes with adjustments to the feeding mechanism and sorting chutes.
 Limitations: The processing power of Arduino limits complex color recognition
algorithms. For large-scale industrial applications, more powerful industrial control
systems might be needed.

Chapter 7: Conclusions and Future Work

Conclusion
The Arduino color sorting machine automates color sorting tasks and serves as a great
educational project in electronics, programming, and automation. It can be customized for
various objects but limitations exist in processing power for highly complex tasks.
Advancements in sensor technology and machine learning offer exciting possibilities for
creating more accurate and intelligent sorting machines in the future.

Further Considerations:

 Machine Learning Integration: Implementing basic machine learning on the


Arduino using libraries like TensorFlow Lite Micro can allow the machine to adapt to
a wider range of colors or object variations.
 IoT Integration: With Wi-Fi or Bluetooth enabled boards, the machine can be
monitored remotely or integrated into larger automation systems for data logging and
analysis.

14
 Improved Sorting Mechanism: Utilizing multiple sensors or more sophisticated
sorting mechanisms can enable the sorting of objects based on multiple colors or
complex sorting criteria.

Appendix A: Project Outline details


1. Introduction
 Brief overview of the color sorting machine.
 Mention of its purpose and functionality.
2. Components
 List of hardware components required for the machine.
 Arduino board.
 Color sensor.
 Servo motors (for actuation).
 Conveyor belt (for object movement).
 Power supply.
 Brief description of each component's role in the system.
3. System Architecture
 High-level overview of how the components interact.
 Description of the flow of data and control signals.
 Mention of the main tasks performed by the Arduino.
4. Operation
 Step-by-step explanation of the machine's operation.
1. Initialization:
 Setting up pins and sensors.
 Attaching servo motors.
 Initiating serial communication.
2. Object Detection:
 Moving the top servo to the initial position.
 Incrementally moving the top servo towards the color sensor.
 Reading color values from the sensor.
3. Sorting:
 Processing color data to determine object color.
 Positioning the bottom servo based on the detected color.
 Moving the top servo to drop the object into the corresponding bin.
4. Return to Initial Position:
 Returning the top servo to its initial position to prepare for the next
object.
5. Loop:
 Continuously repeating the above steps.
5. Color Detection Algorithm
 Description of how the color detection algorithm works.
 Setting up the sensor to read RGB values.
 Determining the color based on predefined thresholds.
 Handling cases where the color cannot be identified.

15
6. Implementation Details
 Technical details regarding the Arduino code and its structure.
 Pin assignments.
 Initialization process.
 Control flow for object detection, sorting, and return to initial position.
 Overview of the color sorting logic and servo control.
7. Challenges and Considerations
 Potential challenges in implementing the color sorting machine.
 Considerations for optimizing performance and accuracy.
 Possible extensions or improvements to the system.
8. Conclusion
 Summary of the Arduino color sorting machine project.
 Reflection on its functionality and potential real-world applications.
 Encouragement for further exploration or development.
9. References
 Citations or links to resources used in designing and implementing the color sorting
machine.
 Mention of any external libraries or tools utilized.

Appendix B: Mechanical Drawing

16
Appendix C: Electric Drawings

17
Appendix D: Programming Code Listing

#include <Servo.h>
#define S0 2
#define S1 3
#define S2 4
#define S3 5
#define sensorOut 6
Servo topServo;
Servo bottomServo;
int frequency = 0;
int color = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
digitalWrite(S0, HIGH); //20% scalling
digitalWrite(S1, LOW);
topServo.attach(7);
bottomServo.attach(8);

18
Serial.begin(9600);
}

void loop() {
topServo.write(0); //set top servo at the first hole to catch the candy
delay(500);

for(int i = 0; i <= 55; i++) { //move top servo with the candy to the color sensor position
topServo.write(i);
delay(2);
}
delay(500);

color = readColor(); //read the value from color sensor and put the bottom servo in the right
path
delay(10);
switch (color) {
case 1:
bottomServo.write(0);
break;
case 2:
bottomServo.write(50);
break;
case 3:
bottomServo.write(100);
break;
case 4:
bottomServo.write(70);

case 0:
break;
}
delay(300);

for(int i = 55; i <= 100; i++) { //move top servo with candy from the color sensor position to
the second hole position
topServo.write(i);
delay(2);
}
delay(200);

for(int i = 100; i >= 0; i--) { //return top servo to the first position to catch another candy
topServo.write(i);
delay(2);

19
}
color=0;
}

int readColor() { //color sensor function to read the color

// Setting red
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
Serial.print("R= ");
Serial.print(frequency);
Serial.print(" ");
delay(50);

// Setting Green
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
frequency = pulseIn(sensorOut, LOW);
int G = frequency;
Serial.print("G= ");
Serial.print(frequency);
Serial.print(" ");
delay(50);

// Setting Blue
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
frequency = pulseIn(sensorOut, LOW);
int B = frequency;
Serial.print("B= ");
Serial.print(frequency);
Serial.println(" ");
delay(50);

if(G<320 & G>305 & B>255 & B<275){


color = 1; // Red
}
if(G<280 & G>252 & R>270 & R<285){
color = 2; // Green
}
if (B<227 & B>203 & R>286 & R<304 ){

20
color = 3; // Blue
}
if (G<251 & G>238 & R>211 & R<235 ){
color = 4; // yellow
}
return color;
}

Appendix E: Main Datasheets


 Arduino nano datasheet  https://docs.arduino.cc/resources/datasheets/A000005-
datasheet.pdf
 Color sensor (tcs3200) datasheet 
https://media.digikey.com/pdf/Data%20Sheets/DFRobot%20PDFs/SEN0101_Web.pdf
 Servo motor datasheet (SG-90) https://www.friendlywire.com/projects/ne555-servo-
safe/SG90-datasheet.pdf

21

You might also like