Code covered by the BSD License  

Highlights from
res_meas

image thumbnail

res_meas

by

 

16 May 2007 (Updated )

GUI for resonator measurement and data download from Signal Analyzers and Oscilloscopes

res_feed.m
%% RES_FEED
% RES_FEED calculates the "true" resonator response from a measurement with
%  a high noise floor. It works by assuming that the noise is due to a
%  large capacitor ("feedthrough capacitance") in parallel with the
%  resonator. RES_FEED is designed to work with the gui program "res_meas".
% To use RES_FEED, do the following:
%  1) use res_meas to measure a resonator. Save the data to a
%     file.
%  2) Turn the bias off and measure again at the same frequency
%     (this is a measurement of the noise floor due to the feedthrough
%     capacitance).
%  3) Load the saved data file for the resonator measurement in res_meas
%     (File->Load).
%  4) Type "res_feed" at the command prompt to run this script. The results
%     are saved in the workspace variable "res_extr".
% If you are using previously saved measurement files, load the feedthrough
%  measurement first, and copy the result to the variable 'trace_meas' by
%  typing "trace_meas=trace_load". Then proceed from step 3.
% Note that the absolute phase values may not be meaningful, but the
%  relative values are.
% If the gain of the transimpedance amplifier is set in res_meas (under
%  Measurement Settings), then res_feed will estimate a value for the
%  feedthrough capacitance.
%
% You can use FEEDTHRU to do the feedthrough calculation without using
%  res_meas. RES_FEED calls FEEDTHRU to do the calculation.
%
%
% Examples:
%
% There are two example files included with this file. They are:
%
% Resonator_with_feedthrough.mat
% Feedthrough_measurement.mat
%
% The files correspond to steps 1 & 2 above. To run the example, load the
%  file "Feedthrough_measurement.mat" *into MATLAB* by double-clicking on
%  it or typing "load Feedthrough_measurement.mat". Then continue with
%  steps 3 and 4 above.
%
%
% Requires: feedthru.m
% 
% M.A. Hopcroft
%      hopcroft at mems stanford edu
%
% MH MAR2007
% v1.2  print results
%       fix field "motional"

% MH SEP2005
% v1.1

% The workspace variable "trace_load" is assumed to be the measured total
%  response. The workspace variable "trace_meas" is assumed to be the
%  capacitive feedthrough measurement (i.e., a measurement with bias = 0 V)

% imag
% real
% angle
% abs
% Z = R.*exp(i*theta)
% rad = deg*2*pi/360

if ~exist('trace_load','var') || ~exist('trace_meas','var')
    error('res_feed: Error: trace_load or trace_meas not found in workspace. Type "help res_feed" for info.');
else
    
    % do the resonator extraction based on the existing variables
    res_extr=feedthru(trace_load,trace_meas);
    
    % handle older format
    if isfield(trace_load,'motional')
        trace_load.equ_circuit=trace_load.motional;
    end
    if isfield(trace_meas,'motional')
        trace_meas.equ_circuit=trace_meas.motional;
    end
    
	%%
	% plot
    xfreq=trace_load.trace1.x; % all plots use the x-axis from total response
	ftplot=figure;
	% plot magnitude
	subplot (2,1,1); hold on;
	plot(xfreq,trace_load.trace1.y,'-b');
	plot(xfreq,trace_meas.trace1.y,'-g');
	plot(xfreq,res_extr.trace1.y,'.-k');
    pmarkeramp=plot(res_extr.mark1.x,res_extr.mark1.y,'dr');
	title('Magnitude')
	xlabel('Frequency (Hz)');
	ylabel('Magnitude (dB)');
	legend('Measured','Feedthrough','Extracted',3);
    grid on;
	% plot phase
	subplot(2,1,2); hold on;
	plot(xfreq,trace_load.trace2.y,'-b');
	plot(xfreq,trace_meas.trace2.y,'-g');
	plot(xfreq,res_extr.trace2.y,'.-k');
    pmarkerphs=plot(res_extr.mark2.x,res_extr.mark2.y,'dr');
	title('Phase')
	xlabel('Frequency (Hz)');
	ylabel('Phase (deg)');
	legend('Measured','Feedthrough','Extracted',3);
	grid on;

    % print some results to the workspace
    fprintf('\nres_feed: results: [extracted (measured)]\n\n');
    
    fprintf(1,' Peak Frequency: %.0f Hz (%.0f)\n',res_extr.mark1.x,trace_load.mark1.x);
    fprintf(1,'      Amplitude: %.3f dB (%.3f)\n',res_extr.mark1.y,trace_load.mark1.y);
    fprintf(1,'              Q: %.0f (%.0f)\n',res_extr.Q,trace_load.Q);
    fprintf(1,'  3db Bandwidth: %.0f Hz (%.0f)\n',res_extr.bandwidth,trace_load.bandwidth);
    fprintf(1,'    Phase shift: %.0f deg',res_extr.phase_shift);
    if isfield(trace_load,'phase_shift')
        fprintf(1,' (%.0f)\n',trace_load.phase_shift);
    else
        fprintf(1,'\n');
    end
    if isfield(res_extr,'amp_gain') && isfield(trace_load,'equ_circuit')
        fprintf(1,' Motional Resistance for a gain of %g:\n',res_extr.amp_gain);
        fprintf(1,'                 %g ohms (%g)\n',res_extr.equ_circuit(1),trace_load.equ_circuit(1));
        fprintf(1,' Feedthrough Capacitance for a gain of %g:\n',res_extr.amp_gain);
        fprintf(1,'                 %g F (%g)\n',res_extr.equ_circuit(2),trace_load.equ_circuit(2));
    end
          
    fprintf(1,'\nres_feed: Results saved in the variable "res_extr".\n\n');
    
% 	fprintf(1,' %s %.0g %s\n %s %g\n %s %g %s\n %s %g %s\n %s\n\n',...
%     'Response Peak:',res_extr.mark1.x,'Hz','Q:',res_extr.Q,...
%     '3 db Bandwidth:',res_extr.bandwidth,'Hz',...
%     'Motional Resistance (estimate):',res_extr.equ_circuit(1),'ohms',...
%     'Results saved in the variable "res_extr".');
    
end

Contact us