u1f35c / owondump

Userspace USB Driver for Owon PDS digital oscilliscopes
6 stars 2 forks source link

About

Owondump is a userspace USB driver that interrogates an Owon PDS digital oscilloscope
over the USB bus, and retrieves a trace memory for all selected channels. The downloaded
data is made available on the PC in both vectorgram format and in the bitmap BMP format.

Owondump was originally designed for the 25MHz PDS5022s "Academic" Scope from Owon, but
it now works for other scopes in the same range, including the PDS6062.

Owondump was primarily intended for *nix machines since the manufacturer there is only
a closed-source binary for Microsoft Windows which won't run in WINE, because of the
lack of USB support.  However, it should also be possible to build Owondump against
libusb-win32, the Windows port of the library.   

Once the channel vectorgram data has been retrieved from the scope, it is parsed into a
tabulated text file format that can be displayed using GNUplot or similar plotting packages.

A second utility called owonfileread is included. Owonfileread takes a binary trace dump
file obtained from owondump or from the Owon application for Windows. The binary file is
parsed and the trace data is written out in the same tabulated text file format.

A very useful third utility called readtrace is included. It was written by Michel Pollet.
It is a TCL script to parse the trace dump and detect edges and deduce the frequency.

Author

Owondump was written by Michael Murphy and is released to the public under the terms of
the GNU GPL, or General Public License.     

Copyright May 2010, Michael Murphy <ee07m060@elec.qmul.ac.uk>

Licence

Owondump is free software: you can redistribute it and/or modify it under the terms of
the latest GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.

Requires

gcc
GNU make
libusb-0.1 - http://libusb.wiki.sourceforge.net/
Also, you may need to install libusb:
sudo apt-get install libusb-dev

Compiling

gcc -o owondump owondump.c -lusb
gcc -o owonfileread owonfileread.c -lusb

Running

[michael@core2quad owondump]$ ./owondump

..Initialising libUSB
..Searching USB buses for Owon
..Found an Owon device 5345:1234 on bus 002
..Resetting device.
..Attempting USB lock on device  5345:1234
..Trying to claim interface 0 of 5345:1234 
..Successfully claimed interface 0 to 5345:1234 
..Attempting to get the Device Descriptor
..Successfully obtained device descriptor!
..Attempting to bulk write START command to device...
..Successful bulk write of 0005 bytes!
..Attempting to bulk read 000c (12) bytes from device...
..Successful bulk read of 000c (12) bytes! :
..Attempting to malloc read buffer space of 000075d3h (30163) bytes
..Successful malloc!
..Owon ready to bulk transfer 000075d3h (30163) bytes
..Attempting to bulk read 000075d3h (30163) bytes from device...
..Successful bulk read of 000075d3h (30163) bytes! : 
..Found data from Owon PDS5022S
..Found vector gram data
-------------------------------
              Channel: CH1
         sample count: 5000
 vertical sensitivity: 2000mV
             timebase: 0.5ms
-------------------------------
-------------------------------
              Channel: CH2
         sample count: 5000
 vertical sensitivity: 2000mV
             timebase: 0.5ms
-------------------------------
-------------------------------
              Channel: CHA
         sample count: 5000
 vertical sensitivity: 2000mV
             timebase: 0.5ms
-------------------------------
..Successfully opened text file 'output.bin.txt'!
..Successfully written trace data to 'output.bin.txt'!
..Successfully closed text file 'output.bin.txt'!
..Successfully opened file 'output.bin'!
..Successfully written 30163 bytes to file output.bin
..Attempting to release interface 0
..Successful release of interface 0!

[michael@core2quad owondump]$ cat output.bin.txt

# Units:(mV) -- Timebase: (0.5ms)
#         CH1         CH2         CHA
1       4880.0      5040.0      4880.0
2       4880.0      4960.0      4880.0
3       4880.0      4960.0      4880.0
4       4880.0      4960.0      4880.0
5       4880.0      5040.0      4880.0
6       4880.0      5040.0      4880.0
7       4880.0      4960.0      4960.0
8       4880.0      4960.0      4880.0
9       4880.0      5040.0      4880.0
10      4960.0      5040.0      4960.0
11      4880.0      5040.0      4960.0
12      4960.0      5040.0      4880.0
13      4880.0      4960.0      4880.0
14      4880.0      4960.0      4880.0
15      4880.0      5040.0      4960.0
16      4880.0      5040.0      4960.0
17      4880.0      4960.0      4880.0
18      4880.0      5040.0      4880.0
19      4880.0      4960.0      4880.0
[..]

gnuplot> set terminal jpeg 
gnuplot> set output 'trace.jpg'
gnuplot> plot 'test.bin.txt' u 2 s b w l lw 5 t 'CH1 5000mV 500ns', 'test.bin.txt' u 4 s b w l lw 5 t 'CHA 5000mV 500ns'

Concluding Notes

The human-readable vectorgram file format produced by Owondump exactly mirrors the format produced by the
original Windows s/w from Owon / Lilliput Technologies.   This format works fine when the scope channels
are all configured to use the same timebase. However when channel #1 is set to 5nS and channel #2 is set
to 100mS, for example, the tabulated sample data cannot be plotted sensibly.

Ideally, the tabulated data should have a text header that details the timebase settings for each of the
channels. This header would then be parsed by the trace plotting package.

The Owon seems a bit quirky. If the device is not reset before a transfer is made, the data toggle for
the BULK IN endpoint gets stuck, and cannot be shifted. Without that reset, the BULK IN transfers would
otherwise timeout. 

Thank you to :

    Owon / Lilliput Technologies for manufacturing a very nice range of oscilloscopes,
    and for contributing to the Open Source software community.

    Pavel Čejka for his encouragement and for his very kind words to Owon :-)

    Eamon "Ed" Skelton of Cork, Ireland, for help and support in providing trace binaries 
    for the PDS6062S oscilloscope.

    Michel Pollet for his bug squishing, his elegant method of factoring the timebase, and
    for writing readtrace, a tool for edge detection and frequency determination.

    Lucas Salvador for his offer to translate the software into Spanish.

    No doubt many others I have forgotten.

All comments and contributions welcomed!

Michael Murphy - <ee07m060@elec.qmul.ac.uk> - May 2010