include ; use ; use $fn = 42; echo("extruder gear factor", pow(large_teeth / small_teeth, gear_stages)); 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 gearbox() { // back wall color("cyan") translate([-gearbox_width / 2, -gearbox_height / 2, -gearbox_wall]) outer_plate(); // front wall color("cyan") translate([-gearbox_width / 2, -gearbox_height / 2, gear_stage_height * gear_stages + gear_stages_dist * (gear_stages - 1)]) difference() { outer_plate(); 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); } } %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 top_cover() { difference() { cube([gearbox_width, gearbox_wall, gearbox_depth]); 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]) cylinder(d = extruder_wall_hole_screw, h = gearbox_wall + 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 = gearbox_wall + 2); } } module gearbox_assembly() { difference() { gearbox(); for (i = [-1, 1]) translate([0, i * gears_dist / 2, -bearing_height]) outer_bearings(); } color("green") for (i = [-1, 1]) scale([1, i, 1]) translate([-gearbox_width / 2, gearbox_height / 2, -gearbox_wall]) top_cover(); %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 piston() { //cylinder(d = piston_dia, h = piston_height); roundedcylinder(piston_dia, piston_height, piston_radius, true); } module piston_cyl() { difference() { cylinder(d = cylinder_dia, h = cylinder_height); translate([0, 0, piston_wall]) cylinder(d = piston_dia + 2 * piston_gap, h = cylinder_height + 2); } } module piston_visual() { color("blue") difference() { piston_cyl(); translate([-cylinder_dia / 2, -cylinder_dia / 2 - 1, -1]) cube([cylinder_dia, cylinder_dia / 2 + 1, cylinder_height + 2]); } translate([0, 0, piston_bottom_gap]) translate([0, 0, extruder_axis_anim_position]) { color("green") piston(); %color("orange") translate([0, 0, -actuator_length]) cylinder(d = 8, h = actuator_length); } } module extruder_lever() { translate([-extruder_lever_width / 2, 0, -extruder_lever_length + (extruder_lever_length - extruder_lever_hole_dist) / 2]) difference() { cube([extruder_lever_width, extruder_lever_depth, extruder_lever_length]); translate([extruder_lever_width / 2, -1, (extruder_lever_length - extruder_lever_hole_dist) / 2]) rotate([-90, 0, 0]) { for (i = [0, extruder_lever_hole_dist]) translate([0, -i, 0]) cylinder(d = extruder_lever_holes, h = extruder_lever_depth + 2); } } } module extruder() { translate([0, gearbox_depth - gearbox_wall, -gears_dist / 2]) rotate([90, 0, 0]) translate([0, 0, gearbox_depth - gearbox_wall * 2]) rotate([0, 180, 0]) gearbox_assembly(); translate([0, -cylinder_dia / 2, -cylinder_height - extruder_travel / 2]) { translate([0, 0, -additional_piston_offset]) piston_visual(); color("red") translate([0, 0, cylinder_height + extruder_travel / 2]) rotate([0, -acos(anim_pos_extruder * -2 + 1), 0]) extruder_lever(); } } module whole_extruder() { translate([0, 0, cylinder_height + extruder_travel / 2 + additional_piston_offset]) extruder(); } //gearbox_assembly(); //piston(); //piston_cyl(); //extruder_lever(); //center_plate(); //outer_plate(); //top_cover(); //piston_visual(); whole_extruder();