Skip to content

Commit

Permalink
Merge pull request #2 from fronzbot/dev
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
fronzbot authored Jul 13, 2023
2 parents 7c30146 + 55e300b commit a3f5533
Show file tree
Hide file tree
Showing 21 changed files with 693 additions and 395 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug Report
about: Create a bug report about an issue with the library

---


**Describe the bug**

<INSERT TEXT HERE>

**To Reproduce**

Steps to reproduce the behavior:

1.
2.
3.

**Expected Behavior**

<INSERT TEXT HERE>

**python-adc-eval version:** <Library version>

**Additional Information**

<Any other information relevent to the bug report>
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Feature request
about: Suggest a new feature for this library to support

---

**Description**

<Clear and concise description of the feature>

**Additional Information**

<Additional information relevent to the feature request.>
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
reviewers:
- fronzbot
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_test.txt
- name: Lint
run: |
tox -r -e lint
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine build
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
twine upload dist/*
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__pycache__
__pycache__
.tox
python_adc_eval.egg-info
dist
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Kevin Fronczak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.rst
include LICENSE
include requirements.txt
14 changes: 0 additions & 14 deletions README.md

This file was deleted.

65 changes: 65 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
python-adc-eval |Lint| |PyPi Version| |Codestyle|
===================================================

A python-based ADC evaluation tool, suitable for standalone or library-based usage

Details
--------

Package based on
`esynr3z/adc-eval <https://github.com/esynr3z/adc-eval>`__

Tiny tools collection (Python
`NumPy <https://numpy.org/>`__\ +\ `Matplotlib <https://matplotlib.org/>`__
based) to do spectral analysis and calculate the key performance
parameters of an ADC. Just collect some data from the ADC, specify basic
ADC parameters and run analysis. See `example.ipynb <example.ipynb>`__
(you will need `Jupyter Notebook <https://jupyter.org/>`__ to be
installed).

.. figure:: analyser.png
:alt: analyser

analyser

References: - `Analog Devices MT-003 TUTORIAL “Understand SINAD, ENOB,
SNR, THD, THD + N, and SFDR so You Don’t Get Lost in the Noise
Floor” <https://www.analog.com/media/en/training-seminars/tutorials/MT-003.pdf>`__
- `National Instruments Application Note 041 “The Fundamentals of
FFT-Based Signal Analysis and
Measurement” <http://www.sjsu.edu/people/burford.furman/docs/me120/FFT_tutorial_NI.pdf>`__

Inspired by Linear Technology (now Analog Devices)
`PScope <https://www.analog.com/en/technical-articles/pscope-basics.html>`__
tool.


USAGE
=======

To load the library in a module:

.. code-block:: python
import adc_eval
Given an array of values representing the output of an ADC, the spectrum can be analyzed with the following:

.. code-block:: python
import adc_eval
adc_eval.spectrum.analyze(<adc list>, <adc_bits>, <adc vref>, <adc fsamp>, window='hanning', no_plot=<True/False>)
|pscope| Image source: `Creating an ADC Using FPGA Resources WP -
Lattice <https://www.latticesemi.com/-/media/LatticeSemi/Documents/WhitePapers/AG/CreatingAnADCUsingFPGAResources.ashx?document_id=36525>`__

.. |pscope| image:: pscope.png
.. |Lint| image:: https://github.com/fronzbot/python-adc-eval/workflows/Lint/badge.svg
:target: https://github.com/fronzbot/python-adc-eval/actions?query=workflow%3ALint
.. |PyPi Version| image:: https://img.shields.io/pypi/v/spithon.svg
:target: https://pypi.org/project/python-adc-eval
.. |Codestyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
1 change: 1 addition & 0 deletions adc_eval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Initialization file for module."""
17 changes: 8 additions & 9 deletions converters.py → adc_eval/converters.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Analog <-> Digital converters behavioral models
"""
"""Analog <-> Digital converters behavioral models."""

import numpy as np


def analog2digital(sig_f, sample_freq=1e6, sample_n=1024, sample_bits=8, vref=3.3, noisy_lsb=1):
sample_quants = 2 ** sample_bits
def analog2digital(
sig_f, sample_freq=1e6, sample_n=1024, sample_bits=8, vref=3.3, noisy_lsb=1
):
"""Analog to digital converter."""
sample_quants = 2**sample_bits
sample_prd = 1 / sample_freq
t = np.arange(0, sample_n * sample_prd, sample_prd)
dv = vref / sample_quants
Expand All @@ -25,6 +23,7 @@ def analog2digital(sig_f, sample_freq=1e6, sample_n=1024, sample_bits=8, vref=3.


def digital2analog(samples, sample_bits=8, vref=3.3):
quants = 2 ** sample_bits
"""Digital to analog converter."""
quants = 2**sample_bits
dv = vref / quants
return samples * dv
9 changes: 3 additions & 6 deletions signals.py → adc_eval/signals.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Some basic signal functions
"""
"""Basic signal functions."""

import numpy as np


def sin(t, peak=1.5, offset=1.65, freq=1e3, ph0=0):
"""Generate a sine wave."""
return offset + peak * np.sin(ph0 + 2 * np.pi * freq * t)


def noise(t, mean=0, std=0.1):
"""Generate random noise."""
return np.random.normal(mean, std, size=len(t))
Loading

0 comments on commit a3f5533

Please sign in to comment.