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