@@ -172,14 +172,8 @@ class VoltageDivider(Analog, BaseVoltageDivider):
172172 @init_in_parent
173173 def __init__ (self , * , output_voltage : RangeLike , impedance : RangeLike ) -> None :
174174 super ().__init__ (impedance = impedance )
175-
176175 self .output_voltage = self .ArgParameter (output_voltage )
177-
178- ratio_lower = self .output_voltage .lower () / self .input .link ().voltage .lower ()
179- ratio_upper = self .output_voltage .upper () / self .input .link ().voltage .upper ()
180- self .require (ratio_lower <= ratio_upper ,
181- "can't generate divider to create output voltage of tighter tolerance than input voltage" )
182- self .assign (self .ratio , (ratio_lower , ratio_upper ))
176+ self .assign (self .ratio , self .output_voltage .shrink_multiply (1 / self .input .link ().voltage ))
183177
184178
185179class VoltageSenseDivider (Analog , BaseVoltageDivider ):
@@ -193,14 +187,8 @@ class VoltageSenseDivider(Analog, BaseVoltageDivider):
193187 @init_in_parent
194188 def __init__ (self , * , full_scale_voltage : RangeLike , impedance : RangeLike ) -> None :
195189 super ().__init__ (impedance = impedance )
196-
197190 self .full_scale_voltage = self .ArgParameter (full_scale_voltage )
198-
199- ratio_lower = self .full_scale_voltage .lower () / self .input .link ().voltage .upper ()
200- ratio_upper = self .full_scale_voltage .upper () / self .input .link ().voltage .upper ()
201- self .require (ratio_lower <= ratio_upper ,
202- "can't generate divider to create output voltage of tighter tolerance than input voltage" )
203- self .assign (self .ratio , (ratio_lower , ratio_upper ))
191+ self .assign (self .ratio , self .full_scale_voltage / self .input .link ().voltage .upper ())
204192
205193
206194class FeedbackVoltageDivider (Analog , BaseVoltageDivider ):
@@ -213,10 +201,7 @@ def __init__(self, *, output_voltage: RangeLike, impedance: RangeLike,
213201
214202 self .output_voltage = self .ArgParameter (output_voltage )
215203 self .assumed_input_voltage = self .ArgParameter (assumed_input_voltage )
216- self .actual_input_voltage = self .Parameter (RangeExpr (
217- (self .output_voltage .lower () / self .actual_ratio .upper (),
218- self .output_voltage .upper () / self .actual_ratio .lower ())
219- ))
204+ self .actual_input_voltage = self .Parameter (RangeExpr ())
220205
221206 def contents (self ) -> None :
222207 super ().contents ()
@@ -227,11 +212,8 @@ def contents(self) -> None:
227212 "\n <b>impedance:</b> " , DescriptionString .FormatUnits (self .actual_impedance , "Ω" ),
228213 " <b>of spec:</b> " , DescriptionString .FormatUnits (self .impedance , "Ω" ))
229214
230- ratio_lower = self .output_voltage .upper () / self .assumed_input_voltage .upper ()
231- ratio_upper = self .output_voltage .lower () / self .assumed_input_voltage .lower ()
232- self .require (ratio_lower <= ratio_upper ,
233- "can't generate feedback divider with input voltage of tighter tolerance than output voltage" )
234- self .assign (self .ratio , (ratio_lower , ratio_upper ))
215+ self .assign (self .ratio , (1 / self .assumed_input_voltage ).shrink_multiply (self .output_voltage ))
216+ self .assign (self .actual_input_voltage , self .output_voltage / self .actual_ratio )
235217
236218
237219class SignalDivider (Analog , Block ):
0 commit comments