[Disclaimer: All content in the articles of this blog is based from resources available to the public and general practice. No proprietary or copyrighted content nor any kind of information revealing the protocol and procedures of any company will be disclosed. This signifies that all content in the articles of this blog are purely crafted from academic resources, online reference materials, personal experience, etc.]


When designing a circuit, there are times when you want to test the circuits behavior while varying an input or output electrical characteristic. This task can get very exhausting specially when you want to sweep over a very wide range. For example, going back to my article on using NI Multisim to determine line regulation of 2 different circuits, doing that on the test bench may take an eternity. Luckily, there are ways to automate such daunting measurements. In this article, I give a brief introduction on how to automate your measuring instruments with Agilent’s VISA assistant and MATLAB using GPIB (General Purpose Interface Bus) connectors.



VISA (not a credit card)


VISA stands for Virtual Instrument Standard Architecture defined by Agilent Technologies, National Instruments, and Tektronix that can be used to communicate between your measuring instruments regardless of the physical connector you use to interconnect them.


The VISA GUI interface is very user-friendly and you’ll understand what your instrument settings are when you open it.

Note: Make sure that your instruments don’t have the same GPIB address.


To create a VISA-GPIB object in MATLAB, use the visa command (must have instrument control toolbox installed).


obj = visa('<vendor>','<unique VXI description of instrument');


Example:


v = visa('agilent','GPIB-VXI0::80::INSTR');


The vendor is agilent. Chassis is 0. Logical address is 80.


Automating Your Measurement

Connect to the instrument:


fopen(v)


Configure v to complete a read operation when the line feed character is read from the instrument.



set(v,'EOSMode','read')

set(v,'EOSCharCode','LF')




Now, you can make changes to your instrument from MATLAB. Use the fprintf command to send the commands. Sometimes instruments come with a manual that contain codes to control their settings (in fact, you can control your instruments via VISA-VXI but it isn’t codable).



Example:



I want to change the output voltage of an Agilent E1441A Function/Arbitrary Waveform Generator to 5V peak-to-peak.



fprintf(v,'Volt 5')

fprintf(v,'Volt?')




If I want to make sure that the change happened, I can query it.



data = fscanf(v)

data =

+5.00000E+00




If I want to sweep the voltage, say from 0 to 5V with an increment of 100mV , I can use the following code:



x = 0;

a = 0;

data = zeros(1,50);

while (x < 49)

a = a + 0.1;

fprintf(v,'Volt %f',a)

fprintf(v,'Volt?')

x = x + 1;

data(x) = fscanf(v)

End




Once you’re done, clear the data from MATLAB.



fclose(v)

delete(v)

clear v



Some Important Pointers:

  • Some measurements may require instruments to be in sync with each other. For example, one instrument is measuring at 1 PLC and another is measuring at 100 PLC. If you just run the MATLAB code without taking into consideration the measurement time, and your code has a formula in it, you may get an erroneous result. A caveman solution to this is to add a delay in your script file, while adding a "detection" algorithm would be much better though time expensive.
  • Make sure to keep in mind the number of GPIBs you can connect together in a bus (I think it shouldn't exceed 10 m. or 8-10 measuring instruments).