1818
1919def hysteresis_threshold_ratios (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm ):
2020 """
21- Calculates hysteresis threshold factors for push-pull comparators
21+ Calculate hysteresis threshold factors for push-pull comparators.
2222
23- Assumes that r1 and r2 are used to divide Vcc using a fixed ratio to
24- obtain a threshold voltage.
25- Additionally, Rh sources or sinks current to the threshold voltage,
26- depending on the current state of the comparator.
27- Additionally it it assumed that the same voltage (Vcc) that feeds
28- the R1+R2 divider is output from the comparator and input to Rh.
23+ Assume that r1 and r2 are used to divide Vcc using a fixed ratio to obtain
24+ a threshold voltage. Additionally, Rh sources or sinks current to the
25+ threshold voltage, depending on the current state of the comparator.
26+ Additionally it is assumed that the same voltage (Vcc) that feeds the
27+ R1+R2 divider is output from the comparator and input to Rh.
2928
30- This function computes the (lower, upper) division ratios by
31- assuming rh is set either parallel with R1 (upper) or with R2 (lower).
29+ This function computes the (lower, upper) division ratios by assuming
30+ rh is set either parallel with R1 (upper) or with R2 (lower).
3231
33- Returns a tuple (lower, upper) containing floats
34- representing the division ratios.
32+ Return a tuple (lower, upper) containing floats representing the
33+ division ratios.
3534
3635 Parameters
3736 ----------
3837 r1 : float or EngineerIO string
39- The top resistor of the divider
38+ The top resistor of the divider.
4039 r2 : float or EngineerIO string
41- The bottom resistor of the divider
40+ The bottom resistor of the divider.
4241 rh : float or EngineerIO string
43- The hysteresis resistor of the divider
42+ The hysteresis resistor of the divider.
4443 """
4544 r1 = normalize_resistance (r1 ) if isinstance (r1 , str ) else r1
4645 r2 = normalize_resistance (r2 ) if isinstance (r2 , str ) else r2
@@ -55,18 +54,20 @@ def hysteresis_threshold_ratios(r1: ResistanceOhm, r2: ResistanceOhm, rh: Resist
5554
5655def hysteresis_threshold_ratios_opendrain (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm ):
5756 """
58- Same as hysteresis_threshold_ratios(), but for open-drain comparators.
59- In contrast to hysteresis_threshold_ratios(), ignores rh for the upper
60- threshold.
57+ Calculate hysteresis threshold ratios for open-drain comparators.
58+
59+ This is similar to hysteresis_threshold_ratios(), but for open-drain
60+ comparators. In contrast to hysteresis_threshold_ratios(), ignores rh for
61+ the upper threshold.
6162
6263 Parameters
6364 ----------
6465 r1 : float or EngineerIO string
65- The top resistor of the divider
66+ The top resistor of the divider.
6667 r2 : float or EngineerIO string
67- The bottom resistor of the divider
68+ The bottom resistor of the divider.
6869 rh : float or EngineerIO string
69- The hysteresis resistor of the divider
70+ The hysteresis resistor of the divider.
7071 """
7172 r1 = normalize_resistance (r1 ) if isinstance (r1 , str ) else r1
7273 r2 = normalize_resistance (r2 ) if isinstance (r2 , str ) else r2
@@ -79,7 +80,7 @@ def hysteresis_threshold_ratios_opendrain(r1: ResistanceOhm, r2: ResistanceOhm,
7980 return (thl , thu )
8081
8182def __hysteresis_threshold_voltages (r1 , r2 , rh , vcc , fn ):
82- """Internal push-pull & open-drain common code"""
83+ """Internal push-pull and open-drain common code. """
8384 r1 = normalize_resistance (r1 ) if isinstance (r1 , str ) else r1
8485 r2 = normalize_resistance (r2 ) if isinstance (r2 , str ) else r2
8586 rh = normalize_resistance (rh ) if isinstance (rh , str ) else rh
@@ -89,50 +90,54 @@ def __hysteresis_threshold_voltages(r1, r2, rh, vcc, fn):
8990
9091def hysteresis_threshold_voltages (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm , vcc : VoltageV ):
9192 """
92- Same as hysteresis_threshold_ratios(), but calculates actual
93+ Calculate actual voltages instead of ratios for hysteresis thresholds.
94+
95+ This is similar to hysteresis_threshold_ratios(), but calculates actual
9396 voltages instead of ratios.
9497
95- Returns (lower voltage, upper voltage), a tuple of floats.
98+ Return (lower voltage, upper voltage), a tuple of floats.
9699
97100 Parameters
98101 ----------
99102 r1 : float or EngineerIO string
100- The top resistor of the divider
103+ The top resistor of the divider.
101104 r2 : float or EngineerIO string
102- The bottom resistor of the divider
105+ The bottom resistor of the divider.
103106 rh : float or EngineerIO string
104- The hysteresis resistor of the divider
107+ The hysteresis resistor of the divider.
105108 vcc : float or EngineerIO string
106- The supply voltage that drives the output of the comparator
107- and the R1/R2 network.
109+ The supply voltage that drives the output of the comparator and the
110+ R1/R2 network.
108111 """
109112 return __hysteresis_threshold_voltages (
110113 r1 , r2 , rh , vcc , hysteresis_threshold_ratios )
111114
112115def hysteresis_threshold_voltages_opendrain (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm , vcc : VoltageV ):
113116 """
114- Same as hysteresis_threshold_ratios_opendrain(), but calculates actual
115- voltages instead of ratios.
117+ Calculate actual voltages instead of ratios for open-drain comparators.
118+
119+ This is similar to hysteresis_threshold_ratios_opendrain(), but calculates
120+ actual voltages instead of ratios.
116121
117- Returns (lower voltage, upper voltage), a tuple of floats.
122+ Return (lower voltage, upper voltage), a tuple of floats.
118123
119124 Parameters
120125 ----------
121126 r1 : float or EngineerIO string
122- The top resistor of the divider
127+ The top resistor of the divider.
123128 r2 : float or EngineerIO string
124- The bottom resistor of the divider
129+ The bottom resistor of the divider.
125130 rh : float or EngineerIO string
126- The hysteresis resistor of the divider
131+ The hysteresis resistor of the divider.
127132 vcc : float or EngineerIO string
128- The supply voltage that drives the output of the comparator
129- and the R1/R2 network.
133+ The supply voltage that drives the output of the comparator and the
134+ R1/R2 network.
130135 """
131136 return __hysteresis_threshold_voltages (
132137 r1 , r2 , rh , vcc , hysteresis_threshold_ratios_opendrain )
133138
134139def __hysteresis_threshold_factors (r1 , r2 , rh , fn ):
135- """Internal push-pull & open-drain common code"""
140+ """Internal push-pull and open-drain common code. """
136141 r1 = normalize_resistance (r1 ) if isinstance (r1 , str ) else r1
137142 r2 = normalize_resistance (r2 ) if isinstance (r2 , str ) else r2
138143 rh = normalize_resistance (rh ) if isinstance (rh , str ) else rh
@@ -144,73 +149,76 @@ def __hysteresis_threshold_factors(r1, r2, rh, fn):
144149
145150def hysteresis_threshold_factors (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm ):
146151 """
147- Same as hysteresis_threshold_ratios(), but calculates the
148- factor (nominal R1+R2 division ratio / actual ratio) for
149- both the lower and the upper threshold instead of the ratios
152+ Calculate the factor (nominal R1+R2 division ratio / actual ratio) for both
153+ the lower and the upper threshold instead of the ratios.
150154
151- Returns (lower factor, upper factor), a tuple of floats.
155+ This is similar to hysteresis_threshold_ratios(), but calculates the factor
156+ (nominal R1+R2 division ratio / actual ratio) for both the lower and the upper
157+ threshold instead of the ratios.
152158
153- This is useful e.g. for computing
159+ Return (lower factor, upper factor), a tuple of floats.
160+
161+ This is useful e.g. for computing.
154162
155163 Parameters
156164 ----------
157165 r1 : float or EngineerIO string
158- The top resistor of the divider
166+ The top resistor of the divider.
159167 r2 : float or EngineerIO string
160- The bottom resistor of the divider
168+ The bottom resistor of the divider.
161169 rh : float or EngineerIO string
162- The hysteresis resistor of the divider
170+ The hysteresis resistor of the divider.
163171 """
164172 return __hysteresis_threshold_factors (
165173 r1 , r2 , rh , hysteresis_threshold_ratios )
166174
167175def hysteresis_threshold_factors_opendrain (r1 : ResistanceOhm , r2 : ResistanceOhm , rh : ResistanceOhm ):
168176 """
169- Same as hysteresis_threshold_ratios_opendrain(), but calculates the
170- factor (nominal R1+R2 division ratio / actual ratio) for
171- both the lower and the upper threshold instead of the ratios
177+ Calculate the factor for open-drain comparators.
178+
179+ This is similar to hysteresis_threshold_ratios_opendrain(), but calculates
180+ the factor (nominal R1+R2 division ratio / actual ratio) for both the lower
181+ and the upper threshold instead of the ratios.
172182
173- Returns (lower factor, upper factor), a tuple of floats.
183+ Return (lower factor, upper factor), a tuple of floats.
174184
175- This is useful e.g. for computing
185+ This is useful e.g. for computing.
176186
177187 Parameters
178188 ----------
179189 r1 : float or EngineerIO string
180- The top resistor of the divider
190+ The top resistor of the divider.
181191 r2 : float or EngineerIO string
182- The bottom resistor of the divider
192+ The bottom resistor of the divider.
183193 rh : float or EngineerIO string
184- The hysteresis resistor of the divider
194+ The hysteresis resistor of the divider.
185195 """
186196 return __hysteresis_threshold_factors (
187197 r1 , r2 , rh , hysteresis_threshold_ratios_opendrain )
188198
189199def hysteresis_resistor (r1 : ResistanceOhm , r2 : ResistanceOhm , fh = 0.05 ):
190200 """
191- Computes the hysteresis resistor Rh for a given
192- R1, R2 divider network and a given deviation factor.
193-
194- The deviation factor fh represents the one-sided deviation
195- from the nominal R1/R2 ratio. The total hysteresis is +-fh,
196- i.e 2*fh.
201+ Compute the hysteresis resistor Rh for a given R1, R2 divider network
202+ and a given deviation factor.
197203
198- For example, for fh=0.05, the threshold will be 95% and 105%
199- of the nominal ratio respectively .
204+ The deviation factor fh represents the one-sided deviation from the
205+ nominal R1/R2 ratio. The total hysteresis is +-fh, i.e 2*fh .
200206
201- For open-drain comparators, fh represents the full deviation
202- as the upper threshold is equivalent to the nominal threshold .
207+ For example, for fh=0.05, the threshold will be 95% and 105% of the
208+ nominal ratio respectively .
203209
210+ For open-drain comparators, fh represents the full deviation as the
211+ upper threshold is equivalent to the nominal threshold.
204212
205213 Parameters
206214 ----------
207215 r1 : float or EngineerIO string
208- The top resistor of the divider
216+ The top resistor of the divider.
209217 r2 : float or EngineerIO string
210- The bottom resistor of the divider
218+ The bottom resistor of the divider.
211219 fh : float or EngineerIO string
212220 The deviation factor (e.g. 0.05 for 5% one-sided hysteresis
213- deviation from the nominal r1/r2 value)
221+ deviation from the nominal r1/r2 value).
214222 """
215223 r1 = normalize_resistance (r1 ) if isinstance (r1 , str ) else r1
216224 r2 = normalize_resistance (r2 ) if isinstance (r2 , str ) else r2
0 commit comments