Git Product home page Git Product logo

pyrigolwfm's Introduction

Python RIGOL oscilloscopes waveform library & tools

While RIGOL oscilloscopes offer great value for money there seems to be a great lack of tools to read RIGOL oscilloscopes waveform (WFM) files.

Based on the protocol extracted by the wfm_view project this project implements a feature complete WFM reader library.

The library has been tested with RIGOL DS1052E but should also work with other oscilloscopes.

Additionally a small example application wfmutil.py is included which provides

  • Header extraction
  • Export to CSV, identical to the internal CSV export of the scope. Just faster.
  • Interactive plotting of the waveform, including a FFT.

Features

  • Extract all trigger information
  • Support for alternate trigger and different time bases
  • Correct treatment of time and voltage shifts

Problems

If you run into problems while parsing your waveform, please open an issue.

Examples

Information extraction

% python wfmutil.py info foo.wfm

General
=======
Alternate trigger        : True
Cur. selected channel    : CH1

Channel CH1
===========
Enabled                  : 1
Samplerate               : 2.500e+08 Samples/s
No. of recorded samples  : 524288
Y inverted               : 0
Time delay               : 0.000e+00 s
Y shift                  : -8.320e-02 V
Y grid scale             : 2.000e-01 V/div
Probe attenuation        : 1.0
Time grid scale          : 2.000e-08 s/div

Channel CH1 Trigger
-------------------
Edge direction           : RISE
Coupling                 : DC
Holdoff                  : 5.000e-07 s
Source                   : CH1
Mode                     : Edge
Level                    : 9.600e-01 V
Sweep                    : Auto
Sensitivity              : 3.800e-01 V

Channel CH2
===========
Enabled                  : 1
Samplerate               : 2.000e+07 Samples/s
No. of recorded samples  : 524288
Y inverted               : 0
Time delay               : 0.000e+00 s
Y shift                  : -2.000e-01 V
Y grid scale             : 1.000e+00 V/div
Probe attenuation        : 10.0
Time grid scale          : 1.000e-03 s/div

Channel CH2 Trigger
-------------------
Coupling                 : DC
Slope lower level        : 0.000e+00 V
Slope type               : RISE >
Holdoff                  : 5.000e-07 s
Source                   : CH2
Slope slope              : 1.040e+06 V/s
Mode                     : Slope
Level                    : 1.040e+00 V
Slope width              : 1.000e-06 s
Sweep                    : Auto
Sensitivity              : 3.800e-01 V

CSV export

% python wfmutil.py csv foo.wfm | head
X(CH1),CH1,X(CH2),CH2,
Second,Volt,Second,Volt,
-1.04858e-03,-6.03e-01,-1.31072e-02,-3.64e+00,
-1.04857e-03,-6.03e-01,-1.31071e-02,-3.64e+00,
-1.04857e-03,-6.03e-01,-1.31071e-02,-3.64e+00,
-1.04856e-03,-6.03e-01,-1.31070e-02,-3.64e+00,
-1.04856e-03,-6.03e-01,-1.31070e-02,-3.64e+00,
-1.04856e-03,-6.03e-01,-1.31069e-02,-3.64e+00,
-1.04855e-03,-6.03e-01,-1.31069e-02,-3.64e+00,
-1.04855e-03,-6.03e-01,-1.31068e-02,-3.64e+00,

Note, that this example uses two time bases via alternate trigger. Because of this there are two time bases in this CSV export. The exported file is identical to the files generated by the scope itself.

License

Copyright (c) 2013, Matthias Blaicher
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: 

1. Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pyrigolwfm's People

Contributors

mabl 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  avatar

pyrigolwfm's Issues

Logic Analyzer support is missing

LA support is still missing. The probable location of the fields is known - unfortunately at least one WFM file is needed to develop the support against it.

DS2000 series WFM files not supported (DS2072A tested)

This is the error I receive:

pesto:pyRigolWFM-master robert$ python wfmutil.py --forgiving info Newfile1.wfm 
Format does not follow the known file format. Try the --forgiving option.
If you'd like to help development, please report this error:

Field padding1 ==  not met, got 8

Will try to investigate later.

Document difference between suffix "M" and "D" variables

The chan_header and time_header contain duplicate fields which I have thought to be identical. The origin of the D/M suffix was taken over from the wfm_viewer project.

There is a difference in those though: The *M type variables contain the scale and offset information during capture - while the *D variables are the current settings used for display.

So in this context M means _M_easured and D means _D_isplayed.

DS4022 format parsing error

python wfmutil.py info /media/.../Newfile9.wfm

_Format does not follow the known file format. Try the --forgiving option.
If you'd like to help development, please report this error:

Field padding1 == not met, got 8_

Newfile9.wfm.zip

Logic Analyzer files crash (DS1052D, files added)

These files fail on loading, usually because they try to address an unused index. I will upload two measurements as WFM, TXT and BMP (as asked in #3).

The trigger modes on DS1052D list Edge, Pulse, Slope, Video, Alternate, Pattern, Duration. The bt200i2c example uses Pattern. Code that seems to work:

trgDict["mode"] = ("Edge", "Pulse", "Slope", "Video", "Alternate", "Pattern", "Duration")[trigHdr["mode"]]

The trigger source can be D0 through D15. The bt200i2c example uses D0. Code that seems to work given LA mode is

trgDict["source"] = "D%d" % trigHdr["source"]

The trigger coupling can be H, L, X, Rise, Fall. The bt200i2c example uses Fall. I am unsure about the order. Let me know if/how I can help.

The trigger sweep is as always. The bt200i2c example uses auto.

DS1104Z unsupported.

This is the error I got:
python wfmutil.py info NewFile3.wfm
Format does not follow the known file format. Try the --forgiving option.
If you'd like to help development, please report this error:

Field magic == 42405 not met, got 65281

I cloned the repository and added an example wfm file. This is the repo https://github.com/joewa/pyRigolWFM.git
Channel 2-4 was measured.

Cheers
Jörg

Can't read bins from my RIGOL scope model MSO5354

I am not able to import binary data generated by my scope.
Model is MSO5354.
Thanks for your code!

> python pyRigolWFM/wfmutil.py info --forgiving data/wave0.bin

Field magic == 42405 not met, got 18258

DS1054Z file format parsing

I've tried the latest code on a WFM generated by a DS1054Z. The first error that came up was:

./wfmutil.py plot --forgiving ../data/test1/NewFile1.wfm 
Format does not follow the known file format. Try the --forgiving option.
If you'd like to help development, please report this error:
Field magic == 42405 not met, got 65281

If I edit the magic number in wfm.py it hits the next one:

Field padding1 ==  not met, got ��

It would be great to see the DS1054Z supported, happy to help where I can. The file is available here for 14 days: https://transfer.sh/1fBvNf/newfile1.wfm

Many thanks

DS1024C are not parsed correctly

As reported by Vincent here the file format of the DS1024C seems to be incompatible with the current parser.

The error is

./wfmutil.py info Bouton0.wfm
Format does not follow the known file format. Try the –forgiving option.
If you’d like to help development, please report this error:

Field smpRate >= 0 not met, got -1.03636966193e-21

Probably the fields are shifted in this version.

Field unused1 not met

Accidently, when typing in a new filename on the Rigol DS1102E, I clicked on the Chinese "Dragon" symbol. The symbol changed into the string "En". I guess that the "Dragon" stands for Chinese filenames because I was not able to use latin characters any longer. I wrote the wfm-file to a USB stick and from there to a computer (renaming it there) It is now named "1.wfm" which is much easier to read. Anyway, when parsing the file with wfmutil.py info 1.wfm I got:

Format does not follow the known file format. Try the --forgiving option.
If you'd like to help development, please report this error:

Field unused1 == ^@^@^@^@ not met, got \342\244^C^@

Using the --forgiving option I could parse the data and retrieve meaningful information.

Y-Offsets

I use a Rigol DS1102E. Could be that the issue cannot be observed on the DS1052.

I had a waveform recorded with "Y grid scale: 5.000e-01 V/div, Y shift: -1.500e-01 V". The information was transmitted in the wfm-file header and parsed by wfmutil.py correctly.

Edit: "Y shift" was -1.5 V on the DS1102E. Therefore, the value was parsed incorrectly. I missed that initially.

To convert to "real" voltages I use the formula (125 - $1) * 0.02 + 1.5), $1 being an unsigned byte value from the data array. The results match the displayed data on the scope.

In the contrary, the "wfmutil.py csv" values are shifted by -1.65V. I.e., instead of real 0V, the csv-file contains -1.65V.

Just a guess: Looks like "Y shift" is parsed too small (by a factor of 10) and considered with the wrong sign.

DS1042c LA

Hi!
I can`t convert wfm to ols or csv. Rigol DS1042C
wfm file: http://www2.zippyshare.com/v/34879194/file.html

C:>C:\pyRigolWFM-master\wfmutil.py ols C:\NewFile2.wfm
Traceback (most recent call last):
File "C:\pyRigolWFM-master\wfmutil.py", line 47, in
scopeData = wfm.parseRigolWFM(f, args.forgiving)
File "C:\pyRigolWFM-master\wfm.py", line 311, in parseRigolWFM
scopeData["triggers"] = parseTriggerHdr(fileHdr["trigHdr1"])
File "C:\pyRigolWFM-master\wfm.py", line 281, in parseTriggerHdr
trgDict["source"] = ("CH1", "CH2", "EXT", "AC Line")[trigHdr["source"]]
IndexError: tuple index out of range

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.