What is causing the user-interface error of "Error Generated by Remote Interface" on my function generator?

27 次查看(过去 30 天)
I've been trying to automate my lab's Keysight 33600A Series Waveform Generator with MATLAB. I'm trying to write a simple frequency sweep.
So far, my code has been able to control and automate the process. However, everytime the frequency is incremented, the waveform generator screen flashes "Error Generated by Remote Interface". Even though the user interface on the waveform generator is changing with respect to my script (value of frequency), the actual voltage is never delivered as an output.
I was reading here that the strings I am sending to the instrument could be incompatible with the driver. I am not sure how to verify or probe this myself. Any ideas on how to have my code work in unison with the instrument drivers?
Seen below is my script:
%% KEYSIGHT 33600A Series - Waveform Generator
% Note: In order to use this script, one needs to first download and
% install:
% MATLAB Instrument Toolbox
% MATLAB Instrument Driver for Keysight VISA
close all
clear all
clc
%% Configuring PC with Function Generator Driver via USB
resourceList = visadevlist
visaUSB = visadev("USB0::0x0957::0x5707::MY53805141::0::INSTR"); % Creates connection to a device through VISA resource name
instrhwinfo('ivi')
% Driver Information: IVI
% https://www.mathworks.com/hardware-support
% /instrument-control-toolbox
% /agilent-3352x-function-arbitrary-waveform-generator-from-matlab.html?s_tid=srchtitle
%% Instrument Connection
% Find a VISA-USB object.
obj1 = instrfind('Type', 'visa-usb', 'RsrcName', 'USB0::0x0957::0x5707::MY53805141::0::INSTR', 'Tag', '')
% Create the VISA-USB object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = visa('KEYSIGHT', 'USB0::0x0957::0x5707::MY53805141::0::INSTR');
else
fclose(obj1);
obj1 = obj1(1);
end
%% Instrument Connection, Configuration, and Control
% Communicating with instrument object, obj1.
fopen(obj1);
f_max = 10000; % [Hz]
inc = 101; % [Hz]
f_Sweep = linspace(0,f_max,inc)
for i = 1:length(f_Sweep)
fprintf(obj1, ':VOLTAGE 4.9'); % [Vpp]
fprintf(obj1, sprintf(':FREQUENCY %d',f_Sweep(i)))
pause(1)
end
% Disconnect from instrument object, obj1.
fclose(obj1);

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2024-1-23
Hi Keiran Fung,
It appears to me that you are having hard time in resolving the error: "Error Generated by Remote Interface". Based on the script you provided, here are a few things you might consider revising to troubleshoot the issue:
  • Frequency Command Format: The frequency command should specify the frequency in a format that the instrument expects. It's common for instruments to require frequency values to be in floating-point format, and sometimes the units (e.g., Hz, kHz, MHz) need to be explicitly stated.
  • Frequency Range: The "linspace" function in your script includes 0 Hz as the starting frequency, which might not be a valid frequency for the generator to output. Devices typically have a minimum frequency limit above 0 Hz.
  • Error Checking: After each command, it is a good practice to check for errors reported by the instrument. This can be done by querying the instrument's error queue.
Here is a revised version of your code with these points addressed:
%% KEYSIGHT 33600A Series - Waveform Generator
close all;
clear all;
clc;
%% Configuring PC with Function Generator Driver via USB
resourceList = visadevlist;
visaUSB = visadev("USB0::0x0957::0x5707::MY53805141::0::INSTR"); % Creates connection to a device through VISA resource name
instrhwinfo('ivi');
%% Instrument Connection
% Find a VISA-USB object.
obj1 = instrfind('Type', 'visa-usb', 'RsrcName', 'USB0::0x0957::0x5707::MY53805141::0::INSTR', 'Tag', '');
% Create the VISA-USB object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = visa('KEYSIGHT', 'USB0::0x0957::0x5707::MY53805141::0::INSTR');
else
fclose(obj1);
obj1 = obj1(1);
end
%% Instrument Connection, Configuration, and Control
% Communicating with instrument object, obj1.
fopen(obj1);
f_max = 10000; % [Hz]
inc = 101; % [Hz]
% Ensure the frequency sweep starts from a minimum frequency above 0 Hz.
f_min = 1; % Minimum frequency, set above 0 Hz
f_Sweep = linspace(f_min, f_max, inc);
for i = 1:length(f_Sweep)
fprintf(obj1, ':VOLTAGE 4.9'); % [Vpp]
% Use floating-point format and specify units (Hz)
fprintf(obj1, sprintf(':FREQUENCY %fHZ', f_Sweep(i)));
pause(1);
% Check for errors from the instrument
fprintf(obj1, 'SYST:ERR?');
errorStr = fscanf(obj1);
if ~contains(errorStr, '+0,"No error"')
disp(['Error for frequency ', num2str(f_Sweep(i)), ' Hz: ', errorStr]);
break; % Exit the loop if there is an error
end
end
% Disconnect from instrument object, obj1.
fclose(obj1);
I hope this helps!
Best Regards,
Abhishek Chakram

类别

Help CenterFile Exchange 中查找有关 Instrument Connection and Communication 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by