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