Monday, December 17, 2012

SCPI Example and Tools for the 34970A and 34972A

In this post we will look at a Standard Commands for Programmable Instruments (SCPI) example for controlling Agilent's 34970A / 34972A DAQ / Switch Units remotely. In the example we will remotely monitor a channel and then setup and execute a scan. From there we will look at controlling the 34972A via its built-in web interface and how the web interface can be used as a SCPI programming tool for building a custom program.

In the following example a pseudo programming language is used around the SCPI examples. In our pseudo programming language "//' represents comments that will be used to explain what is happening in the demo as we go. The connect() function will be used to connect to the 34970A / 34972A (in our example we will be using a 34972A with LAN, but they each use the same SCPI language). The printf() function will be used to send a command to the 34972A. The query() function will be used to send a command and read back the response from the 34972A. The "data:" will be used to print out the response from the instrument. The SCPI commands will be handled as strings so they will be placed in quotation marks "". A newline "\n" character will be used after each command, depending on the programming language and driver you are using in your program this may or may not be needed.

In the following example we will monitor temperature measurement using a thermocouple J-type sensor. Next will execute a multiple channel.

//Connect to the 34972A via LAN using the IP address, the instruments hostname could also be used
instr = connect("555.555.555.555");
//send a reset so we are starting at a known state
printf(instr, "*RST\n");
//identify the 34972A we are talking to
data = query(instr, "*IDN?\n");
//display the returned identity of the 34972A
data: Agilent Technologies,34972A,ALFREDO172,1.11-1.12-02-01
//configure channel 12 in slot 1 for thermocouple J-type 
printf(instr, "CONF:TEMP TC,J,(@112)\n");
//set channel 12 in slot 1 to the channel we want to monitor
printf(instr, "ROUT:MON:CHAN (@112)\n");
//Start monitoring channel 12, the 34972A will now continuously make measurements on channel 12
printf(instr, "ROUT:MON:STAT ON\n");
//query for channel 112 measurement
data = query(instr, "ROUT:MON:DATA?\n");
//display channel 12 temp measurement in degrees C
data: +1.81960000E+01
//query for another channel 112 measurement (remember monitor runs continuously) 
data = query(instr, "ROUT:MON:DATA?\n");
//display channel 12 temp measurement in degrees C
data: +1.81760000E+01
//turn the monitor function off
printf(instr, "ROUT:MON:STAT OFF\n");
//Now lets setup the scan using four channels in slot 1, 2 temp measurements and 2 resistance measurements
//Since one temperature measurement has already been configured lets do the other
printf(instr, "CONF:TEMP TC,J,(@113)\n");
//Configure both of the resistance measurements
printf(instr, "CONF:RES (@103,108)\n");
//Create a scan list with the four channels
printf(intr, "ROUT:SCAN (@101,105,112,113)\n");
//set the scan list to run five times so we will have a total of 20 measurements (4 channels x 5 sweeps = 20)
printf(intr, "TRIG:COUN 5\n");
//run the scan list
printf(instr, "INIT\n");
//wait 2 seconds for scan to finish 
wait(2);
//get the 20 readings from the 34972A's memory
data = query(instr, "FETC?\n");
//display the readings from the scan
data: +2.85266320E+03,+1.49620420E+02,+1.75500000E+01,+1.77660000E+01,+2.85271470E+03,+1.49617860E+02,+1.75350000E+01,+1.77510000E+01,+2.85271470E+03,+1.49620420E+02,+1.75320000E+01,+1.77510000E+01,+2.85270180E+03,+1.49620420E+02,+1.75420000E+01,+1.77510000E+01,+2.85271470E+03,+1.49621710E+02,+1.75200000E+01,+1.77410000E+01
//clear the scan list (optional)
printf(intr, "ROUT:SCAN (@)\n");
//close the connection to the 34972A
disconnect(instr);

The 34970A and the 34972A, for the most part, offer the same functionality and measurement capability. The main differences come from the remote IO. The 34970A offers GPIB and RS232 connectivity and the 34972A offers LAN and USB connectivity. The 34972A also offers a built-in web interface that can be accessed via the LAN connection. All you need is a LAN connection and a web browser to access the 34972A's web interface. The web interface allows you to control the 34972A remotely and offers tools that help you create custom software for controlling the 34972A remotely.

A 34972A was connected to the same local LAN network that my PC was connected to. I obtained the 34972A's IP address from its front panel. I entered the IP address in the address bar of the web browser on my PC and I was able to connect to the 34972A's web interface. The below figure shows the web interface control page for the 34901A card in slot 1 of the 34972A. From this page I can close switches, monitor a channel, and create scans.


By selecting the "Utility..." button in, the SCPI programming tools can be accessed. As an example, the "Command Monitor" function in the Utility menu provides a list of SCPI commands that coincides with the settings and functionality that were implemented via the web interface. This allows you to mimic on the web interface what you plan to do in your software and then simply cut and paste the resulting commands from the Command Monitor into your program. The below figure shows the Command Monitor window with recorded commands that show a relay being opened and closed continuously, a channel being setup for monitoring, and the monitor reading being fetched from the 34972A. 



In this blog post we looked at some examples of how to remotely control the 34970A and 34972A using SCPI. We then looked at the LAN web interface on the 34972A and how it can be used as a tool for creating custom software based on SCPI. As always if you have anything to add use the comments section below and if you have any questions feel free to email me.

For more information on the 34972A click here

For more information on the 34970A click here

For more information on a free program for controlling the 34970A and the 34972A click here

Sunday, December 9, 2012

Reducing Measurement Errors with Proper Cabling Part 2

This is part 2 of a two part post where we look at reducing measurement errors with proper cabling and grounding methods. The principles covered in this post can be applied to basic measurement setups, DAQ systems, and automated test systems. Click here to read part 1.


Radio Frequency Interference 
Most voltage-measuring instruments can generate false readings in the presence of large, high-frequency signals. Possible sources of high-frequency signals include nearby radio and television transmitters, computer monitors, and cellular telephones. High-frequency energy can be coupled to a DMM on the system cabling. To reduce the interference, try to minimize the exposure of the system cabling to high-frequency RF sources. If your application is extremely sensitive to RFI radiated from the instrument, use a common mode choke in the system cabling as shown below to attenuate instrument emissions. Note you most likely will see a choke on your computer monitor video input cable used for this purpose, look for a cylindrical hard object that has a small subsection of the cable running through the center of it.

Thermal EMF Errors 
Thermoelectric voltages are the most common source of error in low-level DC voltage measurements. Thermoelectric voltages are generated when you make circuit connections using dissimilar metals at different temperatures. Each metal-to-metal junction forms a thermocouple, which generates a voltage proportional to the junction temperature difference. You should take the necessary precautions to minimize thermocouple voltages and temperature variations in low-level voltage measurements. The best connections are formed using copper-to-copper crimped connections. The table below shows common thermoelectric voltages for connections between dissimilar metals.



Noise Caused by Magnetic Fields 
If you are making measurements near magnetic fields, you should take precautions to avoid inducing voltages in the measurement connections. Voltage can be induced by either movement of the input connection wiring in a fixed magnetic field or by a varying magnetic field. An unshielded, poorly dressed input wire moving in the earth’s magnetic field can generate several millivolts. The varying magnetic field around the AC power line can also induce voltages up to several hundred millivolts. You should be especially careful when working near conductors carrying large currents. Where possible, you should route cabling away from magnetic fields. Magnetic fields are commonly present around electric motors, generators, televisions, and computer monitors. Also make sure that your input wiring has proper strain relief and is tied down securely when operating near magnetic fields. Use twisted-pair connections to the instrument to reduce the noise pickup loop area, or dress the wires as close together as possible. When I worked in calibration we would run into the problem of measurement fluctuations caused by magnetic fields when calibrating milli-ohm and milli-volt meters. To reduce these fluctuations we built a metal box that would surround the meter and block magnetic fields. The box had a small opening just big enough to read measurements and change settings.

Low-Level AC Measurement Errors 
When measuring AC voltages less than 100 mV, be aware that these measurements are especially susceptible to errors introduced by extraneous noise sources. An exposed test lead will act as an antenna and the internal DMM will measure the signals received. The entire measurement path, including the power line, act as a loop antenna. Circulating currents in the loop will create error voltages across any impedances in series with the instrument’s input. For this reason, you should apply low-level AC voltages to the instrument through shielded cables. You should also connect the shield to the input LO terminal. Be sure to minimize the area of any ground loops that cannot be avoided. A high-impedance source is more susceptible to noise pickup than a low impedance source. You can reduce the high-frequency impedance of a source by placing a capacitor in parallel with the instrument’s input terminals. You may have to experiment to determine the correct capacitance value for your application. Most extraneous noise is not correlated with the input signal. You can determine the error as shown below.


Correlated noise, while rare, is especially detrimental. Correlated noise will always add directly to the input signal. Measuring a low-level signal with the same frequency as the local power line is a common situation that is prone to this error. You should use caution when switching high-level and low-level signals on the same switch card or module. It is possible that high-level charged voltages may be discharged onto a low-level channel. It is recommended that you either use two different modules or separate the high-level signals from the low-level signals with an unused channel connected to ground.

As always if you have anything to add use the comments section below and if you have any questions feel free to email me.


Click here to read part 1

Monday, December 3, 2012

Reducing Measurement Errors with Proper Cabling Part 1

In this two part post we will look at reducing measurement errors with proper cabling and grounding methods. The principles covered in this post can be applied to basic measurement setups, DAQ systems, and automated test systems.

Cable Specifications
A wide variety of general-purpose and custom cables are available. The following factors influence the type of cable that you choose.
  • Signal Requirements – such as voltage, frequency, accuracy, and measurement speed.
  • Interconnection Requirements – such as wire sizes, cable lengths, and cable routing.
  • Maintenance Requirements – such as intermediate connectors, cable terminations, strain relief, cable lengths, and cable routing.
Cables are specified in a variety of ways. Be sure to check the following specifications for the cable type you intend to use.
  • Nominal Impedance (insulation resistance) – Found on cables that are intended for frequencies above DC. It varies with the frequency of the input signal. Check for HI-to-LO, channel-to-channel, and HI- or LO-to-shield. High frequency RF applications have exact requirements for cable impedance.
  • Dielectric Withstand Voltage – Must be high enough for your application.
Warning: To prevent electrical shock or equipment damage, insulate all channels to the highest potential in the system. It is recommended that you use wire with 600 V rated insulation.
  • Cable Resistance – Varies with wire gauge size and cable length. Use the largest gauge wire possible and try to keep the cable lengths as short as possible to minimize the cable resistance. The following table lists typical cable resistance for copper wire of several gauge sizes (the temperature coefficient for copper wire is 0.35% per °C). Using the sense lines on instruments such as DMMs and performance power supply can compensate for cable resistance.
  • Cable Capacitance – Varies with the insulation type, cable length, and cable shielding. Cables should be kept as short as possible to minimize cable capacitance. In some cases, low-capacitance cable can
    be used.
Cabling resistance table (top) and Impedance table (bottom)
Grounding Techniques
One purpose of grounding is to avoid ground loops and minimize noise. Most systems should have at least three separate ground returns.
  1. One ground for signals. You may also want to provide separate signal grounds between high-level signals, low-level signals, and digital signals.
  2. A second ground is used for noisy hardware such as relays, motors, and high-power equipment.
  3. A third ground is used for chassis, racks, and cabinets. The AC power ground should generally be connected to this third ground.
In general, for frequencies below 1 MHz or for low-level signals, use single-point grounding (see below). Parallel grounding is superior but is also more expensive and more difficult to wire. If single-point grounding is adequate, the most critical points (those with the lowest levels and/or the most precise measurement requirements) should be positioned near the primary ground point. For frequencies above 10 MHz, use the separate grounding system. For signals between 1 MHz and 10 MHz, you can use a single-point system if the longest ground return path is kept to less than 1/20 of a wavelength. In all cases, return-path resistance and inductance should be minimized.

Grounding Schemes

For a detailed look at ground loops and noise check the post Ground Loops and Other Spurious Coupling Mechanisms and How to Prevent Them

Shielding Techniques
Shielding against noise must address both capacitive (electrical) and inductive (magnetic) coupling. The addition of a grounded shield around the conductor is highly effective against capacitive coupling. In switching networks, this shielding often takes the form of coaxial cables and connectors. For frequencies above 100 MHz, double-shielded coaxial cable is recommended to maximize shielding effectiveness. Reducing loop area is the most effective method to shield against magnetic coupling. Below a few hundred kilohertz, twisted pairs may be used against magnetic coupling. Use shielded twisted pair for immunity from magnetic and capacitive pickup. For maximum protection below 1 MHz, make sure that the shield is not one of the signal conductors.



Separation of High-Level and Low-Level Signals
Signals whose levels exceed a 20-to-1 ratio should be physically separated as much as possible. The entire signal path should be examined including cabling and adjacent connections. All unused lines should be grounded (or tied to LO) and placed between sensitive signal paths. In DAQ systems or ATE system when making your wiring connections to screw terminals on a connection interface, be sure to wire like functions on adjacent channels.

Stay tuned for part two next week. And as always if you have anything to add use the comments section below and if you have any questions feel free to email me.