GUI for a Simulink realtime workshop model setting values for gain constans etc
5 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am currently writing a GUI program in matlab for a simulink real time workshop model. I wish my GUI to control an external plant. I wish the user to be able to edit system variables (such as P I and D of a PID controller) using my GUI. I have had significant difficulty with thus. If this were a non realtime simulink model I would use the following :
options = simset('SrcWorkspace','current');
sim('model.mdl',[],options);
To set the simulations workspace to be the same as the GUI’s, and then simply create the variables in the workspace that I wished to input into my model. Unfortunately using this method is not possible as it not possible to use the sim() command with a real time system. It is instead run using the commands:
set_param('model','SimulationMode','external');
set_param('model','SimulationCommand','connect');
set_param('model','SimulationCommand','start');
I would be most grateful if anyone could point me in the right direction.
Thanks,
Paul
0 个评论
采纳的回答
Fangjun Jiang
2011-12-5
Go to your document, Real-Time Workshop->External Mode->Using the External Mode User Interface->Parameter Downloading,
There are instructions regarding downloading parameters. If you are not doing batch downloading, you can use set_param() the same way as you do in a normal mode. Pay attention if you want to change parameters for a source block.
0 个评论
更多回答(1 个)
Paulo Silva
2011-12-4
Use the set_param, make each PID value/gain a variable from workspace, when you change any of those variables you also need to do
set_param('model','SimulationCommand','update');
By default I think that the simulation use the workspace to look for variables it has in the parameters of the blocks, you can use GUIs to change values and send them to workspace using the assignin function
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!