Adaptive PID Controller For DC Motor Speed Control

33 views (last 30 days)
Mnh
Mnh on 11 Oct 2025 at 17:28
Commented: Umar on 15 Oct 2025 at 12:53
I am currently working on a project titled “Speed Control of a DC Motor Using an Adaptive PID Controller.” However, during the control process, I have encountered several issues that cause the motor to operate unstably. Specifically, the plant does not closely follow the reference model at low and medium speed ranges. Therefore, I would like to ask if anyone has a Simulink diagram related to this topic that I could refer to.
  4 Comments
Umar
Umar on 15 Oct 2025 at 6:01

Hi @Mnh,

This will take some time to figure out the root cause. Let me review it carefully and I will get back to you. Hope you are not in rush.

Umar
Umar on 15 Oct 2025 at 12:53

Hi @Mnh,

Thanks for your patience. I went through your code thoroughly and did some extensive research on this error. The root cause is that your 30ms sample time is too fast when combined with real-time plotting and encoder communication - the Arduino can't keep up with the data requests, which is why you're getting the "unable to receive data" error at the readCount() line.

The main issues are: (1) T = 0.03s is too aggressive for this complexity, (2) updating 6 animated plots every cycle creates massive overhead that conflicts with hardware timing, and (3) Arduino Uno's limited 2KB RAM struggles when running RotaryEncoder library with intensive operations.

Quick fixes that should solve it: increase your sample time to T = 0.05 or 0.06, reduce plotting frequency by only updating plots every 5 iterations instead of every cycle (add a counter), and wrap your readCount() in a try-catch block for error handling. Also make sure Arduino IDE is closed when running MATLAB since they can conflict on the serial port.

The timing pressure is what's killing the communication.

Sign in to comment.

Answers (1)

Sabin
Sabin on 13 Oct 2025 at 8:22
Without a sample model we can not really point to any specific problem. You can start building the simulation model using existing examples in Simscape Electrical. This example shows a cascade speed-control structure for a DC motor:
Simscape Electrical also provide a discrete-time PID-based model reference adaptive control that can be used in the example I mentionded:

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!