render_moving_parts=false; slicer=false; microswitch_length=12.82; microswitch_height=6.5; microswitch_width=5.7; microswitch_hole_radius=1.1; microswitch_bottom_to_hole_center = microswitch_hole_radius + 0.6; microswitch_edge_to_hole1_center = microswitch_hole_radius + 2.05; microswitch_edge_to_hole2_center = microswitch_hole_radius + 8.7; microswitch_button_width = 2.82; microswitch_button_height = 1.1; microswitch_button_length = 1.1; microswitch_button_offset = 8.9 - microswitch_button_length; microswitch_contact_width = 0.36; microswitch_contact_height = 9.85 - microswitch_height; microswitch_contact_thickness = 0.36; microswitch_contact1_offset = 0.96; microswitch_contact2_offset = 6.31; microswitch_contact3_offset = 11.13; bushing_dia=6; wall=3; holder_wall=4.5; zrod_leadscrew_dist = 30; leadscrew_dia = 8; leadscrew_nut_wrench_size = 13; // plus some extra clearance leadscrew_nut_height = 6.5; anti_backlash_spring_space = 0; smooth_rod_dia= 8; leadscrew_nuttrap_height = 28; // Magic constant, haven't worked out why this needs to be this value.. microswitch_offset = -4.50; if (render_moving_parts) { // Z smooth rod translate([-zrod_leadscrew_dist/2,0,0]) { color([0.5,0.5,0.5]) { cylinder(r=4, h=50); } } } leadscrew_nuttrap(); translate([0,-15,0 ]) { bushing(); } module bushing() { difference() { cylinder(r=bushing_dia/2, $fn=32, h=smooth_rod_dia); translate([0,0,-0.5]) { cylinder(r=1, $fn=32, h=smooth_rod_dia + 1); } } } module screw() { translate([0,0,-40]) { cylinder(r=1, 80, $fn=10); } if (0) { translate([0,0,-holder_wall*2]) { cylinder(r=3.0, holder_wall, $fn=10); } translate([0,0,microswitch_width+holder_wall]) { cylinder(r=3.0, holder_wall, $fn=10); } } } module microswitch(block_only=false) { color([0.4, 0.4, 0.0]) { difference() { cube([microswitch_height, microswitch_length, microswitch_width]); if (!block_only) { translate([microswitch_bottom_to_hole_center, microswitch_edge_to_hole1_center, -2]) { cylinder(r=microswitch_hole_radius, 10, $fn=10); } translate([microswitch_bottom_to_hole_center, microswitch_edge_to_hole2_center,-2]) { cylinder(r=microswitch_hole_radius, 10, $fn=10); } } } } if (!block_only) { color([0.9, 0.9, 0.9]) { translate([microswitch_height, microswitch_button_offset, (microswitch_width - microswitch_button_width)/2]) { cube([microswitch_button_height, microswitch_button_length, microswitch_button_width]); } } color([0.9, 0.7, 0.1]) { translate([-microswitch_contact_height, microswitch_contact1_offset,(microswitch_width-microswitch_contact_width)/2]) { cube([microswitch_contact_height, microswitch_contact_thickness, microswitch_contact_width]); } translate([-microswitch_contact_height, microswitch_contact2_offset,(microswitch_width-microswitch_contact_width)/2]) { cube([microswitch_contact_height, microswitch_contact_thickness, microswitch_contact_width]); } translate([-microswitch_contact_height, microswitch_contact3_offset,(microswitch_width-microswitch_contact_width)/2]) { cube([microswitch_contact_height, microswitch_contact_thickness, microswitch_contact_width]); } } } } module nut_trap(nut_wrench_size,trap_height,vertical=true, clearance=0.2){ // M3 wrench size = 5.5 cornerdiameter = (((nut_wrench_size)/2)+clearance) / cos(180/6); rotate([0,vertical*90,0]) cylinder(h = trap_height, r = cornerdiameter, center=true, $fn = 6); } module everything() { union() { translate([0,0,leadscrew_nuttra]) { rotate([0,0,30]) { nut_trap(leadscrew_nut_wrench_size + 2*wall, leadscrew_nuttrap_height); } } cube([microswitch_width+holder_wall*2, microswitch_length + 10, leadscrew_nutttrap_height], center=true); } } holder_width = max(holder_wall*2 + microswitch_width, wall * 2 + smooth_rod_dia); module basic_block() { translate([0,0,leadscrew_nuttrap_height/2]) { nut_trap(leadscrew_nut_wrench_size+2*wall,leadscrew_nuttrap_height); } rotate([0,0,90-30]) { translate([-holder_width/2, 0,0]) { cube([holder_width, microswitch_length + leadscrew_nut_wrench_size/2, leadscrew_nuttrap_height]); cube([holder_width, zrod_leadscrew_dist + smooth_rod_dia/2 + bushing_dia, 8]); } } } if (render_moving_parts) { translate([zrod_leadscrew_dist/2,0,0]) { rotate([0,-90,90]) { translate([leadscrew_nuttrap_height-microswitch_height,leadscrew_nut_wrench_size/2,-microswitch_width/2]) { microswitch(); } } } } module holes() { translate([0,0,leadscrew_nuttrap_height/2]) nut_trap(leadscrew_nut_wrench_size,leadscrew_nuttrap_height+2); rotate([0,0,90-30]) { translate([-microswitch_width/2, 0, leadscrew_nuttrap_height - microswitch_height - microswitch_contact_height]) { cube([microswitch_width, microswitch_length + wall + leadscrew_nut_wrench_size/2 + 1, microswitch_height + microswitch_contact_height + 1]); translate([0, leadscrew_nut_wrench_size/2, microswitch_bottom_to_hole_center + microswitch_contact_height]) { translate([0, microswitch_edge_to_hole1_center, 0]) { rotate([0,90,0]) screw(); } translate([0, microswitch_edge_to_hole2_center, 0]) { rotate([0,90,0]) screw(); } } } translate([-microswitch_width/2, leadscrew_nut_wrench_size/2 + wall, -1]) { cube([microswitch_width, 100, leadscrew_nuttrap_height + 2]); } translate([-smooth_rod_dia/2, leadscrew_nut_wrench_size/2 + 1+ microswitch_length, -1]) { cube([smooth_rod_dia, 100, leadscrew_nuttrap_height + 2]); } translate([0, zrod_leadscrew_dist + smooth_rod_dia/2 + bushing_dia/2, 4]) { rotate([0,90,0]) screw(); } } } module leadscrew_nuttrap(){ translate([zrod_leadscrew_dist/2,0,0]) { rotate([0,0,30]) { difference(){ basic_block(); holes(); } translate([0,0,wall/2+leadscrew_nut_height]) difference(){ nut_trap(leadscrew_nut_wrench_size+2*wall-1,wall); rotate([0,0,-30]) cube([leadscrew_dia+1,leadscrew_nut_wrench_size*2,wall+2],center=true); } if (render_moving_parts) { color([0.5,0.5,0.5]) { cylinder(r=4, h=50); translate([0,0,leadscrew_nut_height/2]) { nut_trap(leadscrew_nut_wrench_size, leadscrew_nut_height); } translate([0,0,leadscrew_nuttrap_height - leadscrew_nut_height/2 - 1]) { nut_trap(leadscrew_nut_wrench_size, leadscrew_nut_height); } } } } } }