Fetching Data from Owon SDS7102V to PC
For one of my recent projects, I needed to automatically fetch oscilloscope samples to PC for automatic analysis. I own the Owon SDS7102V oscilloscope so the first step was to find how to get data from it.
The oscilloscope supports USB and ethernet connectivity (non-V versions probably also RS232, but mine has VGA connector instead).
According to the documentation, the Owon SDS7102 should support SCPI commands, but the one I own didn’t respond to any of them (including the SCPI activation command). It either doesn’t support SCPI at all or the FW on my scope is simply too old.Β At the time I checked, the link to the firmware update for my oscilloscope on the Owon site was dead :S
Also in the SCPI manual, there are no commands for reading / downloading data and no commands for triggering. There is another command manual which outlines the Owon proprietary commands for fetching data and the return data format. Owon proprietary commands for setting up the oscilloscope don’t seem to be documented, but the source code of the two applications I will mention later is pretty self-explanatory.
Next to the official Owon PC application, there are at least two published applications for controlling Owon oscilloscope. owon-dump can be used to fetch data and parse it. owoncontrol is used to send commands to the oscilloscope and to change the parameters. Both are open source and seem to be more oriented towards the linux society, with no binary files available, also both are using the USB interface.
I decided it was simpler for me to translate the owon-dump to python and change the interface to TCP than to try to port the programs and compile them under windows.
Owon scope needs to have a manually assigned IP to be able to accept TCP connection from PC (you have to configure it on the oscilloscope). I used a MikroTik Hap Lite as a wireless client to make my oscilloscope WiFi enabled π
The “dump” commands (STARTBMP, STARTBIN, STARTMEMDEPTH) are pretty simple and I had them running quickly. The only thing that can go wrong here is setting the delays/timeouts for the data reception (the scope does take its time when you request a data snapshot).
Here is a simple script that worked for me:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import socket, time, errno, ctypes, struct s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print "Open socket" # set IP and socket to your oscilloscope s.connect(('192.168.88.10',3000)) print "Send command" s.setblocking(0) #s.send('STARTBIN') #s.send('STARTBMP') s.send('STARTMEMDEPTH') chunk_size = 1024 * 16 rcvd_data = 0 full_data = '' timeout = 0 print "Read data ", while (timeout<60): if(rcvd_data == 0): timeout = timeout + 1 else: timeout = 0 try: data_chunk = s.recv(chunk_size) rcvd_data = len(data_chunk) full_data += data_chunk print rcvd_data,",", except socket.error, e: if e.args[0] == errno.EWOULDBLOCK: rcvd_data = 0 else: print e break time.sleep(0.1) print "Close socket" s.close() print len(full_data) print "Write file" with open("Output.bin", "wb") as text_file: text_file.write(full_data) |
The next step was to decode the BIN file and produce some processable data. This involved translating owon-parse to python which took a bit more effort, mainly because of data casting (hint: see struct.unpack).
And now I have some meaningful data I can feed to my processing algorithms π
That’s just how bad an uncompensated probe looks on the square calibration signal π If you look carefully you will notice it’s the same signals as in the first image on the scope.
Do you have the bin file parser? I am looking to do the same thing
You can try compiling the owon-dump sources, which should be easy on linux and not too hard on windows… I will have a dig when I am at home to find the sources translated to python (but note that code might be buggy and it certainly isn’t as clean as dump code presented here)…
You can check out the following code: http://www.rei-labs.net/wp-content/uploads/2018/01/owon_read.zip But beware that it is untested so i suggest you to first do some test readouts at different scope settings (voltage divider, offset, timebase) to verify that it actually works π
Thank you for this article and code. I found that whilst owon_read.zip worked correctly on one python installation it did not on another. The trigger for the problem being a negative y offset. IMHO the cause and solution is:
def read_32():
i = read_u32()
return ctypes.c_long(i).value
should be
def read_32():
i = read_u32()
return ctypes.c_int32(i).value
I’m no Python expert but presumably long can have different implementations.
Here is a similar discussion about Owon oscilloscopes, SCPI and Matlab:
https://www.eevblog.com/forum/testgear/owon-ag-1012-awg-matlab/
The following link could eventually also be helpful to stream data from an Owon oscilloscope to a PC via SCPI, MATLAB or Python:
https://www.eevblog.com/forum/testgear/owon-ag-1012-awg-matlab/msg2813670/#msg2813670
I am trying this code on SDS7102V under Python 3 on Ethernet, apparently it does not communicate (does not respond with anything) even when the syntax is converted. Does SDS7102V support SCPI?
Is there a way to check if the scope correctly responds (it responds to Ping), for instance, connecting it to terminal application (what is the format? RAW?)
Thanks!
You can try connecting using putty to port 3000. You can then send simple textual commands to the scope.
I’ve been able to communicate well with the SDS7102, from linux with a Python program, and using SCPI. All went well till I wanted to get the channel sensitivity (command :CHAN1:SCALe?) No reply from the ‘scope. Undocumented: When in SCPI mode, the scope still accepts STARTMEMDEPTH, STARTBMP and STARTBIN which is great, because switching between proprietary and SCPI mode is tedious.
Do you have any idea which could be the correct SCPI command to get the channel V/div?
:CHANnel1:SCALe? try this