1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-08 08:26:29 +02:00

Fixed knob for pots with split shaft.

Changed the order of knob_for_pot() parameters.
This commit is contained in:
Chris Palmer
2021-10-29 12:37:12 +01:00
parent 370ad8a2d1
commit 9464ad5dbf
4 changed files with 22 additions and 16 deletions

View File

@@ -52,7 +52,7 @@ function knob(name = "knob", top_d = 12, bot_d = 15, height = 18, shaft_length,
name, top_d, bot_d, height, corner_r, shaft_d, shaft_length, flat_d, flat_h, screw, skirt, recess, pointer name, top_d, bot_d, height, corner_r, shaft_d, shaft_length, flat_d, flat_h, screw, skirt, recess, pointer
]; ];
function knob_for_pot(pot, thickness, z = 1, shaft_length = undef, top_d = 12, bot_d = 15, skirt = [20, 2], pointer = false, corner_r = 2, height = 0, washer = true) = //! Construct a knob to fit specified pot function knob_for_pot(pot, thickness, z = 1, washer = true, top_d = 12, bot_d = 15, height = 0, shaft_length = undef, skirt = [20, 2], pointer = false, corner_r = 2, screw = M3_grub_screw) = //! Construct a knob to fit specified pot
let(s = pot_shaft(pot), let(s = pot_shaft(pot),
washer = washer && pot_washer(pot) ? pot_washer(pot) : [0, 0], washer = washer && pot_washer(pot) ? pot_washer(pot) : [0, 0],
nut = pot_nut(pot) ? pot_nut(pot) : [pot_thread_d(pot) * cos(30), pot_thread_h(pot) - thickness], nut = pot_nut(pot) ? pot_nut(pot) : [pot_thread_d(pot) * cos(30), pot_thread_h(pot) - thickness],
@@ -68,6 +68,7 @@ function knob_for_pot(pot, thickness, z = 1, shaft_length = undef, top_d = 12, b
bot_d = bot_d, bot_d = bot_d,
height = height, height = height,
corner_r = corner_r, corner_r = corner_r,
screw = screw,
skirt = skirt, skirt = skirt,
pointer = pointer, pointer = pointer,
shaft_d = s.x, shaft_d = s.x,
@@ -83,11 +84,11 @@ module knob(type, supports = true) { //! Generate the STL for a knob
r_bot = knob_bot_d(type) / 2; r_bot = knob_bot_d(type) / 2;
h = knob_height(type); h = knob_height(type);
r = knob_corner_r(type); r = knob_corner_r(type);
sr = knob_shaft_d(type) / 2 + clearance; screw = knob_screw(type);
sr = knob_shaft_d(type) / 2 + (screw ? clearance : 0);
top_wall = h - knob_shaft_len(type); top_wall = h - knob_shaft_len(type);
fr = knob_flat_d(type) - sr + 2 * clearance; fr = knob_flat_d(type) - sr + 2 * clearance;
fh = knob_flat_h(type); fh = knob_flat_h(type);
screw = knob_screw(type);
skirt = knob_skirt(type); skirt = knob_skirt(type);
recess = knob_recess(type); recess = knob_recess(type);
pointer = knob_pointer(type); pointer = knob_pointer(type);
@@ -125,6 +126,7 @@ module knob(type, supports = true) { //! Generate the STL for a knob
difference() { difference() {
poly_circle(sr); poly_circle(sr);
if(fr > 0)
translate([-sr, fr]) translate([-sr, fr])
square([2 * sr, sr]); square([2 * sr, sr]);
} }
@@ -153,14 +155,17 @@ module knob(type, supports = true) { //! Generate the STL for a knob
//! Knob with grub screw in place //! Knob with grub screw in place
module knob_assembly(type) explode(40, explode_children = true) { //! Assembly with the grub screw in place module knob_assembly(type) explode(40, explode_children = true) { //! Assembly with the grub screw in place
fr = knob_flat_d(type) - knob_shaft_d(type) / 2; sr = knob_shaft_d(type) / 2;
fr = knob_flat_d(type) < sr ? knob_flat_d(type) - sr : sr;
r_top = knob_top_d(type) / 2; r_top = knob_top_d(type) / 2;
r_bot = knob_bot_d(type) / 2; r_bot = knob_bot_d(type) / 2;
screw_length = screw_shorter_than(min(r_top, r_bot) - fr); screw_length = screw_shorter_than(min(r_top, r_bot) - fr);
screw = knob_screw(type);
stl_colour(pp1_colour) render() knob(type, supports = false); stl_colour(pp1_colour) render() knob(type, supports = false);
if(screw)
translate([0, (fr + screw_length), knob_screw_z(type)]) translate([0, (fr + screw_length), knob_screw_z(type)])
rotate([90, 0, 180]) rotate([90, 0, 180])
screw(knob_screw(type), screw_length); screw(screw, screw_length);
} }

View File

@@ -5326,7 +5326,7 @@ The STL includes a support membrane that needs to be cut out and a thread needs
| Function | Description | | Function | Description |
|:--- |:--- | |:--- |:--- |
| `knob(name = "knob", top_d = 12, bot_d = 15, height = 18, shaft_length, skirt = [20, 2], pointer = false, corner_r = 2, screw = M3_grub_screw, shaft_d, flat_d, flat_h, recess)` | Constructor | | `knob(name = "knob", top_d = 12, bot_d = 15, height = 18, shaft_length, skirt = [20, 2], pointer = false, corner_r = 2, screw = M3_grub_screw, shaft_d, flat_d, flat_h, recess)` | Constructor |
| `knob_for_pot(pot, thickness, z = 1, shaft_length = undef, top_d = 12, bot_d = 15, skirt = [20, 2], pointer = false, corner_r = 2, height = 0, washer = true)` | Construct a knob to fit specified pot | | `knob_for_pot(pot, thickness, z = 1, washer = true, top_d = 12, bot_d = 15, height = 0, shaft_length = undef, skirt = [20, 2], pointer = false, corner_r = 2, screw = M3_grub_screw)` | Construct a knob to fit specified pot |
### Modules ### Modules
| Module | Description | | Module | Description |
@@ -5344,9 +5344,9 @@ The STL includes a support membrane that needs to be cut out and a thread needs
| 1 | `potentiometer(imperial_pot)` | Potentiometer imperial_pot | | 1 | `potentiometer(imperial_pot)` | Potentiometer imperial_pot |
| 1 | `potentiometer(imperial_pot_x2)` | Potentiometer imperial_pot_x2 | | 1 | `potentiometer(imperial_pot_x2)` | Potentiometer imperial_pot_x2 |
| 1 | `potentiometer(metric_pot)` | Potentiometer metric_pot | | 1 | `potentiometer(metric_pot)` | Potentiometer metric_pot |
| 1 | `screw(M3_grub_screw, 4)` | Screw M3 grub x 4mm | | 1 | `screw(M3_grub_screw, 3)` | Screw M3 grub x 3mm |
| 2 | `screw(M3_grub_screw, 5)` | Screw M3 grub x 5mm | | 2 | `screw(M3_grub_screw, 4)` | Screw M3 grub x 4mm |
| 2 | `screw(M3_grub_screw, 6)` | Screw M3 grub x 6mm | | 1 | `screw(M3_grub_screw, 6)` | Screw M3 grub x 6mm |
### Printed ### Printed
| Qty | Filename | | Qty | Filename |

View File

@@ -20,7 +20,7 @@ z = 1; // [0: 5]
thickness = 3; // [0: 5] thickness = 3; // [0: 5]
shaft_length = 10; shaft_length = 10;
include <../utils/core/core.scad> include <../core.scad>
use <../printed/knob.scad> use <../printed/knob.scad>
use <../utils/layout.scad> use <../utils/layout.scad>
@@ -31,7 +31,8 @@ knobs = [for(i = [0 : len(potentiometers) - 1]) let(p = potentiometers[i])
top_d = [10, 12, 20, 16, 16 ][i], top_d = [10, 12, 20, 16, 16 ][i],
bot_d = [10, 15, 20, 20, 20 ][i], bot_d = [10, 15, 20, 20, 20 ][i],
skirt = [false, [20, 2], false, [27, 1.5], [27, 1.5]][i], skirt = [false, [20, 2], false, [27, 1.5], [27, 1.5]][i],
pointer = [false, false, [14, [1, 5], 2], [13.5, [1, 1], 3], [13.5, [1, 3], 3]][i] pointer = [false, false, [14, [1, 5], 2], [13.5, [1, 1], 3], [13.5, [1, 3], 3]][i],
screw = let(s = pot_shaft(p)) s.y > s.x / 2 ? M3_grub_screw : false
)]; )];