-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_iot_iron.py
264 lines (223 loc) · 10.9 KB
/
test_iot_iron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import unittest
from edg import *
class IronConnector(Connector, Block):
"""See main design for details about pinning and compatibility.
This assumes a common ground with heater+ and thermocouple+.
TODO: support series heater and thermocouple, requires additional protection circuits on amps
TODO: optional generation for isense_res, if not connected
"""
@init_in_parent
def __init__(self, *, isense_resistance: RangeLike = 22*mOhm(tol=0.05), current_draw: RangeLike=(0, 3.25)*Amp):
super().__init__()
self.conn = self.Block(PinHeader254(3))
self.gnd = self.Port(Ground.empty(), [Common])
self.pwr = self.Export(self.conn.pins.request('2').adapt_to(VoltageSink(
current_draw=current_draw
)))
self.thermocouple = self.Export(self.conn.pins.request('3').adapt_to(AnalogSource(
voltage_out=self.gnd.link().voltage + (0, 14.3)*mVolt,
signal_out=self.gnd.link().voltage + (0, 14.3)*mVolt # up to ~350 C
)), optional=True)
self.isense_res = self.Block(CurrentSenseResistor(resistance=isense_resistance, sense_in_reqd=False))
self.isense = self.Export(self.isense_res.sense_out)
self.connect(self.conn.pins.request('1').adapt_to(VoltageSink(current_draw=current_draw)),
self.isense_res.pwr_out)
self.connect(self.gnd.as_voltage_source(), self.isense_res.pwr_in)
class IotIron(JlcBoardTop):
"""IoT soldering iron controller (ceramic heater type, not RF heating type) with USB-PD in,
buck converter for maximum compatibility and reduced EMI, and builtin UI components (in addition
to wireless connectivity).
Inspired by https://github.com/AxxAxx/AxxSolder/tree/main, see repo README for links on connector pinning.
"""
def contents(self) -> None:
super().contents()
# assume minimum power input of 12v from PD, you probably don't want a 5v USB 15W soldering iron
self.usb = self.Block(UsbCReceptacle(voltage_out=(12, 20)*Volt, current_limits=(0, 5)*Amp))
self.vusb = self.connect(self.usb.pwr)
self.gnd = self.connect(self.usb.gnd)
self.tp_pwr = self.Block(VoltageTestPoint()).connected(self.usb.pwr)
self.tp_gnd = self.Block(GroundTestPoint()).connected(self.usb.gnd)
# POWER
with self.implicit_connect(
ImplicitConnect(self.gnd, [Common]),
) as imp:
(self.reg_3v3, self.tp_3v3, self.prot_3v3), _ = self.chain(
self.vusb,
imp.Block(BuckConverter(output_voltage=3.3*Volt(tol=0.05),
input_ripple_limit=100*mVolt)),
self.Block(VoltageTestPoint()),
imp.Block(ProtectionZenerDiode(voltage=(3.45, 3.9)*Volt))
)
self.v3v3 = self.connect(self.reg_3v3.pwr_out)
# set gate driver at 9v to allow power from USB-PD 9v
(self.reg_gate, self.tp_gate), _ = self.chain(
self.vusb,
imp.Block(VoltageRegulator(output_voltage=12*Volt(tol=0.06))),
self.Block(VoltageTestPoint())
)
self.vgate = self.connect(self.reg_gate.pwr_out)
# 3V3 DOMAIN
with self.implicit_connect(
ImplicitConnect(self.v3v3, [Power]),
ImplicitConnect(self.gnd, [Common]),
) as imp:
self.mcu = imp.Block(IoController())
self.mcu.with_mixin(IoControllerWifi())
self.i2c = self.mcu.i2c.request('i2c')
(self.i2c_pull, ), _ = self.chain(self.i2c, imp.Block(I2cPullup()))
# power input
self.pd = imp.Block(Fusb302b())
self.connect(self.usb.pwr, self.pd.vbus)
self.connect(self.usb.cc, self.pd.cc)
self.connect(self.mcu.gpio.request('pd_int'), self.pd.int)
self.connect(self.i2c, self.pd.i2c)
(self.usb_esd, ), self.usb_chain = self.chain(self.usb.usb, imp.Block(UsbEsdDiode()),
self.mcu.usb.request())
(self.vusb_sense, ), _ = self.chain(
self.vusb,
imp.Block(VoltageSenseDivider(full_scale_voltage=2.2*Volt(tol=0.1), impedance=(1, 10)*kOhm)),
self.mcu.adc.request('vusb_sense')
)
# sensing - cold junction compensation
(self.temp, ), _ = self.chain(self.i2c, imp.Block(Hdc1080()))
# onboard user interface
self.enc = imp.Block(DigitalRotaryEncoder())
self.connect(self.enc.a, self.mcu.gpio.request('enc_a'))
self.connect(self.enc.b, self.mcu.gpio.request('enc_b'))
self.connect(self.enc.with_mixin(DigitalRotaryEncoderSwitch()).sw, self.mcu.gpio.request('enc_sw'))
self.oled = imp.Block(Er_Oled_096_1_1())
self.connect(self.i2c, self.oled.i2c)
self.connect(self.mcu.gpio.request('oled_reset'), self.oled.reset)
(self.spk_drv, self.spk), _ = self.chain(
self.mcu.with_mixin(IoControllerI2s()).i2s.request('spk'),
imp.Block(Max98357a()),
self.Block(Speaker())
)
# debugging LEDs
(self.ledr, ), _ = self.chain(imp.Block(IndicatorSinkLed(Led.Red)), self.mcu.gpio.request('led'))
# IRON POWER SUPPLY
with self.implicit_connect(
ImplicitConnect(self.gnd, [Common]),
) as imp:
(self.conv_force, self.conv, self.tp_conv), _ = self.chain(
self.vusb,
imp.Block(ForcedVoltage(20*Volt(tol=0))),
# want a high output ripple limit so the converter turns off fast to read the thermocouple
imp.Block(CustomSyncBuckConverterIndependent(output_voltage=(5, 5) * Volt, frequency=200 * kHertz(tol=0),
input_ripple_limit=1*Volt,
output_ripple_limit=0.25*Volt)),
self.Block(VoltageTestPoint())
)
self.conv_out = self.connect(self.conv.pwr_out)
self.connect(self.conv.pwr_logic, self.vgate)
pull_model = PulldownResistor(10*kOhm(tol=0.05))
rc_model = DigitalLowPassRc(150*Ohm(tol=0.05), 7*MHertz(tol=0.2))
(self.low_pull, self.low_rc), _ = self.chain(self.mcu.gpio.request('pwm_low'),
imp.Block(pull_model),
imp.Block(rc_model),
self.conv.pwm_low)
(self.high_pull, self.high_rc), _ = self.chain(self.mcu.gpio.request('pwm_high'),
imp.Block(pull_model),
imp.Block(rc_model),
self.conv.pwm_high)
self.tp_pwm_l = self.Block(DigitalTestPoint()).connected(self.conv.pwm_low)
self.tp_pwm_h = self.Block(DigitalTestPoint()).connected(self.conv.pwm_high)
mcu_touch = self.mcu.with_mixin(IoControllerTouchDriver())
(self.touch_sink, ), _ = self.chain(
mcu_touch.touch.request('touch'),
imp.Block(FootprintToucbPad('edg:Symbol_DucklingSolid'))
)
self.iron = imp.Block(IronConnector())
self.connect(self.conv.pwr_out, self.iron.pwr)
# IRON SENSE AMPS - 3v3 DOMAIN
with self.implicit_connect(
ImplicitConnect(self.v3v3, [Power]),
ImplicitConnect(self.gnd, [Common]),
) as imp:
rc_filter_model = AnalogLowPassRc(impedance=1*kOhm(tol=0.1), cutoff_freq=(1, 10)*kHertz)
(self.vsense, self.tp_v, self.vfilt), _ = self.chain(
self.conv.pwr_out,
imp.Block(VoltageSenseDivider(full_scale_voltage=2.2*Volt(tol=0.1), impedance=(1, 10)*kOhm)),
self.Block(AnalogTestPoint()),
imp.Block(rc_filter_model),
self.mcu.adc.request('iron_vsense')
)
(self.ifilt, self.tp_i, self.iamp), _ = self.chain(
self.iron.isense,
imp.Block(Amplifier((18, 25))),
imp.Block(rc_filter_model),
self.Block(AnalogTestPoint()),
self.mcu.adc.request('iron_isense')
)
self.tamp = imp.Block(DifferentialAmplifier(
ratio=(150, 165),
input_impedance=(0.9, 5)*kOhm
))
self.connect(self.tamp.input_negative, self.iron.isense)
self.connect(self.tamp.input_positive, self.iron.thermocouple)
self.connect(self.tamp.output, self.mcu.adc.request('thermocouple'))
self.tp_t = self.Block(AnalogTestPoint()).connected(self.iron.thermocouple)
def multipack(self) -> None:
self.packed_opamp = self.PackedBlock(Opa2333())
self.pack(self.packed_opamp.elements.request('0'), ['ifilt', 'amp'])
self.pack(self.packed_opamp.elements.request('1'), ['tamp', 'amp'])
def refinements(self) -> Refinements:
return super().refinements() + Refinements(
instance_refinements=[
(['mcu'], Esp32s3_Wroom_1),
(['reg_3v3'], Tps54202h),
(['reg_gate'], L78l),
],
instance_values=[
(['refdes_prefix'], 'I'), # unique refdes for panelization
(['mcu', 'pin_assigns'], [
'vusb_sense=39',
'i2c.sda=34',
'i2c.scl=35',
'pd_int=38',
'spk.sd=33',
'spk.sck=32',
'spk.ws=31',
'pwm_low=4',
'pwm_high=5',
'iron_vsense=6',
'iron_isense=7',
'thermocouple=12',
'enc_a=10',
'enc_b=9',
'enc_sw=8',
'oled_reset=11',
'led=_GPIO0_STRAP',
'touch=GPIO3', # experimental
]),
(['mcu', 'programming'], 'uart-auto'),
(['iron', 'isense_res', 'res', 'res', 'footprint_spec'], 'Resistor_SMD:R_2512_6332Metric'), # more power headroom
(['iron', 'isense_res', 'res', 'res', 'require_basic_part'], False),
# these will be enforced by the firmware control mechanism
# (['conv', 'pwr_in', 'current_draw'], Range(0, 3)), # max 3A input draw
# force JLC frequency spec
(['conv', 'power_path', 'inductor', 'part'], 'SLF12565T-150M4R2-PF'),
(['conv', 'power_path', 'inductor', 'manual_frequency_rating'], Range(0, 1e6)), # from charts, inductance constant up to 1MHz
(['reg_3v3', 'power_path', 'inductor', 'part'], 'SWPA5040S220MT'),
(['reg_3v3', 'power_path', 'inductor', 'manual_frequency_rating'], Range(0, 11e6)),
(['reg_gate', 'ic', 'actual_dropout'], Range.exact(0)), # allow tracking
(['conv', 'sw', 'high_fet', 'part'], ParamValue(['conv', 'sw', 'low_fet', 'part'])),
(['conv', 'sw', 'low_fet', 'manual_gate_charge'], Range.exact(100e-9)), # reasonable worst case estimate
(['conv', 'sw', 'high_fet', 'manual_gate_charge'], ParamValue(['conv', 'sw', 'low_fet', 'manual_gate_charge'])),
],
class_refinements=[
(HalfBridgeDriver, Ucc27282),
(Speaker, ConnectorSpeaker),
(PassiveConnector, JstPhKVertical), # default connector series unless otherwise specified
(EspProgrammingHeader, EspProgrammingTc2030),
(TagConnect, TagConnectNonLegged),
(TestPoint, CompactKeystone5015),
],
class_values=[
(CompactKeystone5015, ['lcsc_part'], 'C5199798'), # RH-5015, which is actually in stock
(Nonstrict3v3Compatible, ['nonstrict_3v3_compatible'], True),
]
)
class IotIronTestCase(unittest.TestCase):
def test_design(self) -> None:
compile_board_inplace(IotIron)