Skip to main content

Automating Your Measuring Instruments Via MATLAB Unraveled

[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');


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:


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



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).


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

fprintf(v,'Volt 5')


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

data = fscanf(v)

data =


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)


x = x + 1;

data(x) = fscanf(v)


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



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).


Popular posts from this blog

Calculator Techniques for the Casio FX-991ES and FX-991EX Unraveled

In solving engineering problems, one may not have the luxury of time. Most situations demand immediate results. The price of falling behind schedule is costly and demeaning to one's reputation. Therefore, every bit of precaution must be taken to expedite calculations. The following introduces methods to tackle these problems speedily using a Casio calculator FX-991ES and FX-991EX.

►For algebraic problems where you need to find the exact value of a dependent or independent variable, just use the CALC or [ES] Mode 5 functions or [EX] MENU A functions.

►For definite differentiation and integration problems, simply use the d/dx and integral operators in the COMP mode.

►For models that follow the differential equation: dP/dx=kt and models that follow a geometric function(i.e. A*B^x).

-Simply go to Mode 3 (STAT) (5)      e^x
-For geometric functions Mode 3 (STAT) 6 A*B^x
-(Why? Because the solution to the D.E. dP/dx=kt is an exponential function e^x.
When we know the boundary con…

Yay or Nay? A Closer Look at AnDapt’s PMIC On-Demand Technology

Innovations on making product features customizable are recently gaining popularity. Take Andapt for example, a fabless start-up that unveiled its Multi-Rail Power Platform technology for On-Demand PMIC applications a few months back. (read all about it here: Will PMIC On-Demand Replace Catalog Power Devices?) Their online platform, WebAmp, enables the consumer to configure the PMIC based on desired specifications. Fortunately, I got a hands-on experience during the trial period (without the physical board (AmP8DB1) or adaptor (AmpLink)). In my opinion, their GUI is friendly but it lacks a verification method for tuning (i.e. the entered combination of specs). How would we know if it will perform as expected or if there are contradicting indications that yield queer behavior? Also, there is not just one IP available, but many that cater to a differing number of channels and voltage requirements (each with their own price tag).
Every new emerging technology has the potential to oversh…

Common Difficulties and Mishaps in 6.004 Computation Structures (by MITx)

May 6, 2018
VLSI Project: The Beta Layout [help needed]Current Tasks: ►Complete 32-bit ALU layout [unpipelined] in a 3-metal-layer C5 process. ►Extend Excel VBA macro to generate code for sequential instructions (machine language to actual electrical signals).
Current Obstacles/Unresolved Decisions:
►Use of complementary CMOS or pass transistor logic (do both? time expensive, will depend on sched.
►Adder selection: Brent-Kung; Kogge Stone; Ladner Fischer (brent takes up most space but seems to be fastest, consider fan-out) [do all? time expensive, will depend on sched.)
►layout requirements and DRC errors

Please leave a comment on the post below for advise. Any help is highly appreciated.