필터 지우기
필터 지우기

How to use parallel background computing for triggering a oscilloscope measurement device (VISA API, IVI-C) from a matlab GUI? (error "Cannot parse adapters.config file")

조회 수: 6 (최근 30일)
I want to trigger and collect data of my Tektronix DPO2004B Oscilloscope (Connected via USB and VISA API using a IVI-C Driver) from a Matlab GUI/App. For communication with the Oscilloscope I use the Quick-Control Oscilloscope instrument functionality (https://de.mathworks.com/help/instrument/oscilloscope.html)
If i use the function getDataFromOszilloscope() (see code below) it works fine, but the whole process of data collection takes about 7 seconds. When i call this function from a Matlab app, the execution will be blocked for a long time and other tasks can't be handled during this time. Therefore i want to call this function in a parallel background pool. When i use f = parfeval(backgroundPool, @getDataFromOszilloscope,1); the following error occurs during the connection process inside oscilloscope().
Errormessage: Identifier "instrument:oscilloscope:failedToParseConfigFile"; "Cannot parse adapters.config file".
I guess the problem could be, that the backgroundPool uses all my Workers (6x) on the machine and this doesn't work for this kind of device object, but i have no experience with parallel computing and scheduling. The function can be called when i use the parfeval(@getDataFromOszilloscope,1) without a backgroundPool and one Worker, but it still blocks the rest of my functionality because its not fully separated. I made a solution with the batch() function but it takes a lot of time to start the parallel pool every time i trigger the data acquisition.
Is there any way to get data from this oscilloscope without blocking the execution of other code inside the GUI?
%% Get data from Oszilloscope
p = backgroundPool; %Create backgroundPool
counter = 1;
numOfMeasurements = 4;
f(1:numOfMeasurements) = parallel.FevalFuture; %preallocate Future Object
%% Read specified number of measurements
while true
%Exit while loop if all measurements are collected in Background
if sum(ismember({f.State},'finished')) == numOfMeasurements
out = fetchOutputs(f); %get data from background execution (Matlab throws error here but Problem occurs during parfeval)
break;
end
%Call Oszi at first iteration and after finishing calculation in background
if counter == 1 || strcmp(f(counter-1).State,'finished')
disp('Calling getData')
%Trigger oscilloscope for data collection in background
f(counter) = parfeval(p, @getDataFromOszilloscope,1); %Error
counter = counter+1;
end
disp(f(counter-1).State) %Output to check status of background calculation
% OTHER CODE FOR FURTHER EXECUTION IN APP WILL FOLLOW HERE
end
disp('END')
%% Function for connecting to oscilloscope via installed IVI instrument driver (Uses VISA API)
% Error occurs during connection with the Oscilloscope
function data = getDataFromOszilloscope()
pause(0.1)
VisaAddress = 'USB0::0x0699::0x039B::C020206::0::INSTR';
IVI_Driver = 'Tkdpo2k3k4k';
myScope = oscilloscope(VisaAddress,IVI_Driver); %THE ERROR OCCURS HERE WHEN EXECUTED IN BACKGROUND!
data = readWaveform(myScope,'acquisition', true); %Get Data from Oscilloscope
end
Further information:
Hardware + Driver:
Used Software:

채택된 답변

Harald
Harald 2023년 10월 24일
Hi,
only a limited set of functions is supported in backgroundPool. If a function is supported, this is listed in the "Extended Capabilities" section of the documentation.
batch will always start and shut down workers and is therefore not a good idea for this application.
I would expect things to work in a "regular" parpool, i.e.
p = parpool("Processes", 1);
Best wishes,
Harald
  댓글 수: 1
Florian Zacherl
Florian Zacherl 2024년 8월 22일 9:15
Hi Harald, sorry for the late response and thank you very much for your help. I could solve my problem with parpool("Processes",1).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by