diff --git a/ball_bearings.scad b/ball_bearings.scad new file mode 100644 index 0000000..5ad035a --- /dev/null +++ b/ball_bearings.scad @@ -0,0 +1,231 @@ +////////////////////////////////////////////////////////////////////// +// LibFile: ball_bearings.scad +// Models for standard ball bearing cartridges. +// Includes: +// include +// include +// FileGroup: Parts +// FileSummary: Models for standard ball bearing cartridges. +////////////////////////////////////////////////////////////////////// + + + +// Section: Ball Bearing Models + +// Module: ball_bearing() +// Description: +// Creates a model of a ball bearing assembly. +// Arguments: +// trade_size = String name of a standard ball bearing trade size. ie: "608", "6902ZZ", or "R8" +// id = Inner diameter of ball bearing assembly. +// od = Outer diameter of ball bearing assembly. +// width = Width of ball bearing assembly. +// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` +// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` +// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` +// Example: +// ball_bearing("608"); +// Example: +// ball_bearing("608ZZ"); +// Example: +// ball_bearing("R8"); +// Example: +// ball_bearing(id=12,od=32,width=10,shield=false); +module ball_bearing(trade_size, id, od, width, shield=true, anchor=CTR, spin=0, orient=UP) { + info = is_undef(trade_size)? [id, od, width, shield] : + ball_bearing_info(trade_size); + check = assert(all_defined(info), "Bad Input"); + id = info[0]; + od = info[1]; + width = info[2]; + shield = info[3]; + mid_d = (id+od)/2; + wall = (od-id)/2/3; + color("silver") + attachable(anchor,spin,orient, d=od, l=width) { + if (shield) { + tube(id=id, wall=wall, h=width); + tube(od=od, wall=wall, h=width); + tube(id=id+0.1, od=od-0.1, h=(wall*2+width)/2); + } else { + ball_cnt = floor(PI*mid_d*0.95 / (wall*2)); + difference() { + union() { + tube(id=id, wall=wall, h=width); + tube(od=od, wall=wall, h=width); + } + torus(r_maj=mid_d/2, r_min=wall); + } + for (i=[0:1:ball_cnt-1]) { + zrot(i*360/ball_cnt) right(mid_d/2) sphere(d=wall*2); + } + } + children(); + } +} + + + +// Section: Ball Bearing Info + + +// Function: ball_bearing_info() +// Description: +// Get dimensional info for a standard metric ball bearing cartridge. +// Returns `[SHAFT_DIAM, OUTER_DIAM, WIDTH, SHIELDED]` for the cylindrical cartridge. +// Arguments: +// size = Inner diameter of lmXuu bearing, in mm. +function ball_bearing_info(trade_size) = + assert(is_string(trade_size)) + let( + IN = 25.4, + data = [ + // trade_size, ID, OD, width, shielded + [ "R2", 1/8*IN, 3/8*IN, 5/32*IN, false], + [ "R3", 3/16*IN, 1/2*IN, 5/32*IN, false], + [ "R4", 1/4*IN, 5/8*IN, 0.196*IN, false], + [ "R6", 3/8*IN, 7/8*IN, 7/32*IN, false], + [ "R8", 1/2*IN, 9/8*IN, 1/4*IN, false], + [ "R10", 5/8*IN, 11/8*IN, 9/32*IN, false], + [ "R12", 3/4*IN, 13/8*IN, 5/16*IN, false], + [ "R14", 7/8*IN, 15/8*IN, 3/8*IN, false], + [ "R16", 8/8*IN, 16/8*IN, 3/8*IN, false], + [ "R18", 9/8*IN, 17/8*IN, 3/8*IN, false], + [ "R20", 10/8*IN, 18/8*IN, 3/8*IN, false], + [ "R22", 11/8*IN, 20/8*IN, 7/16*IN, false], + [ "R24", 12/8*IN, 21/8*IN, 7/16*IN, false], + + [ "R2ZZ", 1/8*IN, 3/8*IN, 5/32*IN, true ], + [ "R3ZZ", 3/16*IN, 1/2*IN, 5/32*IN, true ], + [ "R4ZZ", 1/4*IN, 5/8*IN, 0.196*IN, true ], + [ "R6ZZ", 3/8*IN, 7/8*IN, 7/32*IN, true ], + [ "R8ZZ", 1/2*IN, 9/8*IN, 1/4*IN, true ], + [ "R10ZZ", 5/8*IN, 11/8*IN, 9/32*IN, true ], + [ "R12ZZ", 3/4*IN, 13/8*IN, 5/16*IN, true ], + [ "R14ZZ", 7/8*IN, 15/8*IN, 3/8*IN, true ], + [ "R16ZZ", 8/8*IN, 16/8*IN, 3/8*IN, true ], + [ "R18ZZ", 9/8*IN, 17/8*IN, 3/8*IN, true ], + [ "R20ZZ", 10/8*IN, 18/8*IN, 3/8*IN, true ], + [ "R22ZZ", 11/8*IN, 20/8*IN, 7/16*IN, true ], + [ "R24ZZ", 12/8*IN, 21/8*IN, 7/16*IN, true ], + + [ "608", 8, 22, 7, false], + [ "629", 9, 26, 8, false], + [ "635", 5, 19, 6, false], + [ "6000", 10, 26, 8, false], + [ "6001", 12, 28, 8, false], + [ "6002", 15, 32, 9, false], + [ "6003", 17, 35, 10, false], + [ "6007", 35, 62, 14, false], + [ "6200", 10, 30, 9, false], + [ "6201", 12, 32, 10, false], + [ "6202", 15, 35, 11, false], + [ "6203", 17, 40, 12, false], + [ "6204", 20, 47, 14, false], + [ "6205", 25, 52, 15, false], + [ "6206", 30, 62, 16, false], + [ "6207", 35, 72, 17, false], + [ "6208", 40, 80, 18, false], + [ "6209", 45, 85, 19, false], + [ "6210", 50, 90, 20, false], + [ "6211", 55, 100, 21, false], + [ "6212", 60, 110, 22, false], + [ "6301", 12, 37, 12, false], + [ "6302", 15, 42, 13, false], + [ "6303", 17, 47, 14, false], + [ "6304", 20, 52, 15, false], + [ "6305", 25, 62, 17, false], + [ "6306", 30, 72, 19, false], + [ "6307", 35, 80, 21, false], + [ "6308", 40, 90, 23, false], + [ "6309", 45, 100, 25, false], + [ "6310", 50, 110, 27, false], + [ "6311", 55, 120, 29, false], + [ "6312", 60, 130, 31, false], + [ "6403", 17, 62, 17, false], + [ "6800", 10, 19, 5, false], + [ "6801", 12, 21, 5, false], + [ "6802", 15, 24, 5, false], + [ "6803", 17, 26, 5, false], + [ "6804", 20, 32, 7, false], + [ "6805", 25, 37, 7, false], + [ "6806", 30, 42, 7, false], + [ "6900", 10, 22, 6, false], + [ "6901", 12, 24, 6, false], + [ "6902", 15, 28, 7, false], + [ "6903", 17, 30, 7, false], + [ "6904", 20, 37, 9, false], + [ "6905", 25, 42, 9, false], + [ "6906", 30, 47, 9, false], + [ "6907", 35, 55, 10, false], + [ "6908", 40, 62, 12, false], + [ "16002", 15, 22, 8, false], + [ "16004", 20, 42, 8, false], + [ "16005", 25, 47, 8, false], + [ "16100", 10, 28, 8, false], + [ "16101", 12, 30, 8, false], + + [ "608ZZ", 8, 22, 7, true ], + [ "629ZZ", 9, 26, 8, true ], + [ "635ZZ", 5, 19, 6, true ], + [ "6000ZZ", 10, 26, 8, true ], + [ "6001ZZ", 12, 28, 8, true ], + [ "6002ZZ", 15, 32, 9, true ], + [ "6003ZZ", 17, 35, 10, true ], + [ "6007ZZ", 35, 62, 14, true ], + [ "6200ZZ", 10, 30, 9, true ], + [ "6201ZZ", 12, 32, 10, true ], + [ "6202ZZ", 15, 35, 11, true ], + [ "6203ZZ", 17, 40, 12, true ], + [ "6204ZZ", 20, 47, 14, true ], + [ "6205ZZ", 25, 52, 15, true ], + [ "6206ZZ", 30, 62, 16, true ], + [ "6207ZZ", 35, 72, 17, true ], + [ "6208ZZ", 40, 80, 18, true ], + [ "6209ZZ", 45, 85, 19, true ], + [ "6210ZZ", 50, 90, 20, true ], + [ "6211ZZ", 55, 100, 21, true ], + [ "6212ZZ", 60, 110, 22, true ], + [ "6301ZZ", 12, 37, 12, true ], + [ "6302ZZ", 15, 42, 13, true ], + [ "6303ZZ", 17, 47, 14, true ], + [ "6304ZZ", 20, 52, 15, true ], + [ "6305ZZ", 25, 62, 17, true ], + [ "6306ZZ", 30, 72, 19, true ], + [ "6307ZZ", 35, 80, 21, true ], + [ "6308ZZ", 40, 90, 23, true ], + [ "6309ZZ", 45, 100, 25, true ], + [ "6310ZZ", 50, 110, 27, true ], + [ "6311ZZ", 55, 120, 29, true ], + [ "6312ZZ", 60, 130, 31, true ], + [ "6403ZZ", 17, 62, 17, true ], + [ "6800ZZ", 10, 19, 5, true ], + [ "6801ZZ", 12, 21, 5, true ], + [ "6802ZZ", 15, 24, 5, true ], + [ "6803ZZ", 17, 26, 5, true ], + [ "6804ZZ", 20, 32, 7, true ], + [ "6805ZZ", 25, 37, 7, true ], + [ "6806ZZ", 30, 42, 7, true ], + [ "6900ZZ", 10, 22, 6, true ], + [ "6901ZZ", 12, 24, 6, true ], + [ "6902ZZ", 15, 28, 7, true ], + [ "6903ZZ", 17, 30, 7, true ], + [ "6904ZZ", 20, 37, 9, true ], + [ "6905ZZ", 25, 42, 9, true ], + [ "6906ZZ", 30, 47, 9, true ], + [ "6907ZZ", 35, 55, 10, true ], + [ "6908ZZ", 40, 62, 12, true ], + [ "16002ZZ", 15, 22, 8, true ], + [ "16004ZZ", 20, 42, 8, true ], + [ "16005ZZ", 25, 47, 8, true ], + [ "16100ZZ", 10, 28, 8, true ], + [ "16101ZZ", 12, 30, 8, true ], + ], + found = search([trade_size], data, 1)[0] + ) + assert(found!=[], str("Unsupported ball bearing trade size: ", trade_size)) + select(data[found], 1, -1); + + + +// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/linear_bearings.scad b/linear_bearings.scad index 93dc2e9..b44d9d5 100644 --- a/linear_bearings.scad +++ b/linear_bearings.scad @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////// // LibFile: linear_bearings.scad -// Mounts for LMxUU style linear bearings. +// Mounts and models for LMxUU style linear bearings. // Includes: // include // include @@ -12,58 +12,7 @@ include -// Section: Functions - - -// Function: get_lmXuu_bearing_diam() -// Description: Get outside diameter, in mm, of a standard lmXuu bearing. -// Arguments: -// size = Inner size of lmXuu bearing, in mm. -function get_lmXuu_bearing_diam(size) = lookup(size, [ - [ 4.0, 8.0], - [ 5.0, 10.0], - [ 6.0, 12.0], - [ 8.0, 15.0], - [ 10.0, 19.0], - [ 12.0, 21.0], - [ 13.0, 23.0], - [ 16.0, 28.0], - [ 20.0, 32.0], - [ 25.0, 40.0], - [ 30.0, 45.0], - [ 35.0, 52.0], - [ 40.0, 60.0], - [ 50.0, 80.0], - [ 60.0, 90.0], - [ 80.0, 120.0], - [100.0, 150.0] - ]); - - -// Function: get_lmXuu_bearing_length() -// Description: Get length, in mm, of a standard lmXuu bearing. -// Arguments: -// size = Inner size of lmXuu bearing, in mm. -function get_lmXuu_bearing_length(size) = lookup(size, [ - [ 4.0, 12.0], - [ 5.0, 15.0], - [ 6.0, 19.0], - [ 8.0, 24.0], - [ 10.0, 29.0], - [ 12.0, 30.0], - [ 13.0, 32.0], - [ 16.0, 37.0], - [ 20.0, 42.0], - [ 25.0, 59.0], - [ 30.0, 64.0], - [ 35.0, 70.0], - [ 40.0, 80.0], - [ 50.0, 100.0], - [ 60.0, 110.0], - [ 80.0, 140.0], - [100.0, 175.0] - ]); - +// Section: Generic Linear Bearings // Module: linear_bearing_housing() // Description: @@ -125,6 +74,34 @@ module linear_bearing_housing(d=15, l=24, tab=7, gap=5, wall=3, tabwall=5, screw } +// Module: linear_bearing() +// Description: +// Creates a rough model of a generic linear ball bearing cartridge. +// Arguments: +// l/length = The length of the linear bearing cartridge. +// od = The outer diameter of the linear bearing cartridge. +// id = The inner diameter of the linear bearing cartridge. +// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` +// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` +// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` +// Example: +// linear_bearing(l=24, od=15, id=8); +module linear_bearing(l, od=15, id=8, length, anchor=CTR, spin=0, orient=UP) { + l = first_defined([l, length, 24]); + attachable(anchor,spin,orient, d=od, l=l) { + color("silver") { + tube(id=id, od=od, l=l-1); + tube(id=od-1, od=od, l=l); + tube(id=id, od=id+1, l=l); + tube(id=id+2, od=od-2, l=l); + } + children(); + } +} + + +// Section: lmXuu Linear Bearings + // Module: lmXuu_housing() // Description: // Creates a model of a clamp to hold a standard sized lmXuu linear bearing cartridge. @@ -142,10 +119,65 @@ module linear_bearing_housing(d=15, l=24, tab=7, gap=5, wall=3, tabwall=5, screw // lmXuu_housing(size=10, wall=2, tab=6, screwsize=2.5); module lmXuu_housing(size=8, tab=7, gap=5, wall=3, tabwall=5, screwsize=3, anchor=BOTTOM, spin=0, orient=UP) { - d = get_lmXuu_bearing_diam(size); - l = get_lmXuu_bearing_length(size); + info = lmXuu_info(size); + d = info[0]; + l = info[1]; linear_bearing_housing(d=d, l=l, tab=tab, gap=gap, wall=wall, tabwall=tabwall, screwsize=screwsize, orient=orient, spin=spin, anchor=anchor) children(); } +// Module: lmXuu_bearing() +// Description: +// Creates a model of an lmXuu linear ball bearing cartridge. +// Arguments: +// size = Standard lmXuu inner size. +// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` +// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` +// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` +// Example: +// lmXuu_bearing(size=10); +module lmXuu_bearing(size=8, anchor=CTR, spin=0, orient=UP) { + info = lmXuu_info(size); + linear_bearing(l=info[1], id=size, od=info[0], anchor=anchor, spin=spin, orient=orient) children(); +} + + +// Section: lmXuu Linear Bearing Info + + +// Function: lmXuu_info() +// Description: +// Get dimensional info for a standard metric lmXuu linear bearing cartridge. +// Returns `[DIAM, LENGTH]` for the cylindrical cartridge. +// Arguments: +// size = Inner diameter of lmXuu bearing, in mm. +function lmXuu_info(size) = + let( + data = [ + // size, diam, length + [ 4, 8, 12], + [ 5, 10, 15], + [ 6, 12, 19], + [ 8, 15, 24], + [ 10, 19, 29], + [ 12, 21, 30], + [ 13, 23, 32], + [ 16, 28, 37], + [ 20, 32, 42], + [ 25, 40, 59], + [ 30, 45, 64], + [ 35, 52, 70], + [ 40, 60, 80], + [ 50, 80, 100], + [ 60, 90, 110], + [ 80, 120, 140], + [100, 150, 175], + ], + found = search([size], data, 1)[0] + ) + assert(found!=[], str("Unsupported lmXuu linear bearing size: ", size)) + select(data[found], 1, -1); + + + // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/tests/test_linear_bearings.scad b/tests/test_linear_bearings.scad index fb57ba5..a30d682 100644 --- a/tests/test_linear_bearings.scad +++ b/tests/test_linear_bearings.scad @@ -2,27 +2,15 @@ include <../std.scad> include <../linear_bearings.scad> -module test_get_lmXuu_bearing_diam() { - assert_equal(get_lmXuu_bearing_diam(4), 8); - assert_equal(get_lmXuu_bearing_diam(8), 15); - assert_equal(get_lmXuu_bearing_diam(10), 19); - assert_equal(get_lmXuu_bearing_diam(25), 40); - assert_equal(get_lmXuu_bearing_diam(50), 80); - assert_equal(get_lmXuu_bearing_diam(100), 150); +module test_lmXuu_info() { + assert_equal(lmXuu_info(4), [8, 12]); + assert_equal(lmXuu_info(8), [15, 24]); + assert_equal(lmXuu_info(10), [19, 29]); + assert_equal(lmXuu_info(25), [40, 59]); + assert_equal(lmXuu_info(50), [80, 100]); + assert_equal(lmXuu_info(100), [150, 175]); } -test_get_lmXuu_bearing_diam(); +test_lmXuu_info(); -module test_get_lmXuu_bearing_length() { - assert_equal(get_lmXuu_bearing_length(4), 12); - assert_equal(get_lmXuu_bearing_length(8), 24); - assert_equal(get_lmXuu_bearing_length(10), 29); - assert_equal(get_lmXuu_bearing_length(25), 59); - assert_equal(get_lmXuu_bearing_length(50), 100); - assert_equal(get_lmXuu_bearing_length(100), 175); -} -test_get_lmXuu_bearing_length(); - - - -// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap +// vim: expandtab shiftwidth=4 softtabstop=4 nowrap