# -*- coding: utf-8 -*- """Protoboard 830 pontos (tipo MB-102 / BB830). Especificação: 165,1 x 54,6 x 8,5 mm (+ adesivo 1,0 mm), ABS branco. * área de circuito: 63 colunas x 10 linhas (a–e / f–j), passo 2,54; linhas e/f a ±3,81 mm do centro (canal central de 0,3"). * 4 trilhos de alimentação (2 por lado) com 50 furos cada, em 10 grupos de 5; trilhos internos a ±22,86 mm, externos a ±25,40 mm; linhas vermelha (+) e azul (−) serigrafadas. * furos quadrados 1,0 mm com entrada piramidal 1,9 mm. * grampos de bronze fosforoso niquelado: 126 grampos de 5 contatos + 8 grampos de trilho (25 contatos cada, trilho dividido ao meio como no MB-102). * trilhos laterais destacáveis (encaixe rabo-de-andorinha). Sistema local: centro em (0,0); fundo do adesivo em z=0; face superior em z = 9,5. Coluna 1 à esquerda (-X), linha 'a' em baixo (-Y). """ import math, sys, os sys.path.insert(0, os.path.expanduser("~/robo_movel/cad")) import importlib, lib_rm; importlib.reload(lib_rm) from lib_rm import * P = 2.54 LX, LY = 165.1, 54.6 H_BODY, H_ADH = 8.5, 1.0 Z0 = H_ADH ZTOP = H_ADH + H_BODY NCOL = 63 ROWS = "abcdefghij" RAIL_Y = {"b_out": -25.40, "b_in": -22.86, "t_in": 22.86, "t_out": 25.40} RAIL_POL = {"b_out": "-", "b_in": "+", "t_in": "-", "t_out": "+"} SPLIT_Y = 20.0 # separação entre corpo central e trilhos destacáveis def col_x(c): return (c - 32) * P def row_y(r): i = ROWS.index(r) return -3.81 - (4 - i) * P if i < 5 else 3.81 + (i - 5) * P def rail_positions(): """índices k (0..58) dos furos de trilho: grupos de 5 com 1 espaço.""" return [k for k in range(59) if k % 6 != 5] def rail_x(k): return (k - 29) * P def hole(col, row): """Posição (x, y, z_topo) de um furo da área de circuito.""" return V(col_x(col), row_y(row), ZTOP) def rail_hole(rail, k): return V(rail_x(rail_positions()[k]), RAIL_Y[rail], ZTOP) def _hole_tool(): sq = cbox(1.0, 1.0, 6.0, 0, 0, ZTOP - 6.0) top = Part.makeLoft([Part.makePolygon([V(-0.5, -0.5, ZTOP - 0.9), V(0.5, -0.5, ZTOP - 0.9), V(0.5, 0.5, ZTOP - 0.9), V(-0.5, 0.5, ZTOP - 0.9), V(-0.5, -0.5, ZTOP - 0.9)]), Part.makePolygon([V(-0.95, -0.95, ZTOP + 0.01), V(0.95, -0.95, ZTOP + 0.01), V(0.95, 0.95, ZTOP + 0.01), V(-0.95, 0.95, ZTOP + 0.01), V(-0.95, -0.95, ZTOP + 0.01)])], True) return sq.fuse(top) def all_holes(): pts = [(col_x(c), row_y(r)) for c in range(1, NCOL + 1) for r in ROWS] pts += [(rail_x(k), y) for y in RAIL_Y.values() for k in rail_positions()] return pts def dovetail(y_edge, sgn, male): """Rabo-de-andorinha ao longo da junção (8 dentes).""" shapes = [] for i in range(8): x = -LX / 2 + 10 + i * (LX - 20) / 7 w1, w2, d = 3.0, 4.2, 1.6 pts = [V(x - w1 / 2, y_edge, Z0), V(x + w1 / 2, y_edge, Z0), V(x + w2 / 2, y_edge + sgn * d, Z0), V(x - w2 / 2, y_edge + sgn * d, Z0)] f = Part.Face(Part.makePolygon(pts + [pts[0]])) shapes.append(f.extrude(V(0, 0, H_BODY - 1.0))) return Part.makeCompound(shapes) def build(show=True): doc = new_doc("Protoboard_830") part = part_container(doc, "Protoboard_830", "Protoboard 830 pontos (MB-102)") tool1 = _hole_tool() # corpo central e trilhos center = box(LX, 2 * SPLIT_Y, H_BODY, -LX / 2, -SPLIT_Y, Z0) rail_b = box(LX, LY / 2 - SPLIT_Y, H_BODY, -LX / 2, -LY / 2, Z0) rail_t = box(LX, LY / 2 - SPLIT_Y, H_BODY, -LX / 2, SPLIT_Y, Z0) # canal central (2,8 x 5 mm) e ranhuras decorativas nos cantos center = center.cut(box(LX + 2, 2.8, 5.0, -LX / 2 - 1, -1.4, ZTOP - 5.0)) # encaixes rabo-de-andorinha: fêmea no corpo central, macho nos trilhos dt_b = dovetail(-SPLIT_Y, 1, True) dt_t = dovetail(SPLIT_Y, -1, True) center = center.cut([dt_b, dt_t]) rail_b = rail_b.fuse(dt_b).removeSplitter() rail_t = rail_t.fuse(dt_t).removeSplitter() # cavidades dos grampos por baixo cav_c = [] for c in range(1, NCOL + 1): for ys in ((row_y("a"), row_y("e")), (row_y("f"), row_y("j"))): cav_c.append(box(1.9, ys[1] - ys[0] + 2.2, 6.2, col_x(c) - 0.95, ys[0] - 1.1, Z0 - 0.01)) center = center.cut(Part.makeCompound(cav_c)) # furos holes_c = [placed(tool1, V(col_x(c), row_y(r), 0)) for c in range(1, NCOL + 1) for r in ROWS] center = center.cut(Part.makeCompound(holes_c)) for name, shp, keys in (("b", rail_b, ("b_out", "b_in")), ("t", rail_t, ("t_in", "t_out"))): tools = [placed(tool1, V(rail_x(k), RAIL_Y[key], 0)) for key in keys for k in rail_positions()] cav = [box(LX - 10, 1.9, 6.2, -LX / 2 + 5, RAIL_Y[key] - 0.95, Z0 - 0.01) for key in keys] shp = shp.cut(Part.makeCompound(tools + cav)) if name == "b": rail_b = shp else: rail_t = shp add(doc, "Corpo", center, "branco", "Corpo central (63 x 10)", group=part) add(doc, "Trilho_inferior", rail_b, "branco", "Trilhos de alimentação inferiores", group=part) add(doc, "Trilho_superior", rail_t, "branco", "Trilhos de alimentação superiores", group=part) # grampos (bronze fosforoso niquelado) — perfil em U simplificado clips = [] for c in range(1, NCOL + 1): for ys in ((row_y("a"), row_y("e")), (row_y("f"), row_y("j"))): Ly = ys[1] - ys[0] + 1.8 u = box(1.5, Ly, 5.4, col_x(c) - 0.75, ys[0] - 0.9, Z0 + 0.3).cut(box(0.9, Ly + 2, 5.0, col_x(c) - 0.45, ys[0] - 1.9, Z0 + 0.8)) clips.append(u) for key in RAIL_Y: for half in (0, 1): ks = [k for k in rail_positions() if (k < 29) == (half == 0)] x0, x1 = rail_x(ks[0]) - 0.9, rail_x(ks[-1]) + 0.9 u = box(x1 - x0, 1.5, 5.4, x0, RAIL_Y[key] - 0.75, Z0 + 0.3).cut(box(x1 - x0 + 2, 0.9, 5.0, x0 - 1, RAIL_Y[key] - 0.45, Z0 + 0.8)) clips.append(u) add(doc, "Grampos", Part.makeCompound(clips), "aco", "Grampos de contato (134)", group=part) # adesivo + papel protetor add(doc, "Adesivo", box(LX, LY, H_ADH - 0.1, -LX / 2, -LY / 2, 0.1), "creme", "Fita dupla-face", group=part) add(doc, "Papel", box(LX, LY, 0.1, -LX / 2, -LY / 2, 0), "amarelo", "Papel protetor", group=part) # serigrafia red, blue, txt = [], [], [] zt = ZTOP + 0.001 for key, y in RAIL_Y.items(): off = 1.9 if y > 0 else -1.9 yl = y + (off if key.endswith("out") else -off) line = box(LX - 12, 0.5, 0.02, -LX / 2 + 6, yl - 0.25, zt) (red if RAIL_POL[key] == "+" else blue).append(line) for xs in (-LX / 2 + 3.0, LX / 2 - 3.0): t = text_shape(RAIL_POL[key], 2.0, FONT, height=0.02) c = text_center(t) t.translate(V(xs - c.x, y - c.y, zt)) (red if RAIL_POL[key] == "+" else blue).append(t) def put(s, size, x, y, ang=0): t = text_shape(s, size, FONT_REG, height=0.02) c = text_center(t) t.translate(V(-c.x, -c.y, 0)) if ang: t.rotate(V(0, 0, 0), V(0, 0, 1), ang) t.translate(V(x, y, zt)) txt.append(t) for c in [1] + list(range(5, NCOL + 1, 5)): put(str(c), 1.3, col_x(c), row_y("a") - 2.2, 90) put(str(c), 1.3, col_x(c), row_y("j") + 2.2, 90) for r in ROWS: put(r, 1.4, col_x(1) - 2.9, row_y(r)) put(r, 1.4, col_x(NCOL) + 2.9, row_y(r)) add(doc, "Linhas_vermelhas", Part.makeCompound(red), "vermelho", "Serigrafia (+)", group=part) add(doc, "Linhas_azuis", Part.makeCompound(blue), "azul", "Serigrafia (−)", group=part) add(doc, "Numeracao", Part.makeCompound(txt), "grafite", "Numeração e letras", group=part) doc.recompute() save(doc) if show: fit() return doc