From bd903b530d470a3f627c74e3530db41d2aac34d2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 4 Aug 2022 13:55:47 +0800 Subject: [PATCH] add siglent capture script --- siglent.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 siglent.py diff --git a/siglent.py b/siglent.py new file mode 100644 index 0000000..82eb397 --- /dev/null +++ b/siglent.py @@ -0,0 +1,36 @@ +# nix-shell -p python3Packages.pyvisa python3Packages.pyvisa-py python3Packages.numpy + +import pyvisa as visa +import time +import numpy as np + +resources = visa.ResourceManager('@py') +device = resources.open_resource("TCPIP::192.168.1.145::INSTR", write_termination='\n', query_delay=0.25) +print(device.query("*IDN?")) + +device.write("*RST") +time.sleep(5) + +device.write("MSIZ 20M") +device.write("TIME_DIV 200MS") +device.write("C1:VDIV 2V") +device.write("C2:TRA ON") +device.write("C2:VDIV 2V") + +time.sleep(5) + +device.write("STOP") + + +for channel in range(1, 3): + sample_num = int(float(device.query("SANU? C{}".format(channel)))) + print("C{}:{}".format(channel, sample_num)) + + device.write("C{}:WF? DAT2".format(channel)) + response = device.read_raw()[18:] + assert len(response) == sample_num + + array = np.frombuffer(response, dtype="u8") + np.save("siglent_ch{}.npy".format(channel), array) + + time.sleep(1)