How to compute voltage divider bottom resistor by ratio in Python using UliEngineering

You can easily compute the bottom resistor of a voltage divider given the top resistor value and the division ratio using the UliEngineering Python library:

bottom_resistor_by_ratio.py
from UliEngineering.Electronics.VoltageDivider import *
from UliEngineering.EngineerIO import *

# Compute bottom resistor for 10k top resistor and 0.5 ratio
rbottom = bottom_resistor_by_ratio("10k", 0.5)
print(f"Bottom resistor (ratio 0.5, top 10k): {format_value(rbottom, 'Ω')}")

# Compute bottom resistor for 9k top resistor and 0.1 ratio
rbottom = bottom_resistor_by_ratio("9k", 0.1)
print(f"Bottom resistor (ratio 0.1, top 9k): {format_value(rbottom, 'Ω')}")

Example output

bottom_resistor_by_ratio_output.txt
Bottom resistor (ratio 0.5, top 10k): 10.0 kΩ
Bottom resistor (ratio 0.1, top 9k): 1.00 kΩ

The bottom resistor is computed using the formula: $R_{bottom} = R_{top} \times \frac{ratio}{1 - ratio}$, where the ratio is $V_{out}/V_{in}$.


Check out similar posts by category: Electronics, Python