@@ -126,12 +126,13 @@ class SeriesResistor(Resistor, GeneratorBlock):
126126 by distributing the load across multiple devices.
127127
128128 Generally used as a refinement to break up a single (logical) resistor that is dissipating too much power
129- or has an excessive voltage across it."""
129+ or has an excessive voltage across it. Accounts for tolerance stackup for power and voltage distribution
130+ using specified (not actual) resistor tolerance - is a pessimistic calculation."""
130131 @init_in_parent
131132 def __init__ (self , * args , count : IntLike = 2 , ** kwargs ):
132133 super ().__init__ (* args , ** kwargs )
133134 self .count = self .ArgParameter (count )
134- self .generator_param (self .count )
135+ self .generator_param (self .count , self . resistance )
135136
136137 def generate (self ):
137138 super ().generate ()
@@ -141,10 +142,22 @@ def generate(self):
141142 cumu_power_rating : RangeLike = Range .exact (0 )
142143 cumu_voltage_rating : RangeLike = Range .exact (0 )
143144 self .res = ElementDict [Resistor ]()
145+
146+ # calculate tolerance stackup effects on R for worst-case power and voltage
147+ resistance_range = self .get (self .resistance )
148+ resistance_tol = (resistance_range .upper - resistance_range .lower ) / 2 / resistance_range .center ()
149+ resistance_tol = min (0.05 , resistance_tol ) # in practice there should be no >5% resistors
150+ resistance_ratio_range = Range ((1 - resistance_tol ) / (count + resistance_tol * (count - 2 )),
151+ (1 + resistance_tol ) / (count - resistance_tol * (count - 2 )))
152+
153+ elt_resistance = self .resistance / self .count
154+ elt_power = self .power * resistance_ratio_range
155+ elt_voltage = self .voltage * resistance_ratio_range
156+
144157 for i in range (count ):
145- self .res [i ] = res = self .Block (Resistor (resistance = self . resistance / self . count ,
146- power = self . power / self . count ,
147- voltage = self . voltage / self . count ))
158+ self .res [i ] = res = self .Block (Resistor (resistance = elt_resistance ,
159+ power = elt_power ,
160+ voltage = elt_voltage ))
148161 self .connect (last_port , res .a )
149162 cumu_resistance = cumu_resistance + res .actual_resistance
150163 cumu_power_rating = cumu_power_rating + res .actual_power_rating
0 commit comments