AnsweredAssumed Answered

Ensure scope is ready to receive trigger before generating it

Question asked by crouleau on Aug 22, 2017
Latest reply on Aug 22, 2017 by crouleau

I have a C# application that automates a Keysight MSOX4000 series scope and a power supply over SCPI. I need to change the power supply voltage from low to high (e.g. 8V to 12V) and capture the scope traces on three channels during that transition (one of which is hooked up to the power supply). 


The program flow is:

1) Initialize scope (reset to factory default), wait for completion with *OPC?

2) Setup scope channels to be visible and have correct vertical/horizontal ranges

3) Configure trigger

4) Wait for all preceding commands to be complete (with "*OPC?")

5) Set the scope's run mode to Single (":SING")

6) Tell the power supply to switch from 8V to 12V

7) Send "*OPC" again and wait for it - it seems that the ":SING" command only triggers the OPC register when it has acquired a full trace

8) Grab the waveforms off the scope


My problem seems to exist between steps 5 and 6. The program usually works fine, and I get everything I need. However, sometimes it never triggers. In this case, if I manually adjust the power supply voltage down and back up, it does trigger. So the trigger is getting set properly but I think the power supply is transitioning before the scope is ready. If I insert a Thread.Sleep(200) in between steps 5 and 6 it *seems* to work reliably. This program will be used in a variety of circumstances and I'd rather not rely on a static sleep if there's a way to ask the instrument what its status is (and I want to understand what's going on under the hood). I can't figure out how to wait for the scope to be set in run mode: single. If I do an an *OPC wait after 5) I end up waiting forever - I guess because the "single acquisition" operation is not complete. Since there is no ":SING?" command I can't just ask the scope if it's in single acquisition mode.


So I have two questions:


A) How do I tell that the scope is in run mode "Single" and ready for a triggering event?

B) Does step 7) (*OPC?) actually wait for a full scope trace acquisition to be complete (and therefore I can safely hand off to the function that grabs the waveforms)


Thanks for any help!


P.S. I'm looking at using the operation status condition register (":OPER:COND?") - bit 5, "Wait Trig". But the documentation on what that actually does is quite sparse as far as I can tell, and I'm not certain it's reliable for what I'm trying to do.