Thursday, May 31, 2012

*OPC and You

Today I have a guest-blogger, one of my Agilent colleagues (and friends), Matt Carolan. Matt has experience with programming our power products, so I asked him if he had anything he wanted to share with our audience. He has many things to talk about and will most likely contribute to future posts, but decided to start with the *OPC command, which is the “Operation Complete” command. Here is Matt’s post:

Hi, my name is Matt and I am an Application Support Engineer at Agilent Technologies. I have had 12 years of experience programming our power products and I wanted to write about a small but powerful command, *OPC.

*OPC is a standard IEEE-488.2 command that allows you to synchronize your power supply with your program. *OPC lets you know when all pending operations are complete. A pending operation is something such as the voltage being set or the output turning on. I worked as a test engineer for a few years and we always used the *OPC command in our calibration routines. We would send a calibration command (such as CALibration:LEVel:P1) followed by a *OPC? query. This allowed us to ensure that the calibration command had finished executing and that the power supply should be outputting the correct level before we took any measurements with our test system.
    
There are two ways to use *OPC. There is a standard *OPC command and the *OPC? query. The *OPC command will set bit 0 of the Standard Event Status register when all pending operations are complete. You can then use a *ESR? Command to poll the Standard Event Status Register. When this returns a 1, all pending operations are complete. When you use this command, it only works for any pending commands that were sent BEFORE you sent the *OPC command. It will not work for commands sent after the *OPC command. You can send another *OPC command to start the cycle again.

The other way is to use it as a query. When you send a *OPC? query, it will put a 1 in the output buffer when all pending operations are complete. The main drawback of this method is that if there is an operation that takes a long time to complete, your *OPC? query will timeout. You would need to have a long timeout set in your IO library to avoid this. You cannot send any commands after the query without getting an error so this will hold up your program until all pending operations are complete.

If you have any questions please comment here or on the Agilent forum at: https://www.agilent.com/find/forums

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.