Added screw_length() to calculuate screw lengths includin washers, inserts and nuts.

This commit is contained in:
Chris Palmer 2021-01-15 18:12:37 +00:00
parent c33876530e
commit 93b260b7b9
28 changed files with 62 additions and 88 deletions

View File

@ -182,7 +182,7 @@ This is achieved by having a pair of modules: -
} }
module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place
screw_length = screw_longer_than(thickness + insert_length(insert) + 2 * washer_thickness(screw_washer(screw))); screw_length = screw_length(screw, thickness, 2, true, longer = true);
handle_assembly(); handle_assembly();

View File

@ -75,9 +75,9 @@ function box_corner_overlap(type) = box_wall(type);
function box_corner_rad(type) = box_sheet_slot(type) - sheet_slot_clearance / 2 + box_corner_gap(type) + box_corner_overlap(type); function box_corner_rad(type) = box_sheet_slot(type) - sheet_slot_clearance / 2 + box_corner_gap(type) + box_corner_overlap(type);
function box_sheet_r(type) = box_corner_rad(type) - box_sheet_slot(type) - box_corner_overlap(type); function box_sheet_r(type) = box_corner_rad(type) - box_sheet_slot(type) - box_corner_overlap(type);
function box_screw_length(type, top) = screw_longer_than(2 * washer_thickness(box_washer(type)) function box_screw_length(type, top) =
+ sheet_thickness(top ? box_top_sheet(type) : box_base_sheet(type)) let(s = top ? box_top_sheet(type) : box_base_sheet(type))
+ box_corner_gap(type) + box_profile_overlap(type) + box_insert_l(type) - 1); screw_length(box_screw(type), sheet_thickness(s) + box_corner_gap(type) + box_profile_overlap(type) - 1, washers = 2, insert = true, longer = true);
function box_wall_clearance(type) = box_sheet_slot(type) / 2 - sheet_thickness(box_sheets(type)) / 2; function box_wall_clearance(type) = box_sheet_slot(type) / 2 - sheet_thickness(box_sheets(type)) / 2;
function box_margin(type) = box_profile_overlap(type) + box_corner_gap(type); //! How much the bezel intrudes on the specified height function box_margin(type) = box_profile_overlap(type) + box_corner_gap(type); //! How much the bezel intrudes on the specified height

View File

@ -68,7 +68,7 @@ function cam_screw_length(cam) = let(
front = cam_front_size(cam), front = cam_front_size(cam),
screw = pcb_screw(camera_pcb(cam)), screw = pcb_screw(camera_pcb(cam)),
nut = screw_nut(screw) nut = screw_nut(screw)
) screw_longer_than(front.z + washer_thickness(screw_washer(screw)) - nut_trap_depth(nut) + nut_thickness(nut, true)); ) screw_length(screw, front.z - nut_trap_depth(nut), 1, nyloc = true, longer = true);
function hinge_z(cam) = cam_screw_length(cam) - hinge_r; function hinge_z(cam) = cam_screw_length(cam) - hinge_r;
@ -344,9 +344,8 @@ module camera_fastened_assembly(cam, thickness, angle = 0) {
camera_bracket_position(cam) camera_bracket_position(cam)
camera_bracket_screw_positions(cam) { camera_bracket_screw_positions(cam) {
nut = screw_nut(bracket_screw); nut = screw_nut(bracket_screw);
washer = screw_washer(bracket_screw);
t = bracket_thickness(cam); t = bracket_thickness(cam);
screw_length = screw_longer_than(thickness + t + nut_thickness(nut, true) + 2 * washer_thickness(washer)); screw_length = screw_length(bracket_screw, thickness + t, 2, nyloc = true);
vflip() vflip()
translate_z(thickness) translate_z(thickness)
screw_and_washer(bracket_screw, screw_length); screw_and_washer(bracket_screw, screw_length);

View File

@ -133,12 +133,10 @@ assembly(str("corner_block_M", 20 * screw_radius(screw))) {
module fastened_corner_block_assembly(thickness, screw = def_screw, thickness_below = undef, thickness_side2 = undef, name = false, show_block = true, star_washers = true) { //! Printed block with all fasteners module fastened_corner_block_assembly(thickness, screw = def_screw, thickness_below = undef, thickness_side2 = undef, name = false, show_block = true, star_washers = true) { //! Printed block with all fasteners
thickness2 = !is_undef(thickness_below) ? thickness_below : thickness; thickness2 = !is_undef(thickness_below) ? thickness_below : thickness;
thickness3 = !is_undef(thickness_side2) ? thickness_side2 : thickness; thickness3 = !is_undef(thickness_side2) ? thickness_side2 : thickness;
washer = screw_washer(screw); function screw_len(t) = screw_length(screw, t + overshoot, star_washers ? 2 : 1, true);
insert = screw_insert(screw); screw_length = screw_len(thickness);
function screw_length(t) = screw_shorter_than((star_washers ? 2 : 1) * washer_thickness(washer) + t + insert_length(insert) + overshoot); screw_length2 = screw_len(thickness2);
screw_length = screw_length(thickness); screw_length3 = screw_len(thickness3);
screw_length2 = screw_length(thickness2);
screw_length3 = screw_length(thickness3);
if(show_block) if(show_block)
corner_block_assembly(screw, name) children(); corner_block_assembly(screw, name) children();

View File

@ -136,8 +136,7 @@ module door_hinge_assembly(top, door_thickness = 6) { //! The moving assembly th
dir = top ? -1 : 1; dir = top ? -1 : 1;
pin_x = door_hinge_pin_x(); pin_x = door_hinge_pin_x();
pin_y = door_hinge_pin_y(); pin_y = door_hinge_pin_y();
washer = screw_washer(screw); screw_length = screw_length(screw, thickness + door_thickness, 1);
screw_length = screw_shorter_than(thickness + door_thickness + washer_thickness(washer));
translate([0, pin_y - (thickness + door_thickness / 2), dir * width / 2]) { translate([0, pin_y - (thickness + door_thickness / 2), dir * width / 2]) {
rotate([90, 0, 180]) rotate([90, 0, 180])
@ -148,20 +147,20 @@ module door_hinge_assembly(top, door_thickness = 6) { //! The moving assembly th
screw_and_washer(screw, screw_length); screw_and_washer(screw, screw_length);
} }
translate([pin_x, pin_y, top ? 0 : -washer_thickness(screw_washer(pin_screw))]) washer = screw_washer(pin_screw);
washer(screw_washer(pin_screw)); wt = washer_thickness(washer);
translate([pin_x, pin_y, top ? 0 : -wt])
washer(washer);
translate([pin_x, pin_y, top ? washer_thickness(screw_washer(pin_screw)) + stat_width : width]) translate([pin_x, pin_y, top ? wt + stat_width : width])
screw_and_washer(pin_screw, screw_longer_than(2 * washer_thickness(screw_washer(pin_screw)) + width + stat_width)); screw_and_washer(pin_screw, screw_length(pin_screw, width + stat_width, 2, longer = true));
} }
module door_hinge_static_assembly(top, sheet_thickness = 3) { //! The stationary assembly module door_hinge_static_assembly(top, sheet_thickness = 3) { //! The stationary assembly
dir = top ? -1 : 1; dir = top ? -1 : 1;
pin_x = door_hinge_pin_x(); pin_x = door_hinge_pin_x();
stat_washer = screw_washer(stat_screw); stat_screw_length = screw_length(stat_screw, thickness + sheet_thickness, 2, nyloc = true);
stat_nut = screw_nut(stat_screw);
stat_screw_length = screw_longer_than(thickness + sheet_thickness + 2 * washer_thickness(stat_washer) + nut_thickness(stat_nut, true));
translate([pin_x, 0, -dir * (stat_width / 2 + washer_thickness(screw_washer(pin_screw)))]) translate([pin_x, 0, -dir * (stat_width / 2 + washer_thickness(screw_washer(pin_screw)))])
rotate([90, 0, 0]) { rotate([90, 0, 0]) {
@ -169,9 +168,10 @@ module door_hinge_static_assembly(top, sheet_thickness = 3) { //! The stationary
door_hinge_stat_hole_positions() { door_hinge_stat_hole_positions() {
screw_and_washer(stat_screw, stat_screw_length); screw_and_washer(stat_screw, stat_screw_length);
translate_z(-thickness - sheet_thickness) translate_z(-thickness - sheet_thickness)
vflip() vflip()
nut_and_washer(stat_nut, true); nut_and_washer(screw_nut(stat_screw), true);
} }
} }
} }

View File

@ -61,7 +61,7 @@ module door_latch_assembly(sheet_thickness = 3) { //! The assembly for a specifi
washer = screw_washer(screw); washer = screw_washer(screw);
nut = screw_nut(screw); nut = screw_nut(screw);
screw_length = screw_longer_than(height - nut_trap_depth + sheet_thickness + 2 * washer_thickness(washer) + nut_thickness(nut, true)); screw_length = screw_length(screw, height - nut_trap_depth + sheet_thickness, 2, nyloc = true);
translate([0, -height - washer_thickness(washer)]) translate([0, -height - washer_thickness(washer)])
rotate([-90, 0, 0]) { rotate([-90, 0, 0]) {

View File

@ -122,9 +122,7 @@ assembly(str("fixing_block_M", 20 * screw_radius(screw))) {
module fastened_fixing_block_assembly(thickness, screw = def_screw, screw2 = undef, thickness2 = undef, show_block = true, star_washers = true) { //! Assembly with fasteners in place module fastened_fixing_block_assembly(thickness, screw = def_screw, screw2 = undef, thickness2 = undef, show_block = true, star_washers = true) { //! Assembly with fasteners in place
module fb_screw(screw, thickness) { module fb_screw(screw, thickness) {
washer = screw_washer(screw); screw_length = screw_length(screw, thickness, star_washers ? 2 : 1, true, longer = true);
insert = screw_insert(screw);
screw_length = screw_longer_than((star_washers ? 2 : 1) * washer_thickness(washer) + thickness + insert_length(insert));
if(thickness) if(thickness)
translate_z(thickness) translate_z(thickness)

View File

@ -155,9 +155,7 @@ module hinge_fastened_assembly(type, thickness1, thickness2, angle, show_hinge =
hinge_assembly(type, angle); hinge_assembly(type, angle);
screw = hinge_screw(type); screw = hinge_screw(type);
washer_t = 2 * washer_thickness(screw_washer(screw));
nut = screw_nut(screw); nut = screw_nut(screw);
nut_t = nut_thickness(nut, true);
t = hinge_thickness(type); t = hinge_thickness(type);
kr = hinge_knuckle_dia(type) / 2; kr = hinge_knuckle_dia(type) / 2;
@ -165,7 +163,7 @@ module hinge_fastened_assembly(type, thickness1, thickness2, angle, show_hinge =
if(thickness) if(thickness)
hinge_screw_positions(type) { hinge_screw_positions(type) {
translate_z(t) translate_z(t)
screw_and_washer(screw, screw_longer_than(t + thickness + washer_t + nut_t)); screw_and_washer(screw, screw_length(screw, t + thickness, 2, nyloc = true));
translate_z(-thickness) translate_z(-thickness)
vflip() vflip()

View File

@ -69,10 +69,9 @@ module foot(type = foot) { //! Generate STL
module foot_assembly(t = 0, type = foot, flip = false) { //! Assembly with fasteners in place for specified sheet thickness module foot_assembly(t = 0, type = foot, flip = false) { //! Assembly with fasteners in place for specified sheet thickness
screw = foot_screw(type); screw = foot_screw(type);
washer = screw_washer(screw);
nut = screw_nut(screw); nut = screw_nut(screw);
squeeze = 0.5; squeeze = 0.5;
screw_length = screw_longer_than(foot_thickness(type) + t + 2 * washer_thickness(washer) + nut_thickness(nut, true) - squeeze); screw_length = screw_length(screw, foot_thickness(type) + t - squeeze, 2, nyloc = true);
vflip() explode(15, true) { vflip() explode(15, true) {
stl_colour(pp4_colour) foot(type); stl_colour(pp4_colour) foot(type);
@ -146,9 +145,7 @@ assembly("insert_foot") {
module fastened_insert_foot_assembly(t = 3, type = insert_foot) { //! Assembly with fasteners in place for specified sheet thickness module fastened_insert_foot_assembly(t = 3, type = insert_foot) { //! Assembly with fasteners in place for specified sheet thickness
screw = foot_screw(type); screw = foot_screw(type);
washer = screw_washer(screw); screw_length = screw_length(screw, t, 2, insert = true);
insert = screw_insert(screw);
screw_length = screw_shorter_than(insert_length(insert) + t + 2 * washer_thickness(washer));
explode(-10) insert_foot_assembly(type); explode(-10) insert_foot_assembly(type);

View File

@ -91,7 +91,7 @@ assembly("handle") {
} }
module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place
screw_length = screw_longer_than(thickness + insert_length(insert) + 2 * washer_thickness(screw_washer(screw))); screw_length = screw_length(screw, thickness, 2, true, longer = true);
handle_assembly(); handle_assembly();

View File

@ -103,10 +103,9 @@ module pcb_mount_assembly(pcb, thickness, height = 5) { //! A PCB mount assembly
stl_colour(pp1_colour) pcb_mount(pcb, washers = false); stl_colour(pp1_colour) pcb_mount(pcb, washers = false);
washer = screw_washer(screw);
nut = screw_nut(screw); nut = screw_nut(screw);
t = pcb_thickness(pcb); t = pcb_thickness(pcb);
screw_length = screw_longer_than(height + t + washer_thickness + thickness + washer_thickness(washer) + nut_thickness(nut, true)); screw_length = screw_length(screw, height + t + washer_thickness + thickness, 1, nyloc = true);
pcb_mount_screw_positions(pcb) { pcb_mount_screw_positions(pcb) {
translate_z(height + t) { translate_z(height + t) {

View File

@ -65,10 +65,8 @@ function pbox_insert(type) = screw_insert(pbox_screw(type)); //! The insert for
function pbox_washer(type) = screw_washer(pbox_screw(type)); //! The washer for the base screws function pbox_washer(type) = screw_washer(pbox_screw(type)); //! The washer for the base screws
function pbox_screw_length(type, panel_thickness = 0) = //! Length of the base screw function pbox_screw_length(type, panel_thickness = 0) = //! Length of the base screw
let(foot = pbox_foot(type)) let(foot = pbox_foot(type), screw = pbox_screw(type))
screw_shorter_than(pbox_base(type) + washer_thickness(pbox_washer(type)) screw_length(screw, pbox_base(type) + (foot ? foot_thickness(foot) : panel_thickness), 1, true);
+ insert_length(pbox_insert(type))
+ (foot ? foot_thickness(foot) : panel_thickness));
function pbox_mid_offset(type) = pbox_ridges(type).y + pbox_wall(type) / 2; // Offset to wall midpoint function pbox_mid_offset(type) = pbox_ridges(type).y + pbox_wall(type) / 2; // Offset to wall midpoint

View File

@ -156,8 +156,7 @@ assembly(str("PSU_shroud_", name)) {
module psu_shroud_fastened_assembly(type, cable_d, thickness, name, cables = 1) //! Assembly with screws in place module psu_shroud_fastened_assembly(type, cable_d, thickness, name, cables = 1) //! Assembly with screws in place
{ {
washer = screw_washer(screw); screw_length = screw_length(screw,thickness + counter_bore, 2, true);
screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + insert_length(insert) + counter_bore);
psu_shroud_assembly(type, cable_d, name, cables); psu_shroud_assembly(type, cable_d, name, cables);

View File

@ -101,8 +101,7 @@ module ribbon_clamp_fastened_assembly(ways, thickness, screw = screw) { //! Clam
vitamin(str(": Tape self amalgamating silicone ",tape_l," x 25mm")); vitamin(str(": Tape self amalgamating silicone ",tape_l," x 25mm"));
washer = screw_washer(screw); screw_length = screw_length(screw, thickness + ribbon_clamp_screw_depth(screw), 2);
screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + ribbon_clamp_screw_depth(screw));
ribbon_clamp_assembly(ways, screw); ribbon_clamp_assembly(ways, screw);

View File

@ -105,8 +105,7 @@ module socket_box_MKLOGIC_assembly() socket_box_assembly(MKLOGIC);
module socket_box_fastened_assembly(type, thickness) { //! The socket and backbox on each side of the specified panel thickness module socket_box_fastened_assembly(type, thickness) { //! The socket and backbox on each side of the specified panel thickness
screw = mains_socket_screw(type); screw = mains_socket_screw(type);
insert = screw_insert(screw); screw_length = screw_length(screw, mains_socket_height(type) + thickness, 0, true, longer = true);
screw_length = screw_longer_than(mains_socket_height(type) + thickness + insert_length(insert));
explode(-50) explode(-50)
translate_z(-height - thickness) translate_z(-height - thickness)

View File

@ -119,8 +119,7 @@ assembly(str("SSR_shroud_", name)) {
module ssr_shroud_fastened_assembly(type, cable_d, thickness, name) //! Assembly with screws in place module ssr_shroud_fastened_assembly(type, cable_d, thickness, name) //! Assembly with screws in place
{ {
washer = screw_washer(screw); screw_length = screw_length(screw, thickness + counter_bore, 2, true);
screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + insert_length(insert) + counter_bore);
ssr_shroud_assembly(type, cable_d, name); ssr_shroud_assembly(type, cable_d, name);

View File

@ -172,11 +172,9 @@ assembly("strap_end") {
module strap_assembly(length, type = strap) { //! Assembly with screws in place module strap_assembly(length, type = strap) { //! Assembly with screws in place
screw = strap_screw(type); screw = strap_screw(type);
washer = screw_washer(screw); penny = penny_washer(screw_washer(screw));
penny = penny_washer(washer);
insert = strap_insert(type);
screw_length = screw_shorter_than(washer_thickness(washer) + washer_thickness(penny) + insert_length(insert) + panel_clearance + counterbore); screw_length = screw_length(screw, washer_thickness(penny) + panel_clearance + counterbore, 1, true);
stl_colour(pp4_colour) strap(length, type); stl_colour(pp4_colour) strap(length, type);

View File

@ -2902,10 +2902,11 @@ For an explanation of `screw_polysink()` see <https://hydraraptor.blogspot.com/2
|:--- |:--- | |:--- |:--- |
| `screw_boss_diameter(type)` | Boss big enough for nut trap and washer | | `screw_boss_diameter(type)` | Boss big enough for nut trap and washer |
| `screw_head_depth(type, d = 0)` | How far a counter sink head will go into a straight hole diameter d | | `screw_head_depth(type, d = 0)` | How far a counter sink head will go into a straight hole diameter d |
| `screw_longer_than(x)` | Returns shortest screw length longer or equal to x | | `screw_length(screw, thickness, washers, insert = false, nyloc = false, nut = false, longer = false)` | Returns the length of the longest or shortest screw that will got through `thickness` and `washers` and possibly an `insert`, `nut` or `nyloc` |
| `screw_longer_than(x)` | Returns the length of the shortest screw length longer or equal to x |
| `screw_nut_radius(type)` | Radius of matching nut | | `screw_nut_radius(type)` | Radius of matching nut |
| `screw_polysink_r(type, z)` | Countersink hole profile corrected for rounded staircase extrusions. | | `screw_polysink_r(type, z)` | Countersink hole profile corrected for rounded staircase extrusions. |
| `screw_shorter_than(x)` | Returns longest screw length shorter than or equal to x | | `screw_shorter_than(x)` | Returns the length of the longest screw shorter than or equal to x |
### Modules ### Modules
| Module | Description | | Module | Description |

View File

@ -30,7 +30,6 @@ sheet = PMMA3;
height = 10; height = 10;
insert = screw_insert(screw); insert = screw_insert(screw);
washer = screw_washer(screw);
module widget(thickness) { module widget(thickness) {
vitamin(str("widget(", thickness, "): Rivit like thing for ", thickness, "mm sheets")); vitamin(str("widget(", thickness, "): Rivit like thing for ", thickness, "mm sheets"));
@ -92,7 +91,7 @@ assembly("wigdit") {
translate_z(height) { translate_z(height) {
translate_z(sheet_thickness(sheet)) translate_z(sheet_thickness(sheet))
screw_and_washer(screw, screw_longer_than(sheet_thickness(sheet) + 2 * washer_thickness(washer) + 3), true); screw_and_washer(screw, screw_length(screw, sheet_thickness(sheet) + 3, 2, longer = true), true);
explode(5) explode(5)
translate_z(sheet_thickness(sheet) / 2 + eps) translate_z(sheet_thickness(sheet) / 2 + eps)

View File

@ -24,16 +24,13 @@ include <../vitamins/blowers.scad>
module blowers() module blowers()
layout([for(b = blowers) blower_width(b)], 10, true) let(b = blowers[$i]){ layout([for(b = blowers) blower_width(b)], 10, true) let(b = blowers[$i]){
screw = blower_screw(b); screw = blower_screw(b);
washer = screw_washer(screw);
h = blower_lug(b); h = blower_lug(b);
blower(b); blower(b);
blower_hole_positions(b) blower_hole_positions(b)
translate_z(h) translate_z(h)
screw_and_washer(screw, screw_longer_than(h + washer_thickness(washer) + 5)); screw_and_washer(screw, screw_length(screw, h + 5, 1, longer = true));
} }
if($preview) if($preview)

View File

@ -151,10 +151,8 @@ function fan_screw_depth(type, full_depth = false) = fan_boss_d(type) || full_de
function fan_screw_length(type, thickness, full_depth = false) = function fan_screw_length(type, thickness, full_depth = false) =
let(depth = fan_screw_depth(type, full_depth), let(depth = fan_screw_depth(type, full_depth),
washers = depth == fan_depth(type) ? 2 : 1, washers = depth == fan_depth(type) ? 2 : 1)
washer = screw_washer(fan_screw(type)), screw_length(fan_screw(type), thickness + depth, washers, nyloc = true); //! Screw length required
nut = screw_nut(fan_screw(type)))
screw_longer_than(thickness + depth + washer_thickness(washer) * washers + nut_thickness(nut, true)); //! Screw length required
module fan_assembly(type, thickness, include_fan = true, screw = false, full_depth = false) { //! Fan with its fasteners module fan_assembly(type, thickness, include_fan = true, screw = false, full_depth = false) { //! Fan with its fasteners
translate_z(-fan_depth(type) / 2) { translate_z(-fan_depth(type) / 2) {

View File

@ -247,10 +247,7 @@ module iec_inserts(type) { //! Place the inserts
module iec_assembly(type, thickness) { //! Assembly with fasteners given panel thickness module iec_assembly(type, thickness) { //! Assembly with fasteners given panel thickness
screw = iec_screw(type); screw = iec_screw(type);
washer = screw_washer(screw); screw_length = thickness ? screw_length(screw, iec_flange_t(type) + thickness, 1, nyloc = true)
nut = screw_nut(screw);
insert = screw_insert(screw);
screw_length = thickness ? screw_longer_than(iec_flange_t(type) + thickness + washer_thickness(washer) + nut_thickness(nut, true))
: insert_screw_length; : insert_screw_length;
iec(type); iec(type);
@ -262,6 +259,6 @@ module iec_assembly(type, thickness) { //! Assembly with fasteners given panel
if(thickness) if(thickness)
translate_z(-thickness) translate_z(-thickness)
vflip() vflip()
nut_and_washer(nut, true); nut_and_washer(screw_nut(screw), true);
} }
} }

View File

@ -129,15 +129,13 @@ module mod_screw_positions(type) //! Position children at the screw positions
module module_assembly(type, thickness) { //! Module with its fasteners in place module module_assembly(type, thickness) { //! Module with its fasteners in place
screw = mod_screw(type); screw = mod_screw(type);
washer = screw_washer(screw); screw_length = screw_length(screw, thickness + mod_screw_z(type), 2, nyloc = true);
nut = screw_nut(screw);
screw_length = screw_longer_than(thickness + mod_screw_z(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true));
mod(type); mod(type);
mod_screw_positions(type) { mod_screw_positions(type) {
translate_z(mod_screw_z(type)) translate_z(mod_screw_z(type))
nut_and_washer(nut, true); nut_and_washer(screw_nut(screw), true);
translate_z(-thickness) translate_z(-thickness)
vflip() vflip()

View File

@ -1121,9 +1121,7 @@ module pcb_assembly(type, height, thickness) { //! Draw PCB assembly with spaces
screw = pcb_screw(type); screw = pcb_screw(type);
if(!is_undef(screw)) { if(!is_undef(screw)) {
washer = screw_washer(screw); screw_length = screw_length(screw, height + thickness + pcb_thickness(type), 1, nyloc = true);
nut = screw_nut(screw);
screw_length = screw_longer_than(height + thickness + pcb_thickness(type) + washer_thickness(washer) + nut_thickness(nut, true));
taper = screw_smaller_than(pcb_hole_d(type)) > 2 * screw_radius(screw); // Arduino? taper = screw_smaller_than(pcb_hole_d(type)) > 2 * screw_radius(screw); // Arduino?
pcb_screw_positions(type) { pcb_screw_positions(type) {
@ -1138,7 +1136,7 @@ module pcb_assembly(type, height, thickness) { //! Draw PCB assembly with spaces
translate_z(-thickness) translate_z(-thickness)
vflip() vflip()
nut_and_washer(nut, true); nut_and_washer(screw_nut(screw), true);
} }
} }
} }

View File

@ -128,7 +128,7 @@ module ring_terminal_assembly(type, thickness, top = false) { //! Earthing assem
screw = ringterm_screw(type); screw = ringterm_screw(type);
washer = screw_washer(screw); washer = screw_washer(screw);
nut = screw_nut(screw); nut = screw_nut(screw);
screw_length = screw_longer_than(thickness + 2 * washer_thickness(washer) + nut_thickness(nut, true) + ringterm_thickness(type)); screw_length = screw_length(screw, thickness + ringterm_thickness(type), 2, nyloc = true);
explode(10, true) star_washer(washer) explode(10, true) star_washer(washer)
if(top) if(top)

View File

@ -48,7 +48,7 @@ function screw_head_depth(type, d = 0) = //! How far a counter sink
? 0 ? 0
: let(r = screw_radius(type)) screw_head_radius(type) - max(r, d / 2) + r / 5; : let(r = screw_radius(type)) screw_head_radius(type) - max(r, d / 2) + r / 5;
function screw_longer_than(x) = x <= 5 ? 5 : //! Returns shortest screw length longer or equal to x function screw_longer_than(x) = x <= 5 ? 5 : //! Returns the length of the shortest screw length longer or equal to x
x <= 6 ? 6 : x <= 6 ? 6 :
x <= 8 ? 8 : x <= 8 ? 8 :
x <= 10 ? 10 : x <= 10 ? 10 :
@ -56,7 +56,7 @@ function screw_longer_than(x) = x <= 5 ? 5 : //! Returns shortest screw length
x <= 16 ? 16 : x <= 16 ? 16 :
ceil(x / 5) * 5; ceil(x / 5) * 5;
function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns longest screw length shorter than or equal to x function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns the length of the longest screw shorter than or equal to x
x >= 16 ? 16 : x >= 16 ? 16 :
x >= 12 ? 12 : x >= 12 ? 12 :
x >= 10 ? 10 : x >= 10 ? 10 :
@ -64,6 +64,14 @@ function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns longes
x >= 6 ? 6 : x >= 6 ? 6 :
5; 5;
function screw_length(screw, thickness, washers, insert = false, nyloc = false, nut = false, longer = false) = //! Returns the length of the longest or shortest screw that will got through `thickness` and `washers` and possibly an `insert`, `nut` or `nyloc`
let(washer = washers ? washers * washer_thickness(screw_washer(screw)) : 0,
insert = insert ? insert_length(screw_insert(screw)) : 0,
nut = nut || nyloc ? nut_thickness(screw_nut(screw), nyloc) : 0,
total = thickness + washer + insert + nut
)
longer || nut || nyloc ? screw_longer_than(total) : screw_shorter_than(total);
function screw_smaller_than(d) = d >= 2.5 && d < 3 ? 2.5 : floor(d); // Largest diameter screw less than or equal to specified diameter function screw_smaller_than(d) = d >= 2.5 && d < 3 ? 2.5 : floor(d); // Largest diameter screw less than or equal to specified diameter
function screw_insert(screw, i = 0) = let(d = screw_radius(screw) * 2) function screw_insert(screw, i = 0) = let(d = screw_radius(screw) * 2)

View File

@ -71,15 +71,13 @@ use <nut.scad>
use <washer.scad> use <washer.scad>
module ssr_assembly(type, screw, thickness) { //! Assembly with fasteners in place module ssr_assembly(type, screw, thickness) { //! Assembly with fasteners in place
nut = screw_nut(screw); screw_length = screw_length(screw, thickness + ssr_base_t(type), 2, nyloc = true);
washer = screw_washer(screw);
screw_length = screw_longer_than(2 * washer_thickness(washer) + thickness + ssr_base_t(type) + nut_thickness(nut, true));
ssr(type); ssr(type);
ssr_hole_positions(type) { ssr_hole_positions(type) {
translate_z(ssr_base_t(type)) translate_z(ssr_base_t(type))
nut_and_washer(nut, true); nut_and_washer(screw_nut(screw), true);
translate_z(-thickness) translate_z(-thickness)
vflip() vflip()

View File

@ -146,9 +146,8 @@ module vero_cutouts(type, angle = undef) vero_components(type, true, angle); //!
module veroboard_assembly(type, height, thickness, flip = false) //! Draw the assembly with components and fasteners in place module veroboard_assembly(type, height, thickness, flip = false) //! Draw the assembly with components and fasteners in place
assembly(vero_assembly(type)) { assembly(vero_assembly(type)) {
screw = vero_screw(type); screw = vero_screw(type);
washer = screw_washer(screw);
nut = screw_nut(screw); nut = screw_nut(screw);
screw_length = screw_longer_than(height + thickness + vero_thickness(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true)); screw_length = screw_length(screw, height + thickness + vero_thickness(type), 2, nyloc = true);
translate_z(height) { translate_z(height) {
veroboard(type); veroboard(type);