GithubHelp home page GithubHelp logo

pklaus / ds1054z Goto Github PK

View Code? Open in Web Editor NEW
177.0 16.0 40.0 151 KB

Python package for the Rigol DS1054Z Oscilloscope

Home Page: https://ds1054z.readthedocs.org/

Python 100.00%
rigol oscilloscope ds1054z python3 cli

ds1054z's Introduction

Github pklaus/ds1054z PyPI Package

ds1054z

This package allows you to connect to your Rigol DS1054Z oscilloscope via Ethernet. It comes with a versatile command line tool.

Off course, you can also use it to control the scope with your own script by using the API this package has to offer.

While this software is named after the entry level oscilloscope DS1054Z, I believe there is no reason it wouldn't work with just any scope of the DS1000Z and MSO1000Z series by Rigol:

  • DS1054Z
  • DS1074Z
  • DS1104Z
  • DS1074Z-S
  • DS1104Z-S
  • MSO1074Z
  • MSO1104Z
  • MSO1074Z-S
  • MSO1104Z-S

Features

  • Discovering your scope via mDNS / DNS-SD
  • Saving Screenshots (incl. adjustable dimming of on-screen controls)
  • Running / stopping the scope
  • Acquiring waveforms
  • ... more to come!

Installation

The installation is dead simple:

pip install ds1054z[savescreen,discovery]

ds1054z depends on python-vxi11 which should automatically get installed along with itself.

For more information on the installation, please consult the installation section of the package documentation.

Recommended Firmware

Older versions of the oscilloscope's firmware have many issues. The VXI-11 connection could be unstable or commands might return unexpected data. Specifically, I'm recommending version 00.04.04.SP3 (alias 00.04.04.03.02) published on 2017-02-08.

Usage

Command Line Tool

This package installs a versatile command line (CLI) tool called ds1054z. You can use it to save the screen of your scope, for example:

ds1054z save-screen --overlay 0.6 192.168.0.23

As a result, a file like this will be saved to your current working directory:

oscilloscope screenshot

You can find out more ways to use the CLI tool with ds1054z --help or by reading the manual.

Developers

If you're into Python programming, use the DS1054Z class in your own code:

from ds1054z import DS1054Z

scope = DS1054Z('192.168.0.23')
print("Connected to: ", scope.idn)

print("Currently displayed channels: ", str(scope.displayed_channels))

Author

Resources

ds1054z's People

Contributors

atx avatar pklaus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ds1054z's Issues

A close method is needed.

I'd like to wrap a context manager around DS1054Z class.
So that the TCP/IP connection resource could be released after usage.
Now the close operation is only implemented in del in vxi11 which could only be triggered by Python auto garbage collection.
This module lacks a close method on purpose.

Feature Request: Backup and Restore Settings

The ds1054z CLI tool should enable users to backup and restore settings related to the scope with a simple command. Having a backup of the settings would allow operators of the scope to play around with all the knobs and settings while being able to quickly going back to the old settings if needed. The backup should be written to a (human and machine friendly) local file and should contain the following information:

  • time axis
    • timebase
    • zero-offset
  • active channels:
    • Y-offset
    • Y-scale
    • coupling
  • acquisition
    • number of samples (auto, fixed number)
  • "measurements":
    • measurement kind
    • related channel
  • display (zoom?)
  • trigger
    • condition (channel, edge, level)
    • mode (auto, normal, single)

When it comes to the global scope status (running, stopped, single) I think it should not be restored. It would make more sense to stop the scope during the restore operation and leave it up to the user to press the start/single/whatever button (or send the corresponding command) after restoring.

Proposed CLI signature:

ds1054z settings --backup somefile
ds1054z settings --restore somefile
ds1054z settings --backup newfile --restore oldfile  # first back up, then restore 

in discovery.py print/raise error including "requires zeroconf package" when zeroconf is not installed

I just tried import ds1054z.discovery and found it failed to import. Got confused by the main page instructions pip install ds1054z[savescreen,discovery] which don't make sense to me because of the square brackets (I haven't seen that in pip syntax documentation before). Finally I checked the github directory tree and saw the comment at the top of discovery.py saying I needed zeroconf if I got the import error. So why not print an additional message for less skilled users than myself?

Need zeroconf and then followed by a warning

Discovery depends on the zeroconf Python package which is missing. After running pip install zeroconf i then get the following message.

FutureWarning: <ds1054z.discovery.Listener object at 0x0000024D925F71C0> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
warnings.warn(

and no other outputs. the oscilloscope is connected to the laptop. I am not sure that it is connected to the wifi

question: usb support?

hello. this tool is great. just what i need.
my problem is i dont have ethernet in my computer.
does your app can work with usb ?
thanks!

MSO1074Z is not detected properly.

When trying to use the class with a Rigol MSO1074Z, i got this error:

    raise NameError(msg)
NameError: Unknown device identification:
RIGOL TECHNOLOGIES,MSO1074Z,DS1ZC182100884,00.04.04.SP3
If you believe this device should be supported by this package, feel free to contact the maintainer with this information.

I commented the following lines in __init__.py

        """
        if not match:
            msg = "Unknown device identification:\n%s\n" \
                  "If you believe this device should be supported " \
                  "by this package, feel free to contact " \
                  "the maintainer with this information." % idn
            raise NameError(msg)
        """

I'm workig in a new branch in order to add to the class the capability of properly detect the MSO1074Z model.

setting the trigger level

First off all great job in developing the API for this scope. I'm very happy to be able to automate my measurements now using it.

One feature however is missing (at least for me): setting the trigger level.
Is there a way to set the trigger level in any way (maybe using using the vxi11 write(.) method) ?

Kind regards, keep up the good work!

get_waveform_samples does not fetch the complete internal memory in RAW mode

I've just noticed that get_waveform_samples("CHAN1", "RAW") always returns 1200 samples,
from my DS1054z, regardless of the state of the scope or the configured memory depth.

After enabling logging reading through the debug output I realized that the points field in the waveform preamble is always set to 1200 for me,
whereas memory_depth_curr_waveform returns the correct memory depth for all scenarios I've tested so far.

Here is a small piece of code to reproduce this:

#!/usr/bin/env python3

import logging
from ds1054z import DS1054Z

def main():
    logging.basicConfig(level=logging.DEBUG)

    scope = DS1054Z('192.168.0.23')
    print("Connected to: ", scope.idn)

    samples = scope.get_waveform_samples("CHAN1", "RAW")
    print(len(samples))

    print(scope.memory_depth_curr_waveform)


if __name__ == '__main__':
    main()

The output while the scope is stopped, with only one channel active and the memory depth set to 12M manually is:

DEBUG:pyds1054z.ds1054z:sending: b'*IDN?'
DEBUG:pyds1054z.ds1054z:received: b'RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4\n'
DEBUG:pyds1054z.ds1054z:sending: b'*IDN?'
DEBUG:pyds1054z.ds1054z:received: b'RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4\n'
Connected to:  RIGOL TECHNOLOGIES,DS1054Z,XXXXXXXXXXXXXXX,00.04.02.SP4
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:SOURce CHAN1'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:FORMat BYTE'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:MODE RAW'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:PREamble?'
DEBUG:pyds1054z.ds1054z:received: b'0,2,1200,1,1.000000e-09,-6.000000e-03,0,2.074219e-01,-78,122\n'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:STARt 1'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:STOP 1200'
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:DATA?'
DEBUG:pyds1054z.ds1054z:received a long answer: 23 39 30 30 30 30 30 31 32 30 ... 70 71 71 71 71 71 70 70 71 0A
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:PREamble?'
DEBUG:pyds1054z.ds1054z:received: b'0,2,1200,1,1.000000e-09,-6.000000e-03,0,2.074219e-01,-78,122\n'
1200
DEBUG:pyds1054z.ds1054z:sending: b':WAVeform:MODE?'
DEBUG:pyds1054z.ds1054z:received: b'RAW\n'
DEBUG:pyds1054z.ds1054z:sending: b':TRIGger:STATus?'
DEBUG:pyds1054z.ds1054z:received: b'STOP\n'
DEBUG:pyds1054z.ds1054z:sending: b':ACQuire:MDEPth?'
DEBUG:pyds1054z.ds1054z:received: b'12000000\n'
12000000

(I've removed the output for info as it contained only timing information.)

I'd like to know if anybody can reproduce this, or if this is a problem specific to my setup.
If I can find the time next week, I'll try to reproduce it on my other DS1054z.

Meanwhile I've been able to get get_waveform_samples working for me,
by using the memory_depth_curr_waveform instead of the points value from the waveform preamble to determine how many sample should be fetched from the scope.
In theory this should not break anything else, as the modified line is in _get_waveform_bytes_internal.

I can also provide a pull request with my fix.

Should the repo be renamed?

Hello. Since this lib is useful for the oscilloscopes other than ds1054z, I guess it's a bit strange to keep this name. Should it be renamed? (I have almost implemented some abstractions I hope useful to add support of more oscilloscopes).

save-screen: "IOError: image file is truncated"

When I do save-screen and there's a whole lot of stuff on the oscilloscope screen (i.e. high frequency oscillations), it dies with IOError. This seems to happen repeatably for dense screen contents, but save-screen works fine most of the time.

$ ds1054z save-screen 192.168.4.3
Traceback (most recent call last):
  File "/usr/local/bin/ds1054z", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/ds1054z/cli.py", line 291, in main
    im.putalpha(255)
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1398, in putalpha
    self.load()
  File "/usr/local/lib/python2.7/site-packages/PIL/ImageFile.py", line 211, in load
    raise IOError("image file is truncated")
IOError: image file is truncated

DS1054z not detected

The DS1054z will not be discovered via zeroconf. Adding the proper ip address solve the issue.

I'm using this model acc. info from ds1054z info <ip_addr>
Vendor: RIGOL TECHNOLOGIES
Product: DS1054Z
Serial: DS1ZA204820248
Firmware: 00.04.04.SP3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.