Once upon a time Series, Shunt and Ladder attenuator calculator for selectable (ie. ≥ 24, ≤24) steps

Joined 2008
Paid Member
Years ago there were online a few resistance value calculators for stepped attenuators with user selectable number of steps with at least one going well above 60 (100?) steps if you put that in.
Does anybody happen to remember any calculators of that sort? Even if there's no longer an active link, if you do remember whose it was there's a chance it could be found in the archive.
For a series stepped attenuator, you can use: https://pynative.com/online-python-code-editor-to-execute-python-code/

And run the following code (input your desired values where it says #example usage):

from math import sqrt, pow, log10

def calculate_attenuator_resistors(num_steps, db_per_step, total_attenuator_impedance):
attenuation_ratio = pow(10, db_per_step / 10)
total_attenuation = pow(attenuation_ratio, num_steps)
resistance_ratio = sqrt(attenuation_ratio)

current_resistor = total_attenuator_impedance / ((1 - resistance_ratio ** num_steps) / (1 - resistance_ratio))

print("Step\tResistor Value (ohms)")

resistor_values = []

for step in range(1, num_steps + 1):
current_resistor *= resistance_ratio

print("Resistor Values:")
for resistor_value in resistor_values:

# Example usage
num_steps = 60
db_per_step = -2
total_attenuator_impedance = 100000

calculate_attenuator_resistors(num_steps, db_per_step, total_attenuator_impedance)
Joined 2008
Paid Member
Well , holy smoke , you guys were quick ! Thanks ! ! !
Trying to make the first post as short as I could I deleted the rotary word thinking it wasn't essential in thinking of value calculations. I'd forgotten about relay based circuits.
Nevertheless, now there are other suggestions for relay based attenuators (thanks Mark!) the thread may be more generally useful.

The original reason i asked is because these days 24 steps seems to have become the de facto standard for calculators based on rotary switches, but the best deals at surplus storefronts are often on old overstock custom types from OEM or MIL shelves.
For example, one local place has a bin of 32 position switches with heavily tarnished or dirty contacts but with 5$ price tag might be worth mixing and matching some of their parts to make up a good working unit. Mulling it over and poking around on the web it's clear most don't consider other than 24 steps a possibility.

. . . . and to answer swich401's first question, . . . . All three.

Joined 2008
Paid Member
Hi swich401,

After clearing the instruction on line one , I tried to run a direct copy and paste of your code from above but got errors of unexpected indent and expected indent. On following the prompts eventually got to 'attenuation_ratio' is not defined. Haven't tried past that. Does a direct copy and paste work on your machine?

The forum keeps removing the indenting from the code. You need to indent the lines like the image shows below (click the start of the line and hit the tab key on your keyboard):

Attenuator calculator.jpg