📄 esg_arb.m
字号:
% function esg_arb(filename, waveform_data, scale)
% where:
% waveform_data = complex input data
% scale = optional parameter which
% scales the from .0001 to 1
% of the dac fullscale
%
% This function loads a Matlab vector, waveform_data, into the memory
% of the Dual Arbitrary Waveform Generator of a
% Hewlett Packard ESG-D Signal Generator (with option
% UND). There are two parts which must be in the
% Matlab path: esg_arb.m
% esg_darb.dll
%
% This was developed in Matlab 5.0.
%
% The function only works under Microsoft Windows NT or
% Windows 95 or later.
%
% It is necessary to have the signal generator connected to
% the PC via GPIB. The computer must have a GPIB
% interface card from either Hewlett Packard (82341 but
% NOT 82335 )or National Instruments installed. If the
% card is from HP, the associated SICL library must be
% installed.
%
% This function takes a vector, waveform_data, which is made up of
% complex data. The real part will be loaded into the
% I part of the Dual Arbitrary Waveform Memory, and the
% imaginary part of waveform_data is loaded into the Q part of the
% ARB memory. Before downloading, the data in waveform_data is
% scaled to the appropriate range and then converted to
% 14 bit integers (for the 14 bit dacs).
%
% There is a special case if both the real and imaginary
% parts of the data are constant and less than or equal
% to one. In this case, the values will scale to +1
% being dac full scale, and -1 being dac 0. This is
% useful for entering dc values.
%
% This program will automatically find the GPIB card,
% interface, and the ESG's address.
%
% No checking is done for ARB memory available.
% No checking is done to see if the requested filename
% is being 'played' in the ESG-D.
% No checking is done to see if the UND option is installed
% in the ESG-D signal generator.
%
function esg_arb(esg_gpib_addr, filename, waveform_data, scale);
system_dependent(7) % Causes messages to flush to screen immediately
[numrows, numcols] = size(waveform_data);
if (numrows > 1)
waveform_data = waveform_data.'; % Make a row vector.
end
[numrows, numcols] = size(waveform_data);
if (numrows > 1)
disp(' ')
error('Input data must be a single dimension vector.')
end
if (numcols < 16)
disp(' ')
error('Input data vector must have at least 16 points.')
end
if exist('scale') < .5 % If scale wasn't passed in
scale = 1;
end
scale = max(scale, .0001); % Limit the scale factor to
scale = min(scale, 1); % .0001 to 1.0
if length(filename)==0 % Ensure filename is not blank
filename = 'user';
end
if length(filename)>16 % Limit length of filename
filename = filename(1:16);
end
disp(' ');
disp(['Converting Data to ESG Arbitrary Waveform format.']);
center = 8192; % Center of dac ( 0 volts out)
mx = max([max(abs(real(waveform_data))) max(abs(imag(waveform_data)))]);
% Add a special case: If the data in real and imaginary parts
% are constant and less than or equal to 1, use the data to
% give a dc voltage out based on full scale being 1 and
% 0 scale being -1.
if (max(real(waveform_data)) == min(real(waveform_data)))
if (max(imag(waveform_data)) == min(imag(waveform_data)))
if ((max(abs(real(waveform_data))) <= 1) & (max(abs(imag(waveform_data))) <= 1))
mx = 1;
end
end
end
if mx~=0 % Range is 8192-8192 to 8192+8191
waveform_data = waveform_data/mx*(center-1); % Scale to +/- 8191
end
waveform_data = waveform_data*scale; % Apply any user-entered scale
waveform_data = waveform_data + center + j*center; % Add in the dac offset
waveform_data = round(waveform_data); % Round to integers
clear numrows numcols;
clear center;
clear mx;
% At the moment, don't know how to force this DLL to use a specific ESG
% (at esg_gpib_addr). May figure this out later.
% esg_darb(esg_gpib_addr, waveform_data, filename); ???
esg_darb(waveform_data, filename);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -