How to generate the transfer function of a DC motor?

47 views (last 30 days)
Chak Chan
Chak Chan on 21 Dec 2017
Answered: Arkadiy Turevskiy on 20 Jun 2019
I'm designing a PID controller for a DC motor. The motor is controlled by a board based on STM32F4, so my question is, is there a way to automatically generate PID code on the board by measuring real-time input/output with Simulink? Any detailed answers/tutorials/videos would definitely help!
Thank you in advance!

Accepted Answer

Birdman on 21 Dec 2017
Edited: Birdman on 21 Dec 2017
Well, there is no online tool that will generate PID code for the controlled system. For that purpose, as usual, the best you can do is to model the DC motor with its transfer function model. For this, you can estimate its parameters. There are several videos and tutorials for this. All you need to do is to excite the system with some test inputs and record the output and the use Estimation Tool for it. All the things I mentioned will be done offline. Check the following links:
Also for the record, I leave the link of STM32F4 library in Simulink:
Chak Chan
Chak Chan on 21 Dec 2017
Currently the board supports communication with CAN and Dbus. Which one is more preferable?

Sign in to comment.

More Answers (1)

Arkadiy Turevskiy
Arkadiy Turevskiy on 20 Jun 2019
Starting in R2017b we are shipping capabilities for online tuning of PID controllers.
The best way to do this is by using Closed-Loop PID Autotuner block. You add this block to your Simulink model that you will generate code from, and you configure the model to activate autotuning based on a provided trigger signal.
The algorithm in this block will conduct an online experiment on your plant by injecting a small excitation signal and measuring the output. Beasued on measured data it will estimate plant frequency response and will compute PID gains that can automatically update existing PID gains once tuning is finished.
Take a look at this video and doc.
To tune PID gains on hardware (in generated code) with this capaility, you will need access to a license of Simulink Control Design and Simulink Coder.


More Answers in the  Power Electronics Control

Community Treasure Hunt

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

Start Hunting!