Using Simulink signal as a function variable (Real time Control System)
3 views (last 30 days)
Show older comments
I am working with an existing model of a brushless DC motor in order to simulate a control system I want to use on an actual motor. I have modeled a Fuzzy Logic controller that uses the error and change in error in order to actively tune the Proportional and Integral gains of the PI-controller, which is already built into the motor model I have. My problem is that the model I am using defines the P and I gains as constants within an S-function that runs as part of the simulation, whereas I would like input my tuned gains (which are constantly updating based on the simulation progression) in real-time.
I was originally saving the gain values to variables in the workspace, but these do not update until the end of the sim, and therefore are not helpful. I would like to be able to call these updated gains into the control function of the system in real time. Is this possible to do with the existing model? I realize that the 'best' approach would normally be to re-make my own model and use the gains as input signals in the system. However, as this is merely for simulation purposes, it is not worthwhile for me to spend time doing this - I merely would like it as a proof-of-concept.
0 Comments
Answers (2)
Ryan G
on 17 Jul 2012
Edited: Ryan G
on 17 Jul 2012
You need to make sure the P and I gains are Tunable Parameters in the s-function. Based on what you have already written about your issue it sounds like they are not tunable.
7 Comments
Ryan G
on 17 Jul 2012
If you look at the script for the EML I wrote you see I utilize assignin. This updates the base workspace parameter. After that the set_param function is essentially triggering the block, in this case an s-function, to determine that it has updated the parameter and will re-check the workspace for that parameter and update accordingly.
See Also
Categories
Find more on Event Functions 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!