Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ubruhin committed Oct 10, 2023
1 parent 7007b9b commit 5834e6e
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions generate_sot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def generate(
body_length: float,
total_height: float,
lead_span: float,
lead_height: float,
lead_contact_length: float,
leads_left: Iterable[Tuple[str, float, float]],
leads_right: Iterable[Tuple[str, float, float]],
Expand All @@ -26,7 +27,6 @@ def generate(
dot_diameter = min(body_width * 0.25, 0.8)
dot_position = dot_diameter
dot_depth = 0.1
lead_height = 0.17
lead_z_top = body_standoff + (body_height / 2)
bend_radius = 0.1 + (lead_height / 2)

Expand All @@ -43,20 +43,21 @@ def generate(
.cylinder(5, dot_diameter / 2, centered=(True, True, False), combine='cut')
dot = cq.Workplane('XY', origin=dot_center) \
.cylinder(0.05, dot_diameter / 2, centered=(True, True, False))
lead_path = cq.Workplane("XZ") \
.hLine(lead_contact_length - (lead_height / 2) - bend_radius) \
.ellipseArc(x_radius=bend_radius, y_radius=bend_radius, angle1=270, angle2=360, sense=1) \
.vLine(lead_z_top - lead_height - (2 * bend_radius)) \
.ellipseArc(x_radius=bend_radius, y_radius=bend_radius, angle1=90, angle2=180, sense=-1) \
.hLine((lead_span / 2) - bend_radius - lead_contact_length + (lead_height / 2))
leads_by_width = dict()

assembly = StepAssembly(name)
assembly.add_body(body, 'body', StepColor.IC_BODY)
assembly.add_body(dot, 'dot', StepColor.IC_PIN1_DOT)

leads_by_width = dict()
for x_sgn, rotation, leads in [(-1, 0, leads_left), (1, 180, leads_right)]:
for lead_name, lead_y, lead_width in leads:
if lead_width not in leads_by_width:
lead_path = cq.Workplane("XZ") \
.hLine(lead_contact_length - (lead_height / 2) - bend_radius) \
.ellipseArc(x_radius=bend_radius, y_radius=bend_radius, angle1=270, angle2=360, sense=1) \
.vLine(lead_z_top - lead_height - (2 * bend_radius)) \
.ellipseArc(x_radius=bend_radius, y_radius=bend_radius, angle1=90, angle2=180, sense=-1) \
.hLine((lead_span / 2) - bend_radius - lead_contact_length + (lead_height / 2))
leads_by_width[lead_width] = cq.Workplane('ZY') \
.rect(lead_height, lead_width) \
.sweep(lead_path)
Expand All @@ -77,12 +78,46 @@ def generate(


if __name__ == '__main__':
generate(
name='SOT223-4P230_700X180L175X75T175X300',
body_width=3.5,
body_length=6.5,
total_height=1.8,
lead_span=7.0,
lead_height=0.27,
lead_contact_length=0.9,
leads_left=[
('1', 2.3, 0.7),
('2', 0, 0.7),
('3', -2.3, 0.7),
],
leads_right=[
('4', 0, 3.0),
],
)
generate(
name='SOT23-3',
body_width=1.3,
body_length=2.9,
total_height=1.1,
lead_span=2.3,
lead_height=0.14,
lead_contact_length=0.5,
leads_left=[
('1', 0.95, 0.4),
('2', -0.95, 0.4),
],
leads_right=[
('3', 0, 0.4),
],
)
generate(
name='SOT95P280X145-5',
body_width=1.6,
body_length=2.9,
total_height=1.45,
lead_span=2.8,
lead_height=0.17,
lead_contact_length=0.45,
leads_left=[
('1', 0.95, 0.4),
Expand All @@ -100,6 +135,7 @@ def generate(
body_length=2.9,
total_height=1.45,
lead_span=2.8,
lead_height=0.17,
lead_contact_length=0.45,
leads_left=[
('1', 0.95, 0.4),
Expand Down

0 comments on commit 5834e6e

Please sign in to comment.