Skip to content

Instantly share code, notes, and snippets.

@steveway
Created January 24, 2025 08:07
Show Gist options
  • Select an option

  • Save steveway/931507957d47d62722130579bd7c9370 to your computer and use it in GitHub Desktop.

Select an option

Save steveway/931507957d47d62722130579bd7c9370 to your computer and use it in GitHub Desktop.
Reading speed test for Siglent Multimeters
#! /usr/bin/env python3
import pyvisa as visa
from serial.serialutil import SerialException
import time
def main():
# Get list of connected devices
rm = visa.ResourceManager()
device_list = {}
for device_name in rm.list_resources():
print(device_name)
device_id = ""
try:
device_id = rm.open_resource(device_name).query("*IDN?")
except (visa.VisaIOError, FileNotFoundError, SerialException):
pass
if "sdm" in device_name.lower(): # Add only devices which names contain "sdm"
if device_name not in device_list:
device_list[device_name] = rm.open_resource(device_name)
for name in device_list.keys():
device = device_list[name]
device.timeout = 200000
print(name.split("::")[3])
device.write("SAMP:COUNT 1")
cumulative_voltage = 0
start_time = time.time()
for i in range(500):
voltage = device.query("READ?")
cumulative_voltage += float(voltage)
end_time = time.time()
print(f"Time: {end_time - start_time}")
print(f"Time per read: {(end_time - start_time) / 500}")
print(f"Average voltage: {cumulative_voltage / 500}")
device.write("SAMP:COUNT 10000")
device.write("TRIG:COUNT 1")
start_time = time.time()
result = device.query("READ?")
end_time = time.time()
print(f"Time: {end_time - start_time}")
print(f"Time per read: {(end_time - start_time) / 10000}")
print(f"Voltage: {sum([float(voltage) for voltage in result.split(',')]) / 10000}")
print(f"Number of reads: {len(result.split(','))}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment