mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-09-09 14:40:44 +02:00
Added screw threads to most things that are threaded.
Added a mechanism for tests.py and views.py to have command line options.
This commit is contained in:
@@ -52,21 +52,24 @@ module d_pillar() { //! Draw a pillar for a D-connector
|
||||
height = 4.5;
|
||||
screw = 2.5;
|
||||
screw_length = 8;
|
||||
pitch = metric_coarse_pitch(screw);
|
||||
|
||||
translate_z(-screw_length)
|
||||
if(show_threads)
|
||||
color(d_pillar_color * 0.7)
|
||||
male_metric_thread(screw, metric_coarse_pitch(screw), screw_length, false, false);
|
||||
male_metric_thread(screw, pitch, screw_length, false, top = 0, colour = d_pillar_color);
|
||||
else
|
||||
color(d_pillar_color)
|
||||
cylinder(d = screw, h = screw_length + 1);
|
||||
|
||||
color(d_pillar_color)
|
||||
color(d_pillar_color) {
|
||||
linear_extrude(height = height)
|
||||
difference() {
|
||||
circle(r = rad, $fn = 6);
|
||||
circle(d = screw);
|
||||
}
|
||||
}
|
||||
if(show_threads)
|
||||
female_metric_thread(screw, pitch, height, false, colour = d_pillar_color);
|
||||
}
|
||||
|
||||
module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specified D plug, which can be IDC, PCB or plain solder bucket
|
||||
|
@@ -22,6 +22,7 @@
|
||||
//
|
||||
include <../core.scad>
|
||||
use <../utils/quadrant.scad>
|
||||
use <../utils/thread.scad>
|
||||
|
||||
function insert_length(type) = type[1]; //! Length
|
||||
function insert_outer_d(type) = type[2]; //! Outer diameter at the top
|
||||
@@ -45,17 +46,18 @@ module insert(type) { //! Draw specified insert
|
||||
|
||||
vitamin(str("insert(", type[0], "): Heatfit insert M", insert_screw_diameter(type)));
|
||||
$fn = 64;
|
||||
explode(20, offset =[0, 0, -5]) color(brass) translate_z(eps) {
|
||||
vflip(){
|
||||
r1 = insert_screw_diameter(type) / 2;
|
||||
r2 = insert_barrel_d(type) / 2;
|
||||
r3 = insert_ring3_d(type) / 2;
|
||||
r4 = insert_ring2_d(type) / 2;
|
||||
r5 = insert_outer_d(type) / 2;
|
||||
h1 = ring1_h;
|
||||
h2 = ring1_h + gap;
|
||||
h3 = ring1_h + gap + ring2_h;
|
||||
h4 = ring1_h + gap + ring2_h + gap;
|
||||
thread_d = insert_screw_diameter(type);
|
||||
explode(20, offset =[0, 0, -5]) translate_z(eps) vflip() {
|
||||
r1 = thread_d / 2;
|
||||
r2 = insert_barrel_d(type) / 2;
|
||||
r3 = insert_ring3_d(type) / 2;
|
||||
r4 = insert_ring2_d(type) / 2;
|
||||
r5 = insert_outer_d(type) / 2;
|
||||
h1 = ring1_h;
|
||||
h2 = ring1_h + gap;
|
||||
h3 = ring1_h + gap + ring2_h;
|
||||
h4 = ring1_h + gap + ring2_h + gap;
|
||||
color(brass)
|
||||
rotate_extrude()
|
||||
polygon([
|
||||
[r1, 0],
|
||||
@@ -72,7 +74,9 @@ module insert(type) { //! Draw specified insert
|
||||
[r5, h1],
|
||||
[r5, 0],
|
||||
]);
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, metric_coarse_pitch(thread_d), length, center = false, colour = brass);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,8 @@
|
||||
//! Nuts for leadscrews.
|
||||
//
|
||||
include <../core.scad>
|
||||
include <../utils/tube.scad>
|
||||
use <../utils/tube.scad>
|
||||
use <../utils/thread.scad>
|
||||
|
||||
function leadnut_bore(type) = type[2]; //! Thread size
|
||||
function leadnut_od(type) = type[3]; //! Outer diameter of the shank
|
||||
@@ -33,6 +34,8 @@ function leadnut_holes(type) = type[8]; //! The number of screw hole
|
||||
function leadnut_hole_dia(type) = type[9]; //! The diameter of the screw holes
|
||||
function leadnut_hole_pitch(type) = type[10]; //! The radia pitch of the screw holes
|
||||
function leadnut_screw(type) = type[11]; //! The type of the fixing screws
|
||||
function leadnut_pitch(type) = type[12]; //! Screw pitch
|
||||
function leadnut_lead(type) = type[13]; //! Screw lead
|
||||
|
||||
function leadnut_shank(type) = leadnut_height(type) - leadnut_flange_t(type) - leadnut_flange_offset(type); //! The length of the shank below the flange
|
||||
|
||||
@@ -47,11 +50,18 @@ module leadnut_screw_positions(type) { //! Position children at the screw holes
|
||||
|
||||
module leadnut(type) { //! Draw specified leadnut
|
||||
vitamin(str("leadnut(", type[0], "): ", type[1]));
|
||||
bore_r = (leadnut_bore(type) + 0.5) / 2;
|
||||
bore_d = leadnut_bore(type);
|
||||
bore_r = bore_d / 2;
|
||||
h = leadnut_height(type);
|
||||
pitch = leadnut_pitch(type);
|
||||
lead = leadnut_lead(type);
|
||||
|
||||
color("dimgrey") vflip()
|
||||
translate_z(-leadnut_flange_offset(type) - leadnut_flange_t(type)) {
|
||||
tube(or = leadnut_od(type) / 2, ir = bore_r, h = leadnut_height(type), center = false);
|
||||
tube(or = leadnut_od(type) / 2, ir = bore_r, h = h, center = false);
|
||||
|
||||
if(show_threads)
|
||||
thread(bore_d, lead, h, thread_profile(pitch / 2, pitch * 0.366, 30), false, starts = lead / pitch, female = true, solid = false);
|
||||
|
||||
translate_z(leadnut_flange_offset(type))
|
||||
linear_extrude(height = leadnut_flange_t(type))
|
||||
|
@@ -17,8 +17,8 @@
|
||||
// If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
LSN8x2 = ["LSN8x2", "Leadscrew nut 8 x 2", 8, 10.2, 15, 22, 3.5, 1.5, 4, 3.5, 8, M3_cap_screw];
|
||||
LSN8x8 = ["LSN8x8", "Leadscrew nut 8 x 8 RobotDigg",8, 12.75,19, 25.4, 4.1, 0, 3, 3.5, 19.05/2, M3_cap_screw];
|
||||
LSN8x2 = ["LSN8x2", "Leadscrew nut 8 x 2", 8, 10.2, 15, 22, 3.5, 1.5, 4, 3.5, 8, M3_cap_screw, 2, 2];
|
||||
LSN8x8 = ["LSN8x8", "Leadscrew nut 8 x 8 RobotDigg",8, 12.75,19, 25.4, 4.1, 0, 3, 3.5, 19.05/2, M3_cap_screw, 2, 8];
|
||||
|
||||
leadnuts = [LSN8x2, LSN8x8];
|
||||
|
||||
|
@@ -26,6 +26,8 @@ include <../core.scad>
|
||||
use <washer.scad>
|
||||
use <screw.scad>
|
||||
use <../utils/rounded_cylinder.scad>
|
||||
use <../utils/thread.scad>
|
||||
use <../utils/tube.scad>
|
||||
brass_colour = brass;
|
||||
|
||||
function nut_size(type) = type[1]; //! Diameter of the corresponding screw
|
||||
@@ -37,7 +39,8 @@ function nut_trap_depth(type) = type[6]; //! Depth of nut trap
|
||||
function nut_flat_radius(type) = nut_radius(type) * cos(30); //! Radius across the flats
|
||||
|
||||
module nut(type, nyloc = false, brass = false, nylon = false) { //! Draw specified nut
|
||||
hole_rad = nut_size(type) / 2;
|
||||
thread_d = nut_size(type);
|
||||
hole_rad = thread_d / 2;
|
||||
outer_rad = nut_radius(type);
|
||||
thickness = nut_thickness(type);
|
||||
nyloc_thickness = nut_thickness(type, true);
|
||||
@@ -45,18 +48,29 @@ module nut(type, nyloc = false, brass = false, nylon = false) { //! Draw specifi
|
||||
vitamin(str("nut(", type[0], arg(nyloc, false, "nyloc"), arg(brass, false, "brass"), arg(nylon, false, "nylon"),
|
||||
"): Nut M", nut_size(type), " x ", thickness, "mm ", desc));
|
||||
|
||||
explode(nyloc ? 10 : 0)
|
||||
color(brass ? brass_colour : nylon ? grey30: grey70) {
|
||||
colour = brass ? brass_colour : nylon ? grey30: grey70;
|
||||
explode(nyloc ? 10 : 0) {
|
||||
color(colour) {
|
||||
linear_extrude(height = thickness)
|
||||
difference() {
|
||||
circle(outer_rad, $fn = 6);
|
||||
|
||||
circle(hole_rad);
|
||||
}
|
||||
|
||||
if(nyloc)
|
||||
translate_z(-eps)
|
||||
rounded_cylinder(r = outer_rad * cos(30) , h = nyloc_thickness, r2 = (nyloc_thickness - thickness) / 2, ir = hole_rad);
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, metric_coarse_pitch(thread_d), thickness, center = false, colour = colour);
|
||||
|
||||
if(nyloc)
|
||||
translate_z(thickness)
|
||||
color("royalblue")
|
||||
tube(or = thread_d / 2 + eps, ir = (thread_d * 0.8) / 2, h = (nyloc_thickness - thickness) * 0.8, center = false);
|
||||
}
|
||||
if($children)
|
||||
translate_z(nut_thickness(type, nyloc))
|
||||
children();
|
||||
@@ -73,7 +87,8 @@ module nut_and_washer(type, nyloc) { //! Draw nut with corresponding washer
|
||||
}
|
||||
|
||||
module wingnut(type) { //! Draw a wingnut
|
||||
hole_rad = nut_size(type) / 2;
|
||||
thread_d = nut_size(type);
|
||||
hole_rad = thread_d / 2;
|
||||
bottom_rad = nut_radius(type);
|
||||
top_rad = type[4] / 2;
|
||||
thickness = nut_thickness(type);
|
||||
@@ -87,25 +102,31 @@ module wingnut(type) { //! Draw a wingnut
|
||||
|
||||
vitamin(str("wingnut(", type[0], "): Wingnut M", nut_size(type)));
|
||||
|
||||
explode(10) color(grey70) {
|
||||
rotate_extrude()
|
||||
polygon([
|
||||
[hole_rad, 0],
|
||||
[bottom_rad, 0],
|
||||
[top_rad,, thickness],
|
||||
[hole_rad, thickness]
|
||||
]);
|
||||
for(rot = [0, 180])
|
||||
rotate([90, 0, rot]) linear_extrude(height = wing_thickness, center = true)
|
||||
hull() {
|
||||
translate([wing_span / 2 - wing_width / 2, wing_height - wing_width / 2])
|
||||
circle(wing_width / 2);
|
||||
polygon([
|
||||
[bottom_rad * cos(top_angle) - eps, 0],
|
||||
[wing_span / 2 - wing_width / 2, wing_height - wing_width / 2],
|
||||
[top_rad * cos(top_angle) - eps, thickness],
|
||||
]);
|
||||
}
|
||||
colour = silver;
|
||||
explode(10) {
|
||||
color(colour) {
|
||||
rotate_extrude()
|
||||
polygon([
|
||||
[hole_rad, 0],
|
||||
[bottom_rad, 0],
|
||||
[top_rad,, thickness],
|
||||
[hole_rad, thickness]
|
||||
]);
|
||||
for(rot = [0, 180])
|
||||
rotate([90, 0, rot]) linear_extrude(height = wing_thickness, center = true)
|
||||
hull() {
|
||||
translate([wing_span / 2 - wing_width / 2, wing_height - wing_width / 2])
|
||||
circle(wing_width / 2);
|
||||
polygon([
|
||||
[bottom_rad * cos(top_angle) - eps, 0],
|
||||
[wing_span / 2 - wing_width / 2, wing_height - wing_width / 2],
|
||||
[top_rad * cos(top_angle) - eps, thickness],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(thread_d, metric_coarse_pitch(thread_d), thickness, center = false, colour = colour);
|
||||
}
|
||||
}
|
||||
function nut_trap_radius(nut, horizontal = false) = nut_radius(nut) + (horizontal ? layer_height / 4 : 0); //! Radius across the corners of a nut trap
|
||||
|
@@ -23,6 +23,7 @@
|
||||
//! A permanent magnet that can be magnatized and de-magnatized electronically.
|
||||
//
|
||||
include <../core.scad>
|
||||
use <../utils/thread.scad>
|
||||
|
||||
pitch = 33.8;
|
||||
width = 40;
|
||||
@@ -64,15 +65,20 @@ module opengrab() { //! Draw OpenGrab module
|
||||
translate_z(depth - pillar - pcb / 2)
|
||||
cube([width, width, pcb], center = true);
|
||||
|
||||
color(brass)
|
||||
translate_z(1)
|
||||
opengrab_hole_positions()
|
||||
|
||||
translate_z(1)
|
||||
opengrab_hole_positions() {
|
||||
color(brass)
|
||||
linear_extrude(height = depth - 1)
|
||||
difference() {
|
||||
circle(d = 4.7 / cos(30), $fn = 6);
|
||||
|
||||
circle(r = 3/2);
|
||||
}
|
||||
|
||||
if(show_threads)
|
||||
female_metric_thread(3, metric_coarse_pitch(3), depth - 1, center = false, colour = brass);
|
||||
}
|
||||
}
|
||||
|
||||
module opengrab_target() { //! Draw OpenGrab target
|
||||
|
@@ -44,26 +44,26 @@ module pillar(type) { //! Draw specified pillar
|
||||
thread_d = pillar_thread(type);
|
||||
bot_thread_l = pillar_bot_thread(type);
|
||||
top_thread_l = pillar_top_thread(type);
|
||||
thread_colour = pillar_i_colour(type) * (show_threads ? 0.7 : 1);
|
||||
thread_colour = pillar_i_colour(type);
|
||||
pitch = metric_coarse_pitch(thread_d);
|
||||
|
||||
vitamin(str("pillar(", type[0], "): Pillar ", pillar_name(type), " ", sex, " M", thread_d, "x", height));
|
||||
|
||||
color(thread_colour) {
|
||||
if(bot_thread_l > 0)
|
||||
translate_z(-bot_thread_l + eps)
|
||||
if(show_threads)
|
||||
male_metric_thread(thread_d, metric_coarse_pitch(thread_d), bot_thread_l, false, false);
|
||||
else
|
||||
if(bot_thread_l > 0)
|
||||
translate_z(-bot_thread_l + eps)
|
||||
if(show_threads)
|
||||
male_metric_thread(thread_d, pitch, bot_thread_l, false, top = 0, colour = thread_colour);
|
||||
else
|
||||
color(thread_colour)
|
||||
cylinder(h = bot_thread_l, d = thread_d);
|
||||
|
||||
if(top_thread_l > 0)
|
||||
translate_z(height + top_thread_l - eps)
|
||||
if(show_threads)
|
||||
vflip()
|
||||
male_metric_thread(thread_d, metric_coarse_pitch(thread_d), top_thread_l, false, false);
|
||||
else
|
||||
if(top_thread_l > 0)
|
||||
translate_z(height - eps)
|
||||
if(show_threads)
|
||||
male_metric_thread(thread_d, pitch, top_thread_l, false, bot = 0, colour = thread_colour);
|
||||
else
|
||||
color(thread_colour)
|
||||
cylinder(h = top_thread_l, d = thread_d);
|
||||
}
|
||||
|
||||
color(pillar_i_colour(type)) {
|
||||
linear_extrude(height = height)
|
||||
@@ -79,6 +79,16 @@ module pillar(type) { //! Draw specified pillar
|
||||
cylinder(h = top - bot, d = thread_d + eps);
|
||||
}
|
||||
|
||||
if(show_threads) {
|
||||
if(top_thread_l < 0)
|
||||
translate_z(height)
|
||||
vflip()
|
||||
female_metric_thread(thread_d, pitch, -top_thread_l, false, colour = thread_colour);
|
||||
|
||||
if(bot_thread_l < 0)
|
||||
female_metric_thread(thread_d, pitch, -bot_thread_l, false, colour = thread_colour);
|
||||
}
|
||||
|
||||
if(pillar_od(type) > pillar_id(type))
|
||||
color(pillar_o_colour(type)) linear_extrude(height = height)
|
||||
difference() {
|
||||
|
@@ -25,31 +25,53 @@ use <../utils/thread.scad>
|
||||
|
||||
rod_colour = grey80;
|
||||
studding_colour = grey70;
|
||||
leadscrew_colour = grey70;
|
||||
|
||||
module rod(d , l) { //! Draw a smooth rod with specified length and diameter
|
||||
module rod(d , l, center = true) { //! Draw a smooth rod with specified diameter and length
|
||||
vitamin(str("rod(", d, ", ", l, "): Smooth rod ", d, "mm x ", l, "mm"));
|
||||
|
||||
chamfer = d / 10;
|
||||
color(rod_colour)
|
||||
hull() {
|
||||
cylinder(d = d, h = l - 2 * chamfer, center = true);
|
||||
|
||||
cylinder(d = d - 2 * chamfer, h = l, center = true);
|
||||
}
|
||||
}
|
||||
|
||||
module studding(d , l) { //! Draw a threaded rod with specified length and diameter
|
||||
vitamin(str("studding(", d, ", ", l,"): Threaded rod M", d, " x ", l, "mm"));
|
||||
|
||||
chamfer = d / 20;
|
||||
pitch = metric_coarse_pitch(d);
|
||||
color(studding_colour)
|
||||
if(show_threads && pitch)
|
||||
male_metric_thread(d, pitch, l);
|
||||
else
|
||||
translate_z(center ? 0 : l / 2)
|
||||
hull() {
|
||||
cylinder(d = d, h = l - 2 * chamfer, center = true);
|
||||
|
||||
cylinder(d = d - 2 * chamfer, h = l, center = true);
|
||||
}
|
||||
}
|
||||
|
||||
module studding(d , l, center = true) { //! Draw a threaded rod with specified diameter and length
|
||||
vitamin(str("studding(", d, ", ", l,"): Threaded rod M", d, " x ", l, "mm"));
|
||||
|
||||
chamfer = d / 20;
|
||||
pitch = metric_coarse_pitch(d);
|
||||
|
||||
translate_z(center ? 0 : l / 2)
|
||||
if(show_threads && pitch)
|
||||
male_metric_thread(d, pitch, l, colour = rod_colour);
|
||||
else
|
||||
color(studding_colour)
|
||||
hull() {
|
||||
cylinder(d = d, h = l - 2 * chamfer, center = true);
|
||||
|
||||
cylinder(d = d - 2 * chamfer, h = l, center = true);
|
||||
}
|
||||
}
|
||||
|
||||
module leadscrew(d , l, lead, starts, center = true) { //! Draw a leadscrew with specified diameter, length, lead and number of starts
|
||||
vitamin(str("leadscrew(", d, ", ", l, ", ", lead, ", ", starts, "): Leadscrew ", d, " x ", l, "mm, ", lead, "mm lead, ", starts, " starts"));
|
||||
|
||||
pitch = lead / starts;
|
||||
chamfer = pitch / 2;
|
||||
|
||||
translate_z(center ? 0 : l / 2)
|
||||
if(show_threads && pitch)
|
||||
thread(d - pitch, lead, l, thread_profile(pitch / 2, pitch * 0.366, 30), top = 45, bot = 45, starts = starts, center = center, colour = rod_colour);
|
||||
else
|
||||
color(leadscrew_colour)
|
||||
hull() {
|
||||
cylinder(d = d, h = l - 2 * chamfer, center = true);
|
||||
|
||||
cylinder(d = d - 2 * chamfer, h = l, center = true);
|
||||
}
|
||||
}
|
||||
|
@@ -73,34 +73,33 @@ module screw(type, length, hob_point = 0, nylon = false) { //! Draw specified sc
|
||||
thread = max_thread ? length >= max_thread + 5 ? max_thread
|
||||
: length
|
||||
: length;
|
||||
shank = length - thread;
|
||||
d = 2 * screw_radius(type);
|
||||
pitch = metric_coarse_pitch(d);
|
||||
colour = nylon || head_type == hs_grub ? grey40 : grey80;
|
||||
|
||||
module shaft(headless = 0) {
|
||||
module shaft(socket = 0, headless = false) {
|
||||
point = screw_nut(type) ? 0 : 3 * rad;
|
||||
d = 2 * screw_radius(type);
|
||||
pitch = metric_coarse_pitch(d);
|
||||
l = length - shank;
|
||||
shank = length - thread - socket;
|
||||
|
||||
if(show_threads && !point && pitch)
|
||||
translate_z(-l - shank)
|
||||
color(colour * 0.7)
|
||||
male_metric_thread(d, pitch, l, !!headless, false);
|
||||
translate_z(-length)
|
||||
male_metric_thread(d, pitch, thread - (shank > 0 || headless ? 0 : socket), false, top = headless ? -1 : 0, solid = !headless, colour = colour);
|
||||
else
|
||||
color(colour * 0.9)
|
||||
rotate_extrude() {
|
||||
translate([0, -length + point])
|
||||
square([rad, length - headless - point]);
|
||||
square([rad, length - socket - point]);
|
||||
|
||||
if(point)
|
||||
polygon([
|
||||
[0, -length], [0, point - length], [rad - 0.1, point - length]
|
||||
[0.4, -length], [0, point - length], [rad, point - length]
|
||||
]);
|
||||
}
|
||||
if(shank - headless > 0)
|
||||
color(colour)
|
||||
translate_z(-shank)
|
||||
cylinder(r = rad + eps, h = shank - headless);
|
||||
|
||||
if(shank > 0)
|
||||
color(colour)
|
||||
translate_z(-shank - socket)
|
||||
cylinder(r = rad + eps, h = shank);
|
||||
}
|
||||
|
||||
explode(length + 10) {
|
||||
@@ -121,23 +120,20 @@ module screw(type, length, hob_point = 0, nylon = false) { //! Draw specified sc
|
||||
}
|
||||
if(head_type == hs_grub) {
|
||||
color(colour) {
|
||||
if(!show_threads) {
|
||||
translate_z(-socket_depth)
|
||||
linear_extrude(height = socket_depth)
|
||||
difference() {
|
||||
circle(r = rad);
|
||||
r = show_threads ? rad - pitch / 2 : rad;
|
||||
translate_z(-socket_depth)
|
||||
linear_extrude(height = socket_depth)
|
||||
difference() {
|
||||
circle(r);
|
||||
|
||||
circle(socket_rad, $fn = 6);
|
||||
}
|
||||
circle(socket_rad, $fn = 6);
|
||||
}
|
||||
|
||||
shaft(socket_depth);
|
||||
}
|
||||
else
|
||||
render() difference() {
|
||||
shaft(socket_depth);
|
||||
shaft(socket_depth, true);
|
||||
|
||||
cylinder(r = socket_rad, $fn = 6, h = 2 * socket_depth, center = true);
|
||||
}
|
||||
if(show_threads)
|
||||
translate_z(-length)
|
||||
cylinder(r = r, h = length - socket_depth);
|
||||
}
|
||||
}
|
||||
if(head_type == hs_hex) {
|
||||
|
@@ -26,6 +26,7 @@ include <screws.scad>
|
||||
use <washer.scad>
|
||||
include <ring_terminals.scad>
|
||||
use <../utils/tube.scad>
|
||||
use <rod.scad>
|
||||
|
||||
function NEMA_width(type) = type[1]; //! Width of the square face
|
||||
function NEMA_length(type) = type[2]; //! Body length
|
||||
@@ -34,7 +35,7 @@ function NEMA_body_radius(type) = type[4]; //! Body radius
|
||||
function NEMA_boss_radius(type) = type[5]; //! Boss around the spindle radius
|
||||
function NEMA_boss_height(type) = type[6]; //! Boss height
|
||||
function NEMA_shaft_dia(type) = type[7]; //! Shaft diameter
|
||||
function NEMA_shaft_length(type)= type[8]; //! Shaft length above the face
|
||||
function NEMA_shaft_length(type)= type[8]; //! Shaft length above the face, if a list then a leadscrew: length, lead, starts
|
||||
function NEMA_hole_pitch(type) = type[9]; //! Screw hole pitch
|
||||
function NEMA_holes(type) = [-NEMA_hole_pitch(type) / 2, NEMA_hole_pitch(type) / 2]; //! Screw positions for for loop
|
||||
function NEMA_big_hole(type) = NEMA_boss_radius(type) + 0.2; //! Clearance hole for the big boss
|
||||
@@ -50,7 +51,7 @@ module NEMA_outline(type) //! 2D outline
|
||||
circle(NEMA_radius(type));
|
||||
}
|
||||
|
||||
module NEMA(type) { //! Draw specified NEMA stepper motor
|
||||
module NEMA(type, shaft_angle = 0) { //! Draw specified NEMA stepper motor
|
||||
side = NEMA_width(type);
|
||||
length = NEMA_length(type);
|
||||
body_rad = NEMA_body_radius(type);
|
||||
@@ -88,9 +89,15 @@ module NEMA(type) { //! Draw specified NEMA stepper motor
|
||||
}
|
||||
}
|
||||
|
||||
color(NEMA_shaft_length(type) > 50 ? "silver" : stepper_cap_colour)
|
||||
translate_z(-5)
|
||||
cylinder(r = shaft_rad, h = NEMA_shaft_length(type) + 5); // shaft
|
||||
shaft = NEMA_shaft_length(type);
|
||||
translate_z(-5)
|
||||
rotate(shaft_angle)
|
||||
if(!is_list(shaft))
|
||||
color(stepper_cap_colour)
|
||||
cylinder(r = shaft_rad, h = shaft + 5); // shaft
|
||||
else
|
||||
not_on_bom()
|
||||
leadscrew(shaft_rad * 2, shaft.x + 5, shaft.y, shaft.z, center = false)
|
||||
|
||||
translate([0, side / 2, -length + cap / 2])
|
||||
rotate([90, 0, 0])
|
||||
|
@@ -22,14 +22,14 @@
|
||||
//
|
||||
|
||||
// corner body boss boss shaft
|
||||
// side, length, radius, radius, radius, depth, shaft, length, holes
|
||||
NEMA17 = ["NEMA17", 42.3, 47, 53.6/2, 25, 11, 2, 5, 24, 31 ];
|
||||
NEMA17M = ["NEMA17M", 42.3, 40, 53.6/2, 25, 11, 2, 5, 20, 31 ];
|
||||
NEMA17M8= ["NEMA17M8", 42.3, 40, 53.6/2, 25, 11, 2, 8, 280, 31 ];
|
||||
NEMA17S = ["NEMA17S", 42.3, 34, 53.6/2, 25, 11, 2, 5, 24, 31 ];
|
||||
NEMA16 = ["NEMA16", 39.5, 19.2, 50.6/2, 50.6/2, 11, 2, 5, 12, 31 ];
|
||||
NEMA14 = ["NEMA14", 35.2, 36, 46.4/2, 21, 11, 2, 5, 21, 26 ];
|
||||
NEMA23 = ["NEMA23", 56.4, 51.2, 75.7/2, 35, 38.1/2, 1.6, 6.35, 24, 47.1 ];
|
||||
// side, length, radius, radius, radius, depth, shaft, length, holes
|
||||
NEMA17 = ["NEMA17", 42.3, 47, 53.6/2, 25, 11, 2, 5, 24, 31 ];
|
||||
NEMA17M = ["NEMA17M", 42.3, 40, 53.6/2, 25, 11, 2, 5, 20, 31 ];
|
||||
NEMA17M8= ["NEMA17M8", 42.3, 40, 53.6/2, 25, 11, 2, 8, [280, 8, 4], 31 ];
|
||||
NEMA17S = ["NEMA17S", 42.3, 34, 53.6/2, 25, 11, 2, 5, 24, 31 ];
|
||||
NEMA16 = ["NEMA16", 39.5, 19.2, 50.6/2, 50.6/2, 11, 2, 5, 12, 31 ];
|
||||
NEMA14 = ["NEMA14", 35.2, 36, 46.4/2, 21, 11, 2, 5, 21, 26 ];
|
||||
NEMA23 = ["NEMA23", 56.4, 51.2, 75.7/2, 35, 38.1/2, 1.6, 6.35, 24, 47.1 ];
|
||||
|
||||
stepper_motors = [NEMA14, NEMA16, NEMA17S, NEMA17M, NEMA17, NEMA23];
|
||||
|
||||
|
@@ -23,6 +23,8 @@
|
||||
include <../core.scad>
|
||||
use <nut.scad>
|
||||
use <washer.scad>
|
||||
use <../utils/thread.scad>
|
||||
use <../utils/tube.scad>
|
||||
|
||||
function toggle_part(type) = type[1]; //! Part description
|
||||
function toggle_width(type) = type[2]; //! Body width
|
||||
@@ -80,7 +82,29 @@ module toggle(type, thickness) { //! Draw specified toggle switch with the nuts
|
||||
translate_z(-h1 / 2 - t)
|
||||
cube([toggle_width(type), toggle_height(type), h1], center = true);
|
||||
|
||||
color("silver") {
|
||||
if(show_threads) {
|
||||
d = toggle_od(type);
|
||||
pitch = inch(1/40);
|
||||
h = 5 * pitch * sqrt(3) / 16;
|
||||
|
||||
male_metric_thread(d, pitch, thread, center = false, solid = false, colour = silver);
|
||||
|
||||
color(silver)
|
||||
tube(or = d / 2 - h, ir = toggle_id(type) / 2, h = thread, center = false);
|
||||
}
|
||||
else
|
||||
color(silver)
|
||||
rotate_extrude()
|
||||
difference() {
|
||||
hull() {
|
||||
square([toggle_od(type) / 2, thread - chamfer]);
|
||||
|
||||
square([toggle_od(type) / 2 - chamfer, thread]);
|
||||
}
|
||||
square([toggle_id(type) / 2, thread + 1]);
|
||||
}
|
||||
|
||||
color(silver) {
|
||||
if(toggle_collar_t(type))
|
||||
cylinder(d = toggle_collar_d(type), h = toggle_collar_t(type));
|
||||
|
||||
@@ -90,15 +114,6 @@ module toggle(type, thickness) { //! Draw specified toggle switch with the nuts
|
||||
translate_z(-h2 / 2)
|
||||
cube([toggle_width(type) + 2 * eps, toggle_height(type) - 2 * inset, h2], center = true);
|
||||
|
||||
rotate_extrude()
|
||||
difference() {
|
||||
hull() {
|
||||
square([toggle_od(type) / 2, thread - chamfer]);
|
||||
|
||||
square([toggle_od(type) / 2 - chamfer, thread]);
|
||||
}
|
||||
square([toggle_id(type) / 2, thread + 1]);
|
||||
}
|
||||
|
||||
translate_z(toggle_pivot(type)) {
|
||||
angle = toggle_angle(type);
|
||||
|
@@ -103,12 +103,14 @@ module spring_washer(type) { //! Draw spring version of washer
|
||||
vitamin(str("spring_washer(", type[0], "_washer): Washer spring M", hole, " x ", thickness, "mm"));
|
||||
ir = washer_id(type) / 2;
|
||||
or = diameter / 2;
|
||||
path = circle_points((ir + or) / 2, exploded() ? thickness / 2 : 0);
|
||||
pitch = exploded() ? thickness / 2 : 0;
|
||||
path = circle_points((ir + or) / 2, pitch);
|
||||
profile = rectangle_points(thickness, or - ir);
|
||||
len = len(path);
|
||||
color(hard_washer_colour)
|
||||
translate_z(thickness / 2)
|
||||
rotate(180)
|
||||
sweep(path, profile);
|
||||
rotate(-90)
|
||||
sweep(path, profile, twist = -helical_twist_per_segment(ir, pitch, len) * (len - 1));
|
||||
|
||||
if($children)
|
||||
translate_z(thickness)
|
||||
|
Reference in New Issue
Block a user