downloading data buffer from 2000 into Matlab

2000, 2001, 2002, 2010, 2100, 2110

downloading data buffer from 2000 into Matlab

Postby jwarnock » April 29th, 2011, 2:02 pm

Help - I'm trying to use Matlab to write a relatively generic program, using SCPI commands, that will dump data generated from different internal scan channels on the 2000scan DMM into a text file "dmm_reading.txt" that students can use with Matlab, Mathematica and/or Excel.
I'm failing to get more than the initial scan reading when trying to download data from the DMM buffer through the KUSB-488B interface. I don't generate any error messages, but I only get the initial reading in the data buffer repeatedly written to my file "dmm_reading.txt".
I'm a novice to SCPI and suspect that the "read" command may not be the best one to use for a buffer dump. Please help me with some sample code that works! Thanks,
Tom (Univ. of Vermont)

Code: Select all
% Find a GPIB object.
obj1 = instrfind('Type', 'gpib', 'BoardIndex', 0, 'PrimaryAddress', 16, 'Tag', '');

% Create the GPIB object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
    obj1 = gpib('Keithley', 0, 16);
else
    fclose(obj1);
    obj1 = obj1(1)
end
%define file to write data to.
fid=fopen('dmm_reading.txt','w');
%define configuration variables
Numdata=10;
NumChan=2;
Maxdata=Numdata*NumChan
element=zeros(1,Maxdata)
% Configure instrument object, obj1
fopen(obj1);
set(obj1, 'EOSMode', 'read&write');
get(obj1,'Status')
fclose(obj1);
%remotely configure the instrument settings
%read data from DMM (recall) data buffer
fopen(obj1);
count=0
for i=1:Numdata;
    for j=1:NumChan;
    count=count+1;
    count
    fprintf(obj1,'form:elem: read');
    fprintf(obj1,'read?');
    reading=fscanf(obj1)
    %reading=element(1,count);
    fwrite(fid, reading);
    end
end
% Disconnect from instrument object, obj1.
fclose(obj1);
% Clean up all objects.
delete(obj1);
%clear the data from the workspace'
clear all;
jwarnock
 
Posts: 3
Joined: April 28th, 2011, 5:32 pm
Country: United States

Re: downloading data buffer from 2000 into Matlab

Postby Dale C » April 29th, 2011, 3:21 pm

Is this data stored into the TRACE buffer?
By this I mean did you use the TRACE commands?
:TRACE:CLEAR
:TRACE:POINTS 100
:TRACE:FEED:CONT NEXT
If so
To obtain any stored data from the TRACE buffer you must use the
:TRACE:DATA?
command , then address the instrument to talk.
If you are using READ? in a loop, then it will only give you one reading per READ?
That is if the SAMPLE:COUNT is set to 1 like it is with *RST.
Another method is that you could send one READ? with the SAMP:COUNT 1000
Then this would take 100 readings with one READ? type trigger.
Hope this helps.
Dale C
Keithley Applications
Keithley Applications
 
Posts: 2254
Joined: June 10th, 2010, 9:22 am
Country: United States

Re: downloading data buffer from 2000 into Matlab

Postby jwarnock » April 29th, 2011, 3:35 pm

In referring to the DMM's data buffer, I was referring to whever the values are stored that are displayed using the "recall" button on the meter. Is this the buffer referenced by the "trace" function?
jwarnock
 
Posts: 3
Joined: April 28th, 2011, 5:32 pm
Country: United States

Re: downloading data buffer from 2000 into Matlab

Postby Dale C » May 2nd, 2011, 9:03 am

Yes. the Recall button on the front panel is the TRACE BUFFER.
First make sure the data is stored in the TRACE BUFFER by pressing RECALL and seeing the data.
If it is there then the command
:TRACE:DATA?
will set up the instrument to send the TRACE BUFFER data on the next talk command.
Dale C
Keithley Applications
Keithley Applications
 
Posts: 2254
Joined: June 10th, 2010, 9:22 am
Country: United States

Re: downloading data buffer from 2000 into Matlab

Postby jwarnock » May 19th, 2011, 2:40 pm

I've followed your advice (see code), but am able to get only 65 of the 1000 voltage readings stored in the DMM's "recall" buffer dumped into Matlab and written to the txt file.
Code: Select all
%define file to write data to.
fid=fopen('dmm_reading.txt','w');
%define configuration variables

% Configure instrument object, obj1
fopen(obj1);
set(obj1, 'EOSMode', 'read&write');
get(obj1,'Status')
fclose(obj1);

%remotely configure the instrument settings

%read data from DMM (recall) data buffer
fopen(obj1);
fprintf(obj1,'Format:Elements Reading');
fprintf(obj1,'Trace:Data?');
reading=fscanf(obj1);
fwrite(fid,reading);

%put contents of dmm_into Matlab matrix
datavalues=dlmread('dmm_reading.txt');
datavalues
length(datavalues)

%Clear readings from DMM (Recall) buffer
%fprintf(obj1,'Trace:Clear');

% Disconnect from instrument object
fclose(obj1);
% Clean up all objects.
delete(obj1);
%clear the data from the workspace'
clear all;


Any suggestions and sample coding would be greatly appreciated.
thanks,
Tom
jwarnock
 
Posts: 3
Joined: April 28th, 2011, 5:32 pm
Country: United States


Return to Series 2000 and Series 2100 DMM's

Who is online

Users browsing this forum: No registered users and 2 guests

cron