Merge pull request #58 from AxTheB/master
[clinton/prusa3.git] / box_frame / x-end.scad
index 6501dcf..c8a5d06 100644 (file)
@@ -9,35 +9,41 @@
 include <configuration.scad>
 use <bushing.scad>
 use <inc/bearing-guide.scad>
+use <y-drivetrain.scad>
 
 //height and width of the x blocks depend on x smooth rod radius
 x_box_height = 52 + 2 * bushing_xy[0];
 x_box_width = (bushing_xy[0] <= 4) ? 17.5 : bushing_xy[0] * 2 + 9.5;
+bearing_height = max ((bushing_z[2] > 30 ? x_box_height : (2 * bushing_z[2] + 8)), x_box_height);
 
 module x_end_motor(){
 
     mirror([0, 1, 0]) {
 
-        x_end_base([3, 3, 0, 0], thru=false);
+        x_end_base([3, 3, min((bushing_xy[0] - 4) * 2, 3), 0], thru=false);
 
 
         translate([0, -z_delta - 2, 0]) difference(){
             union(){
-                translate([-13.75, -14 + z_delta / 2, 30]) cube_fillet([17.5, 14 + z_delta, x_box_height], center = true, vertical=[0, 0, 3, 1.5], top=[0, 3, 6, 3], $fn=16);
-                translate([-10, -34, 9]) intersection(){
-                    translate([0, 0, 0]) cube_fillet([10, 37, x_box_height - 42], center = true, vertical=[0, 0, 0, 0], top=[0, 3, 5, 3]);
-                    translate([-10/2, 10, -26]) rotate([45, 0, 0]) cube_fillet([10, 60, 60], radius=2);
-                    translate([0, 0, 21]) cube([10, 60, x_box_height], center = true);
+                intersection() {
+                    translate([-15, -34, 30]) cube([20, 60, x_box_height], center = true);
+                    union() {
+                        translate([-13.75, -14 + z_delta / 2, 24]) cube_fillet([17.5, 14 + z_delta, 55], center = true, vertical=[0, 0, 3, 1.5], top=[0, 3, 6, 3], $fn=16);
+                        translate([-10, -34, 9]) intersection(){
+                            translate([0, 0, -5]) cube_fillet([10, 37, 28], center = true, vertical=[0, 0, 0, 0], top=[0, 3, 5, 3]);
+                            translate([-10/2, 10, -26]) rotate([45, 0, 0]) cube_fillet([10, 60, 60], radius=2);
+                        }
+                    }
                 }
-                translate([-15, -32, 30.25]) rotate([90, 0, 0])  rotate([0, 90, 0]) nema17(places=[1, 0, 1, 1], h=10);
+                translate([-15.5, -32, 30.25]) rotate([90, 0, 0])  rotate([0, 90, 0]) nema17(places=[1, 0, 1, 1], h=11);
             }
 
             // motor screw holes
             translate([21-5, -21-11, 30.25]){
                 // belt hole
-                translate([-30, 11, 0]) cube([10, 36, 20], center = true);
+                translate([-30, 11, -0.25]) cube([11, 36, 24], center = true);
                 //motor mounting holes
-                translate([-29, 0, 0]) rotate([0, 0, 0])  rotate([0, 90, 0]) nema17(places=[1, 1, 0, 1], holes=true, shadow=5, $fn=7, h=8);
+                translate([-28.5, 0, 0]) rotate([0, 0, 0])  rotate([0, 90, 0]) nema17(places=[1, 1, 0, 1], holes=true, shadow=5, $fn=small_hole_segments, h=8);
             }
         }
         //smooth rod caps
@@ -46,29 +52,27 @@ module x_end_motor(){
     }
 }
 
-module x_end_base(vfillet=[3, 3, 3, 3], thru=true, len=40){
+module x_end_base(vfillet=[3, 3, 3, 3], thru=true, len=40, offset=0){
 
     difference(){
         union(){
-            translate([-10 - bushing_xy[0], -10 + len / 2, 30]) cube_fillet([x_box_width, len, x_box_height], center=true, vertical=vfillet, top=[5, 3, 5, 3]);
+            translate([-10 - bushing_xy[0], -10 + len / 2 + offset, 30]) cube_fillet([x_box_width, len, x_box_height], center=true, vertical=vfillet, top=[5, 3, 5, 3]);
 
             translate([0, 0, 4 - bushing_xy[0]]) {
                 //rotate([0, 0, 0]) translate([0, -9.5, 0]) 
-                translate([z_delta, 0, 0]) linear(bushing_z, x_box_height);
+                translate([z_delta, 0, 0]) render(convexity = 5) linear(bushing_z, bearing_height);
                 // Nut trap
-                //difference(){
-                translate([-2, 17, 4]) cube_fillet([20, 16, 8], center = true, vertical=[6, 0, 0, 0], $fn=4);
-                    //bottom hole
+                translate([-2, 18, 5]) cube_fillet([20, 14, 10], center = true, vertical=[8, 0, 0, 5]);
                 //}
             }
         }
         // here are bushings/bearings
-        translate([z_delta, 0, 4 - bushing_xy[0]]) linear_negative(bushing_z, x_box_height);
+        translate([z_delta, 0, 4 - bushing_xy[0]]) linear_negative(bushing_z, bearing_height);
 
         // belt hole
-        translate([-5.5-10+1.5, 22-9, 30]) cube([idler_width + 1, 55, 27], center = true);
+        translate([-5.5 - 10 + 1.5, 22 - 9 + offset, 30]) cube([max(idler_width + 2, 11), 55, 27], center = true);
 
-        translate([-10 - bushing_xy[0], 0, 0]) {
+        translate([-10 - bushing_xy[0], offset, 0]) {
             if(thru == true){
                 translate([0, -11, 6]) rotate([-90, 0, 0]) pushfit_rod(bushing_xy[0] * 2 + 0.2, 50);
                 translate([0, -11, xaxis_rod_distance+6]) rotate([-90, 0, 0]) pushfit_rod(bushing_xy[0] * 2 + 0.2, 50);
@@ -77,12 +81,14 @@ module x_end_base(vfillet=[3, 3, 3, 3], thru=true, len=40){
                 translate([0, -7, xaxis_rod_distance+6]) rotate([-90, 0, 0]) pushfit_rod(bushing_xy[0] * 2 + 0.2, 50);
             }
         }
-        translate([0, 0, 4 - bushing_xy[0]]) {  // m5 nut insert
-                    translate([0, 17, -10]) rotate([0,0,45]){
-                        cylinder(h = 40, r=2.75);
-                        //nut slid in
-                        translate([3, 0, 14]) cube([9.2*2, 9.2*sqrt(3/4)+0.4, 4.1], center = true);
-                    }
+        translate([0, 0, 5 - bushing_xy[0]]) {  // m5 nut insert
+            translate([0, 17, 0]) rotate([0, 0, 10]){
+                //rod
+                translate([0, 0, -1]) cylinder(h=(4.1 / 2 + 5), r=2.75, $fn=32);
+                //nut
+                translate([0, 0, 9]) cylinder(r=4.6, h=14.1, center = true, $fn=6);
+
+            }
         }
     }
     //threaded rod
@@ -91,23 +97,26 @@ module x_end_base(vfillet=[3, 3, 3, 3], thru=true, len=40){
 
 module x_end_idler(){
     difference() {
-        x_end_base(len=45);
+        x_end_base(len=45 + z_delta / 3, offset=-10 - z_delta / 3);
         // idler hole
-        translate([-14, 26, 29]) rotate([0, 90, 0]) {
-            idler_assy(idler_bearing);
-            translate([0,20,0])
-                cube([idler_assy_r_outer(idler_bearing) * 2, 40, idler_width + 1], center=true);
-            if (idler_bearing[3]) {
-                %translate([0, 0, -(idler_width / 2)]) bearing_guide_outer();
-                %translate([0, 0, idler_width / 2]) mirror([0, 0, 1]) bearing_guide_inner();
-            }
+        translate([-20, -15 - z_delta / 2, 30]) {
+            rotate([0, 90, 0]) cylinder(r=m4_diameter / 2, h=33, center=true, $fn=small_hole_segments);
+            translate([15 - 2 * single_wall_width, 0, 0]) rotate([90, 0, 90]) cylinder(r=m4_nut_diameter_horizontal / 2, h=3, $fn=6);
+
         }
+        #translate([-6 - x_box_width, 11, 29.5 - (max(idler_bearing[0], 16) / 2)]) cube([x_box_width + 1, 11, 1.5 + max(idler_bearing[0], 16)]);
     }
+        %translate([-14, -9, 30.5 - (max(idler_bearing[0], 16) / 2)]) x_tensioner();
+}
+
+module x_tensioner(len=62, idler_height=max(idler_bearing[0], 16)) {
+        idlermount(len=len, rod=m4_diameter / 2, idler_height=idler_height, narrow_len=46, narrow_width=idler_width + 2 - single_wall_width);
 }
 
-mirror([0, 0, 0]) x_end_idler(thru=true);
-// translate([40, 40, 0]) x_end_idler(thru=false);
-translate([50, 0, 0]) x_end_motor();
+
+translate([-40, 0, 4 - bushing_xy[0]]) x_tensioner();
+mirror([1, 0, 0]) x_end_idler(thru=true);
+mirror([1, 0, 0]) translate([-50, 0, 0]) x_end_motor();
 
 module pushfit_rod(diameter, length){
     cylinder(h = length, r=diameter/2, $fn=30);
@@ -117,7 +126,7 @@ module pushfit_rod(diameter, length){
 }
 
 if (idler_bearing[3] == 1) {
-    translate([-25, -20 - idler_bearing[0] / 2, 0]) {
+    translate([-25, -30 - idler_bearing[0] / 2, 0]) {
         render() bearing_guide_inner();
         translate([idler_bearing[0]+10, 0, 0])
             render()bearing_guide_outer();