Send signals to Signal Table and Axes simultaneously using Simulink Real Time in App Designer

8 views (last 30 days)
Hello,
I am using simulink real time with speedgoat to plot 24 separate signals into an app using app designer, however I am starting out by simply trying to plotting only a few signals instead of all 24 bc I am still troubleshooting my code. I am trying to plot each signal to both an axes plot and to a signal table using the commands below. I can successfully do either the axes on their own, or the signal table on it's own, but when I try to have both incorporated into the app at the same time, the app will start as normal but refuse to actually plot anything at all in either instrument.
A FEW times I have successfully gotten both to populate/plot at at the same time, however this is very unreliable. I don't know why it is being inconsistent.
Do I need to have an slrealtime.Instrument() object for the signal tables? I'm not sure the proper syntax to use for that since the signal tables need a struct. First time posting a question like this, so if I need to provide more info please let me know. This is the startup callback code I am using below. Any help is much appreciated!
% AXES CALLBACK CODE THAT WORKS
app.LoadButton.Application = 'ACM_test';
instAxesP1 = slrealtime.Instrument();
instAxesP1.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 1);
instAxesP2 = slrealtime.Instrument();
instAxesP2.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 2);
instMgr = slrealtime.ui.tool.InstrumentManager(app.UIFigure);
instMgr.Instruments = [instAxesP1, instAxesP2];
********************************************
% SIGNAL TABLE CALLBACK CODE THAT WORKS
app.LoadButton.Application = 'ACM_test';
app.PressureTable.Signals = struct( ...
'BlockPath', {'ACM_test/IO135/Analog input ', ...
'ACM_test/IO135/Analog input '},...
'PortIndex', {1,2});
*********************************************
% COMBINED CALLBACK CODE THAT DOESN'T WORK
app.LoadButton.Application = 'ACM_test';
app.PressureTable.Signals = struct( ...
'BlockPath', {'ACM_test/IO135/Analog input ', ...
'ACM_test/IO135/Analog input '},...
'PortIndex', {1,2});
instAxesP1 = slrealtime.Instrument();
instAxesP1.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 1);
instAxesP2 = slrealtime.Instrument();
instAxesP2.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 2);
instMgr = slrealtime.ui.tool.InstrumentManager(app.UIFigure);
instMgr.Instruments = [instAxesP1, instAxesP2];
*********************************************

Answers (1)

Dimitri MANKOV
Dimitri MANKOV on 24 Jun 2022
Hi Josiah,
The syntax of your callbacks looks correct to me... I usually initialize the signal table in the "startup" callback of my UI, while the instrument objects are created in a separate callback of the same app. Does it change anything if you use one instrument object instead of several as follows?
app.LoadButton.Application = 'ACM_test';
app.PressureTable.Signals = struct( ...
'BlockPath', {'ACM_test/IO135/Analog input ', ...
'ACM_test/IO135/Analog input '},...
'PortIndex', {1,2});
instAxes = slrealtime.Instrument();
instAxes.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 1);
instAxes.connectLine(app.UIAxesPressure, 'ACM_test/IO135/Analog input ', 2);
instMgr = slrealtime.ui.tool.InstrumentManager(app.UIFigure);
instMgr.Instruments = instAxes;
Do you have several targets defined in the Simulink Real-Time Explorer, do you use the "Target Selector" component in your UI? If yes, perhaps it might make your app more robust if you change your code as follows:
app.LoadButton.Application = 'ACM_test';
app.LoadButton.TargetSource = app.TargetSelector;
...
instMgr = slrealtime.ui.tool.InstrumentManager(app.UIFigure);
instMgr.TargetSource = app.TargetSelector;
instMgr.Instruments = instAxes;
Hope this is helpful!
Dimitri

Community Treasure Hunt

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

Start Hunting!