diff --git a/libtest.png b/libtest.png index 04b1238..3763fe3 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/readme.md b/readme.md index 7326623..3040856 100644 --- a/readme.md +++ b/readme.md @@ -2658,6 +2658,8 @@ Linear rails with carriages. | `rail_carriage(type)` | Carriage type | | `rail_end(type)` | Minimum distance screw can be from the end | | `rail_end_screw(type)` | Screw used for ends only (Countersink used for better location) | +| `rail_groove_offset(type)` | Offset of centre of groove from top of rail | +| `rail_groove_width(type)` | Groove width | | `rail_height(type)` | Height of rail section | | `rail_hole(type)` | Screw hole diameter | | `rail_pitch(type)` | Distance between screws | @@ -2678,7 +2680,7 @@ Linear rails with carriages. |:--- |:--- | | `carriage(type, rail, end_colour = grey(20)` | Draw the specified carriage | | `carriage_hole_positions(type)` | Position children over screw holes | -| `rail(type, length)` | Draw the specified rail | +| `rail(type, length, colour = grey(90)` | Draw the specified rail | | `rail_assembly(type, length, pos, carriage_end_colour = grey(20)` | Rail and carriage assembly | | `rail_hole_positions(type, length, first = 0, screws = 100, both_ends = true)` | Position children over screw holes | | `rail_screws(type, length, thickness, screws = 100, index_screws = undef)` | Place screws in the rail | diff --git a/tests/png/rails.png b/tests/png/rails.png index bc29aa4..9eb9ae2 100644 Binary files a/tests/png/rails.png and b/tests/png/rails.png differ diff --git a/vitamins/rail.scad b/vitamins/rail.scad index b1d8ea6..24c791e 100644 --- a/vitamins/rail.scad +++ b/vitamins/rail.scad @@ -33,6 +33,9 @@ function rail_bore_depth(type) = type[7]; //! Counter bore depth function rail_screw(type) = type[8]; //! Screw type function rail_carriage(type) = type[9]; //! Carriage type function rail_end_screw(type) = type[10]; //! Screw used for ends only (Countersink used for better location) +function rail_groove_offset(type)=type[11]; //! Offset of centre of groove from top of rail +function rail_groove_width(type)=type[12]; //! Groove width + function rail_screw_height(type, screw) = rail_height(type) - rail_bore_depth(type) + screw_head_depth(screw, rail_hole(type)); //! Position screw taking into account countersink into counterbored hole function rail_travel(type, length) = length - carriage_length(rail_carriage(type)); //! How far the carriage can travel @@ -134,43 +137,45 @@ module carriage(type, rail, end_colour = grey(20), wiper_colour = grey(20)) { // carriage_end(type, end_w, end_h, end_l); } -module rail(type, length) { //! Draw the specified rail +module rail(type, length, colour = grey(90), use_polycircles = false) { //! Draw the specified rail width = rail_width(type); height = rail_height(type); vitamin(str("rail(", type[0], ", ", length, "): Linear rail ", type[0], " x ", length, "mm")); - color(grey(90)) { + color(colour) { + rbr = rail_bore(type) / 2; + w = corrected_radius(rbr) * 2 + 2 * eps; // width of core big enough for the holes linear_extrude(height - rail_bore_depth(type)) difference() { - square([length, width], center = true); + square([length, w], center = true); + rail_hole_positions(type, length) - circle(d = rail_hole(type)); + if (use_polycircles) + poly_circle(rail_hole(type) / 2); + else + circle(d = rail_hole(type)); } + translate_z(rail_height(type) - rail_bore_depth(type)) + linear_extrude(rail_bore_depth(type)) difference() { + square([length, w], center = true); - translate_z(rail_height(type) - rail_bore_depth(type)) { - h1 = rail_bore_depth(type) > 2 ? rail_bore_depth(type) / 3 : rail_bore_depth(type) / 2; - h0 = rail_bore_depth(type) > 2 ? (rail_bore_depth(type) - h1) / 2 : 0; - h2 = rail_bore_depth(type) - h1 - h0; - - linear_extrude(h0) difference() { - square([length, width], center = true); rail_hole_positions(type, length) - circle(d = rail_bore(type)); + if (use_polycircles) + poly_circle(rbr); + else + circle(rbr); } - translate_z(h0) - linear_extrude(h1) difference() { - w1 = max(width - 2, rail_bore(type)); - square([length, w1], center = true); - rail_hole_positions(type, length) - circle(d = rail_bore(type)); - } - translate_z(h0 + h1) - linear_extrude(h2) difference() { - square([length, width], center = true); - rail_hole_positions(type, length) - circle(d = rail_bore(type)); - } - } + + go = height - rail_groove_offset(type); + gw = rail_groove_width(type); + gd = gw / 2; + sw = (width - w) / 2; + for (m = [0, 1]) + mirror([0, m, 0]) + translate([0, -width / 2]) + rotate([0, -90, 0]) + linear_extrude(length, center = true) + polygon([ [0, 0], [0, sw], [height, sw], [height, 0], [go + gw/2, 0], [go, gd], [go - gw/2, 0] ]); } } diff --git a/vitamins/rails.scad b/vitamins/rails.scad index 0600a7b..02a6761 100644 --- a/vitamins/rails.scad +++ b/vitamins/rails.scad @@ -32,14 +32,14 @@ SSR15_carriage = [ 40.3, 23.3, 34, 24, 4.5, 0, 26, M4_cap_screw ]; // Rails // // -// Wr Hr E P D d h -MGN5 = [ "MGN5", 5, 3.6, 5, 15, 3.6, 2.4, 0.8, M2_cs_cap_screw, MGN5_carriage, M2_cs_cap_screw ]; // Screw holes too small for M2 heads -MGN7 = [ "MGN7", 7, 5, 5, 15, 4.3, 2.4, 2.6, M2_cap_screw, MGN7_carriage, M2_cs_cap_screw ]; -MGN9 = [ "MGN9", 9, 6, 7.5, 20, 6.0, 3.5, 3.5, M3_cap_screw, MGN9_carriage, M3_cs_cap_screw ]; -MGN12= [ "MGN12", 12, 8, 10, 25, 6.0, 3.5, 4.5, M3_cap_screw, MGN12_carriage, M3_cs_cap_screw ]; -MGN12H=[ "MGN12H",12, 8, 10, 25, 6.0, 3.5, 4.5, M3_cap_screw, MGN12H_carriage,M3_cs_cap_screw ]; -MGN15= [ "MGN15", 15, 10, 10, 40, 6.0, 3.5, 5.0, M3_cap_screw, MGN15_carriage, M3_cs_cap_screw ]; -SSR15= [ "SSR15", 15, 12.5,10, 60, 7.5, 4.5, 5.3, M4_cap_screw, SSR15_carriage, M4_cs_cap_screw ]; +// Wr Hr E P D d h go gw +MGN5 = [ "MGN5", 5, 3.6, 5, 15, 3.6, 2.4, 0.8, M2_cs_cap_screw, MGN5_carriage, M2_cs_cap_screw, 1, 1 ]; // Screw holes too small for M2 heads +MGN7 = [ "MGN7", 7, 5, 5, 15, 4.3, 2.4, 2.6, M2_cap_screw, MGN7_carriage, M2_cs_cap_screw, 1.5, 1.5 ]; +MGN9 = [ "MGN9", 9, 6, 7.5, 20, 6.0, 3.5, 3.5, M3_cap_screw, MGN9_carriage, M3_cs_cap_screw, 1.5, 1.5 ]; +MGN12= [ "MGN12", 12, 8, 10, 25, 6.0, 3.5, 4.5, M3_cap_screw, MGN12_carriage, M3_cs_cap_screw, 2.25, 2.75 ]; +MGN12H=[ "MGN12H",12, 8, 10, 25, 6.0, 3.5, 4.5, M3_cap_screw, MGN12H_carriage,M3_cs_cap_screw, 2.25, 2.75]; +MGN15= [ "MGN15", 15, 10, 10, 40, 6.0, 3.5, 5.0, M3_cap_screw, MGN15_carriage, M3_cs_cap_screw, 2.5, 2.75 ]; +SSR15= [ "SSR15", 15, 12.5,10, 60, 7.5, 4.5, 5.3, M4_cap_screw, SSR15_carriage, M4_cs_cap_screw, 2.5, 2.75 ]; rails = [MGN5, MGN7, MGN9, MGN12, MGN12H, MGN15, SSR15];