I am developing a MATLAB App Designer GUI for a measurement system

The GUI needs to:
  • connect to multiple instruments:
  • Keysight P5001A VNA IVI-c (and TCP/IP commands?)
  • Pyrometer (RS-485 serial)
  • Amplifier HBH (TCP/IP)
  • Powermeter Anritsu (TCP/IP)
  • perform continuous measurements using a timer
  • update plots in real time
  • allow start/stop of measurements safely
  • handle connection/disconnection
My question is about software architecture:
Should I:
• implement each instrument as a separate MATLAB class?
• store instrument objects as properties of the app?
• use a single timer or multiple timers?
• separate GUI and measurement logic?
I already got told that there is a problem using two TCP/IP devices simultanius, as its overwrites the connection. I Already have a class for the two VNA´s i am using and a little example codes. Nonetheless i am still confused how to beginn and what to look for. So are there recommended design patterns or examples?
Thanks for Kind help in advance!

5 Comments

I do not recall hearing about problems with using multiple TCP/IP simultaneously. Would you happen to have links about that problem?
Its only someone has told me. The person made therefore two scripts and two GUI for the different devices used. I dont know if its because he didnt made classes for the devices and just connected them via an initialisation callback function.
I don't know of any specific examples that illustrate more than just one but I don't see anything in the doc for tcpclient that indicates you can't a connection on different ports for each instrument. Presuming you have the device(s), can't you just try that? It would seem maybe you already have from the sample code you do have written?
As for the generic questions, my recommendation is to not worry overmuch about the GUI initially; you can call any MATLAB code from the app although certainly you will want to maintain all the pertinent instrument instances in the globall "app" structure for easy reference throughout the app and in the callbacks.
As for timer(s), since each of these instruments is going to be running independently, it depends a little on whether they are triggered or polled to return readings and whether there's a triggering event that occurs before reading a response or if you are just polling continuous data streams. If you had the parallel TB, it might be possible to spawn each instrument into its own thread and then broadcast a trigger to each from a single timer; there will still be a slight time skew owing to the different latency and response time of each instrument. Otherwise, the choice would seem to be to have the time trigger a poll request to each device.
I wouldn't see there being a need nor any advantage in adding complexity of trying to have multiple independent apps; that just adds yet another level of complexity.
Thanks for the answer. I just looked at the code from my "presuccesor" and saw he didnt use tcpclient when trying to implment both devices. So maybe thats why he warned me about possible error? i dont know.
But for the generic part i got this article send to me : Developing MATLAB Apps Using the Model-View-Controller Pattern - MATLAB & Simulink. And i think i will follow the Guide from there.
About the timer(s): Thanks for the advice! its actually a good advice. Now i just need to work it out.
Thank you @dpb
Typically it is better to run the device asynchronously and have them serviced by callbacks.
Unless, that is, the devices need to be polled for current values

Sign in to comment.

Answers (0)

Categories

Products

Release

R2025b

Asked:

on 1 Mar 2026 at 0:58

Commented:

about 15 hours ago

Community Treasure Hunt

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

Start Hunting!