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:
I guess I could just put these hard delays everywhere in my script but it seems really clunky and not the best way.