跳转到主要内容

Rigol DS1000E/D示波器远程控制

项目描述

远程控制Rigol DS1000E/D系列数字示波器。

示例用法

>>> import matplotlib.pyplot as plt
>>> from ds1052 import DS1052, PointsMode
>>> with DS1052() as dso:
...     # Acquire the waveform of channel 1 in "normal" points mode
...     # which returns 600 data points.
...     waveform = dso.read_waveforms([1], PointsMode.normal)[0]
...
>>> # Vertical scale and offset.
>>> waveform.v_scale
1.0
>>> waveform.v_offset
0.52
>>> # Timebase scale and offset.
>>> waveform.tb_scale
0.0005
>>> waveform.tb_offset
0.0
>>> # waveform.t is a numpy array with time axis values. 0 is the trigger
>>> # time; waveform.v is a numpy array with the voltage values.
>>> plt.plot(waveform.t, waveform.v)
[<matplotlib.lines.Line2D object at 0x7f8b8e075640>]
>>> plt.show()
>>>

DS1000示波器的多数设置都可作为属性使用

>>> import ds1052
>>> dso = ds1052.DS1052()
>>> dso.open()
>>> dso.timebase_scale
0.0005
>>> dso.timebase_offset
0.0
>>> dso.trigger.edge.level
1.48
>>> dso.trigger.edge.coupling
<TriggerCoupling.dc: 'DC'>
>>> dso.channel[2].coupling
<ChannelCoupling.dc: 'DC'>
>>> dso.channel[2].scale
1.0
>>> dso.channel[2].offset
-3.52
>>> dso.channel[2].scale = 0.6
>>> dso.channel[2].scale
0.6

>>> # Measurement values are returned as tuples (value, qualifier).
>>> dso.channel[1].voltage_rms
(2.14, <MeasurementQualifier.value: ('value',)>)
>>> # MeasurementQualifier.less_than indicates that the DSO could make
>>> # a measurement with sufficient precision. (Settings of this example:
>>> # Channel 1 input is a 1kHz square wave; the sampling rate is 500k/s.
>>> # 500 samples per period are clearly not enough to measure the rise
>>> # time.)
>>> dso.channel[1].rise_time
(3e-05, <MeasurementQualifier.less_than: 'less than'>)

>>> # Finally, DS1052.close() should be called to unlock the keyboard.
>>> # (If DS1052 is used as a context manager, the close() call is made
>>> # when the context is left.)
>>> dso.close()

ya_ds1052的目标

  1. 提供一个易于使用的远程控制接口到DS1000E/D示波器。

  2. 尽可能提供DS1000E/D的许多怪癖的解决方案,这些怪癖有一个非常不寻常的SCPI实现。最明显的问题是DSO没有实现*OPC?(操作完成命令)。这使得有时很难,但至少麻烦地确定设置更改何时最终应用。这个库尝试在可能的情况下实现检查这种更改是否已完全应用,何时可以执行操作而不会太大地减慢性能。(Rigol自己的Ultrascope软件发送SCPI命令的最小时间距离为0.12秒。这使得某些操作,如读取所有设置的输出变得非常慢,这似乎是不必要的。)

安装

pip install ya_ds1052

这将安装附加库numpyaenum

在许多情况下,必须手动安装一个重要依赖项:USBTMC层的实现。ya_ds1052与三个USBTMC驱动程序一起工作

  • Linux内核的usbtmc驱动程序。使用此驱动程序不需要额外的Python模块。

  • Python包python-usbtmc。此包反过来需要PyUSB包。有关更多详细信息,请参阅http://alexforencich.com/wiki/en/python-usbtmc/start。请注意,该包已有一段时间未更新。

  • Python包PyVISA以及合适的后端。已经测试了ya_ds1052与后端pyvisa-py(另一个Python包)以及National Instruments的VISA库(对于最新的Linux内核版本,安装有些棘手)。

    请注意,DS1000E/D的USBTMC实现并不完全符合标准。VISA后端必须提供一些针对DS1000特性的解决方案。

    运行pyvisa-info以检查PyVISA检测到的后端。

在Linux上,可能需要添加udev规则以使用户能够访问DS1000示波器的设备文件。将名为45-ds1000.rules的文件添加到目录`/etc/udev/rules.d/`中,内容如下:

SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0588", GROUP="users", MODE="0660"

(将组名users更改为满足您需求的任何名称,以管理不同用户的访问权限。)

然后运行

udevadm control --reload-rules && udevadm trigger

以激活新规则。确保您和其他将使用示波器的用户是udev规则中指定的用户组的成员。如果您必须将您自己或其他用户添加到用户组,请记住,新组成员身份是在新登录后识别的,即,用户必须注销并重新登录才能访问设备文件。

变更日志

0.1.2

  • 新方法DS1052.screenshot():从DS1052检索BMP图像。
  • 属性DS1052.channel[].filter_enabled:在DS1052处于“停止”模式时尝试设置此属性时引发DS1052PropertySetError。
  • 改进了DS1052.trigger.{edge,pulse,video}.level的范围检查:仅允许在范围(-6 * v_scale .. 6 * v_scale)- v_offset中的值,其中v_scale和v_offset是触发源的垂直缩放/偏移。
  • 对于DS1052.trigger.slope.voltage_level_lower和DS1052.trigger.slope.voltage_level_upper,执行与上述相同的检查。
  • 类TriggerModeSettingsEdge, TriggerModeSettingsPulse, TriggerModeSettingsVideo, TriggerModeSettingsSlope, TriggerModeSettingsAlternation, Trigger, Channel, _Channels, DS1052:添加了get_config()和set_config()方法。
  • 新增属性Channel.offset_range, Channel.trigger_level_range, Channel.scale_range
  • 属性Channel.offset:修复了值限制计算错误。

0.1.1

首次公开发布

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分布

ya_ds1052-0.1.2.tar.gz (90.2 kB 查看散列

上传时间

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面