AnsweredAssumed Answered

3458A digitizing Matlab

Question asked by lhornburg Employee on Apr 19, 2013
Latest reply on Jan 26, 2016 by roehr
Attached is a simple program showing how to digitize with the 3458A in Matlab.  Data is sent directly over the bus, bypassing memory.

clear all; close all; clc;


dmm = visa('AGILENT','GPIB0::22::INSTR');
set (dmm,'InputBufferSize',400000);
set (dmm,'timeout', 25);  %set the bus timeout for 25 seconds
set (dmm, 'ByteOrder', 'bigEndian');
fopen(dmm);
fprintf (dmm,'reset');
fprintf (dmm,'end always');  %sets up the correct EOL, use end on if using internal memory 
fprintf (dmm,'id?');
id = fscanf (dmm);
id
fprintf (dmm,'preset dig'); %presets DMM for DCV digitizing (see page 218 of 3458A user's manual)
fprintf (dmm,'mem fifo');
fprintf (dmm,'dcv 10');
fprintf (dmm,'trig auto');
fprintf (dmm,'nrdgs 1000'); %set for 1000 rdgs per trigger


fprintf (dmm,'iscale?');    %get scale factor for sint format 
scale = fscanf (dmm,'%f');

fprintf (dmm,'tarm sgl'); %Arm instrument once and begin triggering

[data] = fread(dmm,1000,'short');  %Read the data

scaledreadings = scale*data;  %multiply alldata by proper scaling factor
plot(scaledreadings)  %plot the data
scaledreadings        %output to screen

fclose(dmm);  

Attachments

Outcomes