Choose a country or area to see content specific to your location
- Home
- Resources
- Resources
What are you looking for?
Using *OPC?
When you programmatically setup an instrument for an operation, you typically send multiple instrument commands. Most instruments are able to buffer multiple commands. Allowing the instrument to receive new commands, even though a previous command is not yet completed.
This code sends several commands to an instrument.
With DMM .WriteString "*RST" .WriteString "*CLS" .WriteString "*ESE 1" .WriteString "*SRE 32" End With
Provided the instrument can complete all these commands before an additional conflicting command or query is sent, the code will work as anticipated. A better way to send a block of commands is to have the instrument report when the block is complete before sending additional commands. The SCPI standard provides the *OPC? query that you can use to ensure the instrument has completed all operations before your program continues.
An instrument responds to the *OPC? query by setting a "1" in the output buffer after all received commands have completed. This allows you to synchronize your program and the instrument operation.
With DMM .WriteString "*RST" .WriteString "*CLS" .WriteString "*ESE 1" .WriteString "*SRE 32" .WriteString "*OPC?" ' Assure syncronization strTemp = .ReadString ' Discard returned value End With
Note that using the *OPC? query holds the I/O bus until the instrument commands have been completed. It may not be acceptable to hold the GPIB bus when you are controlling multiple instruments. In those cases use the *OPC bit in the Standard Event register and implement some form of status reporting system. An example using the *OPC bit is provided in the Using SRQ Events section.