Interfacing Simulink Real-Time and Matlab on Speedgoat
7 次查看(过去 30 天)
显示 更早的评论
I am trying to control inputs to a Modbus block in a simulink model running on a Speedgoat Real time target machine. Is it possible to control the input parameter from a Matlab script while the HIL simuluation is running? I have tried using setparam, but it only changes the value on the Simulink model, but not on the real time simulation. The only way I know to change values is on the slrt explorer. I need to be able to change values automatically while simultanesouly running a loop in Matlab.
0 个评论
回答(1 个)
Jon Lobo
2019-8-21
Hi Michaela,
This is absolutely doable. You might notice that when you build your Simulink model and download to the Speedgoat target that there is a SimulinkRealTime.target object called "tg" in the base workspace.
If it isn't there, you can also execute the following in MATLAB.
tg = slrt;
From the tg object, you'll be able to see various information about the target computer: name of application on target, status, signals, parameters etc.
The object also has some methods you can use for getting and setting parameters on the target. In particular, try using "tg.setparam" (setparam).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Target Computer Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!