z-axis support for aluminum extrusion frame
[clinton/prusa3.git] / box_frame / bushing.scad
1 // PRUSA iteration3
2 // Bushing/bearing housings
3 // GNU GPL v3
4 // Josef Průša <josefprusa@me.com>
5 // Václav 'ax' Hůla <axtheb@gmail.com>
6 // http://www.reprap.org/wiki/Prusa_Mendel
7 // http://github.com/josefprusa/Prusa3
8
9 // ThingDoc entry
10 /**
11 * @id yBearingHolder
12 * @name Y Axis Bearing Holder
13 * @category Printed
14 */
15
16 include <configuration.scad>
17
18 // ensure that the part length is at least the length of bushing barrel plus add
19 function adjust_bushing_len(conf_b, h, add=layer_height*2) = ((conf_b[2]+add) > h) ? conf_b[2]+add : h;
20
21 //distance from the flat side of bushing holder to rod center
22 function bushing_foot_len(conf_b, h=10.5, add=4*single_wall_width) = ((conf_b[1]+add) > h) ? conf_b[1]+add : h;
23
24 function bushing_outer_radius(conf_b) = conf_b[1] + 4*single_wall_width;
25
26 // basic building blocks, housings for 1 bushing/bearing
27 // at [0,0] there is center of the smooth rod, pointing in Z
28
29 module linear_bushing_negative_single(conf_b=bushing_xy, h=0){
30 // barrel with the dimensions of a bushing/bearing
31 // to be substracted as needed
32 translate([0, 0, -0.01]) cylinder(r = conf_b[1], h = adjust_bushing_len(conf_b, h) + 0.02);
33 }
34
35 module linear_bearing_negative_single(conf_b=bushing_xy, h=0, shadow=false){
36 // barrel with the dimensions of the bearing
37 translate([0, 0, -0.01 + 3 * layer_height]) cylinder(r = conf_b[1], h = adjust_bushing_len(conf_b, h) + 0.02);
38 if (shadow == false) {
39 translate([0, -conf_b[1]+1, -0.01 + 3 * layer_height]) cube([30, 2 * conf_b[1] - 2, adjust_bushing_len(conf_b, h) + 0.02]);
40 }
41 }
42
43 module linear_bushing_single(conf_b=bushing_xy, h=0) {
44 // This is the printed barrel around bushing
45 // with foot pointing to -x
46 translate([-bushing_foot_len(conf_b), -7, 0]) cube([bushing_foot_len(conf_b), 14, adjust_bushing_len(conf_b, h)]);
47 cylinder(r=bushing_outer_radius(conf_b), h=adjust_bushing_len(conf_b, h));
48 }
49
50 module linear_bushing_negative(conf_b=bushing_xy, h=0){
51 // return simple negative stretched all along and a smooth rod
52 translate([0,0,-0.1]) cylinder(r = conf_b[0] + single_wall_width, h=adjust_bushing_len(conf_b, h)+0.2);
53 linear_bushing_negative_single(conf_b, h=adjust_bushing_len(conf_b, h));
54 }
55
56 module linear_bearing_negative(conf_b = bushing_xy, h = 0, shadow=false){
57 //same as linear_bushing_negative, but with z direction constrained parts
58 translate([0,0,-0.1]) cylinder(r = conf_b[0] + single_wall_width, h=adjust_bushing_len(conf_b, h, 8*layer_height)+0.2);
59 //lower bearing
60 linear_bearing_negative_single(conf_b, 0, shadow);
61 if (h > 2*conf_b[2] + 9*layer_height){
62 translate([0,0,h]) mirror([0,0,1]) linear_bearing_negative_single(conf_b, 0, shadow);
63 }
64 }
65
66 module linear_negative_preclean(conf_b = bushing_xy) {
67 // makes sure there is nothing interfering
68 // to be substracted before linear()
69 cylinder(r = conf_b[1] + single_wall_width, h=300, center=true);
70 }
71
72 module linear_bushing_sloped(conf_b=bushing_xy, h= 100){
73 // cut the bushing at angle, so it can be printed upside down
74 intersection(){
75 linear_bushing_single(conf_b, h = h);
76 // hardcoded, may need fixing for different barelled bushings
77 // atm there is only one and I am too lazy
78 translate([0, 0, -2]) rotate([0,-50,0]) cube([30, 40, 80], center=true);
79 }
80 }
81
82 module linear_bushing(conf_b=bushing_xy, h=0){
83 // this is the function to be used for type 1 linears (barrel holder)
84 // It has bushing on bottom and for parts longer than 3x the barel length on top too
85 difference() {
86 union() {
87 translate([-bushing_foot_len(conf_b), -7, 0]) cube([2, 14, adjust_bushing_len(conf_b, h)]);
88 linear_bushing_single(conf_b);
89 if (h>3*conf_b[2]) {
90 translate([0,0,h]) mirror([0,0,1]) linear_bushing_sloped(conf_b);
91 }
92 }
93 linear_bushing_negative(conf_b, h);
94 }
95 }
96
97 module linear_bearing(conf_b=bushing_xy, h=0){
98 difference() {
99 union() {
100 difference(){
101 union(){
102 //main block
103 //translate([-bushing_foot_len(conf_b), -7, 0]) cube([4, 14, adjust_bushing_len(conf_b, h, 9*layer_height)]); <- removed for duplicity:)
104 translate([0,0,0]) cylinder(h = adjust_bushing_len(conf_b, h, 9*layer_height), r=bushing_outer_radius(conf_b), $fn=60);
105 }
106 //smooth entry cut
107 translate([12,0,-1]) rotate([0,0,45]) cube([20, 20, 200], center=true);
108 }
109 intersection(){
110 translate([0, -(bushing_outer_radius(conf_b)), 0]) cube([30, 2*bushing_outer_radius(conf_b) , max(h, conf_b[2] + 9 * layer_height)]);
111 union() {
112 // upper clamp for long holders
113 if (h > 2*conf_b[2] + 9*layer_height || conf_b[2] > 45){
114 translate ([0,0, max(h, conf_b[2]) - 8 ]) bearing_clamp(conf_b, 2*(bushing_outer_radius(conf_b)));
115 }
116 //lower clamp
117 translate ([0, 0, 10]) bearing_clamp(conf_b, 2*(bushing_outer_radius(conf_b)));
118 }
119 }
120 }
121 //main axis
122 translate([0,0,-2]) cylinder(h = adjust_bushing_len(conf_b, h)+10, r=conf_b[1]);
123 //main cut
124 translate([0, -conf_b[1]+1, -1]) cube([30, 2*conf_b[1]-2, 200]);
125 }
126 difference() {
127 translate([-bushing_foot_len(conf_b), -7, 0]) cube([4, 14, adjust_bushing_len(conf_b, h, 9*layer_height)]);
128 linear_negative(conf_b, h);
129 }
130 }
131
132 // this should be more parametric
133 module firm_foot(conf_b = conf_b_lm8uu){
134 difference(){
135 union() {
136 translate([8.5/2,0,0]) cube_fillet([8.5, 42 + xy_delta * 2, 20], top=[11, 0, 11, 0], center=true);
137 }
138 translate([9, 14.5 + xy_delta, 0]) rotate([0, -90, 0]) screw(head_drop=1, $fn=small_hole_segments);
139 translate([9,-14.5 - xy_delta, 0]) rotate([0,-90,0]) screw(head_drop=1,$fn=small_hole_segments);
140 }
141 }
142
143 module y_bearing(conf_b=bushing_xy){
144
145 difference() {
146 union() {
147 difference() {
148 union() {
149 translate([-bushing_foot_len(conf_b), 0, 10]) firm_foot();
150 if (bushing_xy[2] > 45) {
151 translate([-bushing_foot_len(conf_b), 0, adjust_bushing_len(bushing_xy, 45) - 8]) mirror([0, 0, 1]) firm_foot();
152 }
153 }
154 linear_negative_preclean();
155 }
156 linear();
157 }
158 //linear_negative(bushing_xy, 20);
159 }
160 }
161
162 module bearing_clamp_brick(conf_b, h){
163 translate([-(m4_nut_diameter/2+conf_b[1]), 0, 0])
164 cube([m4_nut_diameter + 2 * conf_b[1], m4_nut_diameter + 1, h], center = true);
165 }
166
167 module bearing_clamp(conf_b=bushing_xy, h=0){
168 // inspired by John Ridley and Jonas Kühling
169 rotate([90, 0, 0]) {
170 difference(){
171 union(){
172 translate([m3_diameter / 2 + conf_b[1] + 0.3, 0, 0])
173 cylinder(h=h, r = m4_nut_diameter / 2 + 0.5, center = true);
174 translate([m3_diameter / 2 + conf_b[1] + 0.3, 0, 0]) {
175 bearing_clamp_brick(conf_b, h);
176 rotate([0,0,35])
177 bearing_clamp_brick(conf_b, h);
178 }
179 }
180 translate([m3_diameter / 2 + conf_b[1] + 0.3, 0, 0]) {
181 cylinder(r=m3_diameter / 2, h=h+2, center=true,$fn=small_hole_segments);
182 %cylinder(r=m3_diameter / 2, h=h+2, center=true,$fn=small_hole_segments);
183 }
184 }
185 }
186 }
187
188
189 module linear_negative(conf_b = bushing_xy, h = 0, shadow=false){
190 //selects right negative based on type
191 if (conf_b[3] == 0) {
192 linear_bearing_negative(conf_b, h, shadow);
193 } else {
194 linear_bushing_negative(conf_b, h, shadow);
195 }
196 }
197
198 module linear(conf_b = bushing_xy, h = 0){
199 //selects right model based on type
200 if (conf_b[3] == 0) {
201 linear_bearing(conf_b, h);
202 } else {
203 linear_bushing(conf_b, h);
204 }
205 %linear_negative(conf_b, h, true);
206 }
207
208 if (i_am_box == 1) {
209 %cylinder(r=bushing_xy[0], h=90);
210
211 y_bearing();
212 translate([0,52,0]) y_bearing();
213
214 if (bushing_xy[2] < 45) {
215 translate ([-30,23,0]) mirror([1,0,0]) y_bearing();
216 }
217 } else {
218 cube([0.1, 0.1, 0.1]);
219 }