Skip to content

Commit b9883aa

Browse files
Merge branch 'main' into project/jianu_novac.carp
2 parents 239b3e1 + 166222d commit b9883aa

204 files changed

Lines changed: 23691 additions & 12551 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# Line Follower Robot
2+
3+
Autonomous robot that follows a line using an infrared sensor array and controls two DC gear motors through an L298N motor driver, based on an STM32 microcontroller.
4+
5+
:::info
6+
7+
**Author**: Andrei Bem \
8+
**GitHub Project Link**: https://github.com/UPB-PMRust-Students/acs-project-2026-bemandrei
9+
10+
:::
11+
12+
## Description
13+
14+
This project consists of building an autonomous line follower robot using an STM32 microcontroller as the main control unit. The robot is designed to follow a black line drawn on a light surface using an infrared (IR) sensor array mounted at the front.
15+
16+
The IR sensors detect differences in reflectivity between the black line and the white background. These signals are read by the STM32 board, which processes them in real time and decides how the robot should move.
17+
18+
The robot uses two DC gear motors (yellow TT motors) for movement. These motors are controlled through an L298N motor driver, which allows independent control of each motor. This enables the robot to turn left or right by adjusting the speed or direction of each wheel.
19+
20+
A key aspect of this project is the use of two separate power sources:
21+
- one battery pack for the STM32 (logic)
22+
- one battery pack for the motors (through L298N)
23+
24+
This design ensures stable operation by preventing voltage drops and noise generated by motors from affecting the microcontroller.
25+
26+
## Motivation
27+
28+
I chose this project because it represents a fundamental concept in robotics: autonomous navigation using simple sensors.
29+
30+
The project helped me understand:
31+
- how embedded systems interact with hardware components
32+
- how to read and process digital sensor signals
33+
- how to control motors using a driver module
34+
- how to design a stable power system
35+
36+
Additionally, this project is a good introduction to embedded programming using STM32 and real-time control systems.
37+
38+
## Architecture
39+
40+
The system is divided into four main layers:
41+
42+
**Sensing Layer**: IR Sensor Array
43+
A board containing multiple infrared sensors placed in a line. Each sensor detects whether it is positioned over a dark line or a light surface.
44+
45+
**Control Layer**: STM32 Microcontroller
46+
The STM32 board reads sensor inputs via GPIO pins and applies the control logic. Based on the sensor pattern, it determines the movement direction.
47+
48+
**Actuation Layer**: L298N Motor Driver + DC Motors
49+
The L298N module receives control signals from the STM32 and drives the motors. Each motor can be controlled independently, allowing differential steering.
50+
51+
**Power Layer**: Dual Battery System
52+
- Battery pack 1 → STM32 (logic)
53+
- Battery pack 2 → L298N + motors
54+
55+
All grounds are connected together to ensure proper signal reference.
56+
57+
### Architecture Diagram
58+
59+
![Architecture Diagram](schematics/architecture.svg)
60+
61+
### Hardware photo
62+
63+
## Electrical Design and Connections
64+
65+
The system is built using three main hardware blocks: STM32 board, IR sensor array and L298N motor driver.
66+
67+
### 1. Motor Driver (L298N)
68+
69+
The L298N module controls the motors and acts as an interface between STM32 and the motors.
70+
71+
Connections:
72+
73+
- OUT1 + OUT2 → Left motor
74+
- OUT3 + OUT4 → Right motor
75+
76+
Control signals from STM32:
77+
78+
- IN1 → GPIO (controls left motor direction)
79+
- IN2 → GPIO
80+
- IN3 → GPIO (controls right motor direction)
81+
- IN4 → GPIO
82+
83+
Optional:
84+
- ENA → PWM pin (left motor speed control)
85+
- ENB → PWM pin (right motor speed control)
86+
87+
Power supply:
88+
- +V (VIN) → Motor battery pack (+)
89+
- GND → Motor battery (-)
90+
91+
---
92+
93+
### 2. IR Sensor Array
94+
95+
The IR sensor board is placed in front of the robot and contains multiple sensors.
96+
97+
Connections:
98+
99+
- VCC → STM32 power (3.3V or 5V depending on module)
100+
- GND → STM32 GND
101+
102+
Outputs:
103+
104+
- OUT1 → STM32 GPIO
105+
- OUT2 → STM32 GPIO
106+
- OUT3 → STM32 GPIO
107+
- OUT4 → STM32 GPIO
108+
- OUT5 → STM32 GPIO
109+
110+
Each output returns a digital signal indicating whether the line is detected.
111+
112+
### 3. STM32 Board Power
113+
114+
The STM32 is powered separately from the motors:
115+
116+
- VCC → Battery pack (logic supply)
117+
- GND → Common ground
118+
119+
### 4. Power System (VERY IMPORTANT)
120+
121+
The robot uses **two battery packs**:
122+
123+
- Battery pack 1 → powers STM32
124+
- Battery pack 2 → powers L298N and motors
125+
126+
Even though power is separated, **ALL GNDs MUST BE CONNECTED**:
127+
- STM32 GND
128+
- L298N GND
129+
- Sensor GND
130+
131+
Without a common ground, the system will not function correctly.
132+
133+
### Functional Flow
134+
135+
1. Sensors detect the line position
136+
2. STM32 reads sensor signals
137+
3. Control logic determines direction
138+
4. STM32 sends commands to L298N
139+
5. L298N drives motors
140+
6. Robot adjusts movement continuously
141+
142+
## Log
143+
144+
### Week 1 - 7 May
145+
146+
Researched how line follower robots work and how IR sensors detect surfaces.
147+
Chose components and designed the architecture.
148+
149+
### Week 8 - 14 May
150+
151+
Assembled the robot chassis and mounted motors and wheels.
152+
Connected L298N and tested motor movement.
153+
154+
### Week 15 - 21 May
155+
156+
Connected IR sensor array and tested sensor readings.
157+
Implemented basic movement logic.
158+
159+
### Week 22 - 28 May
160+
161+
Improved control logic and movement stability.
162+
Worked on documentation and testing.
163+
164+
## Hardware
165+
166+
**STM32 Development Board**
167+
Main controller used for reading sensors and controlling motors.
168+
169+
**IR Sensor Array**
170+
Detects the position of the line.
171+
172+
**L298N Motor Driver**
173+
Controls the motors.
174+
175+
**DC Gear Motors (TT Yellow Motors)**
176+
Provide movement.
177+
178+
**Rubber Wheels**
179+
Attached to motors.
180+
181+
**Battery Packs (x2)**
182+
Separate power for logic and motors.
183+
184+
**Chassis**
185+
Supports all components.
186+
187+
**Jumper Wires**
188+
Electrical connections.
189+
190+
### Schematics
191+
We have schematic file mad with AUTODESK FUSION!
192+
193+
![Schematic diagram](schematics/fusion_schematic.svg)
194+
195+
### Bill of Materials
196+
197+
| Device | Usage | Price |
198+
|--------|-------|-------|
199+
| STM32 Development Board | Main controller | 60 |
200+
| L298N Motor Driver | Motor control | 10.99 |
201+
| IR Sensor Array | Line detection | 15 |
202+
| DC Gear Motors (x2) | Movement | 20 |
203+
| Wheels (x2) | Movement | 10 |
204+
| Battery pack (motors) | Power | 15 |
205+
| Battery pack (STM32) | Power | 15 |
206+
| Jumper wires | Connections | 10 |
207+
| Chassis | Structure | 20 |
208+
209+
## Software
210+
211+
The firmware is implemented using embedded Rust.
212+
213+
| Library | Description | Usage |
214+
|---------|-------------|-------|
215+
| `embassy-stm32` | STM32 support | GPIO and timers |
216+
| `embassy` | Async runtime | Task scheduling |
217+
| `embedded-hal` | Hardware abstraction | GPIO |
218+
| `defmt` | Logging | Debugging |
219+
220+
### Control Logic
221+
222+
| Sensor Input | Action |
223+
|-------------|--------|
224+
| Center sensors active | Move forward |
225+
| Left sensors active | Turn left |
226+
| Right sensors active | Turn right |
227+
| No sensors active | Stop |
228+
229+
## Links
230+
231+
https://en.wikipedia.org/wiki/Line_follower
232+
https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html
Lines changed: 65 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)