I am trying to make some RFP measurements over GPIB with the N5531. I am using a N1911 for the power meter. My program will work fine for most measuremnts but I get timeout error messages at random times when trying to read back the data from the N5531. For example, using this code in C#:
I get the timeout error at random frequencies. What am I doing wrong? I am not sure how to properly implement *OPC, if I can get some help with that I would appreciate it. Thanks
I get the timeout error at random frequencies. What am I doing wrong? I am not sure how to properly implement *OPC, if I can get some help with that I would appreciate it. Thanks
SLEEP statements are not recommended for instrument specific timing for this very reason. Use of the *OPC? command that you asked about is a good alternative to using a hard coded delays.
*OPC? (operation complete) is a system-level control command that can inform your control software that the current operation is complete.
*OPC? tells the instrument to return a +1 in response to the query as soon as the previous instrument command has finished executing. Then your software can execute the next command in the program sequence without any unnecessary delay.
To make use of this command initiate the measurement, check if the operation is complete, then fetch your data.
In pseudo code it would be
send INIT
send *OPC?
read the operation complete string
send FETCH?
read your data
Here is an example of how you might change your code to make use of *OPC?
I'm not able to try this code out, so please view it as an example with no warranty and not a cut and paste solution.
This solution will not only avoid timeouts, it will also speed up your code!
Best regards,