SCPI Makes Life Easy

 

How many times have you looked for an instrument driver, and find that it doesn’t exist? It happens, and that overwhelming feeling of doom looms overhead. Don’t let that feeling overcome you until you have verified that there is not a SCPI interface. SCPI stands for “Standard Commands for Programmable Instruments.” As the name says there could possibly be a set of standard commands that will help you still be able to control your instrument. Most instruments support SCPI as their protocol, which is lucky for us developers.

The first thing I usually do when handed an instrument that doesn’t have drivers is try to find the programming manual online. A Google search usually finds it right away. Just a warning, these manuals can be HUGE, so don’t be overwhelmed. Most programming manuals are in a searchable PDF format which is very beneficial when looking for commands you need.

There are a handful of commands that i use when I am establishing a connection with my instrument before I start to develop my drivers. I will continue my example of working with a Keysight N9030B Spectrum Analyzer which I have plugged into my system as “COM1.”

Image removed.

One of the most common SCPI commands is *IDN?. In the above example, I will open the VISA session, and send the *IDN? command, and read the output, and close the VISA session. The string that was read is in the comment box. Here are a few of my favorites that help establishing a driver set:

*CLS – Clear Errors

*ESR? – Returns the error number

*RST – Resets the instrument

*OPC? – Queries if the current operation is complete

Once you have established communication, you are ready to start developing your drivers. SCPI has a specific syntax that needs to be followed. Here is an example of setting the Phase Noise optimization on/off from the programming manual:

:CALCulate:MARKer:PHNoise:OPTimize ON|OFF|1|0

Notice capitals? Did you know those are the only “important” part of the command and you don’t have to include the lowercase letters? Also, the values in the “|” are options to set to different states. That being said the above example could also be written as follows:

:CALCulate:MARKer:PHNoise:OPTimize 1

OR

:CALC:MARK:PHN:OPT 1

Both of these examples are setting the phase noise optimization to “ON”. Another cool thing about SCPI is adding a question mark at the end of a command and reading it. Do you want to know if your phase noise optimization is on or off? Send this:

Image removed.

Image removed.

All that is left is to build VIs that contain the commands that are needed. Many times you will need to write many SCPI commands to get the instrument in the state where a certain measurement can be made. It is ideal to make each function into its own VI. That way you can drop the functions wherever needed in the code, and be on your way.

Endigit is happy to help you with making the drivers as well. We have a lot of experience writing LabVIEW instrument drivers. Contact us if you would like more information.

 

 

 

Author