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”)
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:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox).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:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox). 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:
Oscilloscope Tektronix DPO2004B
– IVI-C Driver Tkdpo2k3k4k v1.5 https://www.tek.com/en/support/software/driver/dpo2000-mso2000-dpo3000-and-dpo4000-mso3000-and-mso4000-mdo3000-and
Used Software:
Matlab R2023b
Matlab Instrument Toolbox
Instrument Control Toolbox Support Package for National Instruments VISA and ICP Interfaces https://de.mathworks.com/help/instrument/install-the-national-instruments-visa-and-icp-interfaces-support-package.html
NI-VISA software packages (installed with the VISA instrument control toolbox). parallel computing, background computing, ivi-c, tektronix, oscilloscope, visa, bocked execution MATLAB Answers — New Questions