Catto / Topic Map · Electronic Measurements I Level 4
Electronic Measurements I · 120 h · Topic 11 of 11

Measurement automation

A badly written command does not stop a measurement program: the instrument only stores an error in its queue, and if nobody reads it, the data look good.

GPIB VISA SCPI PyVISA Data acquisition

01Why automate a measurement

Sweeping the frequency response of a filter at a hundred points, recording a temperature every minute for a week or testing a thousand boards at the end of a production line cannot be done by hand. An automatic measurement system controls the instruments from a computer: it configures them, triggers the measurements, reads the results and stores them with all their data. It gains speed, repeatability and record-keeping: each measurement is made exactly the same way, and it is documented which instrument, under which conditions and when.

02Controller, bus and instruments

InterfaceCharacteristicsUse
GPIB (IEEE 488)8-bit parallel bus, up to 15 instruments, about 20 m, around 1 MB/sLaboratory benches since the 1970s; still very widespread
RS-232Point-to-point serial, slowSimple instruments and old equipment
USB-TMCUSB with a standardized class for instrumentsCurrent benchtop instruments
LAN / LXIEthernet with common discovery and trigger rulesDistributed systems and remote control
PXIInstruments on cards inside a chassis with a PCI Express bus and synchronized triggeringProduction testing, high speed

So as not to write a different program for each interface, the software uses an intermediate library, VISA, which opens a session with any instrument from an address such as GPIB0::22::INSTR, USB0::…::INSTR or TCPIP0::192.168.1.20::INSTR, and offers the same functions for writing and reading. In Python, the PyVISA package uses it; in industry LabVIEW is also used.

03The SCPI language

Almost all programmable instruments understand SCPI (Standard Commands for Programmable Instruments), a text language with hierarchical commands separated by colons. Each word has a long form and a short one, the part in capitals: MEASure:VOLTage:DC? can be written MEAS:VOLT:DC?. Commands ending in ? are queries and return a response. The IEEE 488.2 standard adds common commands that start with an asterisk:

CommandWhat it does
*IDN?Returns manufacturer, model, serial number and version
*RSTBrings the instrument to a known state
*OPC?Responds 1 when the pending operations have finished: used to synchronize
SYST:ERR?Reads the next error from the queue; a robust program empties it at the end

04The structure of a measurement program

A well-made program always follows the same steps: bring the instrument to a known state, configure it explicitly (without depending on how the last user left it), trigger, read, check that there are no errors and store the data with its context. In Python with PyVISA:

import pyvisa
rm = pyvisa.ResourceManager()
dmm = rm.open_resource("USB0::0x1234::0x5678::MY001::INSTR")
dmm.timeout = 5000                      # milliseconds
print(dmm.query("*IDN?"))
dmm.write("*RST")
dmm.write("CONF:VOLT:DC 10")            # fixed function and range
dmm.write("VOLT:DC:NPLC 10")            # integration of 10 mains cycles
dmm.write("TRIG:COUN 5")
readings = [float(x) for x in dmm.query("READ?").split(",")]
print(dmm.query("SYST:ERR?"))           # should be +0,"No error"

The speed of an automatic measurement is almost always set by the instrument, not the bus. A multimeter that integrates 10 mains cycles takes 200 ms per reading at 50 Hz, and autoranging and auto-zero add more. It is the same trade-off seen in interference: more integration time, less noise and more 50 Hz rejection, but fewer readings per second.

Lab · an SCPI console

A simulated programmable multimeter, connected to a 1.234567 V source and a 1000.12 Ω resistor. You tap a command or type it, and the instrument responds like a real one, with its error queue and the time each reading would take. The model is fictional.


        

05Acquisition boards and good practices

For many signals at once, data acquisition boards (DAQ) are used: a converter with an input multiplexer, digital inputs and outputs, counters and sometimes analog outputs, connected over USB, PCI Express or Ethernet. With multiplexing, the sampling rate is shared among the channels, and switching channels requires a settling time: with high-impedance sources, one channel contaminates the next.

Automatic data is worth as much as its context. Each file should store, along with the readings, the identification and configuration of the instruments, the environmental conditions, the date of the last calibration and the version of the program.

06In the laboratory

Activity 1 · First contact

Connect a multimeter or an oscilloscope over USB, identify it with *IDN? from PyVISA and read a measurement.

Activity 2 · Automatic frequency response

Program a generator and an oscilloscope to sweep a filter from 100 Hz to 100 kHz in 50 logarithmic points and plot the Bode diagram.

Activity 3 · Long-duration logging

Record the voltage of a discharging battery every 10 s for hours, storing the data with its context in a CSV file.

07Common mistakes

  • Not configuring everything explicitly. The program works until someone leaves the instrument in another mode.
  • Reading before the measurement finishes. Without *OPC? or a suitable wait time, old data is read.
  • Ignoring the error queue. A badly written command does not stop the program: it only leaves an error that nobody reads.
  • Saving numbers without units or context. A file of readings without configuration is useless a month later.

08Self-assessment

How long does a multimeter take to take 100 readings with NPLC 10 on a 50 Hz mains?

At least 100 · 200 ms = 20 s, plus the own time of each conversion.

What is the short form of SENSe:VOLTage:DC:RANGe?

SENS:VOLT:DC:RANG, and since SENSe is optional, also VOLT:DC:RANG.

What is *OPC? for?

To wait for the instrument to finish what is pending before continuing: it responds 1 only then.

What advantage does VISA give over programming each interface?

That the same program works with the instrument connected over GPIB, USB or network, changing only the address.

09Further reading

  • SCPI Consortium. Standard Commands for Programmable Instruments (SCPI), Volume 1: Syntax and Style. SCPI Consortium, 1999. The language standard: syntax, command hierarchy and response format.
  • John Park and Steve Mackay. Practical Data Acquisition for Instrumentation and Control Systems. Newnes, 2003. Acquisition boards, interfaces and software for measurement systems.
  • Alan S. Morris and Reza Langari. Measurement and Instrumentation: Theory and Application. 3rd ed., Academic Press, 2020. Computerized measurement systems in the context of complete instrumentation.
Development of the topic “Measurement automation” of Electronic Measurements I (Level 4), based on the curriculum of the UTN Electronic Engineering program, 2023 curriculum — Ordinance No. 1849 of the UTN Higher Council. Back to the Topic Map · catto.ar