OpenFlexure Microscope OpenSCAD docs
libs/lib_sample_clips.scad
The modules needed to build sample clips for the microscope stage.
module default_sample_clip()
[Source]
module default_sample_clip(){ sample_clip(default_clip_clamp_point(), w=7, radius_of_curvature=6.5, rear_clearance=7); }
function default_clip_clamp_point()
[Source]
function default_clip_clamp_point() = [0, 20, -1];
module sample_clip( clamp_point, t=2.5, w=6, radius_of_curvature=undef, slope=30, rear_clearance=undef )
[Source]
module sample_clip(clamp_point, t=2.5, w=6, radius_of_curvature=undef, slope=30, rear_clearance=undef){ default_roc = clamp_point.z/2 + clamp_point.y*sin(slope) - t/2; //roc is the inner radius of curvature roc = if_undefined_set_default(radius_of_curvature, default_roc); cent_roc = roc + t/2; outer_roc = roc + t; //z distance from the contact point to the centre of the curved part z_dist = clamp_point.z - cent_roc; //a is the distance from the contact-point cylinder to the //centre of the curved part a = sqrt(clamp_point.y^2 + z_dist^2); //angle through which we must rotate the join between angle = acos(cent_roc / a) + atan(z_dist/clamp_point.y); join_pos = [0, cent_roc*cos(angle), cent_roc*sin(angle) + outer_roc]; difference(){ union(){ //anchor to stage cylinder(d=w, h=t, $fn=16); //arm that holds the sample clip_arm(t, w, join_pos, clamp_point); //curved part with cut out space for screw head difference(){ clip_curve(t, w, roc, angle, rear_clearance); translate_z(t-tiny()){ m3_cap_counterbore(bore_h=2*t, hole_h=2*t); } } } cylinder(d=m3_clearance_d(), h=99, center=true, $fn=16); } }
module clip_arm(t, w, join_pos, clamp_point)
[Source]
module clip_arm(t, w, join_pos, clamp_point){ sequential_hull(){ translate(join_pos){ rotate_y(90){ cylinder(d=t, h=w, center=true); } } translate(clamp_point + [0, 0, t/2]){ rotate_y(90){ cylinder(d=t, h=w, center=true); } } translate(clamp_point + [0, t, t]){ rotate_y(90){ cylinder(d=t, h=w, center=true); } } } }
module clip_curve(t, w, roc, angle, rear_clearance=undef)
[Source]
module clip_curve(t, w, roc, angle, rear_clearance=undef){ outer_roc = roc + t; ratio_is_one = is_undef(rear_clearance) || (rear_clearance > outer_roc); squeeze = ratio_is_one? 1 : rear_clearance/outer_roc; translate([-w/2, 0, roc+t]){ rotate_y(90){ difference(){ linear_extrude(w){ half_squished_ring(t=t, roc=roc, squeeze=squeeze); } translate_z(-49){ cube([99, 99, 99]); } translate_z(-49){ rotate(angle){ cube([99, 99, 99]); } } } } } }
module half_squished_ring(t, roc, squeeze=undef)
[Source]
module half_squished_ring(t, roc, squeeze=undef){ outer_roc = roc + t; ratio = if_undefined_set_default(squeeze, 1); difference(){ scale([1, ratio, 1]){ circle(outer_roc); } offset(-t){ scale([1, ratio, 1]){ circle(outer_roc); } } translate_y(99/2+tiny()){ square(99, center=true); } } difference(){ circle(outer_roc); circle(roc); translate_y(-(99/2+tiny())){ square(99, center=true); } } }