MATLAB Answers

0

How to generate the transfer function of a DC motor?

Asked by Chak Chan on 21 Dec 2017
Latest activity Answered by Arkadiy Turevskiy on 20 Jun 2019
Hi,
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!

  0 Comments

Sign in to comment.

2 Answers

Answer by Birdman
on 21 Dec 2017
Edited by Birdman
on 21 Dec 2017
 Accepted Answer

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:

  3 Comments

The motor can actually communicate with the board based on STM32F4. In that case, is possible to read the input/output of the motor using Simulink(i.e., use Simulink as an oscilloscope)?
Of course, you can use the analog input/output pins of the board and analog input/output blocks from the Simulink.
Currently the board supports communication with CAN and Dbus. Which one is more preferable?

Sign in to comment.


Answer by 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.

  0 Comments

Sign in to comment.