Multiple measurement in parallel with Instrument Toolbox and Parallel Comuting Toolbox

4 views (last 30 days)
Hello,
I am trying to find a way to make multiple measurements with MATLAB in parallel.
I will first explain my case. I have a simple RF system, in my case an RF cavity, I am looking for the incident RF power, the reflective power, the transmitted power, and also for the RF source spectrum. For this, I bought three wattmeters, compatible with Intrument Toolbox, and of course a spectrum analyzer. I created a GUI with GUIDE, where I have three text areas. And I want to display, on this GUI, the power measured by each wattmeter, and the spectrum (in the same window or in a second window).
The only one solution I found is to create a kind of "update function" which gets the last measurement of each wattmeter one by one, and then the spectrum analyzer. It is not very convenient but OK. My problem is the following: I need to know the different powers very quickly, but I only need the spectrum once every 10 seconds, and the spectrum is very very long to acquire with the required accuracy (due to the required acquisition bandwidth). So, with my solution, the wattmeter measurements are frozen until the spectrum is acquired.
I was wondering if I could solve it with the Parallel Toolbox. For example, with spmd, I can launch the wattmeters on one thread, and the spectrum analyzer on another thread. But I don't succeed to display the result of the wattmeters. If I try to use things like "set(handles.text2,'String',num2str(i)); " in the wattmeters thread, where handles.text2 is the first textbox and i the measurement, it does not update the textbox in the spmd block. If I try to use things like warndlg, I have the message : "Warning: dialog is no longer supported when MATLAB is started with the -nodisplay or -noFigureWindows option or there is no display."
Would somebody know how to display a result in a dialogbox or in a GUI when using parallel code ? (I can display it in the command window, but it is really not convenient...) Or would there be another solution to not have to wait for the spectrum analyzer and continue the code ?
I can send examples for illustration.
Thank you.

Answers (2)

Walter Roberson
Walter Roberson on 9 Oct 2017
It is not possible to update graphics from within a parallel worker.
It is possible to acquire data within a parallel worker, and there are various ways to move the data back to the main routine or to a different worker.
On the other hand, it is common for there to be methods to acquire data in background, with it taking whatever interrupts it needs to in order to get the data where it needs to be. It is possible to arrange to have routines called when the data is received -- and those routines could update the displayed spectrum.
To advise more carefully we would need to see some of your current acquisition code.

Guillaume
Guillaume on 9 Oct 2017
Dear Walter,
Thank you for your answer. I send you an example of code using a Rohde&Schwarz wattmeter and a Tektronix Spectrum Analyzer. I use the libraries proposed by the manufacturers.
This code works on my PC, but due to the very low bandwidth (10 Hz), it is really slow. I would like to display the wattmeter independently of the spectrum analyzer.
I attached the Matlab code.
Guillaume
  5 Comments
Guillaume
Guillaume on 11 Oct 2017
I did some tests, I found another solution. The spectrum analyzer uses a device object library, and visibly, with the functions, invoke(myDevice,"AcquireData") and invoke(myDevice,"WaitForTraceReady",TimeOut), I get something similar to "readasync". At least, I can use it to continue the code, if the result of WaitForTraceReady is that the trace is not ready. It is a bit tricky, but it works...
Thank you,
Guillaume
Walter Roberson
Walter Roberson on 11 Oct 2017
When using readasync() you would normally configure the visa object with BytesAvailableFcn to trigger a callback when data is ready. You would set ByteAvailableFcnMode to control whether you want to read a particular number of bytes or whether you want to read to a terminator (likely what you would want). You might need to configure the object InputBufferSize. Actually you might want to skip readasynch() and just configure the ReadAsynchMode to 'continuous' along with having configured Terminator and BytesAvailableFcnMode and BytesAvailableFcn

Sign in to comment.

Categories

Find more on Instrument Connection and Communication in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!