How to display the real-time numerical value of a Simulink signal in a box in an App Designer app?
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have been trying to display the value of a signal in my GUI. For clarity to people reading this, I have text boxes in an app (made using Simulink's AppDesigner) called measurement1, measurement2, and measurement3. There are also three signals in my Simulink model called signal1, signal2, and signal3, which are always changing in real-time to various values ranging from 0 to 300. The paths for these signals are 'System/UI/signal1', 'System/UI/signal2', and 'System/UI/signal3'.
I want to show the numerical value of signal1 in the GUI, in the measurement1 text box. The same for signal2 in measurement2, and signal3 in measurement3.
To avoid confusion: In the picture, you can see I convert them to strings. This is just so their values appear in the Simulink displays called disp_signal1/2/3. Without converting to a string, their values would not appear in those displays.

GUI/App:

I tried following what appears to be a similar problem here: https://www.mathworks.com/matlabcentral/answers/875213-how-to-display-the-current-value-of-a-tagetpc-signal-in-a-numeric-edit-field-app-designer-and-up
But it wasn't quite enough to help me. I tried following the solution but it wasn't working (the text box still just shows 0). It's possible I was not supposed to type everything as shown, but I am not sure what parts of that code only apply to their model/GUI. I also tried doing this:
app.measurement1.Text = getsignal(tg, 'System/UI/signal1', 1);
But it says:
Error using slrealtime.Target/throwErrorWithCause
Unable to get 'System/UI/signal1:1' signal value on target computer 'TargetPC1: 'System/UI/signal1' block does not exist.
Error in slrealtime.Target/getsignal
Caused by:
Error using slrealtime.internal.SignalAccess/getSignalInfoFromCodeDescriptor
'System/UI/signal1' block does not exist.
0 Commenti
Risposta accettata
Dimitri MANKOV
il 6 Feb 2025
Hi Kevin,
Have you tried using a Simulink Real-Time Insturement object instead of the "getsignal" function embedded within a timer object? The instrument object has been introduced in MATLAB R2020b and greatly simplifies the design of UIs for Simulink Real-Time in App Designer.
Futhermore, the Simulink Real-Time App Generator tool introduced in MATLAB R2022a can help you generate a first draft of a UI specific to your application, with the correct instrumentation callbacks written automatically.
I hope this is helpful!
Dimitri
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Target Computer Setup in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!