Want to Switch Axis Ratio During Real-Time Run in Speedgoat/Simulink

7 views (last 30 days)
I am using a real-time application with an instrument panel that has three signal axes in a component grid. While streaming data in real-time, I want to set up a radiobutton set which can be selected to adjust the x-axis from 0-10 to 0-5, or 0-15 seconds for example. The data being streamed is a few minutes long, and thus when the data reaches the end of the signal axes, it wraps back to the begining, and the axis again will update for another 10 seconds, ie axis limits are [10,20] if in default settings after an update. I want to switch these axis limits mid run, but I cannot get the AxesTimeSpan to appropriately change based on the radibutton selected. Instead the axis will always wrap and only display another 10 seconds of data. Furthermore I would like to update the axis when the radiobutton value is changed, so the new axis limit will be the current time when the button was switched, plus one interupt, for logistics sake. I cannot find a way to get the current simulation time, which I need to be able to reset the axis limits as app.InstrumentedSignalsAxes.XLim = [CurrentSimTime+1, CurrentSimTime+1+(xWrapTime)] where xWrapTime is the length of the x-axis which is to be displayed before a wrap, ie 5, 10 or 15 seconds
Currently the Axes are defaulted to
hInst = slrealtime.Instrument();
hInst.AxesTimeSpan = 10;
And when I want to change the axis update during wraps I change the code to
hInst = slrealtime.Instrument();
hInst.AxesTimeSpan = 5;
in the radiobutton callback.
However this does not work when the figure wraps again. Instead it jsut wraps with the 10 seconds as mentioned before.
Finally when trying to find the system time as an output, to reset the x limits, I have tried to get the data from a clock block, but keep getting errors stating the the block is not loaded. I could be using the wrong get, as I tried get_param for the clock value, and I have also tried to getparam(systemtime) however this again seems to not work for 2022a.
Any help would be appreciated, and if more information is needed please let me know. Thanks!

Accepted Answer

Dimitri MANKOV
Dimitri MANKOV on 24 Jun 2022
Edited: Dimitri MANKOV on 24 Jun 2022
Hi Todd,
In general, you can use the "ModelStatus.ExecTime" property of the target object to get the current execution time of your real-time application, as documented here. However, I'm not sure to which extent this approach would be applicable to your use case, since you would need to continuously fetch that value from the target (for example using a timer object), which goes against the way that the instrumentation object is supposed to be used, in my opinion.
Here's a simple App Designer UI example that adjusts the axes time span successfully during runtime:
The following callbacks are used for both components:
% Value changed function: TimeSpanEditField
function TimeSpanEditFieldValueChanged(app, event)
value = app.TimeSpanEditField.Value;
app.Instrument.AxesTimeSpan = value;
end
% Value changed function: Switch
function SwitchValueChanged(app, event)
value = app.Switch.Value;
app.Instrument.AxesTimeSpanOverrun = value;
end
... where app.Instrument is defined as:
app.Instrument = slrealtime.Instrument;
Does that approach work for you?
Best,
Dimitri

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!