""" Title: Pyvisa,针对 RIGOL DS1102 Z-E 的截图 Author: 0xac <0xac.cn> Data: 20230527 Pyvisa,针对 RIGOL DS1102 Z-E 的数据采样 数据采集: + Freq CH1, + Vpp CH1, + Vpp CH2, + Rise Delay CH1 -> CH2, + Fail Delay CH1 -> CH2 必须安装 NI-VISA 驱动 https://www.ni.com/zh-cn/support/downloads/drivers/download.ni-visa.html#346210 依赖: pip install pyvisa This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """
""" Title: Pyvisa,针对 RIGOL DS1102 Z-E 的截图 Author: 0xac <0xac.cn> Data: 20230527 必须安装 NI-VISA 驱动 https://www.ni.com/zh-cn/support/downloads/drivers/download.ni-visa.html#346210 依赖: pip install pyvisa This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """
import time import csv from datetime import datetime
""" Title: 一个数据处理的示例 Author: 0xac <0xac.cn> Data: 20230527 依赖: pip install numpy matplotlib This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt
# 数据读入 filename = 'data.csv' data = np.loadtxt(open(filename,"rb"),delimiter=",")
# 转换 Freq = np.array([sublist[0] for sublist in data]) Vpp1 = np.array([sublist[1] for sublist in data]) Vpp2 = np.array([sublist[2] for sublist in data]) RPHase12 = np.array([sublist[3] for sublist in data]) FPHase12 = np.array([sublist[4] for sublist in data])
""" Title: 一个箱线图的示例 Author: 0xac <0xac.cn> Data: 20230527 依赖: pip install numpy matplotlib This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt
# 数据读入 filename = 'data.csv' data = np.loadtxt(open(filename,"rb"),delimiter=",")
# 转换 Freq = np.array([sublist[0] for sublist in data]) Vpp1 = np.array([sublist[1] for sublist in data]) Vpp2 = np.array([sublist[2] for sublist in data]) RPHase12 = np.array([sublist[3] for sublist in data]) FPHase12 = np.array([sublist[4] for sublist in data])
""" Title: Pyvisa,针对 RIGOL DS1102 Z-E 波形读取 Author: 0xac <0xac.cn> Data: 20230824 必须安装 NI-VISA 驱动 https://www.ni.com/zh-cn/support/downloads/drivers/download.ni-visa.html#346210 依赖: pip install pyvisa numpy matplotlib This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """ import pyvisa as visa import numpy as np import matplotlib.pyplot as plt
vrm = visa.ResourceManager()
try: # 创建 VISA 对象 rscope = vrm.open_resource('USB0::0x1AB1::0x0517::DS1ZE225115369::INSTR') except Exception as e: print("打开仪器失败:", str(e)) print("目前在线的仪器为:", vrm.list_resources()) exit(1)
# 设置设备属性 rscope.timeout = 5000
print("连接到:", rscope.query("*IDN?"))
# 打开设备 rscope.open()
# 读取波形 rscope.write(':wav:data?') data = rscope.read_raw(2048)
""" Title: Pyvisa,针对 RIGOL DS1102 Z-E 的波形连续读取 Author: 0xac <0xac.cn> Data: 20230824 必须安装 NI-VISA 驱动 https://www.ni.com/zh-cn/support/downloads/drivers/download.ni-visa.html#346210 依赖: pip install pyvisa numpy matplotlib This code is licensed under the GNU GPLv3 License <https://www.gnu.org/licenses/gpl-3.0.txt>. You are free to use it under the condition of compliance with the license. Copyright 2023 (C) 0xac <0xac.cn> All rights reserved. """ import pyvisa as visa import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation
vrm = visa.ResourceManager() #
try: # 创建 VISA 对象 rscope = vrm.open_resource('USB0::0x1AB1::0x0517::DS1ZE225115369::INSTR') except Exception as e: print("打开仪器失败:", str(e)) print("目前在线的仪器为:", vrm.list_resources()) exit(1)