Adaptive PID Controller For DC Motor Speed Control
4 Comments
Hi @Mnh, Thanks for sharing the details about your project. However, the message could use a bit more information to help others provide effective support. For example, could you clarify:
What specific issues or errors are you encountering during simulation or implementation?
What kind of adaptive PID controller are you using (e.g., gain scheduling, model reference adaptive control)?
Are you implementing this in a purely simulation-based environment or also on hardware?
Can you share a basic overview or screenshot of your current Simulink model setup?With this information, the community will be in a better position to assist you. Looking forward to more details!
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.
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.
Answers (1)
0 votes
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!