Posted Fri, 04 Aug 2023 21:27:54 GMT by Glebov, Boris
Is there a command to check whether the AFG has finished processing data and commands? For example, if I upload an arb waveform and then copy it from EMEM to a USER slot, can I programmatically check if this finished and the AFG is ready to start generating the waveform on the specified channel?
Posted Tue, 08 Aug 2023 17:40:32 GMT by Teles, Afonso
Hi Boris,

It's not documented, but the instrument does reply to an *OPC? query. I haven't tested it thoroughly on this instrument, but does how one would usually do synchronization through SCPI.
Posted Tue, 08 Aug 2023 17:59:10 GMT by Glebov, Boris
That's great - can you expand on what kind of response to expect and how to interpret it?
Posted Tue, 08 Aug 2023 23:27:59 GMT by Teles, Afonso
Hi Boris,

Probably the best explanation of *OPC? is in this programmer's manual: https://www.tek.com/en/sitewide-content/manuals/4/5/6/4-5-6-series-mso-programmer-manual
Essentially, you'd wait until you read 1 from *OPC? and that would tell you that your OPC operations are done. I've attempted to try it out on the AFG1k but haven't been able to confirm it works.
The *WAI command might also be of interest to you.
Also, a lot of our signal sources are synchronous, making it unnecessary to query *OPC?. I'm still trying to confirm if this is the case for the AFG1k or not.

Do you have a specific setup which has been giving you synchronization problems?
 
Posted Wed, 09 Aug 2023 20:59:20 GMT by Glebov, Boris

In our setup, we are using an AFG to send a trigger sequence (using a burst of a single repetition, activated by software trigger) to another device. The whole setup is integrated into a single Python script, so the overall sequence runs automatically. So I just need to make sure once the script is through the section where the AFG is being set up, that the AFG is actually ready to run. I want the script to block until the AFG is all done and is ready for the software trigger.

I did a couple quick tests. For this, I prepare a waveform that is 7585 points long (so copying will take some real time). Running it in the console looks like this:

>>> if True:
    t0 = time()
    afg.wvfm_copy(1, 'EMEM') # copy from EMEM to USER1
    t1 = time()
    print(f'Elapsed time: {t1 - t0:.3F} sec')

Elapsed time: 0.000 sec
>>> if True:
    t0 = time()
    afg.wvfm_copy(1, 'EMEM') # copy from EMEM to USER1
    afg._dev.query('*OPC?')
    t1 = time()
    print(f'Elapsed time: {t1 - t0:.3F} sec')

'0'
Elapsed time: 0.780 sec

In execution, there is a noticeable delay until `0` prints out.

This looks to me like the AFG won't process the *OPC? command until it has finished copying data. The query method will then wait (up to the VISA timeout limit, which here is 2 sec) for the *OPC? query to return anything, which effectively blocks until completion.

By the way, I have not sent the *WAI command.

Does this make sense and align with what you have been able to test?

Posted Wed, 09 Aug 2023 23:17:54 GMT by Teles, Afonso

Hi Boris,

Yep your test is great and I've also ran similar tests which confirms that *OPC? works to synchronize commands. Specifically, running *OPC? by itself takes 35 ms, doing data:copy is about 1 ms, but if we do both it takes 50 ms, which implies that *OPC? is waiting about 15 ms for data:copy to finish, as expected.

I also tested using other queries like system:err? or data:value? and those had the same effect, which lead me to believe the AFG's programming interface is synchronous, so explicit synchronization with *OPC? is likely not needed.

You must be signed in to post in this forum.