1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-01-16 13:08:15 +01:00

Added printed knobs for pots.

This commit is contained in:
Chris Palmer 2021-10-28 12:50:22 +01:00
parent c8d9bb7d09
commit b424bea622
9 changed files with 313 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 KiB

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 944 KiB

After

Width:  |  Height:  |  Size: 945 KiB

View File

@ -123,6 +123,7 @@ use <tests/fixing_block.scad>
use <tests/flat_hinge.scad>
use <tests/foot.scad>
use <tests/handle.scad>
use <tests/knob.scad>
use <tests/PCB_mount.scad>
use <tests/pocket_handle.scad>
use <tests/printed_box.scad>
@ -173,16 +174,19 @@ translate([x5, cable_grommets_y + 470]) {
flat_hinges();
}
translate([x5, cable_grommets_y + 370])
translate([x5, cable_grommets_y + 380])
no_explode() socket_boxes();
translate([x5 + 60, cable_grommets_y + 200])
strap_handles();
translate([640, cable_grommets_y + 200])
printed_pulley_test();
translate([x5, cable_grommets_y + 250])
translate([x5, cable_grommets_y + 200])
knobs();
translate([x5 + 60, cable_grommets_y + 250])
strap_handles();
translate([x5, cable_grommets_y + 300])
handle();
translate([950, 600])

166
printed/knob.scad Normal file
View File

@ -0,0 +1,166 @@
//
// NopSCADlib Copyright Chris Palmer 221
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Parametric knobs for potentiometers and encoders.
//!
//! A knob can be constructed by specififying all the parameters or the potentiometer can be specified to customise it for its shaft with a recess to clear the nut, washer and thread.
//! An optional skirt and / or a pointer can be specified.
//!
//! The STL includes a support membrane that needs to be cut out and a thread needs to be tapped for the grub screw.
//
include <../core.scad>
use <../utils/hanging_hole.scad>
use <../utils/rounded_polygon.scad>
use <../vitamins/potentiometer.scad>
clearance = 0.2;
function knob_name(type) = type[0]; //! Name for the stl maker
function knob_top_d(type) = type[1]; //! Diameter at the top
function knob_bot_d(type) = type[2]; //! Diameter at the bottom
function knob_height(type) = type[3]; //! Height
function knob_corner_r(type) = type[4]; //! Rounded top corner
function knob_shaft_d(type) = type[5]; //! Shaft diameter
function knob_shaft_len(type)= type[6]; //! Shaft length
function knob_flat_d(type) = type[7]; //! The shaft diameter at the flat
function knob_flat_h(type) = type[8]; //! The length of the flat
function knob_screw(type) = type[9]; //! The grub screw type
function knob_skirt(type) = type[10]; //! Skirt diameter and thickness
function knob_recess(type) = type[11]; //! Recess diameter and thickness to clear nut and thread, diameter, nut height, thread height
function knob_pointer(type) = type[12]; //! Pointer outside radius, [point width, back width] and height height
function 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
[
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
let(s = pot_shaft(pot),
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],
shaft_length = is_undef(shaft_length) ? s.z : min(shaft_length, s.z),
h = round_to_layer(shaft_length + pot_thread_h(pot) - thickness - z),
height = max(height, h + 1),
recess = [(z > washer.y ? nut.x / cos(30) : washer.x) + 0.4, round_to_layer(nut.y + washer.y - z + layer_height), round_to_layer(pot_thread_h(pot) - z - thickness + 2 * layer_height)],
flat_d = s.y + 0.06,
flat_h = min(s[3], shaft_length)
)
knob(name = str(pot[0], "_knob"),
top_d = top_d,
bot_d = bot_d,
height = height,
corner_r = corner_r,
skirt = skirt,
pointer = pointer,
shaft_d = s.x,
shaft_length = h,
flat_d = flat_d,
flat_h = flat_h,
recess = recess);
function knob_screw_z(type) = knob_shaft_len(type) - knob_flat_h(type) / 2;
module knob(type, supports = true) { //! Generate the STL for a knob
r_top = knob_top_d(type) / 2;
r_bot = knob_bot_d(type) / 2;
h = knob_height(type);
r = knob_corner_r(type);
sr = knob_shaft_d(type) / 2 + clearance;
top_wall = h - knob_shaft_len(type);
fr = knob_flat_d(type) - sr + 2 * clearance;
fh = knob_flat_h(type);
screw = knob_screw(type);
skirt = knob_skirt(type);
recess = knob_recess(type);
pointer = knob_pointer(type);
stl(knob_name(type))
{
difference() {
union() {
rotate_extrude() {
rounded_polygon([
[0, h, 0],
[r_top - r, h - r, r],
[r_bot, 0, 0],
[0, 0, 0],
]);
if(skirt)
square([skirt.x / 2, skirt.y]);
}
if(pointer)
linear_extrude(pointer.z)
rotate(-90)
hull() {
translate([pointer.x, 0])
square([eps, pointer.y[0]], center = true);
translate([r_bot, 0])
square([eps, pointer.y[1]], center = true);
}
}
shaft_z = recess ? recess.z + (supports ? layer_height : -eps) : -eps;
translate_z(shaft_z) {
h = h - top_wall - shaft_z;
linear_extrude(h)
difference() {
poly_circle(sr);
translate([-sr, fr])
square([2 * sr, sr]);
}
if(h > fh)
poly_cylinder(sr, round_to_layer(h - fh), center = false);
}
if(recess)
translate_z(-eps)
hull() {
poly_cylinder(r = recess.x / 2, h = recess.y + eps, center = false);
linear_extrude(recess.z + eps)
offset(min(-(recess.z - recess.y), 0))
poly_circle(recess.x / 2);
}
if(screw)
translate_z(knob_screw_z(type))
rotate([90, 0, 180])
teardrop_plus(r = screw_pilot_hole(screw), h = max(r_top, r_bot) + eps, center = false);
}
}
}
//! Knob with 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;
r_top = knob_top_d(type) / 2;
r_bot = knob_bot_d(type) / 2;
screw_length = screw_shorter_than(min(r_top, r_bot) - fr);
stl_colour(pp1_colour) render() knob(type, supports = false);
translate([0, (fr + screw_length), knob_screw_z(type)])
rotate([90, 0, 180])
screw(knob_screw(type), screw_length);
}

View File

@ -35,18 +35,18 @@ A list of changes classified as breaking, additions or fixes is maintained in [C
<tr><td> <a href = "#Cable_strips">Cable_strips</a> </td><td> <a href = "#Microswitches">Microswitches</a> </td><td> <a href = "#Sheets">Sheets</a> </td><td> <a href = "#Flat_hinge">Flat_hinge</a> </td><td> <a href = "#Offset">Offset</a> </td><td></td></tr>
<tr><td> <a href = "#Cameras">Cameras</a> </td><td> <a href = "#Microview">Microview</a> </td><td> <a href = "#Spades">Spades</a> </td><td> <a href = "#Foot">Foot</a> </td><td> <a href = "#Quadrant">Quadrant</a> </td><td></td></tr>
<tr><td> <a href = "#Circlips">Circlips</a> </td><td> <a href = "#Modules">Modules</a> </td><td> <a href = "#Spools">Spools</a> </td><td> <a href = "#Handle">Handle</a> </td><td> <a href = "#Round">Round</a> </td><td></td></tr>
<tr><td> <a href = "#Components">Components</a> </td><td> <a href = "#Nuts">Nuts</a> </td><td> <a href = "#Springs">Springs</a> </td><td> <a href = "#PCB_mount">PCB_mount</a> </td><td> <a href = "#Rounded_cylinder">Rounded_cylinder</a> </td><td></td></tr>
<tr><td> <a href = "#DIP">DIP</a> </td><td> <a href = "#O_ring">O_ring</a> </td><td> <a href = "#Stepper_motors">Stepper_motors</a> </td><td> <a href = "#PSU_shroud">PSU_shroud</a> </td><td> <a href = "#Rounded_polygon">Rounded_polygon</a> </td><td></td></tr>
<tr><td> <a href = "#D_connectors">D_connectors</a> </td><td> <a href = "#Opengrab">Opengrab</a> </td><td> <a href = "#Swiss_clips">Swiss_clips</a> </td><td> <a href = "#Pocket_handle">Pocket_handle</a> </td><td> <a href = "#Rounded_triangle">Rounded_triangle</a> </td><td></td></tr>
<tr><td> <a href = "#Displays">Displays</a> </td><td> <a href = "#PCB">PCB</a> </td><td> <a href = "#Toggles">Toggles</a> </td><td> <a href = "#Press_fit">Press_fit</a> </td><td> <a href = "#Sector">Sector</a> </td><td></td></tr>
<tr><td> <a href = "#Extrusion_brackets">Extrusion_brackets</a> </td><td> <a href = "#PCBs">PCBs</a> </td><td> <a href = "#Transformers">Transformers</a> </td><td> <a href = "#Printed_box">Printed_box</a> </td><td> <a href = "#Sweep">Sweep</a> </td><td></td></tr>
<tr><td> <a href = "#Extrusions">Extrusions</a> </td><td> <a href = "#PSUs">PSUs</a> </td><td> <a href = "#Tubings">Tubings</a> </td><td> <a href = "#Printed_pulleys">Printed_pulleys</a> </td><td> <a href = "#Thread">Thread</a> </td><td></td></tr>
<tr><td> <a href = "#Fans">Fans</a> </td><td> <a href = "#Panel_meters">Panel_meters</a> </td><td> <a href = "#Variacs">Variacs</a> </td><td> <a href = "#Ribbon_clamp">Ribbon_clamp</a> </td><td> <a href = "#Tube">Tube</a> </td><td></td></tr>
<tr><td> <a href = "#Fuseholder">Fuseholder</a> </td><td> <a href = "#Pillars">Pillars</a> </td><td> <a href = "#Veroboard">Veroboard</a> </td><td> <a href = "#SSR_shroud">SSR_shroud</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Geared_steppers">Geared_steppers</a> </td><td> <a href = "#Pillow_blocks">Pillow_blocks</a> </td><td> <a href = "#Washers">Washers</a> </td><td> <a href = "#Screw_knob">Screw_knob</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Green_terminals">Green_terminals</a> </td><td> <a href = "#Pin_headers">Pin_headers</a> </td><td> <a href = "#Wire">Wire</a> </td><td> <a href = "#Socket_box">Socket_box</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Hot_ends">Hot_ends</a> </td><td> <a href = "#Potentiometers">Potentiometers</a> </td><td> <a href = "#Zipties">Zipties</a> </td><td> <a href = "#Strap_handle">Strap_handle</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Hygrometer">Hygrometer</a> </td><td> <a href = "#Pulleys">Pulleys</a> </td><td></td><td></td><td></td><td></td></tr>
<tr><td> <a href = "#Components">Components</a> </td><td> <a href = "#Nuts">Nuts</a> </td><td> <a href = "#Springs">Springs</a> </td><td> <a href = "#Knob">Knob</a> </td><td> <a href = "#Rounded_cylinder">Rounded_cylinder</a> </td><td></td></tr>
<tr><td> <a href = "#DIP">DIP</a> </td><td> <a href = "#O_ring">O_ring</a> </td><td> <a href = "#Stepper_motors">Stepper_motors</a> </td><td> <a href = "#PCB_mount">PCB_mount</a> </td><td> <a href = "#Rounded_polygon">Rounded_polygon</a> </td><td></td></tr>
<tr><td> <a href = "#D_connectors">D_connectors</a> </td><td> <a href = "#Opengrab">Opengrab</a> </td><td> <a href = "#Swiss_clips">Swiss_clips</a> </td><td> <a href = "#PSU_shroud">PSU_shroud</a> </td><td> <a href = "#Rounded_triangle">Rounded_triangle</a> </td><td></td></tr>
<tr><td> <a href = "#Displays">Displays</a> </td><td> <a href = "#PCB">PCB</a> </td><td> <a href = "#Toggles">Toggles</a> </td><td> <a href = "#Pocket_handle">Pocket_handle</a> </td><td> <a href = "#Sector">Sector</a> </td><td></td></tr>
<tr><td> <a href = "#Extrusion_brackets">Extrusion_brackets</a> </td><td> <a href = "#PCBs">PCBs</a> </td><td> <a href = "#Transformers">Transformers</a> </td><td> <a href = "#Press_fit">Press_fit</a> </td><td> <a href = "#Sweep">Sweep</a> </td><td></td></tr>
<tr><td> <a href = "#Extrusions">Extrusions</a> </td><td> <a href = "#PSUs">PSUs</a> </td><td> <a href = "#Tubings">Tubings</a> </td><td> <a href = "#Printed_box">Printed_box</a> </td><td> <a href = "#Thread">Thread</a> </td><td></td></tr>
<tr><td> <a href = "#Fans">Fans</a> </td><td> <a href = "#Panel_meters">Panel_meters</a> </td><td> <a href = "#Variacs">Variacs</a> </td><td> <a href = "#Printed_pulleys">Printed_pulleys</a> </td><td> <a href = "#Tube">Tube</a> </td><td></td></tr>
<tr><td> <a href = "#Fuseholder">Fuseholder</a> </td><td> <a href = "#Pillars">Pillars</a> </td><td> <a href = "#Veroboard">Veroboard</a> </td><td> <a href = "#Ribbon_clamp">Ribbon_clamp</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Geared_steppers">Geared_steppers</a> </td><td> <a href = "#Pillow_blocks">Pillow_blocks</a> </td><td> <a href = "#Washers">Washers</a> </td><td> <a href = "#SSR_shroud">SSR_shroud</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Green_terminals">Green_terminals</a> </td><td> <a href = "#Pin_headers">Pin_headers</a> </td><td> <a href = "#Wire">Wire</a> </td><td> <a href = "#Screw_knob">Screw_knob</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Hot_ends">Hot_ends</a> </td><td> <a href = "#Potentiometers">Potentiometers</a> </td><td> <a href = "#Zipties">Zipties</a> </td><td> <a href = "#Socket_box">Socket_box</a> </td><td></td><td></td></tr>
<tr><td> <a href = "#Hygrometer">Hygrometer</a> </td><td> <a href = "#Pulleys">Pulleys</a> </td><td></td><td> <a href = "#Strap_handle">Strap_handle</a> </td><td></td><td></td></tr>
</table>
---
@ -5289,6 +5289,75 @@ Printed handle that can be printed without needing support material due to its t
| 1 | handle_assembly |
<a href="#top">Top</a>
---
<a name="Knob"></a>
## Knob
Parametric knobs for potentiometers and encoders.
A knob can be constructed by specififying all the parameters or the potentiometer can be specified to customise it for its shaft with a recess to clear the nut, washer and thread.
An optional skirt and / or a pointer can be specified.
The STL includes a support membrane that needs to be cut out and a thread needs to be tapped for the grub screw.
[printed/knob.scad](printed/knob.scad) Implementation.
[tests/knob.scad](tests/knob.scad) Code for this example.
### Properties
| Function | Description |
|:--- |:--- |
| `knob_bot_d(type)` | Diameter at the bottom |
| `knob_corner_r(type)` | Rounded top corner |
| `knob_flat_d(type)` | The shaft diameter at the flat |
| `knob_flat_h(type)` | The length of the flat |
| `knob_height(type)` | Height |
| `knob_name(type)` | Name for the stl maker |
| `knob_pointer(type)` | None |
| `knob_recess(type)` | Recess diameter and thickness to clear nut and thread, diameter, nut height, thread height |
| `knob_screw(type)` | The grub screw type |
| `knob_shaft_d(type)` | Shaft diameter |
| `knob_shaft_len(type)` | Shaft length |
| `knob_skirt(type)` | Skirt diameter and thickness |
| `knob_top_d(type)` | Diameter at the top |
### Functions
| 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_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 |
### Modules
| Module | Description |
|:--- |:--- |
| `knob(type, supports = true)` | Generate the STL for a knob |
| `knob_assembly(type) explode(40, explode_children = true)` | Assembly with the grub screw in place |
![knob](tests/png/knob.png)
### Vitamins
| Qty | Module call | BOM entry |
| ---:|:--- |:---|
| 1 | `potentiometer(BTT_encoder)` | BTT_encoder |
| 1 | `potentiometer(KY_040_encoder)` | KY_040_encoder |
| 1 | `potentiometer(imperial_pot)` | Potentiometer imperial_pot |
| 1 | `potentiometer(imperial_pot_x2)` | Potentiometer imperial_pot_x2 |
| 1 | `potentiometer(metric_pot)` | Potentiometer metric_pot |
| 1 | `screw(M3_grub_screw, 4)` | Screw M3 grub x 4mm |
| 2 | `screw(M3_grub_screw, 5)` | Screw M3 grub x 5mm |
| 2 | `screw(M3_grub_screw, 6)` | Screw M3 grub x 6mm |
### Printed
| Qty | Filename |
| ---:|:--- |
| 1 | BTT_encoder_knob.stl |
| 1 | KY_040_encoder_knob.stl |
| 1 | imperial_pot_knob.stl |
| 1 | imperial_pot_x2_knob.stl |
| 1 | metric_pot_knob.stl |
<a href="#top">Top</a>
---

57
tests/knob.scad Normal file
View File

@ -0,0 +1,57 @@
//
// NopSCADlib Copyright Chris Palmer 2021
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
z = 1; // [0: 5]
thickness = 3; // [0: 5]
shaft_length = 10;
include <../utils/core/core.scad>
use <../printed/knob.scad>
use <../utils/layout.scad>
include <../vitamins/potentiometers.scad>
knobs = [for(i = [0 : len(potentiometers) - 1]) let(p = potentiometers[i])
knob_for_pot(p, thickness, z, shaft_length = pot_shaft(p).z > 20 ? shaft_length : undef,
top_d = [10, 12, 20, 16, 16 ][i],
bot_d = [10, 15, 20, 20, 20 ][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]
)];
module knobs(show_pot = false)
layout([for(p = potentiometers) pot_size(p).x], 5) let(p = potentiometers[$i])
if($preview) {
translate_z(z)
knob_assembly(knobs[$i]);
if(show_pot)
translate_z(-thickness)
vflip() {
potentiometer(p, shaft_length = shaft_length);
translate_z(-thickness)
pot_nut(p);
}
}
else
knob(knobs[$i]);
knobs(true);

BIN
tests/png/knob.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB