Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continued example boards #299

Merged
merged 122 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
9699966
WIP G031 defs
ducky64 Sep 29, 2023
ae02154
Update Microcontroller_Stm32g031.py
ducky64 Sep 29, 2023
4a9a692
Update Microcontroller_Stm32g031.py
ducky64 Sep 30, 2023
3b8f3f3
wip its probably not gonna work =(
ducky64 Sep 30, 2023
0ebad4d
rest of the libraries
ducky64 Sep 30, 2023
75d65fa
more towards building
ducky64 Oct 2, 2023
329b497
fix ercs
ducky64 Oct 2, 2023
1367094
erc clean though not done
ducky64 Oct 2, 2023
b0fe8fe
Update test_jd_keyswitch.py
ducky64 Oct 2, 2023
dfd33d8
abstract tvs diode + Jacdac ESD diodes
ducky64 Oct 3, 2023
c8d07e2
JD keyswitch beginnings
ducky64 Oct 4, 2023
1ef852d
layout!
ducky64 Oct 4, 2023
4126e97
Update JacdacKeyswitch.kicad_pcb
ducky64 Oct 4, 2023
a6e26fd
layout rc1
ducky64 Oct 4, 2023
7a0e924
32c3 bare chip wip
ducky64 Oct 4, 2023
fa613c4
moving stuff around
ducky64 Oct 4, 2023
ebbb00b
wip
ducky64 Oct 4, 2023
44f49d9
WIP some infrastructure for reusing strapping pins
ducky64 Oct 5, 2023
adc5c4f
we can now use strapping pins, yay
ducky64 Oct 5, 2023
ba07992
Update IoControllerExportable.py
ducky64 Oct 6, 2023
0302605
antennas kinda
ducky64 Oct 6, 2023
86566c0
a single antenna -_-
ducky64 Oct 6, 2023
8f4f254
slowly getting places? idk
ducky64 Oct 6, 2023
d849339
wip impedance calcs
ducky64 Oct 6, 2023
6f4e7f6
pi matching generator tested, but other things still broken
ducky64 Oct 6, 2023
b57168c
wip kinda questionable
ducky64 Oct 6, 2023
1e36e1b
wip capacitor regex
ducky64 Oct 6, 2023
63c72b0
improved cap tolerance parsing
ducky64 Oct 7, 2023
0ebbeae
refactor to use abs tolerance infrastructurally
ducky64 Oct 7, 2023
51328f9
wip towards layout
ducky64 Oct 7, 2023
d7a838b
Update CeramicResonator_Cstne.py
ducky64 Oct 7, 2023
eb70cdb
wip
ducky64 Oct 7, 2023
2da2ac0
wow it places kinda
ducky64 Oct 8, 2023
3cd76b7
wip its rough
ducky64 Oct 8, 2023
6b27a7b
Update IotFan.kicad_pcb
ducky64 Oct 8, 2023
1f541de
Update IotFan.kicad_pcb
ducky64 Oct 8, 2023
aa19611
wip
ducky64 Oct 8, 2023
90062f6
cleaning
ducky64 Oct 8, 2023
8c58139
wip smaller xtal
ducky64 Oct 8, 2023
7bf08d3
kinda looking reasonable
ducky64 Oct 8, 2023
d71c0fb
DONE WOOHOO
ducky64 Oct 8, 2023
be4f4ac
actually done?
ducky64 Oct 8, 2023
267c93c
Update Microcontroller_Esp32c3.py
ducky64 Oct 8, 2023
86f7aff
Update test_swd_debugger.py
ducky64 Oct 9, 2023
4ece07f
Update JlcCrystal.py
ducky64 Oct 9, 2023
23917ee
picoprobe layout wip
ducky64 Oct 9, 2023
2600676
wip
ducky64 Oct 9, 2023
96558e5
rp routing
ducky64 Oct 9, 2023
bf9b716
cleaning
ducky64 Oct 9, 2023
b3cbfe0
Update PicoProbe.kicad_pcb
ducky64 Oct 9, 2023
e539aee
mildly less terrible rf layout
ducky64 Oct 9, 2023
9b8e4d1
optimization
ducky64 Oct 9, 2023
c75d9ab
wip swd in block
ducky64 Oct 9, 2023
92f4fbd
sort matching_parts
ducky64 Oct 9, 2023
ba35b1f
cleaning
ducky64 Oct 9, 2023
2a37e8d
Update PicoProbe.kicad_pcb
ducky64 Oct 10, 2023
a0f7c62
Update PicoProbe.kicad_pcb
ducky64 Oct 10, 2023
85db213
wip THAT LAST TRACE
ducky64 Oct 10, 2023
7025f8e
routed!
ducky64 Oct 10, 2023
73b9fcd
add temperature sensor + QFN speaker driver
ducky64 Oct 11, 2023
f84ca3a
Create test_iot_iron.py
ducky64 Oct 11, 2023
58e11ab
Update RobotOwl.net
ducky64 Oct 11, 2023
f2e1592
Update IotFan.net
ducky64 Oct 11, 2023
9e748b9
example pcbs
ducky64 Oct 11, 2023
38ca9d8
add custom buck converter wip
ducky64 Oct 11, 2023
fbfd541
fix a bunch of analog stuff, one more erc
ducky64 Oct 11, 2023
afec922
ERC clean
ducky64 Oct 11, 2023
df7d2a8
tps tps tps
ducky64 Oct 11, 2023
3638d13
yay
ducky64 Oct 11, 2023
24d9623
wip gate drivers
ducky64 Oct 11, 2023
3b66a83
wip halfbridge driver
ducky64 Oct 11, 2023
2d4305b
wip mostly erc-complete
ducky64 Oct 11, 2023
d6f49a1
cleaning?
ducky64 Oct 11, 2023
2204395
better current calcs for gate driver
ducky64 Oct 11, 2023
ae0dfbd
erc clean
ducky64 Oct 11, 2023
ed04b49
packed dual opamp!
ducky64 Oct 11, 2023
7b856f7
layout beginnings
ducky64 Oct 11, 2023
dcf8f90
Update IotIron.kicad_pcb
ducky64 Oct 12, 2023
5858d45
less caps by proping ripple limits
ducky64 Oct 12, 2023
ad52244
high level blocks
ducky64 Oct 12, 2023
419a97b
L432K mcu
ducky64 Oct 13, 2023
24749a1
Update IotIron.kicad_pcb
ducky64 Oct 13, 2023
a03c302
floorplanning its coming together
ducky64 Oct 13, 2023
7c85b2a
Update IotIron.kicad_pcb
ducky64 Oct 13, 2023
6d4f613
improving floorplan
ducky64 Oct 13, 2023
4b0b509
Update IotIron.kicad_pcb
ducky64 Oct 14, 2023
d2463f3
layout wip
ducky64 Oct 14, 2023
a16ab73
wip
ducky64 Oct 14, 2023
1c4afef
Update IotIron.kicad_pcb
ducky64 Oct 14, 2023
97ce325
routing
ducky64 Oct 14, 2023
9fab40c
continued routing
ducky64 Oct 14, 2023
d404ea9
routed
ducky64 Oct 15, 2023
e478464
Update IotIron.kicad_pcb
ducky64 Oct 15, 2023
70c4fb7
wip
ducky64 Oct 15, 2023
f4196ee
usb key wip
ducky64 Oct 15, 2023
800be2f
wip
ducky64 Oct 15, 2023
e387ab6
wip smaller ldos
ducky64 Oct 15, 2023
90b0c13
wip
ducky64 Oct 15, 2023
0afe856
smaller leds
ducky64 Oct 15, 2023
0997568
packed cap
ducky64 Oct 15, 2023
5cf9483
tsc circuits
ducky64 Oct 15, 2023
b7f2548
well it is a layout
ducky64 Oct 16, 2023
bb8134c
most resets turn out to be optional
ducky64 Oct 16, 2023
2318373
allow no reset
ducky64 Oct 16, 2023
6f96222
support smaller caps
ducky64 Oct 16, 2023
707e57a
probs ready
ducky64 Oct 16, 2023
a69c13d
Update UsbKey.kicad_pcb
ducky64 Oct 16, 2023
dcb5c41
layout cleanups
ducky64 Oct 16, 2023
5240fb1
Create MouseBites_Recessed.kicad_mod
ducky64 Oct 16, 2023
64152e7
Update UsbKey.kicad_pcb
ducky64 Oct 16, 2023
779f2e7
cleanup a bit
ducky64 Oct 16, 2023
4a3fcf9
mild cleaning
ducky64 Oct 16, 2023
1265166
fix
ducky64 Oct 16, 2023
0ce236c
cleaning
ducky64 Oct 16, 2023
336eccf
refactor frequency vs actual_frequency
ducky64 Oct 16, 2023
035298a
Update IotFan.net
ducky64 Oct 16, 2023
a87b4ac
proper custom converter sizing
ducky64 Oct 17, 2023
d2a2e64
wip
ducky64 Oct 17, 2023
973509a
fix multipacking
ducky64 Oct 17, 2023
5334cb1
layout improvements
ducky64 Oct 18, 2023
b1223c5
ridiculous panel
ducky64 Oct 18, 2023
57e9d74
Update IotIron.net
ducky64 Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion edg/BoardTop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def refinements(self) -> Refinements:
(Fet, JlcFet), # TODO: replace with non-distributor parts list
(SwitchFet, JlcSwitchFet), # TODO: replace with non-distributor parts list
(Led, SmtLed),
(RgbLedCommonAnode, SmtRgbLed),
(RgbLedCommonAnode, Smt0606RgbLed),
(Crystal, JlcCrystal), # TODO: replace with non-distributor parts list
(Oscillator, JlcOscillator), # TODO: replace with non-distributor parts list

Expand Down Expand Up @@ -79,6 +79,7 @@ def refinements(self) -> Refinements:
(Diode, JlcDiode),
(Bjt, JlcBjt),
(Fet, JlcFet),
(Antenna, JlcAntenna),

(Fpc050Bottom, Afc01),
(Fpc050Top, Afc07Top),
Expand Down
3 changes: 3 additions & 0 deletions edg_core/ArrayExpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def _create_unary_set_op(self, op: Union[NumericOp, BoolOp, RangeSetOp, EqOp]) -
def all_unique(self) -> BoolExpr:
return BoolExpr()._new_bind(UnarySetOpBinding(self, EqOp.all_unique))

def all_equal(self) -> BoolExpr:
return BoolExpr()._new_bind(UnarySetOpBinding(self, EqOp.all_equal))

def sum(self) -> ArrayEltType:
return self._create_unary_set_op(NumericOp.sum)

Expand Down
6 changes: 3 additions & 3 deletions edg_core/HierarchyBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def chain(self, *elts: Union[Connection, BasePort, Block]) -> ChainConnect:
current_port = outable_ports[0]
chain_blocks.append(elts[0])
else:
raise EdgTypeError(f"first element 0 to chain", elts[0], (BasePort, Block))
raise EdgTypeError(f"first element 0 to chain", elts[0], (BasePort, Connection, Block))

for i, elt in list(enumerate(elts))[1:-1]:
elt = assert_cast(elt, (Block), f"middle arguments elts[{i}] to chain")
Expand All @@ -426,7 +426,7 @@ def chain(self, *elts: Union[Connection, BasePort, Block]) -> ChainConnect:
else:
raise ChainError(self, f"element {i} to chain {type(elt)} has no Input and Output, or InOut ports")

if isinstance(elts[-1], BasePort):
if isinstance(elts[-1], (BasePort, Connection)):
chain_links.append(self.connect(current_port, elts[-1]))
elif isinstance(elts[-1], Block):
inable_ports = elts[-1]._get_ports_by_tag({Input}) + elts[-1]._get_ports_by_tag({InOut})
Expand All @@ -435,7 +435,7 @@ def chain(self, *elts: Union[Connection, BasePort, Block]) -> ChainConnect:
chain_blocks.append(elts[-1])
chain_links.append(self.connect(current_port, inable_ports[0]))
else:
raise EdgTypeError(f"last argument {len(elts) - 1} to chain", elts[-1], (BasePort, Block))
raise EdgTypeError(f"last argument {len(elts) - 1} to chain", elts[-1], (BasePort, Connection, Block))

return self._chains.register(ChainConnect(chain_blocks, chain_links))

Expand Down
48 changes: 48 additions & 0 deletions electronics_abstract_parts/AbstractAntenna.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from electronics_model import *
from .Categories import *
from .PartsTable import PartsTableColumn, PartsTableRow
from .PartsTablePart import PartsTableSelector


@abstract_block
class Antenna(Block):
@init_in_parent
def __init__(self, frequency: RangeLike, impedance: RangeLike = Range.all(), power: RangeLike = (0, 0*Watt)):
super().__init__()

self.frequency = self.ArgParameter(frequency)
self.actual_frequency_rating = self.Parameter(RangeExpr())

self.impedance = self.ArgParameter(impedance)
self.actual_impedance = self.Parameter(RangeExpr())

self.power = self.ArgParameter(power)
self.actual_power_rating = self.Parameter(RangeExpr())

self.a = self.Port(Passive.empty())


@non_library
class TableAntenna(Antenna, PartsTableSelector, GeneratorBlock):
REFDES_PREFIX = 'ANT'

FREQUENCY_RATING = PartsTableColumn(Range)
IMPEDANCE = PartsTableColumn(Range)
POWER_RATING = PartsTableColumn(Range)

@init_in_parent
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.generator_param(self.frequency, self.power, self.impedance)

def _row_filter(self, row: PartsTableRow) -> bool:
return super()._row_filter(row) and \
self.get(self.frequency).fuzzy_in(row[self.FREQUENCY_RATING]) and \
row[self.IMPEDANCE].fuzzy_in(self.get(self.impedance)) and\
self.get(self.power).fuzzy_in(row[self.POWER_RATING])

def _row_generate(self, row: PartsTableRow) -> None:
super()._row_generate(row)
self.assign(self.actual_frequency_rating, row[self.FREQUENCY_RATING])
self.assign(self.actual_power_rating, row[self.POWER_RATING])
self.assign(self.actual_impedance, row[self.IMPEDANCE])
62 changes: 58 additions & 4 deletions electronics_abstract_parts/AbstractCapacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ def parse_capacitor(cls, value: str) -> Tuple[Range, Range]:
center = PartParserUtil.parse_value(match.group(1), '')
voltage = PartParserUtil.parse_value(match.group(3), 'V')
if match.group(2) is not None:
tolerance = PartParserUtil.parse_tolerance(match.group(2))
tol_str = match.group(2)
if not tol_str.startswith('±'): # format conversion to more strict parser
tol_str = '±' + tol_str
capacitance = PartParserUtil.parse_abs_tolerance(tol_str, center, 'F')
else:
tolerance = (-cls.CAPACITOR_DEFAULT_TOL, cls.CAPACITOR_DEFAULT_TOL)
return (Range.from_tolerance(center, tolerance), Range.zero_to_upper(voltage))
capacitance = Range.from_tolerance(center, (-cls.CAPACITOR_DEFAULT_TOL, cls.CAPACITOR_DEFAULT_TOL))
return (capacitance, Range.zero_to_upper(voltage))

@classmethod
def block_from_symbol(cls, symbol_name: str, properties: Mapping[str, str]) -> 'Capacitor':
Expand Down Expand Up @@ -171,6 +174,8 @@ def add_derated_row(row: PartsTableRow) -> Optional[Dict[PartsTableColumn, Any]]
factor = self.DERATE_LOWEST
derated = row[self.CAPACITANCE] * Range(factor, 1)

if derated.lower == 0: # in case where tolerance is the nominal value
return None
count = math.ceil(self.get(self.capacitance).lower / derated.lower)
derated_parallel_capacitance = derated * count
if not derated_parallel_capacitance.fuzzy_in(self.get(self.capacitance)): # not satisfying spec, remove row
Expand All @@ -182,7 +187,7 @@ def add_derated_row(row: PartsTableRow) -> Optional[Dict[PartsTableColumn, Any]]
self.PARALLEL_CAPACITANCE: row[self.CAPACITANCE] * count}

return table.map_new_columns(add_derated_row).filter(lambda row: (
row[self.PARALLEL_DERATED_CAPACITANCE] in self.get(self.capacitance)
row[self.PARALLEL_DERATED_CAPACITANCE] in self.get(self.capacitance)
))

def _row_generate(self, row: PartsTableRow) -> None:
Expand Down Expand Up @@ -257,3 +262,52 @@ def connected(self, gnd: Optional[Port[VoltageLink]] = None, pwr: Optional[Port[
if pwr is not None:
cast(Block, builder.get_enclosing_block()).connect(pwr, self.pwr)
return self


class CombinedCapacitorElement(Capacitor): # to avoid an abstract part error
def contents(self):
super().contents()
self.assign(self.actual_capacitance, self.capacitance) # fake it, since a combined capacitance is handwavey


class CombinedCapacitor(PassiveComponent, MultipackBlock, GeneratorBlock):
"""A packed capacitor that combines multiple individual capacitors into a single component,
with the sum of or taking the max of the constituent capacitances."""
@init_in_parent
def __init__(self, *, extend_upper: BoolLike = False) -> None:
super().__init__()

self.elements = self.PackedPart(PackedBlockArray(CombinedCapacitorElement()))
self.pos = self.PackedExport(self.elements.ports_array(lambda x: x.pos))
self.neg = self.PackedExport(self.elements.ports_array(lambda x: x.neg))
self.capacitances = self.PackedParameter(self.elements.params_array(lambda x: x.capacitance))
self.voltages = self.PackedParameter(self.elements.params_array(lambda x: x.voltage))
self.voltage_rating_deratings = self.PackedParameter(self.elements.params_array(lambda x: x.voltage_rating_derating))
self.exact_capacitances = self.PackedParameter(self.elements.params_array(lambda x: x.exact_capacitance))

self.actual_capacitance = self.Parameter(RangeExpr())
self.actual_voltage_rating = self.Parameter(RangeExpr())
self.unpacked_assign(self.elements.params(lambda x: x.actual_voltage_rating), self.actual_voltage_rating)

self.extend_upper = self.ArgParameter(extend_upper)
self.generator_param(self.pos.requested(), self.neg.requested(), self.extend_upper)


def generate(self):
super().generate()
capacitance = self.capacitances.sum()
if self.get(self.extend_upper):
capacitance = RangeExpr._to_expr_type((capacitance.lower(), float('inf')))
self.cap = self.Block(Capacitor(capacitance, voltage=self.voltages.hull(),
exact_capacitance=self.exact_capacitances.all(),
voltage_rating_derating=self.voltage_rating_deratings.min()))
self.assign(self.actual_voltage_rating, self.cap.actual_voltage_rating)
self.assign(self.actual_capacitance, self.cap.actual_capacitance)
self.require(self.exact_capacitances.all_equal())

self.pos_merge = self.Block(PackedPassive())
self.neg_merge = self.Block(PackedPassive())
self.connect(self.cap.pos, self.pos_merge.merged)
self.connect(self.cap.neg, self.neg_merge.merged)
self.connect(self.pos, self.pos_merge.elts)
self.connect(self.neg, self.neg_merge.elts)
6 changes: 6 additions & 0 deletions electronics_abstract_parts/AbstractCrystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class CrystalStandardFootprint(Crystal, StandardFootprint[Crystal]):
'3': block.crystal.xtal_out,
'4': block.gnd,
},
'Crystal:Crystal_SMD_2520-4Pin_2.5x2.0mm': lambda block: {
'1': block.crystal.xtal_in,
'2': block.gnd,
'3': block.crystal.xtal_out,
'4': block.gnd,
},
}


Expand Down
2 changes: 1 addition & 1 deletion electronics_abstract_parts/AbstractDebugHeaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SwdCortexTargetConnectorReset(BlockInterfaceMixin[SwdCortexTargetConnector
"""Mixin for SWD connectors with adding the optional reset pin"""
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.reset = self.Port(DigitalBidir.empty()) # can tri-state when not asserted
self.reset = self.Port(DigitalBidir.empty(), optional=True) # can tri-state when not asserted


class SwdCortexTargetConnectorSwo(BlockInterfaceMixin[SwdCortexTargetConnector]):
Expand Down
1 change: 0 additions & 1 deletion electronics_abstract_parts/AbstractDiodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def contents(self):
self.diode = self.Block(ZenerDiode(zener_voltage=self.voltage))
self.connect(self.diode.cathode.adapt_to(VoltageSink(
voltage_limits=(0, self.diode.actual_zener_voltage.lower()),
current_draw=(0, 0)*Amp # TODO should be leakage current
)), self.pwr)
self.connect(self.diode.anode.adapt_to(Ground()), self.gnd)

Expand Down
33 changes: 32 additions & 1 deletion electronics_abstract_parts/AbstractInductor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, Optional, cast

from electronics_model import *
from .PartsTable import PartsTableColumn, PartsTableRow
Expand Down Expand Up @@ -151,3 +151,34 @@ def _row_generate(self, row: PartsTableRow) -> None:
self.assign(self.actual_inductance, row[self.INDUCTANCE])
self.assign(self.actual_current_rating, row[self.CURRENT_RATING])
self.assign(self.actual_frequency_rating, row[self.FREQUENCY_RATING])


class SeriesPowerInductor(DiscreteApplication):
"""VoltageSource/Sink-typed series inductor for power filtering"""
@init_in_parent
def __init__(self, inductance: RangeLike, current: RangeLike = RangeExpr.ZERO,
frequency: RangeLike = RangeExpr.ZERO) -> None:
super().__init__()

self.pwr_out = self.Port(VoltageSource.empty(), [Output]) # forward declaration
self.pwr_in = self.Port(VoltageSink.empty(), [Power, Input]) # forward declaration

self.ind = self.Block(Inductor(
inductance=inductance, current=current, frequency=frequency
))

self.connect(self.pwr_in, self.ind.a.adapt_to(VoltageSink(
current_draw=self.pwr_out.link().current_drawn
)))
self.connect(self.pwr_out, self.ind.b.adapt_to(VoltageSource(
voltage_out=self.pwr_in.link().voltage,
)))

def connected(self, pwr_in: Optional[Port[VoltageLink]] = None, pwr_out: Optional[Port[VoltageLink]] = None) -> \
'SeriesPowerInductor':
"""Convenience function to connect both ports, returning this object so it can still be given a name."""
if pwr_in is not None:
cast(Block, builder.get_enclosing_block()).connect(pwr_in, self.pwr_in)
if pwr_out is not None:
cast(Block, builder.get_enclosing_block()).connect(pwr_out, self.pwr_out)
return self
1 change: 1 addition & 0 deletions electronics_abstract_parts/AbstractLed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Led(DiscreteSemiconductor):
Blue: LedColor = "blue"
Yellow: LedColor = "yellow"
White: LedColor = "white"
Orange: LedColor = "orange"
Any: LedColor = ""

@init_in_parent
Expand Down
4 changes: 4 additions & 0 deletions electronics_abstract_parts/AbstractOpamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ def __init__(self) -> None:
self.inp = self.Port(AnalogSink.empty())
self.inn = self.Port(AnalogSink.empty())
self.out = self.Port(AnalogSource.empty())


class OpampElement(Opamp):
"""Packed opamp element"""
6 changes: 3 additions & 3 deletions electronics_abstract_parts/AbstractPowerConverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __init__(self, *args, ripple_current_factor: RangeLike,
self.input_ripple_limit = self.ArgParameter(input_ripple_limit)
self.output_ripple_limit = self.ArgParameter(output_ripple_limit)

self.frequency = self.Parameter(RangeExpr())
self.actual_frequency = self.Parameter(RangeExpr())


@abstract_block_default(lambda: IdealBuckConverter)
Expand Down Expand Up @@ -199,9 +199,9 @@ class BuckConverterPowerPath(InternalSubcircuit, GeneratorBlock):
@init_in_parent
def __init__(self, input_voltage: RangeLike, output_voltage: RangeLike, frequency: RangeLike,
output_current: RangeLike, current_limits: RangeLike, inductor_current_ripple: RangeLike, *,
input_voltage_ripple: FloatLike,
output_voltage_ripple: FloatLike,
efficiency: RangeLike = (0.9, 1.0), # from TI reference
input_voltage_ripple: FloatLike = 75*mVolt,
output_voltage_ripple: FloatLike = 25*mVolt,
dutycycle_limit: RangeLike = (0.1, 0.9),
inductor_scale: FloatLike = 1.0): # arbitrary
super().__init__()
Expand Down
12 changes: 6 additions & 6 deletions electronics_abstract_parts/AbstractResistor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ def symbol_pinning(self, symbol_name: str) -> Mapping[str, BasePort]:
return {'1': self.a, '2': self.b}

@classmethod
def parse_resistor(cls, value: str):
def parse_resistor(cls, value: str) -> Range:
match = cls.RESISTOR_REGEX.match(value)
assert match is not None, f"could not parse resistor from value '{value}'"
center = PartParserUtil.parse_value(match.group(1), '')
if match.group(2) is not None:
tolerance = PartParserUtil.parse_tolerance(match.group(2))
tol_str = match.group(2)
if not tol_str.startswith('±'): # format conversion to more strict parser
tol_str = '±' + tol_str
return PartParserUtil.parse_abs_tolerance(tol_str, center, 'Ω')
else:
tolerance = (-cls.RESISTOR_DEFAULT_TOL, cls.RESISTOR_DEFAULT_TOL)
return Range.from_tolerance(center, tolerance)
return Range.from_tolerance(center, (-cls.RESISTOR_DEFAULT_TOL, cls.RESISTOR_DEFAULT_TOL))

@classmethod
def block_from_symbol(cls, symbol_name: str, properties: Mapping[str, str]) -> 'Resistor':
Expand Down Expand Up @@ -234,12 +236,10 @@ def __init__(self, resistance: RangeLike) -> None:
))

self.connect(self.pwr_in, self.res.a.adapt_to(VoltageSink(
voltage_limits=(-float('inf'), float('inf')),
current_draw=self.pwr_out.link().current_drawn
)))
self.connect(self.pwr_out, self.res.b.adapt_to(VoltageSource(
voltage_out=self.pwr_in.link().voltage, # ignore voltage drop
current_limits=Range.all()
)))

self.actual_power = self.Parameter(RangeExpr(current_draw * current_draw * self.res.actual_resistance))
Expand Down
Loading
Loading