scottprahl / rigolwfm Goto Github PK
View Code? Open in Web Editor NEWParsers for .wfm binary files created by a wide range of Rigol oscilloscopes
License: BSD 3-Clause "New" or "Revised" License
Parsers for .wfm binary files created by a wide range of Rigol oscilloscopes
License: BSD 3-Clause "New" or "Revised" License
The code is in the repository, but it is untested. A few sets of saved waveforms created by a Rigol DS1000C, DS1000M, DS1000CD, DS1000MD, DS1062CA, DS1102CA, DS1202CA, or DS1302CA scope would fix this. Each set should contain
Ideally the saved waveforms would cover a range of vertical and horizontal settings.
Hi, I'm getting the following error trying to convert a wfm to csv
d4machine% wfmconvert E csv test.wfm
Traceback (most recent call last):
File "/usr/local/bin/wfmconvert", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/RigolWFM/wfmconvert.py", line 93, in main
scope_data = rigol.Wfm.from_file(filename, args.model)
File "/usr/local/lib/python3.7/site-packages/RigolWFM/wfm.py", line 180, in from_file
ch = RigolWFM.channel.Channel(w, ch_number, pname, enabled_channels)
File "/usr/local/lib/python3.7/site-packages/RigolWFM/channel.py", line 132, in __init__
self.seconds_per_point = w.header.seconds_per_point
File "/usr/local/lib/python3.7/site-packages/RigolWFM/wfm1000e.py", line 365, in header
self._m_header = self._root.Header(self._io, self, self._root)
File "/usr/local/lib/python3.7/site-packages/RigolWFM/wfm1000e.py", line 207, in __init__
self._read()
File "/usr/local/lib/python3.7/site-packages/RigolWFM/wfm1000e.py", line 210, in _read
self.magic = self._io.ensure_fixed_contents(b"\xA5\xA5\x00\x00")
File "/usr/local/lib/python3.7/site-packages/kaitaistruct.py", line 279, in ensure_fixed_contents
(actual, expected)
Exception: unexpected fixed contents: got b'\xa5\xa58\x00', was waiting for b'\xa5\xa5\x00\x00'
The scope's on the latest firmware. 00.03.06
Any clues?
I've tried with a couple different files now. I can use the plotter to plot both files out, so that's working. Perhaps there's another way to pip the data to a csv?
Here's the test file:
Attempted to convert a WFM file of DS1202CA to CSV but it failed :
$ python --version
Python 3.8.5
$ wfmconvert C csv NewFile6.wfm
Traceback (most recent call last):
File "/home/ben/Downloads/wfm/bin/wfmconvert", line 8, in
sys.exit(main())
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/wfmconvert.py", line 125, in main
scope_data = rigol.Wfm.from_file(filename, args.model)
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/wfm.py", line 180, in from_file
ch = RigolWFM.channel.Channel(w, ch_number, pname, enabled_channels)
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/channel.py", line 132, in init
self.seconds_per_point = w.header.seconds_per_point
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/wfm1000c.py", line 203, in header
self._m_header = self._root.Header(self._io, self, self._root)
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/wfm1000c.py", line 59, in init
self._read()
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/RigolWFM/wfm1000c.py", line 62, in _read
self.magic = self._io.ensure_fixed_contents(b"\xA5\xA5\x00\x00")
File "/home/ben/Downloads/wfm/lib/python3.8/site-packages/kaitaistruct.py", line 323, in ensure_fixed_contents
raise Exception(
Exception: unexpected fixed contents: got b'\xa1\xa5\x00\x00', was waiting for b'\xa5\xa5\x00\x00'
The wfm file is attached.
Just a few sets of saved waveforms created by a Rigol DS1074B, DS1104B, or DS1204B scope. Each set should contain
Ideally these would cover a range of vertical and horizontal settings.
Hello, I want to use wfmconvert to convert .wfm to .csv.
The follows are my codes, and then I meet error.
`import RigolWFM.wfm as rigol
import RigolWFM.wfmconvert
filename = 'Newfile1.wfm'
scope = 'DS2072A'
w = rigol.Wfm.from_file(filename, scope)
RigolWFM.wfmconvert 2 csv Newfile1.wfm`
File "/Users/Ronja/Desktop/scopedata/wfmdata.py", line 9
RigolWFM.wfmconvert 2 csv Newfile1.wfm
^
SyntaxError: invalid syntax
`import RigolWFM.wfm as rigol
import RigolWFM.wfmconvert
filename = 'Newfile1.wfm'
scope = 'DS2072A'
w = rigol.Wfm.from_file(filename, scope)
RigolWFM.wfmconvert.csv(2,'Newfile1.wfm','convertfile')`
/usr/local/bin/python3 /Users/Ronja/Desktop/scopedata/wfmdata.py
Traceback (most recent call last):
File "/Users/Ronja/Desktop/scopedata/wfmdata.py", line 9, in
RigolWFM.wfmconvert.csv(2,'Newfile1.wfm','convertfile')
File "/Users/Ronja/Library/Python/3.9/lib/python/site-packages/RigolWFM/wfmconvert.py", line 40, in csv
s = scope_data.csv()
AttributeError: 'str' object has no attribute 'csv'
Thank you for your help!
if I try just one LA channel I get a division by zero error:
python .\rigol_plt.py
Traceback (most recent call last):
File "C:\Users\jano\workfolder\code\memosens\rigol_plt.py", line 7, in
w = rigol.Wfm.from_file(filename, scope)
File "C:\Users\jano\AppData\Roaming\Python\Python310\site-packages\RigolWFM\wfm.py", line 209, in from_file
ch = RigolWFM.channel.Channel(w, ch_number, pname, selected)
File "C:\Users\jano\AppData\Roaming\Python\Python310\site-packages\RigolWFM\channel.py", line 162, in init
self.ds1000z(w, channel_number)
File "C:\Users\jano\AppData\Roaming\Python\Python310\site-packages\RigolWFM\channel.py", line 294, in ds1000z
self.points = w.header.points
File "C:\Users\jano\AppData\Roaming\Python\Python310\site-packages\RigolWFM\wfm1000z.py", line 274, in points
self._m_points = self.memory_depth // self.stride
ZeroDivisionError: integer division or modulo by zero
rigol_plt.py contains:
import matplotlib.pyplot as plt
import RigolWFM.wfm as rigol
filename = 'test1.wfm'
scope = 'DS1074Z'
w = rigol.Wfm.from_file(filename, scope)
w.plot()
plt.show()
if along with the LA I turn on CH1, the picture has blocks which are not correct:
If I zoom in:
I also tried wfmconver.exe, it stays forever doing nothing.
the files:
D.zip
firmware on the scope is 00.04.05.SP2, there is nothing newer than this one on Rigol's website.
Hey, thanks for maintaining this useful repository!
I installed RigolWFM 0.6.5 using pip.
After converting the attached door-open.wfm
to CSV using wfmconvert E csv door-open.wfm
, I noticed that the resulting voltage levels seem incorrect (2.88V instead of 28.8V):
$ head door-open.csv
X,CH 1,Start,Increment
ms, V,-3.000000e-02,5.000000e-05
-92.057200,2.88
-92.057000,2.88
-92.056800,2.88
-92.056600,2.88
Whereas with Rigol’s Ultrascope program on Windows, I see the expected voltage level of 28V DC, and the program displays the 10V/div setting I used when capturing:
I tried loading the file into kaitai, but couldn’t see anything obviously misinterpreted—maybe it’ll be apparent to you? :)
Find door-open.wfm
in door-open.zip and feel free to use it as a sample file.
Hi,
I've got a problem when using your software for wfm-files saved with a Rigol DS1054Z. I've recorded 2 channels: 1 and 2. When I have a look at the data in python or using the wfmconvert, the voltage-values are swapped between channel 1 and 2. However, the voltage scale and probe values (e.g. 10X) are not, so that not only the signal curves are swapped between channel 1 and 2 but also wrong scaled.
The firmware is 00.04.04.SP3
Best
Philipp
As of RigolWFM 0.6.6, for some files, wfmconvert decides that mV
is more appropriate, while typically V
is more appropriate.
This seems to be a deliberate code decision:
Lines 286 to 291 in dfcab78
This behavior is getting in my way when importing the CSV files into sigrok, which expects volts.
I don’t see an option to tell sigrok-cli to convert these values, and even if there was one, it would be tedious to figure out which files need conversion and which don’t, when I’m converting many wave forms.
Could you change the CSV export to use volts always please? That should make the resulting CSVs more broadly useful.
Thank you,
The files in the repository are pretty old. The calculated voltages a close to, but do not match the values from the .csv files. The parsing of the header files looks solid and the voltage calculation is the same as that used by all the other Rigol scopes. My hope is that the problem rests in old firmware used to generate the .wfm/.csv files.
The latest scope firmware is at https://www.rigolna.com/firmware/ and a few .wfm/.csv files are needed to test this theory.
The code is in the repository, but it is untested. A few sets of saved waveforms created by a Rigol DS6062, DS6064, DS6102, or DS6104 scope would fix this. Each set should contain
Ideally the saved waveforms would cover a range of vertical and horizontal settings.
Hi Scott, Just wondering when you may have time to include the DS1202ZE?
Hello,
I needed a way to parse some large wfm files (large enough that exporting them to csv directly took waay too long) and came across this wonderful project. For me it did not work out-of-the-box. It turned out to be because I had only exported 2 channels.
Since I am not a "native python speaker" :), It took me a while to figure it out even though it is trivial;
I am posting it here so that maybe someone else may benefit from it; it should probably be fixed in the master also at some point.
channel.py
93c93
- raw_bytes = np.array(data.raw2 & 0x00FF, dtype=np.uint8)
+ raw_bytes = np.array(np.uint16(data.raw2) & 0x00FF, dtype=np.uint8)
95c95
- raw_bytes = np.array(data.raw2 & 0xFF00) >> 8, dtype=np.uint8)
+ raw_bytes = np.array((np.uint16(data.raw2) & 0xFF00) >> 8, dtype=np.uint8)
Best regards,
John
hi,
i wanted to try your RigolWFM on my Raspberry Pi (RPi4 + RasPi OS Bullseye) but i can't get it running:
i did:
pip install --user RigolWFM
and then i tried
import matplotlib.pyplot as plt
import RigolWFM.wfm as rigol
filename = 'example.wfm'
scope = 'DS1000E'
w = rigol.Wfm.from_file(filename, scope)
w.plot()
plt.show()
but i get an error:
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "/home/pi/Documents/test_rigol_wfm.py", line 1, in <module>
import matplotlib.pyplot as plt
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/__init__.py", line 109, in <module>
from . import _api, _version, cbook, docstring, rcsetup
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/colors.py", line 56, in <module>
from matplotlib import _api, cbook, scale
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/scale.py", line 23, in <module>
from matplotlib.ticker import (
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/ticker.py", line 136, in <module>
from matplotlib import transforms as mtransforms
File "/home/pi/.local/lib/python3.9/site-packages/matplotlib/transforms.py", line 46, in <module>
from matplotlib._path import (
ImportError: numpy.core.multiarray failed to import
i also don't find the commandline tool wfmconvert
Hi Scott,
First of all, thanks for your great work!
I'd like to report a problem when a channel is used for triggering, but not shown on the oscilloscope screen.
Steps to reproduce: I used a DS1104Z (latest FW: 00.04.04.SP4) to sample 2 channels, used CH2 for triggering on the slope of a rectangular signal, then turned off CH2 (the yellow CH2 light is off, CH2 is not shown on the screen).
Then I did a single shot capture, then saved the .wfm file.
Now when I read the file using RigolWFM, CH1 and CH2 are interleaved.
I would have expected to only get CH1.
The .wfm file is attached:
NewFile1.wfm.zip
Thanks
Michael
Hi
First of all, this is really great stuff you are doing here.
However, we have a problem that is the inverse of this one. Namely that we want to load arbitrary waveform files onto a scope.
We have a DS1104Z-S that has a dual function generator built in. The manual implies that you can set up an arbitrary waveform on either of the source outputs, but very little information other than that. It turns out that you can edit waveforms, but that is very timeconsuming using the UI. It seems possible to dump things in a .wfm format (though no idea whether that is the same as the capture format, but no reason to suppose that it isn't either) .. but .. you can't read it back in! You can dump and read in a .arb file.
Playing around, it looks as though the .arb format consists of 16384 unsigned, little-endian 16-bit words, which completely fill the generator waveform memory. Smaller files cause a load error!
The encoding would seem to be:
0x0000 - maximum -ve level
0x8000 - zero (little endian encoding is two bytes: 0x00 , followed by 0x80)
0xFFFF - maximum +ve level
There is no header information.
Actual timing, levels, is determined by the settings in the source menu.
There seems to be no way to upload this information via SCPI commands either. Whereas I have had good results using SCPI to download waveform data without having to dump it to a file. This used Python-Vxi11 and also the rather nice frameworks in PyMeasure, though I had to write my own DS1104Z-S instrument adapter, which wasn't very difficult.
Hope that information is of use to someone. Keep up the good work!
Ubuntu 18.04, python3.6, use trunk https://github.com/scottprahl/RigolWFM.git
Osciloscope: DS1102E
Signals:
DS1102E-signals.zip
test file:
$ cat test.py
import sys
import RigolWFM.wfm as rigol
model = "DS1102E"
filename = sys.argv[1]
scope_data = rigol.Wfm.from_file(filename, model)
description = scope_data.describe()
print(description)
Got error:
Traceback (most recent call last):
File "./test.py", line 5, in <module>
scope_data = rigol.Wfm.from_file(filename, model)
File "/tmp/rigol/lib/python3.6/site-packages/RigolWFM/wfm.py", line 206, in from_file
ch = RigolWFM.channel.Channel(w, ch_number, pname, selected)
File "/tmp/rigol/lib/python3.6/site-packages/RigolWFM/channel.py", line 113, in __init__
self.seconds_per_point = w.header.seconds_per_point
File "/tmp/rigol/lib/python3.6/site-packages/RigolWFM/wfm1000e.py", line 380, in header
self._m_header = Wfm1000e.Header(self._io, self, self._root)
File "/tmp/rigol/lib/python3.6/site-packages/RigolWFM/wfm1000e.py", line 202, in __init__
self._read()
File "/tmp/rigol/lib/python3.6/site-packages/RigolWFM/wfm1000e.py", line 210, in _read
raise kaitaistruct.ValidationNotEqualError(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", self.blank_12, self._io, u"/types/header/seq/1")
kaitaistruct.ValidationNotEqualError: /types/header/seq/1: at pos 16: validation failed: not equal, expected b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', but got b'~\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
If I swith type to DS1102D
it works, but shows invalid amplitude scale. Pulse voltage should be 3V
Just a few sets of saved waveforms created by a Rigol DS1074B, DS1104B, or DS1204B scope. Each set should contain
Ideally these would cover a range of vertical and horizontal settings.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.