Agentic AI for Real-Time Adaptive PID Control of a Servo Motor
Abstract
1. Introduction
2. Materials and Methods
2.1. Hardware
2.1.1. Electromechanical Parameters
2.1.2. Servo Motor and Model
2.2. PID Control
2.3. Derivative Filter and Frequency Control
2.4. Calculation of Error Metrics
2.4.1. Overshoot and Steady-State Error
2.4.2. Rise Time and Settling Time
2.4.3. Integral Absolute Error (IAE)
2.4.4. Integral Squared Error (ISE)
2.4.5. Mean Absolute Error (MAE)
2.4.6. Root Mean Squared Error (RMSE)
2.4.7. Integral Time-Weighted Absolute Error (ITAE)
2.4.8. Integral Time-Weighted Squared Error (ITSE)
2.5. Agentic AI Framework
2.6. Real-Time PID Tuning
2.6.1. n8n Integration and PID Control Agent
2.6.2. Optimizer Agent
2.6.3. System Prompts
2.7. Overall Workflow
3. Results
3.1. Real-Time Autonomous Tuning
3.1.1. LLM Model with Tuning Strategy
“Initial PID values started with Kp=0.1, Ki=0, Kd=0, which resulted
in a high steady-state error and significant negative overshoot.
Incremental steps were taken: by increasing Kp, the SSE improved,
though overshoot stayed high.
Introducing Ki and Kd gradually while fine-tuning Kp helped move the
overshoot closer to zero and reduced SSE to around 0.05,
though initial changes were inconsistent.
Further adjustments were made by increasing Kp to improve rise time
(while monitoring overshoot) and then fine-tuning with Ki and Kd,
which led to a balanced response.
Final PID values achieved a steady-state error around 0.21 and
overshoot slightly negative but near zero, with a low rise time of
about 0.18 s. The settling time remained somewhat high, which could be due to conservative system response or minor noise effects.
Final PID values: Kp = 0.2375 Ki = 0.125 Kd = 0.0375”
3.1.2. LLM Model Without Tuning Strategy
Fine Tuning—System Prompt | Fine Tuning—Without System Prompt | |||||
---|---|---|---|---|---|---|
Run | Kp | Ki | Kd | Kp | Ki | Kd |
Run 1 | 0.3375 | 0.175 | 0.0750 | 0.35 | 0.10 | 0.10 |
Run 2 | 0.1250 | 0.10 | 0.0250 | 0.80 | 0.125 | 0.05 |
Run 3 | 0.2375 | 0.125 | 0.0375 | 0.35 | 0.10 | 0.10 |
3.2. Overall Performance
3.3. Human Interaction with the System
3.4. Video Demonstration
4. Discussion
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
LLM | Large Language Model |
AI | Artificial Intelligence |
PID | Proportional–Integral–Derivative |
SSE | Steady-State Error |
IAE | Integral Absolute Error |
ISE | Integral Squared Error |
MAE | Mean Absolute Error |
RMSE | Root Mean Squared Error |
ITAE | Integral Time-Weighted Absolute Error |
ITSE | Integral Time-Weighted Squared Error |
HMI | Human–Machine Interaction |
HRI | Human–Robot Interaction |
Appendix A
Appendix A.1
- PID Control Agent—System Prompt
Appendix A.2
- Optimizer Agent—System Prompt
Appendix A.3
- Optimizer Agent—Without System Prompt/Instructions
Appendix B
Appendix B.1
- Output—Without System Prompt/Instructions
Appendix C
Appendix C.1
- Question: Why Did You Reduce Kp?
- Question: If Load Torque Increases by 10%, How Should the Controller Change?
- Question: What if the Sampling Rate Is Doubled? Do You Think It Is a Good Idea for the Current System?
References
- Romero, M.L.; Suyama, R. Agentic AI for Intent-Based Industrial Automation. arXiv 2025, arXiv:2506.04980. [Google Scholar] [CrossRef]
- Cui, C.; Liu, J.; Hui, P.; Lin, P.; Zhang, C. GenControl: Generative AI-Driven Autonomous Design of Control Algorithms. arXiv 2025, arXiv:2506.12554. [Google Scholar] [CrossRef]
- Arif, T.M. Deep Learning on Embedded Systems: A Hands-On Approach Using Jetson Nano and Raspberry Pi, 1st ed.; John Wiley & Sons: Hoboken, NJ, USA, 2025. [Google Scholar]
- Mueller, B. AI in My PID Loops? It’s More Likely Than You’d Expect. Autom. World 2025. Available online: https://www.automationworld.com/control/article/55279765/control-system-integrators-association-csia-ai-in-industrial-process-control-enhancing-thepid-loop. (accessed on 7 April 2025).
- Arif, T.M.; Rahim, M.A. Deep Learning for Engineers, 1st ed.; Routledge: New York, NY, USA, 2024. [Google Scholar] [CrossRef]
- Arif, T.M. Introduction to Deep Learning for Engineers: Using Python and Google Cloud Platform; Synthesis Lectures on Mechanical Engineering; Springer: Cham, Switzerland, 2020; p. xv + 93. [Google Scholar] [CrossRef]
- Barlow, E.; Arif, T.M.; Bentley, P.; Hiatt, H.; Call, C. An Iterative Actuation Method for Master-Slave Telemanipulation by Humanoid Robot Arm. In Proceedings of the ASME International Mechanical Engineering Congress and Exposition, New Orleans, LA, USA, 29 October–2 November 2023; Volume 6: Dynamics, Vibration, and Control. [Google Scholar] [CrossRef]
- Intelligent Autonomous Systems Group, TU Darmstadt. Intelligent Autonomous Systems Group. Web Page, 2025. Available online: https://www.ias.informatik.tu-darmstadt.de/ (accessed on 30 August 2025).
- D Brown, e.F.; Xie, S.Q. Effectiveness of Intelligent Control Strategies in Robot-Assisted Rehabilitation—A Systematic Review. IEEE Trans. Neural Syst. Rehabil. Eng. 2024, 32, 1828–1840. [Google Scholar] [CrossRef]
- Ding, Y.; Ren, X.; Zhang, X.; Liu, X.; Wang, X. Multi-Phase Focused PID Adaptive Tuning with Reinforcement Learning. Electronics 2023, 12, 3925. [Google Scholar] [CrossRef]
- Lakhani, A.I.; Chowdhury, M.A.; Lu, Q. Stability-Preserving Automatic Tuning of PID Control with Reinforcement Learning. arXiv 2022, arXiv:2112.15187. [Google Scholar] [CrossRef]
- Gundogdu, T.; Komurgoz, G. Self-tuning PID control of a brushless DC motor by adaptive interaction. IEEJ Trans. Electr. Electron. Eng. 2014, 9, 384–390. [Google Scholar] [CrossRef]
- Salem, A.; Mustafa, M.; Ammar, M. Tuning PID Controllers Using Artificial Intelligence Techniques. In Proceedings of the International Conference on Electrical Engineering, Kuta, Bali, Indonesia, 24–25 November 2014; Volume 9, pp. 1–13. [Google Scholar]
- Oonpramuk, M.; Tunyasirut, S.; Puangdownreong, D. Artificial Intelligence-Based Optimal PID Controller Design for BLDC Motor with Phase Advance. Indones. J. Electr. Eng. Inform. (IJEEI) 2019, 7, 720–733. [Google Scholar]
- Arif, T.M.; McKay, S.; Conklin, B. A Novel Platform Orientation System for Proportional-Integral-Derivative-Controlled Ball-Catching Robot. ASME Lett. Dyn. Syst. Control 2022, 2, 040903. [Google Scholar] [CrossRef]
- Tohma, K.; İbrahim Okur, H.; Gürsoy-Demir, H.; Aydın, M.N.; Yeroğlu, C. SmartControl: Interactive PID controller design powered by LLM agents and control system expertise. SoftwareX 2025, 31, 102194. [Google Scholar] [CrossRef]
- Zahedifar, R.; Soleymani, M.; Taheri, A. LLM-Controller: Dynamic Robot Control Adaptation Using Large Language Models. Robot. Auton. Syst. 2025, 186, 104913. [Google Scholar] [CrossRef]
- Åström, K.; Hägglund, T. The future of PID control. Control Eng. Pract. 2001, 9, 1163–1175. [Google Scholar] [CrossRef]
- Isdaryani, F.; Feriyonika, F.; Ferdiansyah, R. Comparison of Ziegler-Nichols and Cohen Coon tuning method for magnetic levitation control system. J. Physics Conf. Ser. 2020, 1450, 012033. [Google Scholar] [CrossRef]
- Bennett, J.; Bhasin, A.; Grant, J.; Lim, W.C. 9.3: PID Tuning via Classical Methods. Engineering LibreTexts, Chemical Process Dynamics and Controls (Woolf), 2025. Available online: https://eng.libretexts.org/Bookshelves/Industrial_and_Systems_Engineering/Chemical_Process_Dynamics_and_Controls_(Woolf)/09%253A_Proportional-Integral-Derivative_(PID)_Control/9.03%253A_PID_Tuning_via_Classical_Methods (accessed on 30 August 2025).
- Fernández-Ramos, J.; Narvarte, L.; López-Soria, R.; Almeida, R.; Carrêlo, I. An assessment of the proportional-integral control tuning rules applied to Photovoltaic Irrigation Systems based on Standard Frequency Converters. Sol. Energy 2019, 191, 468–480. [Google Scholar] [CrossRef]
- Sen, R.; Pati, C.; Dutta, S.; Sen, R. Comparison Between Three Tuning Methods of PID Control for High Precision Positioning Stage. MAPAN J. Metrol. Soc. India 2015, 30, 65–70. [Google Scholar] [CrossRef]
- Muresan, C.I.; Birs, I.; Ionescu, C.; Dulf, E.H.; De Keyser, R. A Review of Recent Developments in Autotuning Methods for Fractional-Order Controllers. Fractal Fract. 2022, 6, 37. [Google Scholar] [CrossRef]
- Pedret, C.; Vilanova, R.; Moreno, R.; Serra, I. A refinement procedure for PID controller tuning. Comput. Chem. Eng. 2002, 26, 903–908. [Google Scholar] [CrossRef]
- Hornsey, S. A Review of Relay Auto-Tuning Methods for the Tuning of PID-Type Controllers. In Reinvention: An International Journal of Undergraduate Research; School of Science and Engineering, Teesside University: Middlesbrough, UK, 2012; Volume 5. [Google Scholar]
- Divakar, K.; Praveen Kumar, M.; Dhanamjayulu, C.; Gokulakrishnan, G. A Technical Review on IMC-PID Design for Integrating Process with Dead Time. IEEE Access 2024, 12, 124845–124870. [Google Scholar] [CrossRef]
- Feng, L.; Ni, Y.H. Accelerated optimization landscape of linear–quadratic regulator. Automatica 2025, 171, 111927. [Google Scholar] [CrossRef]
- Leitão, D.; Cunha, R.; Lemos, J.M. Adaptive Control of Quadrotors in Uncertain Environments. Eng 2024, 5, 544–561. [Google Scholar] [CrossRef]
- Murugan, N.; Mohamed Ismail, M.R. An Efficient Coordinated Observer LQR Control in a Platoon of Vehicles for Faster Settling Under Disturbances. World Electr. Veh. J. 2025, 16, 28. [Google Scholar] [CrossRef]
- Zheng, Z.A.; Ye, Z.; Zheng, X. Intelligent vehicle lateral control strategy research based on feedforward + predictive LQR algorithm with GA optimisation and PID compensation. Sci. Rep. 2024, 14, 22317. [Google Scholar] [CrossRef] [PubMed]
- Camacho, E.F.; Bordons, C. Model Predictive Control, 2nd ed.; Advanced Textbooks in Control and Signal Processing; Springer: London, UK, 2007. [Google Scholar] [CrossRef]
- Mackenroth, U. Robust Control Systems: Theory and Case Studies, 1st ed.; Springer: Berlin/Heidelberg, Germany, 2004. [Google Scholar] [CrossRef]
- Green, M.; Limebeer, D.J.N. Linear Robust Control, reprint ed.; Dover Books on Electrical Engineering; Dover Publications: New York, NY, USA, 2012. [Google Scholar]
- Hajar, J.; Ghane, R.; Hassibi, B. Beyond Quadratic Costs: A Bregman Divergence Approach to H∞ Control. arXiv 2025, arXiv:2505.00319. [Google Scholar] [CrossRef]
- Zhu, J.Y.; Gomez Cano, C.; Vazquez Bermudez, D.; Drozdzal, M. InCoRo: In-Context Learning for Robotics Control with Feedback Loops. arXiv 2024. [Google Scholar] [CrossRef]
- Fei, H.; Xue, T.; He, Y.; Lin, S.; Du, G.; Guo, Y.; Wang, Z. Large language model-driven natural language interaction control framework for single-operator bimanual teleoperation. Front. Robot. AI 2025, 12, 1621033. [Google Scholar] [CrossRef]
- Menon, A.R.; Sharma, R.K.; Singh, P.; Wang, C.; Ferreira, A.M.; Novak, M. Think, Act, Learn: A Framework for Autonomous Robotic Agents using Closed-Loop Large Language Models. arXiv 2025. [Google Scholar] [CrossRef]
- n8n GmbH. N8n—Workflow Automation Tool. 2024. Available online: https://n8n.io/ (accessed on 2 August 2025).
- Quanser Inc. QUBE-Servo2. Available online: https://www.quanser.com/products/qube-servo-2/ (accessed on 1 August 2025).
- Ogata, K. Modern Control Engineering, 5th ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2010. [Google Scholar]
- Dorf, R.C.; Bishop, R.H. Modern Control Systems, 13th ed.; Pearson: London, UK, 2016. [Google Scholar]
- Flask Web Framework. Version 2.0. 2021. Available online: https://flask.palletsprojects.com/ (accessed on 1 August 2025).
- Grinberg, M. Flask Web Development: Developing Web Applications with Python, 2nd ed.; O’Reilly Media: Sebastopol, CA, USA, 2018. [Google Scholar]
- OpenAI. O3-Mini Language Model. 2024. Available online: https://openai.com/index/openai-o3-mini/ (accessed on 2 August 2025).
- OpenAI. GPT-4.1-Mini Language Model. 2024. Available online: https://openai.com/index/gpt-4-1/ (accessed on 2 August 2025).
- Khan, M.T.; Waheed, A. Foundation Model Driven Robotics: A Comprehensive Review. arXiv 2025, arXiv:2507.10087. [Google Scholar] [CrossRef]
- Vemprala, S.H.; Bonatti, R.; Bucker, A.; Kapoor, A. ChatGPT for Robotics: Design Principles and Model Abilities. IEEE Access 2024, 12, 55682–55696. [Google Scholar] [CrossRef]
- Zhao, C.; Tan, Z.; Ma, P.; Li, D.; Jiang, B.; Wang, Y.; Yang, Y.; Liu, H. Is Chain-of-Thought Reasoning of LLMs a Mirage? A Data Distribution Lens. arXiv 2025, arXiv:2508.01191. [Google Scholar]
- Motamed, S.; Culp, L.; Swersky, K.; Jaini, P.; Geirhos, R. Do generative video models understand physical principles? arXiv 2025. [Google Scholar] [CrossRef]
- Rajput, V. Why Scaling RAGs for Production Is So Hard? AIGuys on Medium. 2024. Available online: https://medium.com/aiguys/why-scaling-rags-for-production-is-so-hard-a2f540785e97 (accessed on 17 September 2025).
Video | Link |
---|---|
Video 1 | https://drive.google.com/file/d/1OD_wtOu5WGKWhlSoacgME-8QdfR5AGtZ/view?usp=sharing (accessed on 15 September 2025) |
Video 2 | https://drive.google.com/file/d/1hIQhX_PGSJ4vXkFlxAPIH54zEdsQdcDN/view?usp=sharing (accessed on 15 September 2025) |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Arif, T.M.; Rahim, M.A. Agentic AI for Real-Time Adaptive PID Control of a Servo Motor. Actuators 2025, 14, 459. https://doi.org/10.3390/act14090459
Arif TM, Rahim MA. Agentic AI for Real-Time Adaptive PID Control of a Servo Motor. Actuators. 2025; 14(9):459. https://doi.org/10.3390/act14090459
Chicago/Turabian StyleArif, Tariq Mohammad, and Md Adilur Rahim. 2025. "Agentic AI for Real-Time Adaptive PID Control of a Servo Motor" Actuators 14, no. 9: 459. https://doi.org/10.3390/act14090459
APA StyleArif, T. M., & Rahim, M. A. (2025). Agentic AI for Real-Time Adaptive PID Control of a Servo Motor. Actuators, 14(9), 459. https://doi.org/10.3390/act14090459