PCB Standoff Plate
A mounting plate with four standoffs for any circuit board, made from the hole spacing and the screw size. The standoffs take self-tapping screws (M2, M2.5 or M3) or carry pins that the board simply drops onto, and the plate itself is fixed with two keyhole slots for wall screws, two open slots for bolts, or nothing for double-sided tape. The default, the Raspberry Pi pattern of 58 x 49 mm with M2.5 and 6 mm standoffs, gives a plate of 72 x 63 x 8.5 mm. Spacing, screw size, standoff height, margin, thickness and the fixing style are parameters. Prints flat, no supports.
# PCB Standoff Plate - a mounting plate with four standoffs for any board, by hole spacing
#
# Give it the hole spacing of the board and the screw size, and the plate comes out
# with four standoffs (holes for self-tapping screws, or pins that the board drops
# onto), rounded corners and a way to fix the plate itself: two keyhole slots for
# wall screws, two open slots for bolting it to a panel, or nothing for double-
# sided tape. Prints flat, no supports. Typical spacings: Raspberry Pi 58 x 49,
# Pi Zero 58 x 23, 50 x 50 and 70 x 50 prototype boards.
@param 20..150 step:0.5 group:"Board" desc:"Hole spacing along X (mm)"
$dx = 58
@param 15..120 step:0.5 group:"Board" desc:"Hole spacing along Y (mm)"
$dy = 49
@param choices:["M2", "M2.5", "M3"] group:"Board" desc:"Screw size of the board's holes"
$screw = "M2.5"
@param choices:["screws", "pins"] group:"Board" desc:"Standoffs take self-tapping screws, or carry pins the board drops onto"
$fix = "screws"
@param 3..15 step:0.5 group:"Board" desc:"Standoff height, floor to board underside (mm)"
$so_h = 6
@param 4..15 step:0.5 group:"Plate" desc:"Plate margin outside the holes (mm)"
$margin = 7
@param 2..4 step:0.5 group:"Plate" desc:"Plate thickness (mm)"
$plate_t = 2.5
@param choices:["keyhole", "slots", "none"] group:"Plate" desc:"How the plate is fixed: keyholes for wall screws, slots for bolts, or nothing (tape)"
$mount = "keyhole"
$nom = if $screw == "M2" then 2 else if $screw == "M2.5" then 2.5 else 3
$tap_d = $nom * 0.85 # self-tapping hole
$pin_d = $nom - 0.25 # pin through a clearance hole (M2.5 board holes are 2.7-2.75)
$so_d = $nom * 2 + 2
$W = $dx + 2 * $margin
$D = $dy + 2 * $margin
$corner = min($margin, 6)
$pcb_t = 1.6
def rr($w, $h, $r) = rect ($w - 2 * $r) ($h - 2 * $r) | offset $r
def at_holes($s) = union [$s | translate (($i % 2) * $dx - $dx / 2) (floor($i / 2) * $dy - $dy / 2) 0 for $i in range(4)]
$plate = rr($W, $D, $corner) | extrude $plate_t
$so1 = cylinder ($so_d / 2) $so_h | floor | faces >Z | chamfer 0.4 | translate 0 0 $plate_t
$standoffs = at_holes($so1)
$tap1 = cylinder ($tap_d / 2) ($so_h - 0.5) | floor | translate 0 0 ($plate_t + 0.5)
$taps = at_holes($tap1)
$pin1 = cylinder ($pin_d / 2) ($pcb_t + 0.8) | floor | faces >Z | chamfer 0.4 | translate 0 0 ($plate_t + $so_h)
$pins = at_holes($pin1)
$body0 = $plate + $standoffs
$body1 = if $fix == "pins" then ($body0 + $pins) else ($body0 - $taps)
# --- fixing the plate: keyholes (8 mm head, 4 mm neck) or 4.5 x 9 slots, on the X axis
# --- halfway between the standoffs, inset from the short edges ----------------------
$kx = $dx / 2 - $so_d / 2 - 6 # keyhole centre, clear of the standoffs
assert $kx > 5
$key1 = (cylinder 4 ($plate_t + 2) | floor | translate 0 (-4) (-1))
+ (box 4 9 ($plate_t + 2) center:(true, false, false) | translate 0 (-4) (-1))
$keys = union [$key1 | translate (-$kx) 0 0, $key1 | translate $kx 0 0]
$slot1 = rect 4.5 4.5 | offset 2.25 | extrude ($plate_t + 2) | translate 0 0 (-1)
$slots = union [$slot1 | translate (-$kx) 0 0, $slot1 | translate $kx 0 0]
$body = if $mount == "keyhole" then ($body1 - $keys) else if $mount == "slots" then ($body1 - $slots) else $body1
assert $body.solids == 1
assert $body.bbox.x ~ $W
assert $body.bbox.y ~ $D
assert $body.bbox.z ~ ($plate_t + $so_h + (if $fix == "pins" then $pcb_t + 0.8 else 0))
assert $body.volume < $plate.volume + 4 * pi * ($so_d / 2) * ($so_d / 2) * $so_h + 4 * pi * $pin_d * $pin_d
print "plate (mm)" [$W, $D, $plate_t + $so_h]
$body