0
\$\begingroup\$

I am writing a SCPI script in Python for the Siglent SDS1104X-E. I have been banging my head for a few days trying to get this to work. Below is my main py file:


    
    ################################################################################
    #     Set the Scope IP address and Port number
    ################################################################################
    SCOPE_IP_ADDR = "192.168.1.220"
    SCOPE_IP_PORT = 5025
    ################################################################################
    #     Useful Variables
    ################################################################################
    channel_list = [1, 2, 3, 4] # The values in this list correspond to the 4 channels on the scope.
                                  
    channel_1_dict = {'enable': 'True', 'bandwidth': 'ON', 'coupling': 'D1M',
                      'volt_div': 1, 'volt_offset': 0, 'probe_attenuation': 1}

    sc.config_chan(channel_list[0], channel_1_dict['enable'], channel_1_dict['volt_div'],
               channel_1_dict['volt_offset'], channel_1_dict['coupling'],
               channel_1_dict['bandwidth'], channel_1_dict['probe_attenuation'])

    sc = sds.SDS1104X_Object(SCOPE_IP_ADDR, SCOPE_IP_PORT)
    sc.open_connection()
    sc.reset_inst()
    print(sc.get_id())

My problem is that the reset command (*RST) does not happen fast enough. When configuring multiple channels, it does not always set all of the channels.

Below is a snip from the object that sends the actual commands

    def reset_inst(self):
        self._send_cmd("*RST")

    # helper functions
    def _send_cmd(self, cmd):
        """ send cmd if connected, no resp """
        if self.connection.is_connected:
            self.connection.write(cmd)

    def _send_qry(self, cmd):
        """ send cmd if connected, return resp """
        if self.connection.is_connected:
            self.connection.write(cmd)
            return self.connection.read_raw()
        else:
            return None

The only way I can get this to work is to use the Python "sleep" command after every SCPI command

    time.sleep(3)

The programming manual says to send the *OPC query in order to wait for a command to finish:

enter image description here

I guess I could just put these hard delays everywhere in my script but it seems really clunky and not the best way.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

*RST causes the entire scope to reset. It doesn't send a response before the reset, and it can't send one afterwards - the reset causes it to "forget" everything that happened before the reset.

The programming guide tells you when a command will send a response. A command with a response will have a block named "RESPONSE FORMAT" in its description.

What you want to do is to send the "*RST" then periodically ask if the scope is ready to talk to you.

The examples in the guide start with asking for the device identification using the "*IDN?" command.

Send your "*RST" then a short pause (hundred milliseconds or so) then send the "*IDN?" command. Repeat the pause and the "*IDN?" command until you get a good response.

When you look at other commands, take note of whether or not they send a response. If they don't, then you will have to find a different way to see if they succeeded.

For example, the "*RCL" (recall) command doesn't provide a response. If you want to load a particular bunch of settings you have to send the "*RCL" then check the status of the "EXecution error status Register" (command "EXR?") to see if it worked properly.

\$\endgroup\$
4
  • \$\begingroup\$ I edited my question because I see that I had actually pasted in my code incorrect. I am actually sending IDN? after the RST. I do the RST as an initial clearing of everything when the script first runs. Excuse my ignorant question, but how do I check the execution status register. There doesn't seem to be a command for that. \$\endgroup\$
    – Frank
    Commented Jun 30, 2022 at 14:07
  • \$\begingroup\$ Oh, I see, we are looking at different manuals this is what I am looking at manual. I will go over the commands in your manual and I will let you know what I figure out. \$\endgroup\$
    – Frank
    Commented Jun 30, 2022 at 14:15
  • \$\begingroup\$ Apologies for overloading your comment, just a quick update. I am actually using the allstatus command ALST?, and that seems to be a workaround. My channels and trig get set. The problem is that there are multiple manuals floating around online. So now on to the next problem. hahaha. \$\endgroup\$
    – Frank
    Commented Jun 30, 2022 at 14:59
  • \$\begingroup\$ Yeah, ALTS? gets you all the registers. \$\endgroup\$
    – JRE
    Commented Jun 30, 2022 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.