include ; use ; use extruder_slot_gap_vert = 1; extruder_slot_gap_horz = 2; extruder_real_nut_dia = 6.3; extruder_add_nut_height = 5.0; extruder_arm_dia = extruder_travel + extruder_slot_gap_vert; extruder_arm_post_dia = 9.5; extruder_arm_width = 15.0; extruder_arm_axis_dia = 20.0; extruder_arm_flare_off = 3.0; extruder_arm_axis_h = 10.0; extruder_arm_post_h = 20.0; extruder_arm_off = 10; actuator_slot_w = extruder_arm_dia + bearing_outer + extruder_slot_gap_horz; actuator_slot_h = bearing_outer + extruder_slot_gap_vert; actuator_width = actuator_slot_w + 20; actuator_height = actuator_slot_h + 20; actuator_wall = bearing_height + 2; actuator_rod_len = 100; actuator_rod_len_add_bottom = 50; show_extruder_maximum_positions = false; extruder_maximum_positions = 12; linear_bearing_inner = 8.2; linear_bearing_outer = 15.0; linear_bearing_height = 25.0; linear_mount_inner = linear_bearing_outer + 0.5; linear_mount_wall = 3.0; linear_mount_outer = linear_mount_inner + 2 * linear_mount_wall; linear_mount_height = linear_bearing_height; linear_mount_width = 40.0; linear_mount_cut = 5.0; linear_mount_tab_off = linear_mount_wall; linear_mount_tab_width = 7.0; linear_mount_add_width = 8.0; linear_mount_add_height = 35.0; actuator_rod = 8.0; actuator_rod_wall = 2.5; actuator_rod_width = actuator_rod + 2 * actuator_rod_wall; actuator_rod_h = 6.0; actuator_rod_inset = 3.0; actuator_bearing_off = 12.5; actuator_bearing_dist = extruder_arm_off + extruder_arm_post_h - actuator_wall + actuator_rod_width - 1.5; // TODO not correct formula, but matches for now gearbox_spacer = gearbox_wall / 2; gb_endstop_off = 21; gb_endstop_slit_len = 1.0; $fn = 42; echo("extruder gear factor", pow(large_teeth / small_teeth, gear_stages)); module linear_bearing() { difference() { cylinder(d = linear_bearing_outer, h = linear_bearing_height); translate([0, 0, -1]) cylinder(d = linear_bearing_inner + 1, h = linear_bearing_height + 2); } } module gear_pulley(dia, teeth) { if (draw_pulleys) { gt2_2mm_pulley(teeth, pulley_teeth_height); } else { cylinder(d = dia, h = pulley_teeth_height); } translate([0, 0, pulley_teeth_height]) cylinder(d = pulley_mount_dia, h = pulley_mount_height); } module gear_stage() { translate([0, gears_dist / 2, (gear_stage_height - pulley_height) / 2]) { %color("yellow") rotate([0, 0, -acos(anim_pos_extruder * -2 + 1)]) gear_pulley(large_dia, large_teeth); %color("yellow") translate([0, -gears_dist, 0]) rotate([0, 0, -acos(anim_pos_extruder * -2 + 1)]) gear_pulley(small_dia, small_teeth); } } module center_plate() { difference() { cube([gearbox_width, gearbox_height, gear_stages_dist]); for(i = [-1, 1]) translate([gearbox_width / 2, gearbox_height / 2 + i * gears_dist / 2, 0]) { for(j = [-1, gear_stages_dist - bearing_height]) translate([0, 0, j]) cylinder(d = bearing_outer, h = bearing_height + 1); translate([0, 0, -1]) cylinder(d = axis_hole_diameter, h = gear_stages_dist + 2); } for (i = [0, gearbox_width - gear_stages_dist]) for (j = [-1, gearbox_height - extruder_wall_hole_depth]) translate([gear_stages_dist / 2 + i, j, gear_stages_dist / 2]) rotate([-90, 0, 0]) cylinder(d = extruder_wall_hole_nut, h = extruder_wall_hole_depth + 1); } } module outer_plate() { difference() { cube([gearbox_width, gearbox_height, gearbox_wall]); for (i = [0, gearbox_width - gearbox_wall]) for (j = [-1, gearbox_height - extruder_wall_hole_depth]) translate([gearbox_wall / 2 + i, j, gearbox_wall / 2]) rotate([-90, 0, 0]) cylinder(d = extruder_wall_hole_nut, h = extruder_wall_hole_depth + 1); } } module gb_front_wall() { difference() { color("cyan") translate([-gearbox_width / 2, -gearbox_height / 2, -gearbox_wall]) outer_plate(); for (i = [-1, 1]) translate([0, i * gears_dist / 2, -bearing_height]) outer_bearings(); } } module gb_back_wall() { difference() { color("cyan") translate([-gearbox_width / 2, -gearbox_height / 2, gear_stage_height * gear_stages + gear_stages_dist * (gear_stages - 1)]) outer_plate(); translate([-gearbox_width / 2, -gearbox_height / 2, gear_stage_height * gear_stages + gear_stages_dist * (gear_stages - 1)]) translate([0, (gear_stages % 2) ? 0 : gears_dist, 0]) translate([(gearbox_width - nema17_size) / 2, -nema17_size / 2 + (gearbox_height - gears_dist) / 2, 0]) { nema17_holes_face(3, motor_mount_height + 5, nema17_hole_size + screw_gap); translate([nema17_size / 2, nema17_size / 2, -1]) cylinder(d = nema17_center_size + 2, h = gearbox_wall + 2); } for (i = [-1, 1]) translate([0, i * gears_dist / 2, -bearing_height]) outer_bearings(); } } module gearbox() { gb_back_wall(); gb_front_wall(); %color("yellow") translate([0, (gear_stages % 2) ? 0 : gears_dist, 0]) translate([-gearbox_width / 2, -gearbox_height / 2, gear_stage_height * gear_stages + gear_stages_dist * (gear_stages - 1)]) translate([0, nema17_size, nema17_len + gearbox_wall]) translate([(gearbox_width - nema17_size) / 2, -nema17_size / 2 + (gearbox_height - gears_dist) / 2, 0]) rotate([180, 0, 0]) nema17(nema17_len); for (i = [0 : gear_stages - 1]) translate([0, 0, i * (gear_stage_height + gear_stages_dist)]) rotate([0, 0, i * 180]) { %gear_stage(); color("cyan") if (i < (gear_stages - 1)) translate([-gearbox_width / 2, -gearbox_height / 2, gear_stage_height]) center_plate(); } } module outer_bearings() { cylinder(d = bearing_outer, h = bearing_height + 0.1); translate([0, 0, -gearbox_wall + bearing_height - 1]) cylinder(d = axis_hole_diameter, h = gear_stages * gear_stage_height + gearbox_wall * 2 + gear_stages_dist * (gear_stages - 1) + 2); translate([0, 0, gear_stage_height * gear_stages + gear_stages_dist * (gear_stages - 1) + bearing_height - 0.1]) cylinder(d = bearing_outer, h = bearing_height + 0.1); } module linear_bearing_mount(w = linear_mount_width) { %color("magenta") linear_bearing(); difference() { color("green") hull() { cylinder(d = linear_mount_outer, h = linear_mount_height); translate([-w / 2, -(linear_mount_wall + linear_mount_outer) / 2, 0]) cube([w, linear_mount_wall, linear_mount_height]); } translate([0, 0, -1]) cylinder(d = linear_mount_inner, h = linear_mount_height + 2); translate([-linear_mount_cut / 2, 0, -1]) cube([linear_mount_cut, linear_mount_outer, linear_mount_height + 2]); } for (i = [1, -1]) scale([i, 1, 1]) translate([linear_mount_cut / 2, linear_mount_outer / 2 - linear_mount_tab_off, 0]) difference() { color("green") cube([linear_mount_wall, linear_mount_tab_width + linear_mount_tab_off, linear_mount_height]); for (i = [1, 3]) translate([-1, linear_mount_tab_off * 3 / 4 + linear_mount_tab_width / 2, linear_mount_height / 4 * i]) rotate([0, 90, 0]) cylinder(d = extruder_wall_hole_screw, h = linear_mount_wall + 2); } } module top_cover_holes(h, nuts = 0) { for (i = [0, gearbox_width - gearbox_wall]) for (j = [gearbox_wall / 2, gearbox_depth - gearbox_wall / 2]) translate([gearbox_wall / 2 + i, -1, j]) rotate([-90, 0, 0]) if (nuts) rotate([0, 0, 360 / 12]) cylinder(d = extruder_real_nut_dia, h = h + 2, $fn = 6); else cylinder(d = extruder_wall_hole_screw, h = h + 2); for (i = [0, gearbox_width - gear_stages_dist]) if (gear_stages > 1) for (j = [1 : gear_stages - 1]) translate([gear_stages_dist / 2 + i, -1, j * (gear_stage_height + gear_stages_dist) + gear_stages_dist / 2]) rotate([-90, 0, 0]) cylinder(d = extruder_wall_hole_screw, h = h + 2); } module top_cover_plate(variant = 0) { difference() { if (variant == 0) { color("green") translate([0, 0, -linear_mount_add_width]) cube([gearbox_width, gearbox_wall, gearbox_depth + linear_mount_add_width]); } else if (variant == 1) { color("green") cube([gearbox_width, gearbox_wall, gearbox_depth]); } else if (variant == 2) { color("red") cube([gearbox_width, gearbox_spacer, gearbox_depth]); } else { color("red") translate([-endstop_mount_slot_depth, 0, 0]) cube([gearbox_width + endstop_mount_slot_depth, gearbox_spacer, gearbox_depth]); } if (variant == 1) { top_cover_holes(gearbox_wall + actuator_bearing_off); } else { top_cover_holes(gearbox_wall); } } } module top_cover(variant) { top_cover_plate(variant); if (variant == 0) { translate([gearbox_width / 2, gearbox_wall + actuator_bearing_off, -actuator_bearing_dist]) rotate([-90, 0, 0]) linear_bearing_mount(); } else if (variant == 1) { for (i = [-1, 1]) translate([gearbox_width / 2 + i * gearbox_width / 4, gearbox_wall + actuator_bearing_off, -actuator_bearing_dist]) rotate([-90, 0, 0]) linear_bearing_mount(gearbox_width / 2); } color("green") difference() { hull() { if (variant == 0) { translate([(gearbox_width - linear_mount_width) / 2, gearbox_wall + actuator_bearing_off, (linear_mount_wall + linear_mount_outer) / 2 - linear_mount_wall - actuator_bearing_dist]) cube([linear_mount_width, linear_mount_height, linear_mount_wall]); } else if (variant == 1) { translate([0, gearbox_wall + actuator_bearing_off, (linear_mount_wall + linear_mount_outer) / 2 - linear_mount_wall - actuator_bearing_dist]) cube([gearbox_width, linear_mount_height, linear_mount_wall]); } if (variant == 0) { translate([0, gearbox_wall, -linear_mount_add_width]) cube([gearbox_width, linear_mount_add_height, linear_mount_add_width]); } else if (variant == 1) { translate([0, gearbox_wall - 1, 0]) cube([gearbox_width, extruder_add_nut_height + 1, gearbox_depth]); } } if (variant == 1) { translate([0, gearbox_wall - 2, 0]) top_cover_holes(actuator_bearing_off + linear_mount_height, 1); } } if (variant == 3) { difference() { union() { translate([-endstop_pcb_depth - endstop_mount_slot_depth, gb_endstop_off, 0]) rotate([180, 0, 90]) { %color("yellow") endstop_pcb(); color("red") hull() for (i = [0, 1]) translate([0, endstop_pcb_depth, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist - endstop_mount_slot_width / 2]) cube([endstop_mount_slot_length, endstop_mount_slot_depth, endstop_mount_slot_width]); } color("red") hull() { translate([-endstop_mount_slot_depth, 0, 0]) cube([endstop_mount_slot_depth, gearbox_spacer * 2, gearbox_depth]); translate([-endstop_mount_slot_depth, gb_endstop_off, -endstop_pcb_height + endstop_pcb_hole_dist_y + endstop_pcb_hole_dist]) cube([endstop_mount_slot_depth, endstop_mount_slot_length, endstop_pcb_height - endstop_pcb_hole_dist_y - endstop_pcb_hole_dist]); } } // hole slots for endstop pcb translate([-endstop_pcb_depth - endstop_mount_slot_depth, gb_endstop_off, 0]) rotate([180, 0, 90]) for (i = [0, 1]) translate([endstop_pcb_hole_dist_x, 1, endstop_pcb_height - endstop_pcb_hole_dist_y - i * endstop_pcb_hole_dist]) rotate([-90, 0, 0]) { for (j = [-1, 1]) translate([-j * gb_endstop_slit_len, 0, 0]) cylinder(d = endstop_pcb_hole, h = endstop_mount_slot_depth + 1); translate([-gb_endstop_slit_len, -endstop_pcb_hole / 2, 0]) cube([2 * gb_endstop_slit_len, endstop_pcb_hole, endstop_mount_slot_depth + 1]); } } } } module gearbox_assembly() { gearbox(); // spacers for (i = [0, 1]) translate([-gearbox_width / 2, gearbox_height / 2 - i * (gearbox_height + gearbox_spacer), -gearbox_wall]) top_cover(-i + 3); // top and bottom covers for (i = [0, 1]) translate([-gearbox_width / 2, gearbox_height / 2 - i * (gearbox_height + gearbox_wall) - (i * 2 - 1) * gearbox_spacer, -gearbox_wall]) top_cover(-i + 1); %color("grey") for (i = [-1, 1]) translate([0, i * gears_dist / 2, -gearbox_wall + 1]) cylinder(d = axis_diameter, h = gear_stages * gear_stage_height + gearbox_wall * 2 + gear_stages_dist * (gear_stages - 1) - 2); } module bearing() { difference() { cylinder(d = bearing_outer, h = bearing_height); translate([0, 0, -1]) cylinder(d = bearing_inner, h = bearing_height + 2); } } module extruder_arm() { difference() { color("blue") union() { // post for axis cylinder(d = extruder_arm_axis_dia, h = extruder_arm_axis_h); // lever body translate([-extruder_arm_width / 2, 0, 0]) cube([extruder_arm_width, extruder_arm_dia / 2, extruder_arm_axis_h]); translate([0, extruder_arm_dia / 2, 0]) { // lever body cylinder(d = extruder_arm_width, h = extruder_arm_axis_h); // post for bearing translate([0, 0, extruder_arm_axis_h]) cylinder(d1 = extruder_arm_width, d2 = extruder_arm_post_dia, h = extruder_arm_post_h - extruder_arm_axis_h - extruder_arm_flare_off); translate([0, 0, extruder_arm_axis_h + (extruder_arm_post_h - extruder_arm_axis_h - extruder_arm_flare_off)]) cylinder(d = extruder_arm_post_dia, h = extruder_arm_flare_off); } } // holes for axis, bearing post for (i = [0, 1]) translate([0, i * extruder_arm_dia / 2, -1]) cylinder(d = axis_hole_diameter, h = extruder_arm_post_h + 2); // holes for grub screws for(i = [-90, 90]) translate([0, 0, extruder_arm_axis_h / 2]) rotate([90, 0, i]) cylinder(d = belt_pulley_fix_dia, h = extruder_arm_axis_dia); } // bearing %color("yellow") translate([0, extruder_arm_dia / 2, extruder_arm_post_h + 1]) bearing(); // axis %color("grey") translate([0, 0, -extruder_arm_off]) cylinder(d = axis_diameter, h = extruder_arm_off + extruder_arm_axis_h); } module extruder_actuator() { difference() { color("orange") union() { cube([actuator_width, actuator_wall, actuator_height]); for (i = [0, 1]) for (j = [1, -1]) translate([i * actuator_width, 0, i * actuator_height]) rotate([0, i * 180, 0]) hull() { //union() { cube([actuator_width, actuator_wall, (actuator_height - actuator_slot_h) / 2]); translate([(actuator_width - actuator_rod_width) / 2 + i * gearbox_width / 4 * j, actuator_wall - actuator_rod_width, -actuator_rod_h]) cube([actuator_rod_width, actuator_rod_width, actuator_rod_h]); } } // slot for bearing translate([(actuator_width - actuator_slot_w) / 2, -1, (actuator_height - actuator_slot_h) / 2]) cube([actuator_slot_w, actuator_wall + actuator_rod_width + 2, actuator_slot_h]); // holes for rod for (i = [0, 1]) for (j = [1, -1]) translate([actuator_width / 2 + i * gearbox_width / 4 * j, actuator_wall - actuator_rod_width / 2, -actuator_rod_h - 1 + i * (actuator_height + actuator_rod_h / 2 + 1)]) cylinder(d = actuator_rod, h = actuator_rod_h + actuator_rod_inset + 1); // holes for rod grub screws for (i = [0, 1]) for (j = [1, -1]) for (r = [-45, 45, 180]) translate([actuator_width / 2 + i * gearbox_width / 4 * j, actuator_wall - actuator_rod_width / 2, -actuator_rod_h / 2 + i * (actuator_height + actuator_rod_h)]) rotate([90, 0, r]) cylinder(d = belt_pulley_fix_dia, h = actuator_rod_width); } // rods %color("yellow") for (i = [0, 1]) for (j = [1, -1]) translate([actuator_width / 2 + (-i + 1) * gearbox_width / 4 * j, actuator_rod_width / 2 + actuator_wall - actuator_rod_width, actuator_height + i * (-actuator_height - actuator_rod_len - actuator_rod_len_add_bottom) + (i - 1) * actuator_rod_inset]) cylinder(d = actuator_rod, h = actuator_rod_len + i * actuator_rod_len_add_bottom + actuator_rod_inset); } module extruder() { translate([0, gearbox_depth - gearbox_wall, gearbox_height / 2 + gearbox_wall]) rotate([90, 0, 0]) translate([0, 0, gearbox_depth - gearbox_wall * 2]) rotate([0, 180, 0]) gearbox_assembly(); translate([0, -extruder_arm_off, gearbox_wall + gearbox_height / 2 + gears_dist / 2]) rotate([90, 0, 0]) if (show_extruder_maximum_positions) { for (i = [0 : 360 / extruder_maximum_positions : 360]) rotate([0, 0, i]) extruder_arm(); } else { rotate([0, 0, use_anim ? ($t * -360) : (extruder_axis_position * -180)]) extruder_arm(); } translate([-actuator_width / 2, -actuator_wall - extruder_arm_post_h - extruder_arm_off + 1, -actuator_height / 2 + gearbox_wall + gearbox_height / 2 + gears_dist / 2 + extruder_arm_dia / 2]) if (show_extruder_maximum_positions) { for (i = [0 : 2 / extruder_maximum_positions : 1]) translate([0, 0, -i * extruder_arm_dia]) extruder_actuator(); } else { translate([0, 0, -anim_pos_extruder * extruder_arm_dia]) extruder_actuator(); } } //gb_back_wall(); //gb_front_wall(); //center_plate(); //top_cover(0); //top_cover(1); //top_cover(2); //top_cover(3); //gearbox_assembly(); //extruder_arm(); //extruder_actuator(); extruder();