Author Topic: SCPI process to wait for long command to complete  (Read 3352 times)

0 Members and 1 Guest are viewing this topic.

Offline RossTopic starter

  • Contributor
  • Posts: 31
  • Country: nz
SCPI process to wait for long command to complete
« on: April 06, 2023, 02:38:35 am »
Hi,

I am using a Siglent SSA 3015X and my aim is to trigger a scan and then get some indication of the scan completing via SCPI commands. I am using Python PyVisa and want to know when the scan is complete so I can do something else in the python program.

A web search came up with the sequence (generic not specific to my device):
*CLS
*TRG
*OPC?

This sequence is supposed to clear any event or status registers, trigger a scan and the OPC command is supposed to return 1 when the previous command is complete. What actually happens is the scan starts but the scan takes 10 seconds or so and the OPC query times out.

Alternative option is:
*CLS
*OPC
*TRG
*ESR?

This sequence should clear status and event registers, trigger the scan and then polling the event status register to look for bit zero to be true. What actually happens is the scan is triggered but the *ESR? response is always zero. I thought it might have been my python program so I tried the commands in the web SCPI command terminal of the analyzer and the same thing happens.

What my question to the community is am I using the correct sequence of commands and if I am is the Siglent device not honoring them?

Thanks,

Ross
« Last Edit: April 11, 2023, 02:03:09 am by Ross »
 

Online tautech

  • Super Contributor
  • ***
  • Posts: 29809
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: SCPI process to wait for long command to complete
« Reply #1 on: April 06, 2023, 03:06:47 am »
Are you working from this programming guide Ross ?
https://int.siglent.com/u_file/document/ProgrammingGuide_PG0703P_E02B.pdf

There are some App notes on the US site:
https://siglentna.com/application-notes/ssa3000x-plus/

And BTW, your model is SSA3015X Plus.  ;)
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2903
  • Country: 00
Re: SCPI process to wait for long command to complete
« Reply #2 on: April 06, 2023, 09:59:51 am »
I don't own or have used this specific instrument, but I have dealt with slow SCPI commands quite a lot. Here's a couple of possible solutions that I've used:
  • Increase the timeout. This is something you might be able to set on the transport layer you use to transport the GPIB commands. For example for VXI-11, the Device and Instrument classes in python-vxi11 have a timeout attribute.
  • For status registers like ESR you often have to configure a bit mask of which events trigger it if you want certain bits to be set. Sometimes this even goes two layers deep: set bitmask y so a bit in the Y register is set, and then set bit mask x so the bit corresponding to register Y in the X register are set. Check the manual. These commands might be called something like ESE or MESE. (Programming) manuals will normally show the bits of the various status registers and how they interact between registers.
  • You can often program an instrument to send an SRQ interrupt when a command is complete. How you listen to SRQ depends on the transport you use. I don't think python-vxi11 supports SRQ, so I have not used them recently.
  • Sometimes the best solution is to just insert a sleep if you know the command is going to take at least two minutes, just sleep for two minutes before you do your status query. The downside is that if a command fails, it will take two minutes to find out. But for hobby, where you're not blocking a production line, this is usually not a problem.

Offline RossTopic starter

  • Contributor
  • Posts: 31
  • Country: nz
Re: SCPI process to wait for long command to complete
« Reply #3 on: April 11, 2023, 02:06:25 am »
Are you working from this programming guide Ross ?
https://int.siglent.com/u_file/document/ProgrammingGuide_PG0703P_E02B.pdf

There are some App notes on the US site:
https://siglentna.com/application-notes/ssa3000x-plus/

And BTW, your model is SSA3015X Plus.  ;)

Thanks for the resources, I have been working with the programming guide before posting and have found it light on detail when it comes to the registers. The application notes do have some useful information, but not about this issue.
 

Offline RossTopic starter

  • Contributor
  • Posts: 31
  • Country: nz
Re: SCPI process to wait for long command to complete
« Reply #4 on: April 11, 2023, 11:42:10 pm »
I don't own or have used this specific instrument, but I have dealt with slow SCPI commands quite a lot. Here's a couple of possible solutions that I've used:
  • Increase the timeout. This is something you might be able to set on the transport layer you use to transport the GPIB commands. For example for VXI-11, the Device and Instrument classes in python-vxi11 have a timeout attribute.
  • For status registers like ESR you often have to configure a bit mask of which events trigger it if you want certain bits to be set. Sometimes this even goes two layers deep: set bitmask y so a bit in the Y register is set, and then set bit mask x so the bit corresponding to register Y in the X register are set. Check the manual. These commands might be called something like ESE or MESE. (Programming) manuals will normally show the bits of the various status registers and how they interact between registers.
  • You can often program an instrument to send an SRQ interrupt when a command is complete. How you listen to SRQ depends on the transport you use. I don't think python-vxi11 supports SRQ, so I have not used them recently.
  • Sometimes the best solution is to just insert a sleep if you know the command is going to take at least two minutes, just sleep for two minutes before you do your status query. The downside is that if a command fails, it will take two minutes to find out. But for hobby, where you're not blocking a production line, this is usually not a problem.

Thanks for your ideas. As far as I can tell there is SRO in this instrument. I checked the ESE and have set it to 255, but still the same result. I am now using:

*CLS
*ESE 255
*OPC
*TRG

But it still doesn't work. I have done more googling regarding the sequence in general and I think I have it right which leads me to think that the analyzer is not doing what it should. I guess I will have to implement a delay.
 

Offline PatrickB

  • Contributor
  • Posts: 48
  • Country: fr
Re: SCPI process to wait for long command to complete
« Reply #5 on: April 12, 2023, 12:19:58 pm »
*OPC? should returns 1 when the previous command is finished.

I don't know your device but why not use something like this:
*CLS
....
*TRG
while (*OPC? == 0)
{ } // loop that does nothing, just to wait for OPC to be = 1. Add a small delay in this loop to avoid constantly polling the device.
keep on going
 
The following users thanked this post: Roehrenonkel

Offline dietert1

  • Super Contributor
  • ***
  • Posts: 2473
  • Country: br
    • CADT Homepage
Re: SCPI process to wait for long command to complete
« Reply #6 on: April 12, 2023, 04:11:38 pm »
Implementing GPIB SRQ driven data taking can be difficult. One needs to implement full error handling and recovery to make things work reliably. And an interrupt scheme eventually means multithreading, i mean if you want to use the wait interval for other operations. For example with multiple instruments in the setup.

I just got it working on a Keithley 3706 - after several days of try and error. For a SCPI instrument it should be somewhat easier. The Keithley has a status bit for "output available". If i enable that for the SRQ, i can submit the data request and then it produces the SRQ after the measurements are complete and in the output queue, in my case about 6 seconds. After the interrupt i just listen to the instrument in order to fetch the result.

Regards, Dieter
 

Offline rcjoy

  • Regular Contributor
  • *
  • Posts: 58
  • Country: us
Re: SCPI process to wait for long command to complete
« Reply #7 on: April 12, 2023, 09:02:32 pm »


Regarding SRQ, here's a link to an example from Keysight using PyVisa and SRQ for their instrument, but the concept
should apply in general.

https://rfmw.em.keysight.com/wireless/helpfiles/pxivna/Programming/GPIB_Example_Programs/SRQ_Example.htm
 
You would only do that if you wanted the program to do something else while waiting.
 
The following users thanked this post: Someone

Online tautech

  • Super Contributor
  • ***
  • Posts: 29809
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: SCPI process to wait for long command to complete
« Reply #8 on: April 13, 2023, 10:05:17 pm »
Siglent provided a beta patch through us to Ross which improved things but apparently didn't irradicate his issue.

Any further help from members is appreciated and detailed info taken to Siglent for their consideration.
Thanks chaps.  :clap:
Avid Rabid Hobbyist.
Some stuff seen @ Siglent HQ cannot be shared.
 

Online Someone

  • Super Contributor
  • ***
  • Posts: 5155
  • Country: au
    • send complaints here
Re: SCPI process to wait for long command to complete
« Reply #9 on: April 13, 2023, 11:52:17 pm »
Regarding SRQ, here's a link to an example from Keysight using PyVisa and SRQ for their instrument, but the concept should apply in general.
pyvisa, pyvisa-py, Keithley DMM6500
enable_event
NotImplementedError:

:(
« Last Edit: April 13, 2023, 11:53:48 pm by Someone »
 

Offline dietert1

  • Super Contributor
  • ***
  • Posts: 2473
  • Country: br
    • CADT Homepage
Re: SCPI process to wait for long command to complete
« Reply #10 on: April 14, 2023, 06:36:13 am »
Yes, that's what i meant by error handling. When something doesn't work at least you want to see an error message or a warning.

Regards, Dieter
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf