@@ -112,7 +112,8 @@ def __init__(self) -> None:
112112 self .pwr ,
113113 voltage_limit_tolerance = (- 0.3 , 0.3 ) * Volt ,
114114 signal_limit_bound = (0.5 * Volt , - 0.8 * Volt ),
115- impedance = (142 , 158 ) * kOhm ,
115+ # TODO this is too low for the input resistor and the analog link assertion, but signal attenuation is fine in practice
116+ # impedance=(142, 158) * kOhm,
116117 )
117118 self .inp = self .Port (input_port )
118119 self .inn = self .Port (input_port )
@@ -151,15 +152,15 @@ class Tpa2005d1(SpeakerDriver, Block):
151152 """TPA2005D1 configured in single-ended input mode.
152153 Possible semi-pin-compatible with PAM8302AASCR (C113367), but which has internal resistor."""
153154
154- def __init__ (self , gain : RangeLike = Range . from_tolerance ( 20 , 0.2 )):
155+ def __init__ (self , gain : RangeLike = 20 * Ratio ( tol = 0.2 )):
155156 super ().__init__ ()
156157 # TODO should be a SpeakerDriver abstract part
157158
158159 self .ic = self .Block (Tpa2005d1_Device ())
159160 self .pwr = self .Export (self .ic .pwr , [Power ])
160161 self .gnd = self .Export (self .ic .gnd , [Common ])
161162
162- self .sig = self .Port (AnalogSink (), [Input ])
163+ self .sig = self .Port (AnalogSink . empty (), [Input ])
163164 self .spk = self .Export (self .ic .vo , [Output ])
164165
165166 self .gain = self .ArgParameter (gain )
@@ -185,34 +186,31 @@ def contents(self) -> None:
185186
186187 # Note, gain = 2 * (142k to 158k)/Ri, recommended gain < 20V/V
187188 res_value = (1 / self .gain ).shrink_multiply (2 * Range (142e3 , 158e3 ))
188- in_res_model = Resistor (res_value )
189+ in_res_model = AnalogSeriesResistor (res_value )
189190 fc = (1 , 20 ) * Hertz # for highpass filter, arbitrary, 20Hz right on the edge of audio frequency
191+ in_bias_voltage = self .pwr .link ().voltage / 2 # assumed input bias point
190192
191193 self .inp_res = self .Block (in_res_model )
192194 self .inp_cap = self .Block (
193- Capacitor (
195+ AnalogSeriesCapacitor (
194196 capacitance = (1 / (2 * math .pi * fc ))
195197 .shrink_multiply (1 / self .inp_res .actual_resistance )
196198 .intersect ((1 * 0.8 , float ("inf" )) * uFarad ),
197- voltage = self . sig . link (). voltage ,
199+ output_bias = in_bias_voltage ,
198200 )
199201 )
200- self .connect (self .sig .net , self .inp_cap .neg )
201- self .connect (self .inp_cap .pos , self .inp_res .a )
202- self .connect (self .inp_res .b .adapt_to (AnalogSource ()), self .ic .inp )
202+ self .chain (self .sig , self .inp_cap , self .inp_res , self .ic .inp )
203203
204204 self .inn_res = self .Block (in_res_model )
205205 self .inn_cap = self .Block (
206- Capacitor (
206+ AnalogSeriesCapacitor (
207207 capacitance = (1 / (2 * math .pi * fc ))
208208 .shrink_multiply (1 / self .inn_res .actual_resistance )
209209 .intersect ((1 * 0.8 , float ("inf" )) * uFarad ),
210- voltage = self . sig . link (). voltage ,
210+ output_bias = in_bias_voltage ,
211211 )
212212 )
213- self .connect (self .gnd , self .inn_cap .neg .adapt_to (Ground ()))
214- self .connect (self .inn_cap .pos , self .inn_res .a )
215- self .connect (self .inn_res .b .adapt_to (AnalogSource ()), self .ic .inn )
213+ self .chain (self .gnd .as_analog_source (), self .inn_cap , self .inn_res , self .ic .inn )
216214
217215
218216class Pam8302a_Device (InternalSubcircuit , JlcPart , FootprintBlock ):
@@ -291,10 +289,8 @@ def contents(self) -> None:
291289 )
292290 ).connected (self .gnd , self .pwr )
293291
294- in_cap_model = Capacitor (capacitance = 0.1 * uFarad (tol = 0.2 ), voltage = self .sig .link ().voltage )
295- self .inp_cap = self .Block (in_cap_model )
296- self .connect (self .sig , self .inp_cap .neg .adapt_to (AnalogSink ()))
297- self .connect (self .inp_cap .pos .adapt_to (AnalogSource ()), self .ic .inp )
298- self .inn_cap = self .Block (in_cap_model )
299- self .connect (self .gnd , self .inn_cap .neg .adapt_to (Ground ()))
300- self .connect (self .inn_cap .pos .adapt_to (AnalogSource ()), self .ic .inn )
292+ input_cap_model = AnalogSeriesCapacitor (
293+ capacitance = 0.1 * uFarad (tol = 0.2 ), output_bias = self .pwr .link ().voltage / 2
294+ )
295+ self .inp_cap = self .Block (input_cap_model ).connected (self .sig , self .ic .inp )
296+ self .inn_cap = self .Block (input_cap_model ).connected (self .gnd .as_analog_source (), self .ic .inn )
0 commit comments