AnsweredAssumed Answered

3458A programming in Matlab

Question asked by lhornburg Employee on Apr 19, 2013
Attached is a simple 3458A program I wrote in Matlab which utilizes the internal memor.  If you have any questions let me know.

Please note, using the internal memory slows things down a lot.


clear all; close all; clc;


dmm = visa('AGILENT','GPIB0::22::INSTR');
set (dmm,'InputBufferSize',400000);
set (dmm,'timeout', 25);   %Set timeout to 25 seconds
set (dmm, 'ByteOrder', 'bigEndian');
fopen(dmm);
fprintf (dmm,'reset');
fprintf (dmm,'end on');  %sets up the correct EOL, use end always if memory off
fprintf (dmm,'id?');
id = fscanf (dmm);
id
fprintf (dmm,'preset dig'); %configures for DCV Digitizing see page 218 user's manual
fprintf (dmm,'mem fifo'); %clears any previous data in memory and sets for fifo operation
fprintf (dmm,'dcv 10');
fprintf (dmm,'trig auto');
fprintf (dmm,'aper 1.4e-6');
fprintf (dmm,'timer 1e-3');


fprintf (dmm,'nrdgs 1000,timer');




fprintf (dmm,'tarm sgl'); %Arm the instrument once
pause(1); %wait for the reading to get into memory before pulling them out
fprintf (dmm,'RMEM 1,1000');

[data] = fread(dmm,1000,'short');  %read data from instrument


fprintf (dmm,'iscale?'); %get scaling factor for SINT format (set by Preset Dig)
scale = fscanf (dmm,'%f');

scaledreadings = scale*data;  %multiply data by scaling factor
plot(scaledreadings) %plot data
fclose(dmm);

scaledreadings  %print data to screen  

Attachments

Outcomes