diff --git a/libtest.png b/libtest.png
index 86a1c36..4609f2d 100644
Binary files a/libtest.png and b/libtest.png differ
diff --git a/libtest.scad b/libtest.scad
index 3c89fdc..8e2f161 100644
--- a/libtest.scad
+++ b/libtest.scad
@@ -279,6 +279,9 @@ translate([x0, pulleys_y])
translate([x0, leadnuts_y])
leadnuts();
+translate([x0 + 120, leadnuts_y])
+ leadnuthousings();
+
translate([x0, linear_bearings_y]) {
linear_bearings();
rods();
diff --git a/readme.md b/readme.md
index af53976..61c2031 100644
--- a/readme.md
+++ b/readme.md
@@ -1650,6 +1650,16 @@ Nuts for leadscrews.
| `leadnut_od(type)` | Outer diameter of the shank |
| `leadnut_pitch(type)` | Screw pitch |
| `leadnut_screw(type)` | The type of the fixing screws |
+| `leadnuthousing_height(type)` | Height of housing |
+| `leadnuthousing_hole_pos(type)` | Offset from center for nut hole |
+| `leadnuthousing_length(type)` | Length of housing |
+| `leadnuthousing_mount_screw(type)` | Mounting screw |
+| `leadnuthousing_mount_screw_len(type)` | Mounting screw length |
+| `leadnuthousing_nut(type)` | Nut type this is suitable for |
+| `leadnuthousing_nut_screw_length(type)` | Length of mounting screw for nut |
+| `leadnuthousing_screw_dist_l(type)` | Distance between mounting holes length |
+| `leadnuthousing_screw_dist_w(type)` | Distance between mounting holes width |
+| `leadnuthousing_width(type)` | Width of housing |
### Functions
| Function | Description |
@@ -1661,15 +1671,21 @@ Nuts for leadscrews.
|:--- |:--- |
| `leadnut(type)` | Draw specified leadnut |
| `leadnut_screw_positions(type)` | Position children at the screw holes |
+| `leadnuthousing(type)` | Nut housing, to connect a lead nut to another object |
+| `leadnuthousing_nut_position(type)` | The position of the nut may be off-center, use this to get the position |
+| `leadnuthousing_nut_screw_positions(type)` | get screw positions to mount the nut to the nut housing |
+| `leadnuthousing_screw_positions(type)` | Get screw positions to mount the leadnut housing |
![leadnuts](tests/png/leadnuts.png)
### Vitamins
| Qty | Module call | BOM entry |
| ---:|:--- |:---|
-| 1 | `leadnut(LSN8x2)` | Leadscrew nut 8 x 2 |
+| 1 | `nuthousing(LNHT8x2)` | Lead Screw Nut Housing T8 |
+| 2 | `leadnut(LSN8x2)` | Leadscrew nut 8 x 2 |
| 1 | `leadnut(LSN8x8)` | Leadscrew nut 8 x 8 RobotDigg |
| 1 | `leadnut(SFU1610)` | Leadscrew nut for SFU1610 |
+| 4 | `screw(M3_cap_screw, 15)` | Screw M3 cap x 15mm |
Top
diff --git a/tests/leadnuts.scad b/tests/leadnuts.scad
index a9a67a6..57fc9e4 100644
--- a/tests/leadnuts.scad
+++ b/tests/leadnuts.scad
@@ -25,6 +25,26 @@ module leadnuts()
layout([for(n = leadnuts) leadnut_flange_dia(n)], 5)
leadnut(leadnuts[$i]);
+module leadnuthousings()
+ layout([for(n = leadnuthousings) leadnuthousing_width(n)], 5) {
+ rotate([0,0,270]) {
+ leadnuthousing(leadnuthousings[$i]);
+ explode(15)
+ leadnuthousing_nut_position(leadnuthousings[$i])
+ leadnut(leadnuthousing_nut(leadnuthousings[$i]));
+ explode(17 + leadnuthousing_nut_screw_length(leadnuthousings[$i]))
+ translate_z(leadnuthousing_height(leadnuthousings[$i])/2)
+ leadnuthousing_nut_screw_positions(leadnuthousings[$i])
+ screw(leadnut_screw(
+ leadnuthousing_nut(leadnuthousings[$i])),
+ leadnuthousing_nut_screw_length(leadnuthousings[$i])
+ );
+ }
+ }
+
if($preview)
- let($show_threads = true)
+ let($show_threads = true) {
leadnuts();
+ translate([0,50,0])
+ leadnuthousings();
+ }
diff --git a/tests/png/leadnuts.png b/tests/png/leadnuts.png
index 5ce1a79..ffc6c3a 100644
Binary files a/tests/png/leadnuts.png and b/tests/png/leadnuts.png differ
diff --git a/vitamins/leadnut.scad b/vitamins/leadnut.scad
index 313ff02..2c8bdf9 100644
--- a/vitamins/leadnut.scad
+++ b/vitamins/leadnut.scad
@@ -23,6 +23,7 @@
include <../utils/core/core.scad>
use <../utils/tube.scad>
use <../utils/thread.scad>
+use <../vitamins/screw.scad>
function leadnut_bore(type) = type[2]; //! Thread size
function leadnut_od(type) = type[3]; //! Outer diameter of the shank
@@ -41,6 +42,17 @@ function leadnut_colour(type) = type[15]; //! The colour
function leadnut_shank(type) = leadnut_height(type) - leadnut_flange_t(type) - leadnut_flange_offset(type); //! The length of the shank below the flange
+function leadnuthousing_length(type) = type[2]; //! Length of housing
+function leadnuthousing_width(type) = type[3]; //! Width of housing
+function leadnuthousing_height(type) = type[4]; //! Height of housing
+function leadnuthousing_hole_pos(type) = type[5]; //! Offset from center for nut hole
+function leadnuthousing_screw_dist_l(type) = type[6]; //! Distance between mounting holes length
+function leadnuthousing_screw_dist_w(type) = type[7]; //! Distance between mounting holes width
+function leadnuthousing_mount_screw(type) = type[8]; //! Mounting screw
+function leadnuthousing_mount_screw_len(type) = type[9]; //! Mounting screw length
+function leadnuthousing_nut(type) = type[10]; //! Nut type this is suitable for
+function leadnuthousing_nut_screw_length(type) = type[11]; //! Length of mounting screw for nut
+
module leadnut_screw_positions(type) { //! Position children at the screw holes
holes = leadnut_holes(type);
flat = leadnut_flat(type);
@@ -87,3 +99,58 @@ module leadnut(type) { //! Draw specified leadnut
}
}
}
+
+module leadnuthousing_screw_positions(type) { //! Get screw positions to mount the leadnut housing
+ for(p = [[-1,-1], [1,-1], [1,1], [-1,1]])
+ translate([p.x * leadnuthousing_screw_dist_l(type)/2, p.y * leadnuthousing_screw_dist_w(type)/2, 0])
+ children();
+}
+module leadnuthousing_nut_position(type) { //! The position of the nut may be off-center, use this to get the position
+ translate([leadnuthousing_hole_pos(type),0, leadnuthousing_height(type)/2])
+ children();
+}
+
+module leadnuthousing_nut_screw_positions(type) { //! get screw positions to mount the nut to the nut housing
+ translate([leadnuthousing_hole_pos(type),0, 0])
+ leadnut_screw_positions(leadnuthousing_nut(type))
+ children();
+}
+
+module leadnuthousing(type) { //! Nut housing, to connect a lead nut to another object
+ vitamin(str("nuthousing(", type[0], "): ", type[1]));
+
+ leadnut = leadnuthousing_nut(type);
+ screw = leadnut_screw(leadnut);
+ d = screw_radius(screw) * 2;
+ p = metric_coarse_pitch(d);
+ sl = leadnuthousing_nut_screw_length(type);
+ ms = leadnuthousing_mount_screw(type);
+ msl = leadnuthousing_mount_screw_len(type);
+ md = screw_radius (ms) * 2;
+ mp = metric_coarse_pitch(md);
+
+ color("silver")
+ difference() {
+ cube([leadnuthousing_length(type), leadnuthousing_width(type), leadnuthousing_height(type)], center = true);
+ translate([leadnuthousing_hole_pos(type),0,0]) {
+ cylinder(d=leadnut_od(leadnut), h=leadnuthousing_length(type)+2, center=true);
+ translate_z(leadnut_flange_offset(leadnut))
+ leadnut_screw_positions(leadnut)
+ cylinder(r=screw_radius(leadnut_screw(leadnut)), h=sl+1);
+ }
+
+ rotate([0,90,0])
+ leadnuthousing_screw_positions(type)
+ cylinder(r=screw_radius(ms), h=msl+1);
+
+ }
+ if(show_threads) {
+ translate([leadnuthousing_hole_pos(type),0,leadnuthousing_height(type)/2 - sl/2 - leadnut_flange_t(leadnut)])
+ leadnut_screw_positions(leadnut)
+ female_metric_thread(d, p, sl, center = true, colour = silver);
+ rotate([0,90,0])
+ translate_z(msl/2)
+ leadnuthousing_screw_positions(type)
+ female_metric_thread(md, mp, msl, center = true, colour = silver);
+ }
+}
diff --git a/vitamins/leadnuts.scad b/vitamins/leadnuts.scad
index 7397f5d..2095503 100644
--- a/vitamins/leadnuts.scad
+++ b/vitamins/leadnuts.scad
@@ -29,5 +29,9 @@ LSN8x8 = ["LSN8x8", "Leadscrew nut 8 x 8 RobotDigg", 8, 12.75,19, 25.4, 4.1, 0
SFU1610 = ["SFU1610", "Leadscrew nut for SFU1610", 16, 28, 42.5, 48, 10, 0, 6, 6, 38/2, M6_cap_screw, 5, 10, 40, "#DFDAC5"];
leadnuts = [LSN8x2, LSN8x8, SFU1610];
+// L W H Hole Mounting screws (top) Nut Nut mount screw
+// Pos Dist L Dist W Type L Length
+LNHT8x2 = [ "LNHT8x2", "Lead Screw Nut Housing T8", 30, 34, 30, -1, 20, 24, M4_cs_cap_screw, 15, LSN8x2, 15 ];
+leadnuthousings = [LNHT8x2];
use