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.