Skip to main content

Parser for Siglent 1000/2000X binary output files

Project description

siglent_parser

Image showing plotted analog data

Analyze data obtained from your Siglent scope using the Python tools you know and love!

siglent_parser is a Python library for converting Siglent 1000/2000X binary data to a Numpy array.

The library is currently configured for analog data and 2000X models. However, parameters and logic are in place for expanding the library's functionality to handle digital data and 1000X models. Steps on how to do this are provided in the Todo. The interested party is encouraged to submit a pull request!

The siglent_parser library was tested using a Siglent SDS2304X and was written using Python 3.6 on Windows 10. Attempts have been made to make the library platform independent, although YMMV. The library was created using the specifications provided by Siglent Technologies in the document How to Extract Data from the Binary File of SDS2000X, SDS1000X, and SDS1000X-E.

How to get it

There are three ways to get the library.

Clone

Please consider contributing to the project! Your help is valuable!

To clone, the siglent_parser library, do

hg clone https://excalamus@bitbucket.org/excalamus/siglent_parser

Download

Download a zip of the library from the main downloads page.

PyPi

The siglent_parser libary is available on PyPi.

To install it in your Python envionment, do

pip install siglent-parser

Setup

If the library was cloned or downloaded, you will need to install the library and its dependencies:

# Make sure you're in the directory above siglent_parser
# This will install the library as an editable package
pip install -e siglent_parser

# Make sure you're in the same directory as requirements.txt
pip install -r requirements.txt

At the time of this writing, the only dependency is Numpy.

Using the siglent_parser library

At this time, the siglent_parser library only parses strictly analog files (See Todo). The output is a Numpy array which can then be plotted, etc.

from pathlib import Path
from siglent_paser import SiglentParser

my_analog        = Path(r"tests\resources\analog_sample2\SDS00001.BIN")
my_digital       = Path(r"tests\resources\digital_sample1\SDS00002.BIN")
my_digtal_analog = Path(r"tests\resources\digital_analog_sample1\SDS00003.BIN")

my_data = my_analog
parsy = SiglentParser()

my_df = parsy.parse_binary(my_data)

# Plot the data
import matplotlib.pyplot as plt

plt.plot(my_df['time'], my_df['volts'])
plt.grid(True)
plt.title(str(my_data) + '\n')
plt.xlabel('time')
plt.ylabel('volts')
plt.show()

Todo

Are you an aspiring coder? Perhaps you're an engineer, looking to learn Python and don't know where to start? Are you pining for a project to cut your teeth on, a "real life" opportunity to improve your skills and decorate your resume? Have a Siglent oscilloscope laying around gathering dust? Look no further!

The following items would be helpful in fleshing out this library. Other contributions are also welcome!

  • Expand the functionality to work with 1000X models:

    • Update TABLE2 and TABLE3 according to the specification
    • Include an option for the user to select 1000X or 2000X model
    • Update the constant values used in the "calc" methods to be 1000X compatable
  • Implement digital parsing:

    • Values are already parsed from the binary file
    • Whether data is digital or analog seems to be determined by the wave_length variable.
    • Understand how the wave_length segment of the binary data differs between analog, digital, and analog-digital data
    • Use this understanding to update get_data_type to discern digital types
    • Update the parse_file method to handle digital data
    • Digital data is available in the tests/ directory
  • Create explicit methods for "Calculate the Time Delay", "Calculate the Sample Rate", and "Calculate the Sample Rate"

    • These methods correspond to the calculations given at the end of the specification
    • The calc_vertical_offset and calc_data_to_volt methods have already been implemented
    • Implement the remaining calculations using the others as a guide

Binary

It does not appear that Siglent 1000X/2000X models can stream binary data. Binary data must be saved to USB:

Image showing how to save binary data

License

Copyright 2019 Matt Trzcinski

This file is part of siglent_parser.

siglent_parser is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

siglent_parser 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 siglent_parser. If not, see https://www.gnu.org/licenses/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for siglent-parser, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size siglent_parser-0.0.4-py3-none-any.whl (30.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size siglent_parser-0.0.4.tar.gz (822.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page