1362
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
38
Synchronizing Acquisitions
# (<< is a left shift; left shift is fastest); this is used later
# to "unmask" the result of the Operation Status Event Register
# as there is no direct access to the RUN bit.
# Define completion criterion:
ACQ_DONE = 0
# Means the oscilloscope is stopped
ACQ_NOT_DONE = 1<<RUN_BIT
# Means the oscilloscope is running; value is 8.
This is the
# 4th bit of the Operation Status Condition (and Event) Register.
# The registers are binary and start counting at zero, thus the
# 4th bit (4th position in a binary representation of decimal
# 8 = 2^3 = (1 left shift 3).
This is either High (running = 8)
# or low (stopped and therefore done with acquisition = 0).
print "Acquiring signal(s)..."
# Define acquisition start time.
This is in seconds.
StartTime = time.clock()
# Begin Acquisition with *CLS and the non-blocking :SINGle
# command, concatenated together. The *CLS clears all (non-mask)
# registers & sets them to 0;
KsInfiniiVisionX.write("*CLS;:SINGle")
# Initialize the loop entry condition (assume Acq. is not done).
Acq_State = ACQ_NOT_DONE
# Poll the oscilloscope until Acq_State is a one. (This is NOT a
# "Serial Poll.")
while Acq_State == ACQ_NOT_DONE and (time.clock() - StartTime
<= MAX_TIME_TO_WAIT):
# Ask oscilloscope if it is done with the acquisition via the
# Operation Status Condition (not Event) Register.
# The Condition register reflects the CURRENT state, while
# the EVENT register reflects the first event that occurred
# since it was cleared or read, thus the CONDITION register
# is used.
#
# DO NOT do:
# KsInfiniiVisionX.query("*CLS;SINGle;OPERegister:CONDition?")
# as putting :OPERegister:CONDition? right after :SINgle
# doesn't work reliably
#
# The oscilloscope SHOULD trigger, but it sits there with the
# Single hard key on the oscilloscope lit yellow; pressing
# this key causes a trigger.
Status = int(KsInfiniiVisionX.query(":OPERegister:CONDition?"))
# Bitwise AND of the Status and RUN_MASK.
This exposes ONLY
# the 4th bit, which is either High (running = 8) or low
# (stopped and therefore done with acquisition = 0)
Acq_State = (Status & RUN_MASK)
if Acq_State == ACQ_DONE:
break # Break out of while loop so that the 100 ms pause
# below is not incurred if done.