"""Through-hole PCB relay: Omron G2RL-2, G5V-1, G5V-2, G6A and G6AK. A closed case on the XY plane with the pins down through the board. Pin 1 is at the origin; the pins are placed as the maker's bottom-view PCB layout draws them, seen from above (the layout turned over about its horizontal axis): along it to +X, its next row towards +Y. Dimensions from the makers' data sheets in the README.""" from steve import Model kind = "G6A" # Relay type # kind: (case length along X, width along Y, height above the board; solder pin length below the board, pin across X, pin across Y; # pin 1 from the case's -X end, from its -Y side; pins (x, y) from pin 1). The case sizes are the data sheets' average values. # Omron G2RL, Cat. No. J117-E1-17, Dimensions p. 6, G2RL-2: 29 max. (28.8 average) x 12.7 max. (12.5) x 15.7 max. (15.5), terminals 3.5 long, # 0.5 x 0.8; PCB mounting holes (bottom view): columns at 0, 15, 20, 25 (20 from pin 1 to the third, 5 apart), rows 7.5 apart, (2.3) from # the case end and (2.5) from its side. Weight approx. 12 g (p. 2). # Omron G5V-1, Cat. No. K048-E1-07, Dimensions p. 4: 12.5 max. (12.3) x 7.5 max. (7.3) x 10 max. (9.9), terminals 3.5 long, 0.5 x 0.3; # holes at 0, 2.54 and 10.16, rows 5.08 apart, (1.07) and (1.11) from the case. Weight approx. 2 g. # Omron G5V-2, Cat. No. K046-E1-06, Dimensions p. 4: 20.5 max. (20.3) x 10.1 max. (9.9) x 11.5 max. (11.4), terminals 3.5 long, # 0.5 x 0.3; holes at 0, 7.62, 12.7, 17.78, rows 7.62 apart, (1.3) and (1.2) from the case. Weight approx. 5 g. # Omron G6A, Cat. No. K020-E1-15, Dimensions p. 8: 20.2 max. (20) x 10.1 max. (9.9) x 8.4 max. (8.2), terminals 3.16 long, 0.6 x 0.3; # G6A-274P: holes at 0, 7.62, 12.7, 17.78, rows 7.62 apart, (1.2) from the case; G6AK-274P (double-winding latching): also at 2.54, # ten holes. Weight approx. 3.5 g (p. 2). RELAYS = { "G2RL-2": (28.8, 12.5, 15.5, 3.5, 0.5, 0.8, 2.3, 2.5, ((0, 0), (15, 0), (20, 0), (25, 0), (0, 7.5), (15, 7.5), (20, 7.5), (25, 7.5))), "G5V-1": (12.3, 7.3, 9.9, 3.5, 0.5, 0.3, 1.07, 1.11, ((0, 0), (2.54, 0), (10.16, 0), (0, 5.08), (2.54, 5.08), (10.16, 5.08))), "G5V-2": (20.3, 9.9, 11.4, 3.5, 0.5, 0.3, 1.3, 1.2, ((0, 0), (7.62, 0), (12.7, 0), (17.78, 0), (0, 7.62), (7.62, 7.62), (12.7, 7.62), (17.78, 7.62))), "G6A": (20.0, 9.9, 8.2, 3.16, 0.6, 0.3, 1.2, 1.2, ((0, 0), (7.62, 0), (12.7, 0), (17.78, 0), (0, 7.62), (7.62, 7.62), (12.7, 7.62), (17.78, 7.62))), "G6AK": (20.0, 9.9, 8.2, 3.16, 0.6, 0.3, 1.2, 1.2, ((0, 0), (2.54, 0), (7.62, 0), (12.7, 0), (17.78, 0), (0, 7.62), (2.54, 7.62), (7.62, 7.62), (12.7, 7.62), (17.78, 7.62))), } # Proportions (the data sheets don't dimension the inside): the case is a cover WALL thick over a base plate as thick; the coil, core and contacts inside are one # copper block filling FILL of the space inside the case, standing on its floor, so that the mass comes out near the data sheets' weights. WALL = 0.5 FILL = 0.27 if kind not in RELAYS: raise ValueError(f"no relay {kind!r}: {', '.join(RELAYS)}") length, width, height, pin_length, pin_x, pin_y, from_end, from_side, pins = RELAYS[kind] # Pin 1's place in the case: the PCB layouts' bracketed distances from pin 1 to the case's end and side (the far end takes what's left # of the average case size). x0 = -from_end y0 = -from_side model = Model() # The case: a cover, open underneath, over a base plate WALL thick that closes it. model.box("case", length, width, height, at=(x0 + length / 2, y0 + width / 2, height / 2), op="new", body="case_body", name="Cover") inner = (length - 2 * WALL, width - 2 * WALL, height - 2 * WALL) model.box("inside", inner[0], inner[1], height - WALL, at=(x0 + length / 2, y0 + width / 2, (height - WALL) / 2), op="cut", body="case_body", name="Inside") model.box("base", inner[0], inner[1], WALL, at=(x0 + length / 2, y0 + width / 2, WALL / 2), op="new", body="base_body", name="Base") scale = FILL ** (1 / 3) core = (inner[0] * scale, inner[1] * scale, inner[2] * scale) model.box("coil", core[0], core[1], core[2], at=(x0 + length / 2, y0 + width / 2, WALL + core[2] / 2), op="new", body="coil_body", name="Coil and contacts") pin_bodies = [] for i, (x, y) in enumerate(pins): model.box(f"pin_{i + 1}", pin_x, pin_y, pin_length, at=(x, y, -pin_length / 2), op="new", body=f"pin_{i + 1}_body", name=f"Pin {i + 1}") pin_bodies.append(f"pin_{i + 1}_body") # Materials, for looks and a rough mass (the data sheets name none): a black plastic case (pa6), the inside copper, tin-plated pins. model.material("pa6", bodies=["case_body", "base_body"], color="#1d1e20") model.material("copper", bodies=["coil_body"], color="#b87333") model.material("copper", bodies=pin_bodies, color="#c9cbc8") result = model.result()