Skip to content

Commit

Permalink
switchfet
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 committed Aug 19, 2024
1 parent f7f0b6f commit 4731354
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions edg/jlcparts/JlcPartsBoardTop.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .JlcPartsDiode import JlcPartsDiode, JlcPartsZenerDiode
from .JlcPartsLed import JlcPartsLed
from .JlcPartsBjt import JlcPartsBjt
from .JlcPartsFet import JlcPartsFet
from .JlcPartsFet import JlcPartsFet, JlcPartsSwitchFet
from .JlcPartsPptcFuse import JlcPartsPptcFuse


Expand All @@ -24,7 +24,7 @@ def refinements(self) -> Refinements:
(Led, JlcPartsLed),
(Bjt, JlcPartsBjt),
(Fet, JlcPartsFet),
# (SwitchFet, JlcSwitchFet), # TODO IMPLEMENT ME
(SwitchFet, JlcPartsSwitchFet),
(PptcFuse, JlcPartsPptcFuse),
(FerriteBead, JlcPartsFerriteBead)
]
Expand Down
28 changes: 27 additions & 1 deletion edg/jlcparts/JlcPartsFet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .JlcPartsBase import JlcPartsBase, JlcPartsAttributes


class JlcPartsFet(TableFet, JlcPartsBase):
class JlcPartsBaseFet(BaseTableFet, JlcPartsBase):
_JLC_PARTS_FILE_NAMES = ["TransistorsMOSFETs"]
_CHANNEL_MAP = {
'N Channel': 'N',
Expand All @@ -20,6 +20,8 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st
row_dict[cls.CHANNEL] = cls._CHANNEL_MAP[attributes.get("Type", str)]
row_dict[cls.VDS_RATING] = Range.zero_to_upper(
attributes.get("Drain source voltage (vdss)", float, sub='voltage'))
row_dict[cls.IDS_RATING] = Range.zero_to_upper(PartParserUtil.parse_value(
attributes.get("Continuous drain current (id)", str), 'A'))

# used as a proxy for lower bound for Vgs,max
vgs_for_ids = attributes.get("Drain source on resistance (rds(on)@vgs,id)", float, sub='Vgs')
Expand Down Expand Up @@ -49,3 +51,27 @@ def _entry_to_table_row(cls, row_dict: Dict[PartsTableColumn, Any], filename: st
return row_dict
except (KeyError, TypeError, PartParserUtil.ParseError):
return None


class JlcPartsFet(JlcPartsBaseFet, TableFet):
pass


class JlcPartsSwitchFet(JlcPartsBaseFet, TableSwitchFet):
@init_in_parent
def __init__(self, *args, manual_gate_charge: RangeLike = RangeExpr.ZERO, **kwargs):
super().__init__(*args, **kwargs)
# allow the user to specify a gate charge
self.manual_gate_charge = self.ArgParameter(manual_gate_charge)
self.generator_param(self.manual_gate_charge)

def _table_postprocess(self, table: PartsTable) -> PartsTable:
manual_gate_charge = self.get(self.manual_gate_charge)
def process_row(row: PartsTableRow) -> Optional[Dict[PartsTableColumn, Any]]:
return {self.GATE_CHARGE: manual_gate_charge}

# must run before TableFet power calculations
if not manual_gate_charge == Range.exact(0):
table = table.map_new_columns(process_row, overwrite=True)

return super()._table_postprocess(table)
2 changes: 1 addition & 1 deletion edg/jlcparts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .JlcPartsDiode import JlcPartsDiode, JlcPartsZenerDiode
from .JlcPartsLed import JlcPartsLed
from .JlcPartsBjt import JlcPartsBjt
from .JlcPartsFet import JlcPartsFet
from .JlcPartsFet import JlcPartsFet, JlcPartsSwitchFet
from .JlcPartsPptcFuse import JlcPartsPptcFuse

from .JlcPartsBoardTop import JlcPartsRefinements

0 comments on commit 4731354

Please sign in to comment.