Skip to content

Instantly share code, notes, and snippets.

@jasta
Created September 16, 2022 23:54
Show Gist options
  • Save jasta/5223b79e4972c0ba9bfb791a480bae44 to your computer and use it in GitHub Desktop.
Save jasta/5223b79e4972c0ba9bfb791a480bae44 to your computer and use it in GitHub Desktop.
//
// Cover that fits over a cut-out square in a PVC pipe and provides a flat mounting plate on top.
//
include <BOSL2/std.scad>
include <BOSL2/screws.scad>
// Smoothness of the part, which we need to be fairly high due to the fact that it needs to be
// roughly water tight.
$fn = 128;
inches = 25.4;
// Outer diameter of the pipe part that the cover fits (the part will have a slightly larger diameter)
pipe_OD = 4.125 * inches;
// Width as viewed from above (must be equal or less than pipe_OD or it won't attach)
part_width = 3.125 * inches;
// Thickness as viewed from the side, should be slightly thicker than the pipe wall
part_thickness = 0.5 * inches;
// Length as viewed from above and oriented along the pipe
part_length = 4 * inches;
// Width of the flat mounting portion (<= part_width)
flat_width = 2.125 * inches;
// Length of the flat mounting portion (<= part_length)
flat_length = 3 * inches;
// Thickness of the flat mounting portion (<= part_length)
flat_min_thickness = 1 * inches;
// Length of the screw that connects the top cover to the PVC pipe (> part_thickness)
pipe_screw_length = 0.5 * inches;
// Depth of the hole placed to attach a heat set insert (should be slightly longer than the
// actual insert so the melted plastic has somewhere to go)
mount_insert_length = 7.92 + 2;
// Width of the heat set insert hole, wide enough to set the bottom of the insert in place, but not so
// wide that it can fall through.
mount_insert_width = (5.38 + 5.8) / 2;
// Squared off mounting slots with this spacing as the side lengths.
mount_insert_spacing = 1 * inches;
translate([0, -1.2 * inches, 0]) {
cover_part();
}
//pipe_for_debugging();
module cover_part() {
difference() {
cover_part_base();
pipe_screws();
mount_inserts();
}
}
module cover_part_base() {
eps=0.01;
union() {
rounded_cover_part();
// Flat part on top
difference() {
translate([-flat_width / 2, 0, (part_length - flat_length) / 2])
cube([flat_width, (pipe_OD + flat_min_thickness) / 2, flat_length]);
pipe_portion();
}
}
}
module pipe_screws() {
part_OD = pipe_OD + part_thickness;
// Push the part over slightly closer to the stronger square part
screw_x_fudge = 0.96;
screw_z_inset_pct = 0.15;
screw_x = ((part_width + flat_width) / 4) * screw_x_fudge;
screw_angle = tan((screw_x / (part_OD / 2)) * (180/PI)) * (180/PI);
echo("screw_angle=", screw_angle);
echo("screw_x=", screw_x / inches, ", part_OD=", part_OD / inches);
for (orientation = [-1,1]) {
for (side = [0,1]) {
computed_screw_z_inset_pct = side == 0 ? screw_z_inset_pct : (1 - screw_z_inset_pct);
rotate([-90, 0, orientation * screw_angle])
translate([0, -(part_length * computed_screw_z_inset_pct), (part_OD / 2) - pipe_screw_length])
screw_hole(str("#8-32,", pipe_screw_length / inches), head="flat");
}
}
}
module mount_inserts() {
// Reorient the part so we're looking top-down
rotate([-90, 0, 0]) {
mount_x = -(mount_insert_spacing / 2);
mount_y = -(mount_insert_spacing + part_length) / 2;
// Why is this 99% margin required? It doesn't actually cut the top part off otherwise?
mount_z = (pipe_OD + flat_min_thickness) / 2 - mount_insert_length * 0.99;
translate([mount_x, mount_y, mount_z]) {
for (rel_x = [0, mount_insert_spacing]) {
for (rel_y = [0, mount_insert_spacing]) {
translate([rel_x, rel_y, 0])
cylinder(h=mount_insert_length, r=mount_insert_width);
}
}
}
}
}
module rounded_cover_part() {
intersection() {
// Hollow pipe fitting around pipe_OD
difference() {
cylinder(h=part_length, d=(pipe_OD + part_thickness));
pipe_portion();
}
// The portion of the surrounding pipe we want
translate([-part_width / 2, 0, 0])
cube([part_width, (pipe_OD + part_thickness) / 2, part_length]);
}
}
module pipe_portion() {
cylinder(h=part_length, d=pipe_OD);
}
module pipe_for_debugging() {
color("red")
translate([0,0,-5 * inches])
cylinder(h=(part_length + 10 * inches), d=pipe_OD);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment