% Remote control of a function-generator by GPIB from Matlab ICT. % Hewlett-Packard 33120A '15MHz function / arbitrary waveform generator'. % % This script is (relatively) short and clear because it uses a % separate function fg_cmd() that does most of the work. % % 2010-02-16. % Nathaniel. % %% open the function generator instrument and do basic settings global ih; fg_cmd('!!CONNECT!!'); %% set up an 'arbitrary waveform' on the function generator Vpk = 2.5; % peak voltage f = 50; % frequency at which to repeat the waveform-data Vdc = 0.0; % offset voltage (dc level) % how many points to use: min is 8, max is 16000 N = 1024; % make the waveform: as an example, let's have a first-half of % a sinusoid, then a possible gap (zero) then the other half % of the sinusoid, then a similar gap % how much of the total time should be on the sinusoid (nonzero) duty = 0.5; % the signal s = [ ... sin( linspace(0, pi, round(N*duty/2)) ), ... zeros(1, round(N*(1-duty)/2)), ... sin( linspace(pi, 2*pi, round(N*duty/2)) ), ... zeros(1, round(N*(1-duty)/2)) ... ]; % check/correct number of points (arkward duty cycles might % have caused rounding errors when generating s) if length(s)>N, s = s(1:N); warning('the auto-generated data has been truncated'); elseif length(s)