"""PCB header for pluggable terminal blocks, Phoenix Contact MSTBA 2,5 type: right-angle, 5.0 or 5.08 mm pitch, 2 to 16 positions. Pin 1 is at the origin, the row along +X, the housing on the XY plane with its opening facing -Y, the solder pins down through the board. Dimensions from Phoenix Contact's data sheet in the README.""" from steve import Model pitch = 5.08 # mm Pitch positions = 2 # Positions detail = "full" # full: the opening, the mating pins and the solder pins; simple: the housing's outline # Phoenix Contact data sheet, MSTBA 2,5/ 2-G-5,08 (1757242), Dimensions p. 5 and Dimensional drawing p. 6: width a + 7 (5.0 mm) or a + 7.08 (5.08 mm), length 12, # height 8.6 above the board, solder pins 3.5 long, 2 from the back face. The drawing gives the same housing for 5.0 and 5.08 mm pitch. LENGTH, HEIGHT, PIN_LENGTH, PIN_FROM_BACK = 12, 8.6, 3.5, 2 PIN = 1.2 # the pin section, the wall and the mating pins' reach are proportions, for looks: the data sheet doesn't dimension them SHORT = 1.5 # the mating pins stop this far short of the opening, where the plug's contacts meet them WALL = 1.0 if pitch not in (5.0, 5.08) or not 2 <= positions <= 16: raise ValueError("MSTBA 2,5 comes in 5.0 and 5.08 mm pitch, 2 to 16 positions.") end = 3.5 if pitch == 5.0 else 3.54 width = (positions - 1) * pitch + 2 * end x0 = -end back = PIN_FROM_BACK front = back - LENGTH model = Model() with model.sketch("housing_sketch", on="XY", name="Housing") as sk: sk.rect("housing_rect", (x0, front), (x0 + width, back)) model.extrude("housing", "housing_sketch", distance=HEIGHT, name="Housing") if detail == "full": model.plane("opening_plane", on="XZ", offset=-front, name="Opening") with model.sketch("opening_sketch", on="opening_plane", name="Opening") as sk: sk.rect("opening_rect", (x0 + WALL, WALL), (x0 + width - WALL, HEIGHT - WALL)) model.extrude("opening", "opening_sketch", distance=-(LENGTH - 2 * WALL), op="cut", name="Opening") z = HEIGHT / 2 model.plane("pins_plane", on="XZ", offset=-(back - WALL), name="Mating pins") with model.sketch("pins_sketch", on="pins_plane", name="Mating pins") as sk: for i in range(positions): sk.rect(f"pin_{i}", (i * pitch - PIN / 2, z - PIN / 2), (i * pitch + PIN / 2, z + PIN / 2)) model.extrude("pins", "pins_sketch", distance=LENGTH - WALL - SHORT, name="Mating pins") model.plane("solder_plane", on="XY", offset=-PIN_LENGTH, name="Solder pins") with model.sketch("solder_sketch", on="solder_plane", name="Solder pins") as sk: for i in range(positions): sk.rect(f"solder_{i}", (i * pitch - PIN / 2, -PIN / 2), (i * pitch + PIN / 2, PIN / 2)) model.extrude("solder", "solder_sketch", distance=PIN_LENGTH + 1, name="Solder pins") model.material("pa6", color="#2f7d4a") result = model.result()