AnsweredAssumed Answered

3458A to capture precision data using Matlab

Question asked by huynh213 on Jan 14, 2021

lhornburg, thanks for sharing some sample code and offer your support.

 

I try to capture the DC voltage measurement (max 2.3VDC) with up to 6 decimal place accuracy and plot it over a period of time to evaluate its stability. 

 

Below is the code I have been working on to capture 80 measurements of a VDC, max 2.3V, resolution of 10uV. Problems I have been stuck at:  Unable output up to 6 decimal place accuracy. I tried different data formats such as 'long' but no luck.

 

After solving this issue, I will scale it up to capture more readings for a longer period of time such as 5 minutes. 

Thanks, 

 

 

======================Matlab code=================

%Reference: 3458A continuous readings | https://community.keysight.com/message/60335
%{
Goal:
1. Collect VDC measurement up to 6 decimal place accuracy over a period of time
2. Plot the measurement over time to evaluate its stability
%}

% Clear all the workspace==================================================
clear all; close all; clc;

%Set up GPIB Interface Connection==========================================

% Create a GPIB object.
dmm = instrfind('Type', 'gpib', 'BoardIndex', 0, 'PrimaryAddress', 22, 'Tag', '');

% Create the GPIB object if it does not exist
% otherwise use the object that was found.
if isempty(dmm)
dmm = gpib('HP3458A-HH', 0, 22); %Address 22
else
fclose(dmm);
dmm = dmm(1)
end


%Set up VISA Interface Connection: Error using icinterface/fopen
%dmm = visa('NI','GPIB0::22::INSTR');

%Config dmm================================================================
set (dmm,'InputBufferSize',400000);
set (dmm,'timeout', 25); %set the bus timeout for 25 seconds
set (dmm, 'ByteOrder', 'bigEndian');

% Connect to instrument object, dmm.
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
%Config reading============================================================
fprintf (dmm, 'func dcv, 2.3, 0.000435'); %DMM: DCV, max voltage of 2.3V, Resolution of 10uV
fprintf (dmm,'preset dig'); %presets DMM for DCV digitizing (see page 218)
fprintf (dmm,'mem fifo'); %Enables Reading Memory (FIFO)
fprintf (dmm,'trig auto');
fprintf (dmm,'timer 0.25'); %Set a time interval of 0.25s

fprintf (dmm,'nrdgs 40,timer'); %Set the No of Reading per trigger: 40 readings

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

fprintf (dmm,'tarm auto'); %Begin triggering readings

%format short
%disp(single(rand(3)))
alldata = []; %create variable that will combine all loop data
for S = 1: 1: 1 %Loop 1 times to get all readings

[data] = fread(dmm, 40,'short'); %Read the data
alldata = [alldata data]; %store data in alldata

end

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

fclose(dmm);

Outcomes