1//////////////////////////////////////////////////////////////////////
  2// LibFile: linear_bearings.scad
  3//   Linear Bearing clips/holders.
  4//   To use, add these lines to the top of your file:
  5//   ```
  6//   include <BOSL/constants.scad>
  7//   use <BOSL/linear_bearings.scad>
  8//   ```
  9//////////////////////////////////////////////////////////////////////
 10
 11/*
 12BSD 2-Clause License
 13
 14Copyright (c) 2017, Revar Desmera
 15All rights reserved.
 16
 17Redistribution and use in source and binary forms, with or without
 18modification, are permitted provided that the following conditions are met:
 19
 20* Redistributions of source code must retain the above copyright notice, this
 21  list of conditions and the following disclaimer.
 22
 23* Redistributions in binary form must reproduce the above copyright notice,
 24  this list of conditions and the following disclaimer in the documentation
 25  and/or other materials provided with the distribution.
 26
 27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 28AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 29IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 30DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 31FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 32DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 33SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 34CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 35OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 36OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 37*/
 38
 39
 40include <shapes.scad>
 41include <metric_screws.scad>
 42
 43
 44// Section: Functions
 45
 46
 47// Function: get_lmXuu_bearing_diam()
 48// Description: Get outside diameter, in mm, of a standard lmXuu bearing.
 49// Arguments:
 50//   size = Inner size of lmXuu bearing, in mm.
 51function get_lmXuu_bearing_diam(size) = lookup(size, [
 52		[  4.0,   8.0],
 53		[  5.0,  10.0],
 54		[  6.0,  12.0],
 55		[  8.0,  15.0],
 56		[ 10.0,  19.0],
 57		[ 12.0,  21.0],
 58		[ 13.0,  23.0],
 59		[ 16.0,  28.0],
 60		[ 20.0,  32.0],
 61		[ 25.0,  40.0],
 62		[ 30.0,  45.0],
 63		[ 35.0,  52.0],
 64		[ 40.0,  60.0],
 65		[ 50.0,  80.0],
 66		[ 60.0,  90.0],
 67		[ 80.0, 120.0],
 68		[100.0, 150.0]
 69	]);
 70
 71
 72// Function: get_lmXuu_bearing_length()
 73// Description: Get length, in mm, of a standard lmXuu bearing.
 74// Arguments:
 75//   size = Inner size of lmXuu bearing, in mm.
 76function get_lmXuu_bearing_length(size) = lookup(size, [
 77		[  4.0,  12.0],
 78		[  5.0,  15.0],
 79		[  6.0,  19.0],
 80		[  8.0,  24.0],
 81		[ 10.0,  29.0],
 82		[ 12.0,  30.0],
 83		[ 13.0,  32.0],
 84		[ 16.0,  37.0],
 85		[ 20.0,  42.0],
 86		[ 25.0,  59.0],
 87		[ 30.0,  64.0],
 88		[ 35.0,  70.0],
 89		[ 40.0,  80.0],
 90		[ 50.0, 100.0],
 91		[ 60.0, 110.0],
 92		[ 80.0, 140.0],
 93		[100.0, 175.0]
 94	]);
 95
 96
 97// Module: linear_bearing_housing()
 98// Description:
 99//   Creates a model of a clamp to hold a generic linear bearing cartridge.
100// Arguments:
101//   d = Diameter of linear bearing. (Default: 15)
102//   l = Length of linear bearing. (Default: 24)
103//   tab = Clamp tab height. (Default: 7)
104//   tabwall = Clamp Tab thickness. (Default: 5)
105//   wall = Wall thickness of clamp housing. (Default: 3)
106//   gap = Gap in clamp. (Default: 5)
107//   screwsize = Size of screw to use to tighten clamp. (Default: 3)
108//   orient = Orientation of the housing.  Use the `ORIENT_` constants from `constants.scad`.  Default: `ORIENT_X`.
109//   align = Alignment of the housing by the axis-negative (size1) end.  Use the `V_` constants from `constants.scad`.  Default: `V_UP`
110// Example:
111//   linear_bearing_housing(d=19, l=29, wall=2, tab=6, screwsize=2.5);
112module linear_bearing_housing(d=15, l=24, tab=7, gap=5, wall=3, tabwall=5, screwsize=3, orient=ORIENT_X, align=V_UP)
113{
114	od = d+2*wall;
115	ogap = gap+2*tabwall;
116	tabh = tab/2+od/2*sqrt(2)-ogap/2;
117	orient_and_align([l, od, od], orient, align, orig_orient=ORIENT_X) {
118		difference() {
119			union() {
120				zrot(90) teardrop(r=od/2,h=l);
121				up(tabh) cube(size=[l,ogap,tab+0.05], center=true);
122				down(od/4) cube(size=[l,od,od/2], center=true);
123			}
124			zrot(90) teardrop(r=d/2,h=l+0.05);
125			up((d*sqrt(2)+tab)/2)
126				cube(size=[l+0.05,gap,d+tab], center=true);
127			up(tabh) {
128				fwd(ogap/2-2+0.01)
129					xrot(90) screw(screwsize=screwsize*1.06, screwlen=ogap, headsize=screwsize*2, headlen=10);
130				back(ogap/2+0.01)
131					xrot(90) metric_nut(size=screwsize, hole=false);
132			}
133		}
134	}
135}
136
137
138// Module: lmXuu_housing()
139// Description:
140//   Creates a model of a clamp to hold a standard sized lmXuu linear bearing cartridge.
141// Arguments:
142//   size = Standard lmXuu inner size.
143//   tab = Clamp tab height.  Default: 7
144//   tabwall = Clamp Tab thickness.  Default: 5
145//   wall = Wall thickness of clamp housing.  Default: 3
146//   gap = Gap in clamp.  Default: 5
147//   screwsize = Size of screw to use to tighten clamp.  Default: 3
148//   orient = Orientation of the housing.  Use the `ORIENT_` constants from `constants.scad`.  Default: `ORIENT_X`.
149//   align = Alignment of the housing by the axis-negative (size1) end.  Use the `V_` constants from `constants.scad`.  Default: `V_UP`
150// Example:
151//   lmXuu_housing(size=10, wall=2, tab=6, screwsize=2.5);
152module lmXuu_housing(size=8, tab=7, gap=5, wall=3, tabwall=5, screwsize=3, orient=ORIENT_X, align=V_UP)
153{
154	d = get_lmXuu_bearing_diam(size);
155	l = get_lmXuu_bearing_length(size);
156	linear_bearing_housing(d=d,l=l,tab=tab,gap=gap,wall=wall,tabwall=tabwall,screwsize=screwsize, orient=orient, align=align);
157}
158
159
160// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap