Code covered by the BSD License  

Highlights from
Agilent Spectrum Analyzer Seminar Examples

image thumbnail
from Agilent Spectrum Analyzer Seminar Examples by Richard Overdorf
Agilent MXA, PSA Seminar Examples

MXA_Initialize( vendor, address )
function handle = MXA_Initialize( vendor, address )
% MXA_Initialize Initializes the instrument control connection to the MXA.
%   vendor is the VISA provider for the instrument control interface.
%   address is VISA address of the MXA.
%
%   To run in 'debug' mode, specify and address of ''.

global g_MXACurrentIndex
global g_MXASimulate
global g_MXASampleData

if isempty( strfind(address, '.mat') ) 
    %*---------------------------------------------------*
    %  Live mode
    %*---------------------------------------------------*
    % Delete existing instrument connections
    out = instrfind();
    delete( out(:) );

    % Open a TCP/IP connection
    handle = visa( vendor, address );

    % Resize the input buffer to allow for binary block transfers
    set( handle, 'InputBufferSize', 100000 );

    % Initialize settings
    fopen( handle );
    %set(interface,'ByteOrder','bigEndian');
    fprintf( handle, 'FORM:BORD SWAP' );
    fprintf( handle, 'FORM:DATA REAL,32' ); 
    g_MXASimulate = 0;
else
    %*---------------------------------------------------*
    %  Debug mode
    %*---------------------------------------------------*
    % Load the sample data
    load( address );
    g_MXASampleData = g_ADVTraceFIFO;
    
    % Clear the trace FIFO variable
    clear global g_ADVTraceFIFO
    
    % Initialize simulation variables
    g_MXACurrentIndex = 0;
    g_MXASimulate = 1;
    handle = -1;
end

Contact us at files@mathworks.com