"""PCB screw terminal block, Phoenix Contact MKDS 1,5 (5.0 and 5.08 mm), PT 1,5 (3.5 mm) and MPT 0,5 (2.54 mm) types. Pin 1 is at the origin, the row along +X, the housing on the XY plane, the wire entries facing -Y, the screws on top, the solder pins down through the board. Dimensions from Phoenix Contact's data sheets in the README.""" from steve import Model series = "MKDS 1,5" # Series pitch = 5.08 # mm Pitch positions = 2 # Positions detail = "full" # full: wire entries, screw heads and solder pins; simple: the housing's outline # series: (pitches, positions, height above the board, length, solder pin length, pin across the row, pin along, pin from the wire-entry face, # width past the end pins in all) # MKDS 1,5: data sheet MKDS 1,5/ 2-5,08 (1715721), Dimensions p. 4 and dimensional drawing p. 8: width a + pitch, 13.8, 9.8, pins 3.5, 0.9 x 0.9, 4.6. # PT 1,5: data sheet PT 1,5/ 5-3,5-H (1984646), Drawings p. 4: width a + 3.5, 9.2, 7.6, pins 4.5, 0.9, 3.1 from the back face. # MPT 0,5: data sheet MPT 0,5/ 2-2,54 (1725656), p. 5 and dimensional drawing p. 6: width 5.54 for 2 positions (1.5 past each end pin), 8.5, 6.2, # pins 3.5, 0.5 x 0.9, 3.1 from the back face. SERIES = { "MKDS 1,5": ((5.0, 5.08), (2, 16), 13.8, 9.8, 3.5, 0.9, 0.9, 4.6, None), "PT 1,5": ((3.5,), (2, 16), 9.2, 7.6, 4.5, 0.9, 0.9, 4.5, 3.5), "MPT 0,5": ((2.54,), (2, 12), 8.5, 6.2, 3.5, 0.5, 0.9, 3.1, 3.0), } pitches, (low, high), HEIGHT, LENGTH, PIN_LENGTH, PIN_W, PIN_D, PIN_FROM_FRONT, ends = SERIES[series] if pitch not in pitches or not low <= positions <= high: raise ValueError(f"{series} comes in pitch {pitches} with {low} to {high} positions.") width = (positions - 1) * pitch + (ends if ends is not None else pitch) x0 = -(width - (positions - 1) * pitch) / 2 front = -PIN_FROM_FRONT # the side profile: the step at the top of the wire-entry face and the sloped back are proportions, for looks profile = [(front, 0), (front + LENGTH, 0), (front + LENGTH, 0.72 * HEIGHT), (front + 0.75 * LENGTH, HEIGHT), (front + 0.25 * LENGTH, HEIGHT), (front + 0.25 * LENGTH, 0.8 * HEIGHT), (front, 0.8 * HEIGHT)] model = Model() model.plane("side_plane", on="YZ", offset=x0, name="Side") with model.sketch("body_sketch", on="side_plane", name="Housing") as sk: sk.polyline("body_outline", profile, closed=True) model.extrude("body", "body_sketch", distance=width, name="Housing") if detail == "full": entry, screw = 0.6 * pitch, 0.55 * pitch # the wire entry and screw head sizes are proportions, for looks model.plane("front_plane", on="XZ", offset=-front, name="Wire entries") with model.sketch("entries_sketch", on="front_plane", name="Wire entries") as sk: for i in range(positions): sk.rect(f"entry_{i}", (i * pitch - entry / 2, 0.25 * HEIGHT), (i * pitch + entry / 2, 0.25 * HEIGHT + entry)) model.extrude("entries", "entries_sketch", distance=-0.55 * LENGTH, op="cut", name="Wire entries") model.plane("top_plane", on="XY", offset=HEIGHT, name="Top") with model.sketch("screws_sketch", on="top_plane", name="Screw openings") as sk: for i in range(positions): sk.circle(f"screw_{i}", (i * pitch, front + 0.5 * LENGTH), screw / 2) model.extrude("screws", "screws_sketch", distance=-0.15 * HEIGHT, op="cut", name="Screw openings") model.plane("pin_plane", on="XY", offset=-PIN_LENGTH, name="Solder pins") with model.sketch("pins_sketch", on="pin_plane", name="Solder pins") as sk: for i in range(positions): sk.rect(f"pin_{i}", (i * pitch - PIN_W / 2, -PIN_D / 2), (i * pitch + PIN_W / 2, PIN_D / 2)) model.extrude("pins", "pins_sketch", distance=PIN_LENGTH + 1, name="Solder pins") model.material("pa6", color="#2f7d4a") result = model.result()