MDO3000 Programmer Manual.pdf - 第1021页

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 DES E and *ESE commands. Y ou can also enable service…

100%1 / 1158
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
Status and Events
/* Acqu ire wave
form da ta */
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
measuremen
t*/
*OPC?
Wait for re
ad from Output Queue.
/* Take amplitude measurement */
MEASUREMENT:IMMED:VALUE?
This is the simplest approach. It requires no status handling or loops. However,
you must set the controller time-out for longer than the acquisition operation.
Example of Using the *WA I
Command
The *WAI
command forces completion of previous commands that generate
an OPC message. No commands after the *WAI are processed before the OPC
message(s) are generated
The same command sequence using the *WAI command for synchronization
looks like this:
/* Set up conditional acquisition */
ACQUIRE:STATE OFF
SELECT:CH1 ON
HORIZONTAL:RECORDLENGTH 1000
ACQUIRE:MODE SAMPLE
ACQ
UIRE:STOPAFTER SEQUENCE
/* Acquir e 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 measu rement*/
*/
*WAI
/* Take amplitude measurement */
MEASUREMENT:IMMED:VALUE?
The controller can continue to write commands to the input buffer of the
oscilloscope, but the commands will not be processed by the oscilloscope until
all in-process OPC operations are complete. If the input buffer becomes full,
the controller will be unable to write commands to the buffer. This can causea
time-out.
3-12 MDO4000/B/C, MSO/DPO4000B and MDO3000 Series Oscilloscopes Programmer Manual