Interfacing Simulink Real-Time and Matlab on Speedgoat

14 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Jon Lobo
Jon Lobo il 21 Ago 2019
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).

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by