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