"""PCB header for pluggable terminal blocks, right-angle, Phoenix Contact MSTBA 2,5 type (5.0 or 5.08 mm, 2 to 16 positions) or MC 1,5 type (3.81 mm, 2 to 16). 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 series = "MSTBA 2,5" # Series 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 # series: (pitches, length, height above the board, solder pin length, solder pins from the back face, past each end pin by pitch, pin section) # MSTBA 2,5: 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. # MC 1,5: data sheet MC 1,5/ 2-G-3,81 (1803277), Technische Daten p. 1 and Massszeichnung p. 4: width a + 5.2, length 9.2, height 7.25, solder pins 3.4 long, # 0.8 x 0.8, 8 from the opening (1.2 from the back face). SERIES = { "MSTBA 2,5": ((5.0, 5.08), 12, 8.6, 3.5, 2, {5.0: 3.5, 5.08: 3.54}, 1.2), "MC 1,5": ((3.81,), 9.2, 7.25, 3.4, 1.2, {3.81: 2.6}, 0.8), } pitches, LENGTH, HEIGHT, PIN_LENGTH, PIN_FROM_BACK, ENDS, PIN = SERIES[series] # the wall and the mating pins' reach are proportions, for looks: the data sheets don'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 series == "MSTBA 2,5" else 0.8 if pitch not in pitches or not 2 <= positions <= 16: raise ValueError(f"{series} comes in pitch {pitches}, 2 to 16 positions.") end = ENDS[pitch] 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()