Package: ya-ds1052
Remote control of Rigol DS1000E/D series digital oscilloscopes.Example usage:>>> 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()
>>>Most settings of the DS1000 oscilloscopes are available as properties:>>> 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()Aims of ya_ds1052Provide an easy to use remote control interface to DS1000E/D oscilloscopes.Provide, where possible, workarounds for the many quirks of the DS1000E/D,
which have a, well, unconventional SCPI implementation.
The most glaring problem is that the DSOs do not implement the command*OPC?(operation complete command). This makes it sometimes difficult, but at
least cumbersome, to figure out when the change of a setting is eventually
applied. This library tries, where possible, to implement checks if such changes
have been fully applied and when an operation can be performed without
slowing down the performance too drastically. (Rigol's own Ultrascope
software sends SCPI commands with a minimum time distance of 0.12 seconds.
This makes some operations like a read-out of all settings really slow and
does not seems to be necessary.)Installation:pip install ya_ds1052This installs the additional librariesnumpyandaenum.One important dependency must be installed manually in many cases: An
implementation of the USBTMC layer.ya_ds1052works with three USBTMC
drivers:Theusbtmcdriver of the Linux kernel. Usage of this driver requires
no additional Python module.The Python packagepython-usbtmc. This package in turn needs thePyUSBpackage. Seehttp://alexforencich.com/wiki/en/python-usbtmc/startfor more
details. Note that this package has not been updated since a longer time.The Python packagePyVISA, together with a suitable backend.ya_ds1052is tested with the backendspyvisa-py(another Python package) and with
the National Instruments VISA library for Linux (a bit tricky to install
for recent Linux kernel versions).Be aware that the USBTMC implementation of the DS1000E/D is not fully
standard compliant. The VISA backend must provide some workarounds for
the DS1000's quirks.Runpyvisa-infoto check which backend is detected by PyVISA.On Linux it can be necessary to add a udev rule to give users access to
the device files for the DS1000 oscilloscope. Add a file named45-ds1000.rulesto the directory `/etc/udev/rules.d/' with the following
content:SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0588", GROUP="users", MODE="0660"(Change the group nameusersto whatever suits your needs to manage access
rights for different users.)Then runudevadm control --reload-rules && udevadm triggerto activate the new rule. Ensure that you and other users who will use the
oscilloscope are members of the user group specified in the udev rule.
If you must add yourself or other users to the user group, remember that a
new group memebership is recognized after a new login, i.e., users must
logout and login again before access to the device files is possible.Changelog0.1.2New method DS1052.screenshot(): Retrieves a BMP image from the DS1052.Property DS1052.channel[].filter_enabled: Raise DS1052PropertySetError
on attempts to set this property while the DS1052 is in "stop" mode.Improved range check of DS1052.trigger.{edge,pulse,video}.level:
Only allow values in the range (-6 * v_scale .. 6 * v_scale) - v_offset
where v_scale and v_offset are the vertical scale/offset ot the tirgger
source.Same check as above for DS1052.trigger.slope.voltage_level_lower
and DS1052.trigger.slope.voltage_level_upper.classes TriggerModeSettingsEdge, TriggerModeSettingsPulse,
TriggerModeSettingsVideo, TriggerModeSettingsSlope,
TriggerModeSettingsAlternation, Trigger, Channel, _Channels, DS1052:
Methods get_config() and set_config() added.New properties Channel.offset_range, Channel.trigger_level_range
Channel.scale_rangeProperty Channel.offset: Incorrect calculation of value limits fixed.0.1.1First public release