Skip to main content

Find optimal resistor configurations using E-series standards

Project description

resistor

Find optimal resistor configurations for a target resistance using E-series standards.

Given a target resistance, this tool finds the best single resistor or two-resistor combination (series or parallel) from the E-series standard values, ranked by how well the tolerance envelope contains the target.

Installation

pip install resistor

Or install from source:

git clone https://github.com/commuted/e-table.git
cd e-table
pip install -e .

Usage

Command Line

# Find configurations for 1580 ohms
resistor 1580

# Supports k (kilo) and M (mega) suffixes
resistor 4.7k
resistor 2.2M

# Show more results
resistor 1580 -n 10

# Use different E-series (E24 instead of E96)
resistor 1580 -e 24

# Use 5% tolerance resistors
resistor 1580 -t 5

# Only show single/series/parallel results
resistor 1580 --single-only
resistor 1580 --series-only
resistor 1580 --parallel-only

Python API

from resistor import (
    find_best_resistor_config,
    create_table,
    create_series_table,
    create_parallel_table,
)

# Create lookup tables (do once, reuse for multiple queries)
base_table = create_table(es=96, decades=6, tolerance=0.01)
series_table = create_series_table(base_table)
parallel_table = create_parallel_table(base_table)

# Find best configurations for target
results = find_best_resistor_config(
    target=1580,
    base_table=base_table,
    series_table=series_table,
    parallel_table=parallel_table,
    n=5
)

for r in results:
    print(f"{r['config']}: {r['resistors']} = {r['nominal']}Ω")

How It Works

  1. Generates E-series values (default E96) across multiple decades with tolerance bounds
  2. Computes all series combinations: R_total = R1 + R2
  3. Computes all parallel combinations: R_total = (R1 × R2)/(R1 + R2)
  4. Scores each configuration by how well the tolerance envelope contains the target
  5. Returns top-n results sorted by score

The scoring function returns 0 if the target falls within the tolerance envelope, otherwise returns the normalized distance to the nearest bound. A small tiebreaker based on relative error ensures consistent ordering for equal scores.

E-Series Standards

The E-series (IEC 60063) defines preferred number values for electronic components:

Series Values/Decade Typical Tolerance
E6 6 20%
E12 12 10%
E24 24 5%
E48 48 2%
E96 96 1%
E192 192 0.5%

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=resistor --cov-report=term-missing

License

MIT

Project details


Download files

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

Source Distribution

resistor-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resistor-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file resistor-0.1.0.tar.gz.

File metadata

  • Download URL: resistor-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resistor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6112b5248f67af116e02bab5a6246028203278ade8cd663ee1becb5c989a30ba
MD5 7780231075016d6af3080dafa5e37ef1
BLAKE2b-256 cd2f745b3c8768567701d9374a076f8f806a1fc9ddf166fecb1d2daa5f0691a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for resistor-0.1.0.tar.gz:

Publisher: publish.yml on commuted/resistor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file resistor-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: resistor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resistor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1624242781e4262e9752fef6c5c7e462ec60d58676862425b2cba39b3719e6c5
MD5 b7101765b9d9b876d7d1a19488177df0
BLAKE2b-256 56f104734d0e2d579a21a8a9c7bc361a61eddf787708f7753f00dc9a585c419e

See more details on using hashes here.

Provenance

The following attestation bundles were made for resistor-0.1.0-py3-none-any.whl:

Publisher: publish.yml on commuted/resistor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page