Skip to content

Commit 3e348fc

Browse files
arianasadeghiPOPAGEORGEMATEIgenan2003
authored
Project: Automated Optical Sorting - Ariana Sadeghi (#1014)
* Adaugat documentatia si schema bloc * Adaugat documentatia si schema bloc * I changed the documentation format to respect the template * Revise project information and GitHub link Updated project details and GitHub link. * Salvat modificarile din index si adaugat diagrama * Fix structura foldere, sters SVG si adaugat schema PNG * Update diagrama hardware cu rezolutie marita (2,5x) * Sters fisierul fantoma Zone.Identifier generat de Windows * Schimbat formatul diagramei hardware din png in webp * Sters iar fisierul Zone.Identifier aparut la download * Apply suggestion from @genan2003 Co-authored-by: Omer Genan <81963672+genan2003@users.noreply.github.com> * Update GitHub project link in index.md * Fix markdown formatting: adaugat diagrama webp, reparat tabele si info block * Final documentation update: added async architecture and state machine * fix: remove base64-encoded images from SVG diagram * Actualizare documentatie finala si adaugare poze proiect --------- Co-authored-by: POPAGEORGEMATEI <119328898+POPAGEORGEMATEI@users.noreply.github.com> Co-authored-by: Omer Genan <81963672+genan2003@users.noreply.github.com>
1 parent 6e44109 commit 3e348fc

10 files changed

Lines changed: 118 additions & 0 deletions

File tree

39.2 KB
Loading

website/versioned_docs/version-acs_cc/project/2026/ariana.sadeghi/diagrama_pm.svg

Lines changed: 5 additions & 0 deletions
Loading
47.6 KB
Loading
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Automated Optical Sorting System
2+
An automated system designed to identify and sort objects based on their optical properties and weight using an STM32 microcontroller and Rust (Embassy).
3+
4+
:::info
5+
**Author:** Ariana Sadeghi \
6+
**GitHub Project Link:** [GitHub Repo](https://github.com/UPB-PMRust-Students/acs-project-2026-arianasadeghi)
7+
:::
8+
9+
## Description
10+
The project consists of an industrial-style sorting line that uses a TCS34725 color sensor to detect the RGB signature of objects and an HX711 load cell for weight validation. Based on the sensor data, a custom calibration algorithm classifies the items. A mechanical arm (SG90 servomotor) acts as the sorting mechanism, while a stepper motor drives the conveyor belt continuously. The system's status and detected colors are visually fed back in real-time through an SPI TFT display.
11+
12+
## Motivation
13+
I chose this project to explore the integration of multiple digital communication protocols (I2C, SPI) and precise motor control (PWM and Stepper sequences) in a real-time automation scenario using the Embassy async framework in Rust.
14+
15+
## Architecture
16+
**Main Components**
17+
* **Sensing Module:** TCS34725 Color Sensor (I2C) for optical recognition and HX711 Amplifier with a Load Cell for weight detection.
18+
* **Control Logic:** Continuous polling loop acting as a state machine for detection, classification, and precise timing delays.
19+
* **Actuation Module:** 28BYJ-48 Stepper motor (with ULN2003 driver) for the conveyor belt and an SG90 Servomotor (PWM) for the sorting arm.
20+
* **User Interface:** TFT LCD display controlled via SPI to show current calibration data and detected colors.
21+
22+
## Log
23+
* **Week 5 - 11 May:** Project idea selection and hardware requirements gathering. Basic component testing (Stepper and Servo motors) and pinout planning.
24+
* **Week 12 - 18 May:** Color sensor (TCS34725) I2C integration, TFT display SPI setup, and writing the initial color calibration logic.
25+
* **Week 19 - 25 May:** Finalizing the state machine integration in Rust, fine-tuning the RGB calibration thresholds for specific object colors, adjusting servo timings to sync with the conveyor belt, and completing GitHub documentation.
26+
27+
## Hardware
28+
The system is built around an STM32 Nucleo board programmed in Rust.
29+
The main peripherals include:
30+
* **TCS34725:** RGB Color Sensor for object detection.
31+
* **HX711:** Load cell amplifier with a 1kg/5kg load cell.
32+
* **1.8" TFT Display:** SPI-driven screen for visual feedback.
33+
* **28BYJ-48 Stepper Motor & ULN2003:** Drives the conveyor belt.
34+
* **SG90 Servomotor:** Acts as the sorting arm.
35+
36+
## Schematics
37+
![Schema Hardware](./diagrama_pm.svg)
38+
39+
## Physical Implementation
40+
Below are the layout views of the fully assembled automated sorting system, showcasing the conveyor alignment, sensor housing, and mechanical integration.
41+
42+
![Overall System Assembly](./project.webp)
43+
*Figure 1: Overall assembly of the conveyor belt line and electronics integration.*
44+
45+
![Sensing Zone and Optical Shield](./color_sensor.webp)
46+
*Figure 2: Close-up of the TCS34725 color sensor featuring a custom paper shield to block ambient light reflections.*
47+
48+
![Sensing Zone with Object](./object_sensor.webp)
49+
*Figure 3: Color sensor actively scanning an object passing underneath on the conveyor belt.*
50+
51+
![Stepper Motor Drive](./step_motor.webp)
52+
*Figure 4: The 28BYJ-48 stepper motor and mechanical coupling driving the conveyor belt.*
53+
54+
![Sorting Servo Arm](./servo_in_action.webp)
55+
*Figure 5: SG90 servomotor configured as the sorting arm, positioned to intercept rejected items.*
56+
57+
![TFT Interface](./object_display_color.webp)
58+
*Figure 6: The 1.8" SPI TFT display providing real-time visual feedback of the detected colors.*
59+
60+
![TFT Interface Close-up](./display.webp)
61+
*Figure 7: Close-up view of the TFT screen displaying active color recognition.*
62+
63+
![STM32 Nucleo Wiring](./stm32.webp)
64+
*Figure 8: The STM32 Nucleo board handling all I2C, SPI, and PWM signals asynchronously.*
65+
66+
67+
## Bill of Materials
68+
69+
| Device | Usage | Price |
70+
|---|---|---|
71+
| STM32 Nucleo Board | Main Microcontroller | - |
72+
| TCS34725 Module | Optical/Color Sensing | 22,68 RON |
73+
| HX711 | Weight Sensing | 4,57 RON |
74+
| Load Cell | Weight Sensing | 12,80 RON |
75+
| 1.8" TFT Display | User Interface | 40,62 RON |
76+
| 28BYJ-48 | Conveyor movement | 10,29 RON |
77+
| ULN2003 | Conveyor movement | 4,97 RON |
78+
| SG90 Servomotor | Sorting Arm | 9,49 RON |
79+
80+
## Software
81+
82+
**Concurrency & Async Execution**
83+
The software architecture leverages the cooperative multitasking model provided by the Embassy framework in Rust. Since the stepper motor requires precise step impulses every 3ms to maintain constant conveyor speed, a traditional blocking approach (`delay_ms`) would freeze sensor polling and screen updates. By utilizing `async/await` and asynchronous hardware timers (`Timer::after_millis`), the system interleaves the conveyor drive loop, the I2C color polling, and the SPI screen drawing tasks seamlessly. This ensures zero jitter for the motor and deterministic real-time execution without the overhead of a traditional RTOS.
84+
85+
**System State Machine**
86+
The control loop operates as a finite state machine (FSM) with the following operational transitions:
87+
* **IDLE / SCANNING:** Conveyor belt runs continuously; the system polls the TCS34725 Clear channel waiting for a threshold drop.
88+
* **COLOR_IDENTIFICATION:** Object detected; RGB channels are sampled and evaluated against the software-defined calibration boundaries.
89+
* **WEIGHT_VALIDATION:** The system captures data from the HX711 load cell using a moving average filter to determine and validate the mass.
90+
* **SORTING_ACTION:** A specific PWM duty cycle is sent to the SG90 servomotor after a precise kinematic delay, moving the arm to sort the object.
91+
* **RESET:** The servo returns to its default position (0°), the TFT display resets to idle status, and the FSM returns to the scanning state.
92+
93+
**High-Level Logic**
94+
Practically, the software follows these stages during a successful sorting cycle:
95+
1. **Movement:** The stepper motor runs continuously using a non-blocking sequence to drive the conveyor belt.
96+
2. **Detection:** Continuous polling of the TCS34725 sensor via I2C to read Clear, Red, Green, and Blue light channels, alongside weight readings from the HX711.
97+
3. **Decision:** Comparing RGB values against preset, fine-tuned thresholds to identify specific colors (e.g., White, Yellow, Pink, Purple, Brown).
98+
4. **Action:** Updating the TFT display with the detected color and triggering a precise PWM sequence to extend and retract the Servo arm at the exact moment the object passes.
99+
100+
**Libraries and Drivers**
101+
102+
| Library | Description | Usage |
103+
|---|---|---|
104+
| `embassy-stm32` | Hardware Abstraction (HAL) | Peripheral control (I2C, SPI, PWM, GPIO) |
105+
| `embassy-time` | Time Management | Delay management and timing for the stepper/servo |
106+
| `defmt` / `defmt-rtt` | Logging Framework | Real-time debugging and color calibration output |
107+
108+
109+
## Links
110+
* [Embassy Rust Documentation](https://embassy.dev/)
111+
* [TCS34725 Color Sensor Datasheet](https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf)
112+
* [HX711 Datasheet](https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf)
113+
* [Laboratories text](https://embedded-rust-101.wyliodrin.com/docs/acs_cc/category/lab)
54.2 KB
Loading
40.5 KB
Loading
58.8 KB
Loading
32.3 KB
Loading
46.9 KB
Loading
87.6 KB
Loading

0 commit comments

Comments
 (0)