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