By bongkow · CC BY-NC 4.0
ParkBar: a parametric OpenSCAD design by bongkow, published under CC BY-NC 4.0. View it in 3D, read the code, and copy it to your account to change it.
// ParkBar: remote-controlled parking blocker. A 2020 aluminium profile stands up (90) to block a parking
// space and lies flat (0) so a car can drive over. Part 0 = assembly, part k = one printable part on z=0.
part = 0; // [0:Assembly, 1:Base, 2:Lid, 3:Hub]
NAME = "ParkBar";
$hl = 0; // set by the web app: the assembly draws only part $hl (red in P0); -1 = every part, lifted apart
bar_angle = 90; // [0:90] 0 = lying flat, 90 = standing
bar_len = 500; // 2020 profile length
debug = 0; // [0:off, 1:swing collisions, 2:bought parts vs base] 1 and 2 must render empty
/* [Bought parts: measure yours] */
bar_w = 20; // 2020 profile
sv_l = 40.7; // servo body length (MG996R assumed)
sv_w = 19.7; // servo body thickness
sv_h = 37; // servo body, bottom to case top
sv_shaft_off = 10; // shaft centre from the near body end
sv_tab_l = 54.5; // length over mounting tabs
sv_tab_t = 2.5;
sv_above_tab = 7.5; // case top above the tab's top face
sv_shaft = 6; // spline height above case top
sv_hole_x = 49.5; // tab hole spacing, long way
sv_hole_z = 10; // tab hole spacing, short way
horn_d = 21; // round servo horn disc
horn_t = 2.5;
horn_hole_r = 7.5; // horn screw circle radius
esp = [51.5, 28.5, 1.6]; // ESP32 DevKit (30 pin) board
bat = [77, 41, 21]; // 2x18650 holder
/* [Printed] */
clr = 0.2;
floor_t = 3;
wall = 3;
cheek_t = 5;
wall_h = 32;
lid_t = 2.4;
pivot_z = 18;
hub_wall = 3.8;
wall_s = 6; // hub wall, servo side
wall_p = 8; // hub wall, pivot bolt side
hub_len = 46;
bar_back = 6; // profile end behind the pivot
flange = 16;
anchor_d = 6.5; // M6 ground anchors
$fn = 48;
$ba = bar_angle;
bore = bar_w + 2 * clr;
hub_h = bore + 2 * hub_wall;
hub_w = bore + wall_s + wall_p;
hub_y0 = -(bore / 2 + wall_s);
hub_yp = hub_y0 + hub_w;
// Y stack on the servo side, from the hub outward
sv_top_y = hub_y0 + horn_t - 1 - sv_shaft; // servo case top
yb1 = sv_top_y - sv_above_tab + cheek_t; // box/cheek outer face (bar side)
yi1 = yb1 - cheek_t; // box inner face = servo tab seat
yk0 = hub_yp + 0.6; // far cheek
yk1 = yk0 + cheek_t;
yf1 = yk1 + flange;
x0 = -22;
xi0 = x0 + wall;
post = 7;
sv_cx = sv_l / 2 - sv_shaft_off; // servo body centre x
sv_tab_x1 = sv_cx + sv_tab_l / 2;
esp_x = sv_tab_x1 + 5.5;
bat_x = esp_x + esp.x + 3.5;
xi1 = bat_x + bat.x + 0.5 + post;
x1 = xi1 + wall;
yi0 = yi1 - bat.y - 1;
yb0 = yi0 - wall;
yf0 = yb0 - flange;
esp_y = yi0 + 0.5;
esp_z = floor_t + 10; // board sits high so the header pins hang free
stop_x = hub_h / 2 + 0.05;
posts = [[sv_cx, yi0 + post / 2], [sv_tab_x1 + 0.5 + post / 2, yi1 - post / 2],
[xi1 - post / 2, yi0 + post / 2], [xi1 - post / 2, yi1 - post / 2]];
anchors = [[0, yf0 + flange / 2], [x1 - 14, yf0 + flange / 2], [0, yf1 - flange / 2], [x1 - 14, yf1 - flange / 2]];
module show(k) if ($hl == 0 || $hl == k || $hl == -1) translate([0, 0, $hl == -1 ? k * 10000 : 0]) children();
/** "Pk:NAME" cut into the face at z=0 from below (mirrored so it reads correctly from underneath). */
module engrave(k, size = 4, depth = 0.4)
translate([0, 0, -0.01]) linear_extrude(depth + 0.01) mirror([1, 0, 0])
text(str("P", k, ":", NAME), size = size, halign = "center", valign = "center");
/** cylinder along +Y starting at the current origin */
module ycyl(d, h) rotate([-90, 0, 0]) cylinder(d = d, h = h);
// ---- P1 Base: floor with anchor flanges, electronics box, two cheeks around the hub, end stops ----
module part1() difference() {
union() {
translate([x0, yf0, 0]) cube([x1 - x0, yf1 - yf0, floor_t]);
difference() { // box; its bar-side wall is the servo cheek
translate([x0, yb0, 0]) cube([x1 - x0, yb1 - yb0, wall_h]);
translate([xi0, yi0, floor_t]) cube([xi1 - xi0, yi1 - yi0, wall_h]);
}
translate([-stop_x - 4, yk0, 0]) cube([40, cheek_t, wall_h]); // far cheek
translate([-stop_x - 4, yb1 - 0.01, 0]) cube([4, yk1 - yb1, 30]); // up stop (90)
translate([25, -bar_w / 2, 0]) cube([20, bar_w, pivot_z - hub_h / 2]); // down stop (0)
for (p = posts) translate([p.x - post / 2, p.y - post / 2, 0]) cube([post, post, wall_h]);
difference() { // ESP32 corner posts: 2.5 mm ledge under each board corner, 2 mm rim outside it
for (dx = [0, 1], dy = [0, 1])
translate([esp_x + dx * esp.x - (dx ? 2.5 : 2), esp_y + dy * esp.y - (dy ? 2.5 : 2), 0])
cube([4.5, 4.5, esp_z + esp.z + 1.5]);
translate([esp_x - clr, esp_y - clr, esp_z]) cube([esp.x + 2 * clr, esp.y + 2 * clr, 10]);
}
translate([bat_x - 2.5, yi0, 0]) cube([1.6, yi1 - yi0, floor_t + 8]); // battery divider
}
// servo body cutout, tab screw pilots, and screwdriver holes through the opposite wall
translate([-sv_shaft_off - clr, yi1 - 1, pivot_z - sv_w / 2 - clr]) cube([sv_l + 2 * clr, cheek_t + 2, sv_w + 2 * clr]);
for (sx = [-1, 1], sz = [-1, 1]) translate([sv_cx + sx * sv_hole_x / 2, 0, pivot_z + sz * sv_hole_z / 2]) {
translate([0, yi1 - 1, 0]) ycyl(2.5, cheek_t + 2);
translate([0, yb0 - 1, 0]) ycyl(5, wall + 2);
}
translate([0, yk0 - 1, pivot_z]) ycyl(5.4, cheek_t + 2); // M5 pivot bolt
for (p = posts) translate([p.x, p.y, wall_h - 12]) cylinder(d = 2.5, h = 13); // M3 lid screws
for (a = anchors) translate([a.x, a.y, -1]) cylinder(d = anchor_d, h = floor_t + 2);
translate([(x0 + x1) / 2, (yb0 + yb1) / 2, 0]) engrave(1);
}
// ---- P2 Lid: flat plate, engraved on the inside ----
module part2() difference() {
translate([x0, yb0, 0]) cube([x1 - x0, yb1 - yb0, lid_t]);
for (p = posts) translate([p.x, p.y, -1]) cylinder(d = 3.4, h = lid_t + 2);
translate([(x0 + x1) / 2 + 40, (yb0 + yb1) / 2, 0]) engrave(2);
}
// ---- P3 Hub: sleeve over the profile, servo horn on one side, M5 pivot on the other ----
module hub_raw() difference() { // lying-flat pose, pivot axis = Y through the origin
union() {
translate([0, hub_y0, -hub_h / 2]) cube([hub_len, hub_w, hub_h]);
translate([0, hub_y0, 0]) ycyl(hub_h, hub_w);
}
translate([-bar_back - clr, -bore / 2, -bore / 2]) cube([hub_len + bar_back + 1, bore, bore]);
translate([0, hub_y0 - 0.01, 0]) ycyl(horn_d + 0.4, horn_t + 0.01); // horn pocket
translate([0, hub_y0 - 0.01, 0]) ycyl(8, wall_s + 1); // horn screw access
for (a = [0:90:270]) translate([horn_hole_r * cos(a), hub_y0 - 0.01, horn_hole_r * sin(a)]) ycyl(2, wall_s + 1);
translate([0, hub_yp - wall_p + 1.5, 0]) ycyl(4.5, wall_p); // M5 pivot bolt taps in here
for (x = [15, 38]) translate([x, 0, bore / 2 - 0.5]) cylinder(d = 5.4, h = hub_wall + 1); // M5 into T-nuts
}
module part3() difference() { // printed on its pivot-side face
translate([0, 0, hub_yp]) rotate([-90, 0, 0]) hub_raw();
translate([26, 0, 0]) engrave(3);
}
module swing() translate([0, 0, pivot_z]) rotate([0, -$ba, 0]) children();
module hub_placed() swing() rotate([90, 0, 0]) translate([0, 0, -hub_yp]) part3();
// ---- bought parts ----
module label(t, s = 5) translate([0, 0, -0.6]) linear_extrude(0.7) text(t, size = s, halign = "center", valign = "center");
module bar_ghost() swing() difference() {
translate([-bar_back, -bar_w / 2, -bar_w / 2]) cube([bar_len, bar_w, bar_w]);
translate([hub_len + 70, 0, bar_w / 2]) label("2020 PROFILE", 7);
}
module fixed_ghosts() {
difference() { // servo
union() {
translate([-sv_shaft_off, sv_top_y - sv_h, pivot_z - sv_w / 2]) cube([sv_l, sv_h, sv_w]);
translate([sv_cx - sv_tab_l / 2, yi1 - sv_tab_t, pivot_z - sv_w / 2]) cube([sv_tab_l, sv_tab_t, sv_w]);
translate([0, sv_top_y - 0.01, pivot_z]) ycyl(6, sv_shaft);
}
translate([sv_cx, sv_top_y - sv_h / 2 - 2, pivot_z + sv_w / 2]) label("SERVO");
}
difference() { // ESP32
union() {
translate([esp_x, esp_y, esp_z]) cube(esp);
translate([esp_x + 4, esp_y + 4, esp_z]) cube([esp.x - 8, esp.y - 8, esp.z + 3]);
}
translate([esp_x + esp.x / 2, esp_y + esp.y / 2, esp_z + esp.z + 3]) label("ESP32");
}
difference() { // battery
translate([bat_x, yi0 + 0.5, floor_t]) cube(bat);
translate([bat_x + bat.x / 2, yi0 + 0.5 + bat.y / 2, floor_t + bat.z]) label("2x18650", 8);
}
}
module ghosts() if ($hl <= 0) { fixed_ghosts(); bar_ghost(); }
if (debug == 1) for (a = [0:15:90]) intersection() {
union() { part1(); translate([0, 0, wall_h]) part2(); fixed_ghosts(); }
union() { hub_placed($ba = a); bar_ghost($ba = a); }
} else if (debug == 2) intersection() { part1(); fixed_ghosts(); }
else if (part == 0) {
show(1) part1();
show(2) translate([0, 0, wall_h]) part2();
show(3) hub_placed();
ghosts();
}
if (debug == 0 && part == 1) part1();
if (debug == 0 && part == 2) part2();
if (debug == 0 && part == 3) part3();