244 lines
8.3 KiB
OpenSCAD
244 lines
8.3 KiB
OpenSCAD
// Pico enclosure that saddles a 25mm hoop bar (900mm hoop diameter).
|
||
// OpenSCAD 2021+: F5 preview, F6 render, export STL.
|
||
//
|
||
// Prints as body + lid. Clip onto the bar, secure with zip-ties through the
|
||
// saddle slots. Lid snaps into the bay rim.
|
||
//
|
||
// Frame: bar centre at origin, +Z away from hoop centre, +Y along hoop,
|
||
// +X across the bar.
|
||
|
||
/* [Hoop] */
|
||
// hoop_diameter kept for reference / future curved saddle (~0.9mm sag over 58mm)
|
||
hoop_diameter = 900; // tube centerline diameter (mm)
|
||
bar_diameter = 25; // bar / tube OD (mm)
|
||
bar_clearance = 0.35; // radial slip around the bar
|
||
|
||
/* [Pico bay] */
|
||
pico_length = 52.5; // clearance along hoop
|
||
pico_width = 22.0; // clearance across bar
|
||
pico_height = 12.0; // board + headers / wiring
|
||
wall = 2.0;
|
||
lid_thick = 2.0;
|
||
lid_lip = 1.4;
|
||
lid_clear = 0.3;
|
||
|
||
/* [Saddle / clamp] */
|
||
saddle_wrap_deg = 230; // >180 so it snaps onto the bar
|
||
saddle_wall = 2.6;
|
||
saddle_length = 58; // along hoop (mm)
|
||
ziptie_w = 3.8;
|
||
ziptie_h = 2.0;
|
||
ziptie_inset = 9; // from each saddle end toward centre
|
||
ear_len = 7; // zip-tie ears sticking out each side
|
||
ear_thick = 3;
|
||
|
||
/* [Ports / access] */
|
||
// Pico USB end faces +Y. Board is centred on the bay; hole centres are
|
||
// 2mm in from each short edge of the 51mm PCB.
|
||
board_length = 51.0;
|
||
board_width = 21.0;
|
||
board_thick = 1.0;
|
||
|
||
// Micro-USB B cutout (plug clearance)
|
||
usb_w = 9.0;
|
||
usb_h = 4.2;
|
||
usb_z_above_board = 0.2; // opening starts just above PCB top
|
||
|
||
// Power-out cable (opposite USB, -Y end) — LED / battery feed
|
||
power_hole_d = 6.0;
|
||
|
||
// BOOTSEL through lid (from USB-end PCB edge / board centre)
|
||
// Measured from Pico mechanical layout: ~5.7mm from USB edge, ~4.8mm left of centre.
|
||
bootsel_from_usb_edge = 5.7;
|
||
bootsel_x = -4.8; // -X when USB is at +Y
|
||
bootsel_hole_d = 4.5;
|
||
|
||
/* [Pico mounting posts] */
|
||
// Official Pico hole centres: 47.0 x 11.4 mm
|
||
hole_span_l = 47.0;
|
||
hole_span_w = 11.4;
|
||
post_od = 4.2;
|
||
post_id = 1.7; // M2 self-tap
|
||
post_h = 3.0;
|
||
|
||
/* [Quality] */
|
||
$fn = 80;
|
||
|
||
// ---------------------------------------------------------------------------
|
||
bar_r = bar_diameter / 2;
|
||
saddle_ir = bar_r + bar_clearance;
|
||
saddle_or = saddle_ir + saddle_wall;
|
||
|
||
bay_inner_l = pico_length;
|
||
bay_inner_w = pico_width;
|
||
bay_inner_h = pico_height;
|
||
bay_outer_l = bay_inner_l + 2 * wall;
|
||
bay_outer_w = max(bay_inner_w + 2 * wall, 2 * saddle_or + 1);
|
||
bay_outer_h = bay_inner_h + wall;
|
||
bay_floor_z = saddle_or;
|
||
|
||
// 2D clip profile in the plane normal to the bar (X = across, Y = up).
|
||
module saddle_profile() {
|
||
wrap = saddle_wrap_deg;
|
||
// Keep the top half solid (shoulders under the bay) and a partial ring below.
|
||
difference() {
|
||
union() {
|
||
// outer disc, then cut to wrap angle from the bottom
|
||
circle(r = saddle_or);
|
||
// rectangular shoulders up to bay floor
|
||
translate([-saddle_or, 0])
|
||
square([2 * saddle_or, saddle_or + 0.01]);
|
||
}
|
||
circle(r = saddle_ir);
|
||
// remove the open sector at the bottom (clip mouth)
|
||
half_gap = (360 - wrap) / 2;
|
||
rotate(-(90 + wrap / 2))
|
||
pie_slice(saddle_or + 1, 360 - wrap);
|
||
}
|
||
}
|
||
|
||
module pie_slice(r, ang) {
|
||
// Triangle fan covering `ang` degrees starting at +X, CCW.
|
||
steps = max(3, ceil(ang / 4));
|
||
polygon(concat([[0, 0]],
|
||
[for (i = [0:steps]) [r * cos(i * ang / steps), r * sin(i * ang / steps)]]));
|
||
}
|
||
|
||
module pico_posts() {
|
||
for (x = [-hole_span_w / 2, hole_span_w / 2])
|
||
for (y = [-hole_span_l / 2, hole_span_l / 2])
|
||
translate([x, y, 0])
|
||
difference() {
|
||
cylinder(h = post_h, d = post_od);
|
||
translate([0, 0, -0.05])
|
||
cylinder(h = post_h + 0.1, d = post_id, $fn = 20);
|
||
}
|
||
}
|
||
|
||
module body() {
|
||
// USB opening bottom (board sits on standoffs)
|
||
usb_z = bay_floor_z + wall + post_h + board_thick + usb_z_above_board;
|
||
|
||
difference() {
|
||
union() {
|
||
// Saddle — extruded along the bar (+Y). Hoop curvature over 58mm is
|
||
// ~0.9mm sag; ignored so the part prints and clips simply.
|
||
translate([0, saddle_length / 2, 0])
|
||
rotate([90, 0, 0])
|
||
linear_extrude(height = saddle_length, convexity = 8)
|
||
saddle_profile();
|
||
|
||
// Electronics bay on top of the saddle
|
||
translate([-bay_outer_w / 2, -bay_outer_l / 2, bay_floor_z])
|
||
cube([bay_outer_w, bay_outer_l, bay_outer_h]);
|
||
}
|
||
|
||
// Bay cavity
|
||
translate([-bay_inner_w / 2, -bay_inner_l / 2, bay_floor_z + wall])
|
||
cube([bay_inner_w, bay_inner_l, bay_inner_h + 0.2]);
|
||
|
||
// Lid ledge
|
||
translate([
|
||
-(bay_inner_w + 2 * lid_lip) / 2,
|
||
-(bay_inner_l + 2 * lid_lip) / 2,
|
||
bay_floor_z + bay_outer_h - lid_thick
|
||
])
|
||
cube([
|
||
bay_inner_w + 2 * lid_lip,
|
||
bay_inner_l + 2 * lid_lip,
|
||
lid_thick + 0.15
|
||
]);
|
||
|
||
// USB cutout — +Y end, height matches board on standoffs
|
||
translate([0, bay_outer_l / 2 - wall / 2, usb_z + usb_h / 2])
|
||
cube([usb_w, wall + 2, usb_h], center = true);
|
||
|
||
// Power-out hole — −Y end (opposite USB), for LED / battery wires
|
||
translate([
|
||
0,
|
||
-(bay_outer_l / 2 - wall / 2),
|
||
bay_floor_z + wall + power_hole_d / 2 + 1
|
||
])
|
||
rotate([90, 0, 0])
|
||
cylinder(h = wall + 2, d = power_hole_d, center = true);
|
||
|
||
// Ensure bar bore is clear through the whole saddle
|
||
rotate([90, 0, 0])
|
||
cylinder(h = saddle_length + 2, r = saddle_ir, center = true);
|
||
}
|
||
|
||
// Zip-tie ears on both sides — strap goes around bar + saddle
|
||
for (sx = [-1, 1])
|
||
translate([sx * (saddle_or + ear_len / 2 - 1.2), 0, -ear_thick / 2])
|
||
difference() {
|
||
cube([ear_len + 2.4, saddle_length - 2 * ziptie_inset + ziptie_w, ear_thick], center = true);
|
||
// don't fill the bar bore
|
||
rotate([90, 0, 0])
|
||
cylinder(h = saddle_length, r = saddle_ir, center = true);
|
||
for (sy = [-1, 1])
|
||
translate([0, sy * (saddle_length / 2 - ziptie_inset), 0])
|
||
cube([ear_len + 4, ziptie_w, ziptie_h], center = true);
|
||
}
|
||
|
||
// Board standoffs
|
||
translate([0, 0, bay_floor_z + wall])
|
||
pico_posts();
|
||
|
||
// Lid retention nubs
|
||
nub_z = bay_floor_z + bay_outer_h - lid_thick - 1.0;
|
||
for (x = [-1, 1])
|
||
translate([x * (bay_inner_w / 2 - 0.25), 0, nub_z])
|
||
rotate([90, 0, 0])
|
||
cylinder(h = 8, d = 1.5, center = true, $fn = 16);
|
||
}
|
||
|
||
module lid() {
|
||
outer_l = bay_inner_l + 2 * lid_lip - lid_clear;
|
||
outer_w = bay_inner_w + 2 * lid_lip - lid_clear;
|
||
inner_l = bay_inner_l - lid_clear;
|
||
inner_w = bay_inner_w - lid_clear;
|
||
|
||
// BOOTSEL in body frame: USB end at +Y. Lid shares the same XY origin.
|
||
bootsel_y = board_length / 2 - bootsel_from_usb_edge;
|
||
|
||
difference() {
|
||
union() {
|
||
translate([-outer_w / 2, -outer_l / 2, 0])
|
||
cube([outer_w, outer_l, lid_thick]);
|
||
translate([-inner_w / 2, -inner_l / 2, -lid_lip])
|
||
cube([inner_w, inner_l, lid_lip]);
|
||
}
|
||
// BOOTSEL access (finger / pen)
|
||
translate([bootsel_x, bootsel_y, -lid_lip - 0.5])
|
||
cylinder(h = lid_thick + lid_lip + 1, d = bootsel_hole_d, $fn = 32);
|
||
// Nail notch on USB end
|
||
translate([0, outer_l / 2 - 0.5, lid_thick / 2])
|
||
rotate([0, 90, 0])
|
||
cylinder(h = 14, d = 3.2, center = true, $fn = 24);
|
||
// Snap recesses matching body nubs
|
||
for (x = [-1, 1])
|
||
translate([x * (inner_w / 2 - 0.15), 0, -0.6])
|
||
rotate([90, 0, 0])
|
||
cylinder(h = 9, d = 1.7, center = true, $fn = 16);
|
||
}
|
||
}
|
||
|
||
module print_layout() {
|
||
body();
|
||
translate([bay_outer_w + 14, 0, lid_thick])
|
||
rotate([0, 180, 0])
|
||
lid();
|
||
}
|
||
|
||
module preview_on_bar() {
|
||
body();
|
||
translate([0, 0, bay_floor_z + bay_outer_h - lid_thick])
|
||
color("steelblue", 0.7) lid();
|
||
color("silver", 0.35)
|
||
rotate([90, 0, 0])
|
||
cylinder(h = 90, d = bar_diameter, center = true);
|
||
}
|
||
|
||
print_layout();
|
||
// preview_on_bar();
|