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