diff --git a/latch.scad b/latch.scad index d11a629..795d28f 100644 --- a/latch.scad +++ b/latch.scad @@ -6,48 +6,79 @@ $fn = $preview ? 32 : 64; -module _top_post(thickness, axis, ridge, funnel, tol) { - overlap = ridge+tol; - dia = 2*thickness+axis; - f_diag = (axis+2*funnel)/sqrt(2); +// Thickness of walls +thickness = 3.0; // [2:5:.5] + +// Diameter of axle +axle = 2.5; // [2:5:.5] + +// Clearance above bottom +clearance = 3; // [0:10:1] + +// Width of latch +width = 10; // [5:50:1] + +// Length of latch +length = 20; // [5:100:1] + +/* Other parameters - tune if necessary */ +// Tolerance of parts +tolerance = .2; // [0:1:.1] + +module _top_post(THICK, AXLE, CLEAR, TOL) { + dia = 2*THICK+AXLE; + center = AXLE/2+CLEAR; + f_diag = (2*AXLE)/sqrt(2); difference() { union() { - translate([0, -dia/2, 0]) cube([thickness, dia, dia/2+overlap]); - translate([thickness, 0, dia/2+overlap]) rotate([0, -90, 0]) cylinder(h=thickness, d=dia); + translate([0, -dia/2, 0]) cube([THICK, dia, AXLE/2+CLEAR]); + translate([THICK, 0, center]) rotate([0, -90, 0]) cylinder(h=THICK, d=dia); } - translate([thickness, 0, dia/2+overlap]) rotate([0, -90, 0]) cylinder(h=thickness, d=axis+tol); - translate([0, 0, dia/2-axis/2+overlap]) cube([thickness, dia/2, axis]); - translate([0, dia/2, dia/2+overlap+tol]) rotate([-45, 0, 0]) translate([0, -f_diag/2, -f_diag/2]) cube([thickness, f_diag, f_diag]); + translate([THICK, 0, center]) rotate([0, -90, 0]) cylinder(h=THICK, d=AXLE+TOL); + translate([0, AXLE/2, CLEAR]) rotate([90, 0, 90]) linear_extrude(THICK) polygon([[0, TOL/2], [0, AXLE-TOL/2], [dia/2, 1.5*AXLE], [dia/2, -0.5*AXLE]]); + translate([0, 0, CLEAR+TOL]) cube([THICK, AXLE/2, AXLE-2*TOL]); + translate([0, -dia, -dia]) cube([THICK, dia, dia]); } } -module latch_top(spacing=10, thickness=3, axis=2.5, ridge=.7, funnel=.7, tol=.2) { - translate([spacing/2, 0, 0]) _top_post(thickness, axis, ridge, funnel, tol); - translate([-spacing/2-thickness, 0, 0]) _top_post(thickness, axis, ridge, funnel, tol); +module latch_top(WIDTH=width, THICK=thickness, AXLE=axle, CLEAR=clearance, TOL=tolerance) { + translate([WIDTH/2+TOL, 0, 0]) _top_post(THICK, AXLE, CLEAR, TOL); + translate([-WIDTH/2-THICK-TOL, 0, 0]) _top_post(THICK, AXLE, CLEAR, TOL); } -module latch_tongue(length=20, width=10, thickness=3, axis=2.5, ridge=.7, tol=.2) { - overlap = ridge+thickness; - translate([width+thickness, 0, thickness/2]) rotate([0, -90, 0]) cylinder(h=width+2*thickness, d=axis); - hull() { - translate([width-tol, 0, thickness/2]) rotate([0, -90, 0]) cylinder(h=width-tol, d=thickness); - translate([width-tol, length+thickness-.5, .5]) rotate([0, -90, 0]) cylinder(h=width-tol, d=1); - translate([0, thickness/2, thickness/2]) cube([width-tol, length+thickness/2, thickness/2]); - } - translate([0, length, thickness]) cube([width-tol, thickness, overlap+ridge-.5]); - hull() { - translate([width-tol, length, thickness+overlap+ridge/2]) rotate([0, -90, 0]) cylinder(h=width-tol, d=ridge); - translate([width-tol, length+thickness-.5, thickness+overlap+ridge-.5]) rotate([0, -90, 0]) cylinder(h=width-tol, d=1); +module latch_tongue(LENGTH=length, WIDTH=width, THICK=thickness, AXLE=axle, TOL=tolerance) { + angle = 50; + mid = THICK/2; + translate([0, 0, THICK]) linear_extrude(WIDTH) { + hull() { + translate([mid, 0]) circle(d=THICK); + translate([AXLE/2+THICK, 0]) circle(d=AXLE); + } + hull() { + translate([mid, 0]) circle(d=THICK); + translate([mid, -LENGTH-3*AXLE]) circle(d=THICK); + } + difference() { + translate([AXLE/2+THICK, -LENGTH+AXLE/2]) circle(d=2*THICK+AXLE); + translate([AXLE/2+THICK, -LENGTH+AXLE/2]) circle(d=AXLE+TOL); + translate([THICK, -LENGTH+AXLE/2]) square([AXLE, THICK]); + translate([AXLE/2+THICK, -LENGTH+AXLE/2]) rotate(-angle) translate([-50, 0]) square(100, 100); + } + translate([AXLE/2+THICK+sin(angle)*(AXLE+THICK)/2, -LENGTH+AXLE/2-cos(angle)*(AXLE+THICK)/2]) circle(d=THICK); } + translate([AXLE/2+THICK, 0]) cylinder(h=WIDTH+2*THICK, d=AXLE); } -module latch_catch(width=10, thickness=3, axis=2.5, ridge=.7, tol=.2) { - overlap = ridge; - translate([-width/2, 0, 0]) cube([width-tol, thickness, (thickness+ridge)/2+overlap]); - translate([width/2-tol, 0, thickness/2+overlap]) rotate([0, -90, 0]) cylinder(h=width-tol, d=ridge); +module latch_catch(WIDTH=width, THICK=thickness, AXLE=axle, CLEAR=clearance, TOL=tolerance) { + center = AXLE/2+CLEAR; + translate([WIDTH/2+THICK+TOL, AXLE/2, center]) rotate([0, -90, 0]) cylinder(h=WIDTH+2*THICK+2*TOL, d=AXLE); + translate([WIDTH/2+TOL, 0, 0]) cube([THICK, AXLE, center]); + translate([-WIDTH/2-THICK-TOL, 0, 0]) cube([THICK, AXLE, center]); } -translate([-8, -20, 0]) cube([16, 24.25, 3]); -translate([0, 0, 3]) latch_top(); -translate([20, 0, 0]) mirror([0, 1, 0]) latch_tongue(); -translate([0, -20, 3]) latch_catch(); +translate([0, 0, 8.2]) rotate([0, 90, 0]) { + translate([-8.2, -20, 0]) cube([16.4, 24.25, 3]); + translate([0, 0, 3]) latch_top(); + translate([0, -20, 3]) latch_catch(); +} +translate([20, 0, 0]) latch_tongue(); diff --git a/latch.stl b/latch.stl index c1f892d..81448df 100644 Binary files a/latch.stl and b/latch.stl differ