Skip to content

Zhetessov/Arduino-DC-Motor-Speed-Control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

PWM-Based DC Motor Speed Control Using Arduino and Encoder Feedback

This project investigates PWM-based speed control of a brushed DC motor using an Arduino UNO R4 WiFi, an L298N motor driver, and an integrated quadrature encoder. The system was evaluated in both open-loop and closed-loop modes to study the relationship between PWM duty cycle and motor speed, and to verify the performance of a PI controller under real hardware conditions.

Highlights

  • PWM-based DC motor speed control
  • Encoder-based speed measurement
  • Open-loop motor characterization
  • PI closed-loop speed regulation
  • Real hardware validation
  • Arduino UNO R4 WiFi + L298N + SGM25-370

Overview

The goal of the project is to regulate the speed of a brushed DC motor using PWM and encoder feedback.

The work includes:

  • open-loop characterization of PWM versus motor speed,
  • encoder-based speed measurement,
  • closed-loop PI control,
  • analysis of dead zone, quasi-linear response, and saturation behavior.

Hardware

  • Arduino UNO R4 WiFi
  • L298N dual H-bridge motor driver
  • SGM25-370 DC motor with integrated quadrature encoder
  • External battery pack
  • Jumper wires / breadboard

System Architecture

The control loop is:

Arduino → L298N driver → DC motor → encoder feedback → Arduino

The Arduino generates the PWM command, the L298N drives the motor, and the encoder measures rotational speed for feedback control.

Wiring

Arduino UNO R4 WiFi
├── D9   → L298N ENA (PWM)
├── D8   → L298N IN1
├── D7   → L298N IN2
├── D2   → Encoder Channel A
├── D3   → Encoder Channel B
├── 3.3V → Encoder VCC
└── GND  → Common Ground

L298N
├── OUT1 → Motor+
├── OUT2 → Motor-
├── +12V → Battery+
└── GND  → Battery-

Encoder
├── VCC → Arduino 3.3V
├── GND → Arduino GND
├── A   → D2
└── B   → D3

Experimental Results

The open-loop tests showed:

  • a clear dead zone at low PWM values,
  • an approximately linear region in the middle range,
  • saturation near the maximum PWM value.

The closed-loop PI controller improved tracking performance and maintained the motor speed close to the target value over the useful operating range.

The measured maximum speed was approximately 730–737 ticks per second under the tested conditions.

Results

Experimental Setup

Setup

Open-loop motor characteristic

Open Loop

Closed-loop tracking

Tracking

Repository Structure

.
├─ README.md
├─ PlatformIO/
│  ├─ platformio.ini
│  └─ src/
│     └─ main.cpp
└─ docs/
   ├─ report.pdf
   ├─ images/
   │  └─ setup.png
   └─ plots/
      ├─ open_loop.png
      ├─ pi_400.png
      ├─ pi_600.png
      └─ tracking.png

Documentation

Full project report:

About

PWM-based DC motor speed control with encoder feedback and PI regulation on Arduino UNO R4 WiFi.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages