MDO3000 Programmer Manual.pdf - 第1020页
Status and Events Figure 3-8: P rocessing Seque nce With Synchronization Example of Using the *OPC Command If the corresponding status registers are enabled, the *OPC command sets t he OPC bit in the Standard Event Statu…

Status and Events
Table 3-3: Oscilloscope operations that can generate OPC (cont.)
Command Conditions
TEKSecure
:TRIGger:A SETLevel
Example of Acquiring
and Measur
ing a
Single-Sequence
Waveform
For example, a typical application might involve acquiring a single-sequence
waveform
andthentakingameasurementontheacquiredwaveform. Youcould
use the following command sequence to do this:
/** Set u
p conditi onal acquisit ion **/
ACQUIRE:STATE OFF
SELECT:CH1 ON
HORIZONTAL:RECORDLENGTH 1000
ACQUIRE:MODE SAMPLE
ACQUIRE:STOPAFTER SEQUENCE
/** Ac
quire w aveform data **/
ACQUIRE:STATE ON
/** Set up the measurement parameters **/
MEASUREMENT:IMMED:TYPE AMPLITUDE
MEASUREMENT:IMMED:SOURCE CH
1
/** Tak e amplitude measurement **/
MEA
SUREMENT:MEAS1:VALUE?
The acquisition of the waveform requires extended processing time. It may not
fin
ish before the oscilloscope takes an amplitude measurement (see the following
figure). This can result in an incorrect amplitude value.
Figure 3-7: Command Processing Without Using Synchronization
To ensure the oscilloscope completes waveform acquisition before taking the
measurement on the acquired data, you can synchronize the program using *WAI,
BUSY, *OPC, and *OPC?.
MDO4000/B/C, MSO/DPO4000B and MDO3000 Series Oscilloscopes Programmer Manual 3-9

Status and Events
Figure 3-8: P rocessing Sequence With Synchronization
Example of Using the *OPC
Command
If the corresponding status registers are enabled, the *OPC command sets the
OPC bit in the Standard Event Status Register (SESR) when an operation is
complete. You achieve synchronization by using this command with either a
serial poll or service request handler.
Serial Poll Method: Enable the OPC bit in the Device Event Status Enable
Register (DESER) and the Event Status Enable Register (ESER) using the DESE
and *ESE
commands.
When the operation is complete, the OPC bit in the Standard Event Status Register
(SESR)
will be enabled and the Event Status Bit (ESB) in the Status Byte Register
will be enabled.
The sa
me command sequence using the *OPC command for synchronization with
serial polling looks like this:
/* Se
t up conditional acquisition */
ACQUIRE:STATE OFF
SELECT:CH1 ON
HORIZONTAL:RECORDLENGTH 1000
ACQUIRE:MODE SAMPLE
ACQUIRE:STOPAFTER SEQUENCE
/*
Enable th e status registers */
DESE 1
*ESE 1
*SRE 0
/* Acqu ire waveform data */
ACQUIRE:STATE ON
/* Set up the measurement parameters */
MEASUREMENT:IMMED:TYPE AMPLITUDE
MEASUREMENT:IMMED:SOURCE CH1
/* Wait until the acquisition is complete before taking the
measurement.*/
*OPC
While s erial poll = 0, keep looping
/* Take amplitude measurement */
MEASUREMENT:IMMED:VALUE?
This technique requires less bus traffic than did looping on BUSY.
3-10 MDO4000/B/C, MSO/DPO4000B and MDO3000 Series Oscilloscopes Programmer Manual

Status and Events
Service Reques
t Method: Enable the OPC bit in the Device Event Status Enable
Register (DESER) and the Event Status Enable Register (ESER) using the DESE
and *ESE commands.
You can also enable service requests by setting the ESB bit in the Service Request
Enable Register (SRER) using the *SRE command. When the operation is
complete, the oscilloscope will generate a Service Request.
The same command sequence using the *OPC command for synchronization
looks like this
/* Set up conditional acquisition */
ACQUIRE:STATE OFF
SELECT:CH1 ON
HORIZONTAL:RECORDLENGTH 1000
ACQUIRE
:MODE SAM PLE
ACQUIRE:STOPAFTER SEQUENCE
/* Enab le the st atus registe rs */
DESE 1
*ESE 1
*SRE 32
/* Acq
uire wa veform data */
ACQUIRE:STATE ON
/* Set up the measurement parameters */
MEASUREMENT:IMMED:TYPE AMPLITUDE
MEASUREMENT:IMMED:SOURCE CH1
/* Wait until the acquisition is c omplete befo re taking the
mea
surement*/
*OPC
Th
e program can now do different tasks such as talk to other devices. The SRQ,
when it comes, interrupts those tasks and returns control to this task.
/* Take amplitude measurement */
MEASUREMENT:IMMED:VALUE?
Example of Using the
*OPC? Q uery
The *OPC? query places a 1 in the Output Queue once an operation that generates
an OPC message is complete. The *OPC? query does not return until all pending
OPC operations have completed. Therefore, your time-out must be set to a time at
least as long as the longest expected time for the operations to complete.
The same command sequence using the *OPC? query for synchronization looks
like this:
/* Set up single sequence acquisition */
ACQUIRE:STATE OFF
SELECT:CH1 ON
HORIZONTAL:RECORDLENGTH 1000
ACQUIRE:MODE SAMPLE
ACQUIRE:STOPAFTER SEQUENCE
MDO4000/B/C, MSO/DPO4000B and MDO3000 Series Oscilloscopes Programmer Manual 3-11