1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-01 19:33:06 +02:00

Parametric potentiometers added, changes PCB "potentiometer" parameters.

The first one is now the type that defaults to the previous BigTreeTech version.
The second parameter is the shaft length overrride.

Added ESP32_DOIT_V1, ArduinoNano and KY_040 breakout PCBs.
This commit is contained in:
Chris Palmer
2021-09-11 12:01:04 +01:00
parent 74c52aac04
commit 3299aad5c8
13 changed files with 441 additions and 81 deletions

View File

@@ -38,6 +38,7 @@ use <led.scad>
use <dip.scad>
use <axial.scad>
use <smd.scad>
include <potentiometers.scad>
function pcb_name(type) = type[1]; //! Description
function pcb_length(type) = type[2]; //! Length
@@ -59,7 +60,6 @@ function pcb_size(type) = [pcb_length(type), pcb_width(type), pcb_thickness(type
function pcb_component(type, name, index = 0) = //! Return the component specified by name and index
[for(component = pcb_components(type)) if(component[3] == name) component][index];
function pcb_grid_pos(type, x, y, z = 0) = //! Returns a pcb grid position
let(grid = pcb_grid(type))
[-pcb_size(type).x / 2 + grid.x + x * (is_undef(grid[5]) ? 2.54 : grid[5]),
@@ -366,31 +366,11 @@ module jack(cutout = false) { //! Draw 3.5mm jack
module buzzer(height, diameter, colour) { //! Draw PCB buzzer with specified height, diameter and colour
color (colour)
tube(or = diameter / 2, ir = height > 5 ? 1 : 0.75, h = height, center = false);
color("white")
cylinder(d = 2, h = max(height - 3 , 0.5));
}
module potentiometer(h1, h2) {
color("silver") {
baseSize = [12, 11, 6];
translate_z(baseSize.z / 2)
cube(baseSize, center = true);
translate_z(baseSize.z) {
cylinder(d = 5, h = h1 - 0.5);
if (show_threads)
male_metric_thread(6, metric_coarse_pitch(5), length = h1 - 0.5, center = false);
}
translate_z(baseSize.z + h1 - 0.5)
cylinder(d = 3, h = 0.5);
translate_z(baseSize.z + h1)
linear_extrude(h2)
difference() {
circle(d=5);
square([0.75,5], center = true);
}
}
}
function hdmi_depth(type) = type[2]; //! Front to back depth
function hdmi_width1(type) = type[3]; //! Inside width at the top
function hdmi_width2(type) = type[4]; //! Inside width at the bottom
@@ -1074,7 +1054,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
if(show(comp, "molex_hdr")) molex_254(comp[4], param(5, 0), param(6, undef));
if(show(comp, "jst_xh")) jst_xh_header(jst_xh_header, comp[4], param(5, false), param(6, "white"), param(7, undef));
if(show(comp, "jst_ph")) jst_xh_header(jst_ph_header, comp[4], param(5, false), param(6, "white"), param(7, undef));
if(show(comp, "potentiometer")) potentiometer(param(4, 5), param(5, 9));
if(show(comp, "potentiometer")) let(pot = param(4, BTT_encoder)) translate_z(pot_size(pot).z) vflip() potentiometer(pot, shaft_length = param(5, undef));
if(show(comp, "buzzer")) buzzer(param(4, 9), param(5, 12), param(6, grey(20)));
if(show(comp, "smd_res")) smd_resistor(comp[4], comp[5]);
if(show(comp, "smd_cap")) smd_capacitor(comp[4], comp[5]);

View File

@@ -820,11 +820,71 @@ LIPO_fuel_gauge = [
[] // accessories
];
ESP32_DOIT_V1 = let(l = 51.45, w = 28.33, pitch = inch(1), pins = 15, poffset = inch(0.05)) [
"ESP32_DOIT_V1", "ESP32 DOIT DEV KIT V1",
l, w, 1.6, // Size
2, // corner radius
3, // mounting hole diameter
0, // pad around mounting hole
grey(20), // color
false, // true if parts should be separate BOM items
[for(x = [-1, 1], y = [-1, 1]) [x * 46.7 / 2 + l / 2, y * 23.4 / 2 + w / 2, false]],
[ // components
[l / 2 + poffset, w / 2 - pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset, w / 2 + pitch / 2, 0, "-2p54joiner", pins, 1],
[1.75, w / 2, 180, "usb_uA" ],
[35, w / 2, 0, "block", 17.7, 16, 3, silver], // can
for(y=[-1,1]) [3.5, y * 6.5, 0, "chip", 4, 3, 1.6, silver], // Mock button surround
for(y=[-1,1]) [3.5, y * 6.5, 0, "chip", 1.8,0, 2.0, grey(20)], // Mock buttons
for(y=[-1,1]) [21.6, y * 9, 0, "smd_led", LED0603, y < 0 ? "red" : "blue"],
[14.8 - 2.5, 8, 0, "chip", 5, 5, 0.8],
[l / 2 + poffset + inch(0.7), w / 2 + pitch / 2 - 2, 90, "smd_cap", CAP1206, 1.75],
],
[], // accessories
[(l - inch(pins - 1) / 10) / 2 + inch(0.05), (w - pitch) / 2, pins, 2, silver, 2.54, pitch], // 15x2 grid of holes
];
ArduinoNano = let(l = 43.18, w = 17.78, pitch = inch(0.6), pins = 15, poffset = -0.05, led_spacing = [1.5, 1.8]) [
"ArduinoNano", "Arduino Nano",
l, w, 1.6, // Size
0, // corner radius
1.85, // mounting hole diameter
0, // pad around mounting hole
"#2140BE", // color
false, // true if parts should be separate BOM items
[for(x = [-1, 1], y = [-1, 1]) [x * 40.64 / 2 + l / 2, y * 15.24 / 2 + w / 2]],
[ // components
[l / 2 + poffset, w / 2 - pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset, w / 2 + pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset + inch(0.75), w / 2, 0, "2p54header", 2, 3],
[1.75, w / 2, 180, "usb_uA" ],
[l / 2 - inch(0.25), w / 2, 45, "chip", 7, 7, 1.3],
[l / 2 + poffset + inch(0.15), w / 2, 0, "chip", 3.5, 6, 1.8, silver ], // mock button
[l / 2 + poffset + inch(0.15), w / 2, 0, "chip", 1.3, 2.6, 2.6, grey(90) ], // mock button
for(y = [-1.5 : 1.5]) [l / 2 + poffset + inch(0.4) - led_spacing.x, w / 2 + y * led_spacing.y, 0, "smd_res", RES0603, "1K"],
for(y = [-1.5 : 1.5]) [l / 2 + poffset + inch(0.4) + led_spacing.x, w / 2 + y * led_spacing.y, 0, "smd_led", LED0603, ["green", "red", "orange", "orange"][y + 1.5]],
],
[], // accessories
[(l - inch(pins - 1) / 10) / 2 + poffset, (w - pitch) / 2, pins, 2, silver, 2.54, pitch], // 15x2 grid of holes
];
KY_040 = ["KY_040", "KY_-040 rotart encoder breakout",
26.3, 19.5, 1.6, 0, 3, 0, grey(20), false,
[
[3.23 + 1.5, 1.3 + 1.5],
[3.23 + 1.5 + 16.775, 1.3 + 1.5]
],
[
[-3, 12, 90, "2p54header", 5, 1, undef, undef, true],
[10.8, 11.3, 0, "potentiometer", KY_040_encoder],
],
[]];
tiny_pcbs = [XIAO, MP1584EN, TP4056, ESP_01, LIPO_fuel_gauge];
pcbs = [RAMPSEndstop, MT3608, PI_IO, ExtruderPCB, ZC_A0591, RPI_Pico, RPI0, EnviroPlus, ArduinoUno3, ArduinoLeonardo, WD2002SJ, RPI3, RPI4, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO, BTT_SKR_V1_4_TURBO, DuetE, Duex5];
pcbs = [RAMPSEndstop, KY_040, MT3608, ZC_A0591, ArduinoNano, RPI_Pico, ESP32_DOIT_V1, RPI0, EnviroPlus, ArduinoUno3, ArduinoLeonardo, WD2002SJ, RPI3, RPI4, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO, BTT_SKR_V1_4_TURBO, DuetE, Duex5];
pcbs_not_shown = [Melzi, Duex2, PSU12V1A, Keyes5p1];
pcbs_not_shown = [Melzi, Duex2, PSU12V1A, Keyes5p1, PI_IO, ExtruderPCB];
perfboards = [PERF74x51, PERF70x51, PERF70x50, PERF60x40, PERF70x30, PERF80x20];

207
vitamins/potentiometer.scad Normal file
View File

@@ -0,0 +1,207 @@
//
// 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/>.
//
//! Potentiometers and rotary encoders
include <../utils/core/core.scad>
use <../utils/rounded_cylinder.scad>
use <../utils/round.scad>
use <../utils/thread.scad>
pot_nut_t = 2;
pot_proud = 0.3;
spigot_r = 0.5;
tab = [3.2, 0.5];
function pot_body(type) = type[0]; //! Body diameter or width & depth, height and corner radius
function pot_face(type) = type[1]; //! Faceplate rib width, plate depth and plate height
function pot_wafer(type) = type[2]; //! Width, diameter and thickness of the track wafer plus true if curved
function pot_gangs(type) = type[3]; //! Number of gangs for mult-gang pot
function pot_thread_d(type) = type[4]; //! Nomininal thread diameter
function pot_thread_p(type) = type[5]; //! Thread pritch
function pot_thread_h(type) = type[6]; //! Height of threaded part
function pot_boss_d(type) = type[7]; //! Boss diameter
function pot_boss_h(type) = type[8]; //! Boss height
function pot_spigot(type) = type[9]; //! Spigot width, length and height above the boss
function pot_spigot_x(type) = type[10]; //! Spigot offset from the shaft centre
function pot_shaft(type) = type[11]; //! Diameter, flat diameter, length and flat/slot length and colour. If flat diameter is less than the radius then it is a slot width
function pot_neck(type) = type[12]; //! Diameter and length of the shaft neck
function pot_size(type) = let(d = pot_body(type)) len(d) > 3 ? [d.x , d.y, d.z] : [d.x, d.x, d.y]; //! Get pot body dimensions
function pot_z(type) = pot_thread_h(type) - pot_nut_t - pot_proud; //! Ideal distance behind panel surface to get the nut on comfortably
function pot_spigot_r(type) = let(sp = pot_spigot(type)) sp.x > 2 * spigot_r ? spigot_r : 0;
module potentiometer(type, thickness = 3, shaft_length = undef) {//! Draw a potentiometer with nut spaced by specified thickness
bh = pot_boss_h(type);
s = pot_size(type);
face = pot_face(type);
wafer = pot_wafer(type);
wafer_z = wafer? wafer.z : 0;
round = len(pot_body(type)) < 4;
dia_cast_colour = grey(60);
thread_d = pot_thread_d(type);
thread_h = pot_thread_h(type);
shaft = pot_shaft(type);
color(dia_cast_colour) {
// Boss
if(bh)
cylinder(d = pot_boss_d(type), h = bh);
if(face) {
if(face.x) {
linear_extrude(face.z)
square([face.x, face.y], center = true);
linear_extrude(bh)
difference() {
square([face.x, face.y], center = true);
square([face.x - 2 * face.z, s.x], center = true);
}
}
translate_z(bh - face.z)
linear_extrude(face.z)
intersection() {
circle(d = s.x - eps);
difference() {
square([s.x + eps, face.y], center = true);
if(face.x)
square([face.x - 2 * face.z, s.x], center = true);
}
}
}
// spigot
x = pot_spigot_x(type);
sp = pot_spigot(type);
if(x)
translate([x, 0, bh])
vflip()
rounded_rectangle(sp + [0, 0, bh], pot_spigot_r(type));
// thread
vflip()
if(show_threads)
male_metric_thread(thread_d, pot_thread_p(type), thread_h, center = false, bot = 0, colour = dia_cast_colour);
else
cylinder(d = thread_d, h = pot_thread_h(type));
}
d = pot_body(type);
fz = face ? face.z : 0;
gap = face ? face.z + tab[1] : 0;
total_h = s.z - bh;
gangs = pot_gangs(type);
gang_h = (total_h - (gangs - 1) * gap) / gangs;
pitch = gang_h + gap;
for(i = [0 : gangs - 1])
translate_z(bh + i * pitch) {
// Wafer that carries the track and contacts
if(wafer)
color("sienna") {
linear_extrude(wafer.z) round(wafer[3] ? 1 : 0) {
if(round)
circle(d = s.x - eps);
else
rounded_square([s.x, s.y], d[3]);
intersection() {
translate([0, -s.y / 2])
square([wafer.x, (wafer.y - s.y) * 2], center = true);
if(wafer[3])
circle(wafer.y - s.y / 2);
else
square(100, center = true);
}
}
}
color(silver) {
// Body
translate_z(wafer_z)
if(round)
rounded_cylinder(r = s.x / 2, r2 = d[2], h = gang_h - wafer_z);
else
rounded_rectangle([s.x, s.y, gang_h - wafer_z], d[3]);
// Make tabs that hold the face on
if(face) {
translate_z(-tab[1] - fz)
linear_extrude(face.z + tab[1] + wafer_z)
intersection() {
circle(d = s.x);
for(x = [-1, 1], y = [-1, 1], a = y * 90 + 90 + x * 30)
rotate(a)
translate([s.x / 2, 0])
slot(r = tab.x / 2, l = (s.x - pot_boss_d(type)) / 2 - tab.x / 2, h = 0);
}
}
}
// Face plate between sections
if(face && i) {
color(dia_cast_colour)
translate_z(-fz)
linear_extrude(fz)
intersection() {
circle(d = s.x - eps);
square([s.x + eps, face.y], center = true);
}
color(shaft[4])
vflip()
cylinder(d = shaft.x, h = gap);
}
}
// Shaft
color(shaft[4])
translate_z(-thread_h) vflip() {
shaft_z = is_undef(shaft_length) ? shaft.z : min(shaft_length, shaft.z);
flat_h = shaft[3] - (shaft.z - shaft_z);
plain = shaft_z - flat_h;
neck = pot_neck(type);
neck_h = neck[1];
if(neck_h)
cylinder(d = neck.x, h = neck_h);
if(plain - neck_h > 0)
translate_z(neck_h)
cylinder(d = shaft.x, h = plain - neck_h);
if(flat_h)
translate_z(plain)
linear_extrude(flat_h)
difference() {
circle(d = shaft.x);
if(shaft.y > shaft.x / 2)
translate([0, shaft.x / 2])
square([shaft.x, 2 * (shaft.x - shaft.y)], center = true);
else
if(shaft.y)
square([shaft.y, shaft.x + 1], center = true);
}
}
}

View File

@@ -0,0 +1,29 @@
//
// 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/>.
//
//! Potentiometers and rotary encoders
// body h r face wafer gangs thread d pitch h boss h spigot w, l, h offset shaft d flat h flat h colour neck
imperial_pot_x2 = [[24, 22.5, 1.5], [5.7, 15.33, 0.8], [20, 28, 1.6, true], 2, inch(3/8), inch(1/32), 6.35, 13.6, 2.4, [1.12, 3.03, 2], 11, [6.27, 5.5, 44.3, 44.3, silver], [0, 0]];
imperial_pot = [[24, 12, 1.5], [5.7, 15.33, 0.8], [20, 28, 1.6, true], 1, inch(3/8), inch(1/32), 6.35, 13.6, 2.4, [1.12, 3.03, 2], 11, [6.27, 5.5, 44.3, 44.3, grey(95)], [0, 0]];
metric_pot = [[23, 11, 1.0], [0, 15.33, 0.8], [18, 27, 1.2, false], 1, 10, 0.75, 7.32, 13.9, 2.5, [1.12, 2.88, 1.26], 11, [6.27, 5.5, 43.8, 43.5, grey(50)], [0, 0]];
KY_040_encoder = [[12, 12, 6.5, 1.0], false, false, 1, 7, 0.75, 7, 0, 0, [0.4, 2, 0.8],5.8, [6, 4.5, 13, 10, grey(60)], [4, 0.5]];
BTT_encoder = [[12, 11, 6, 0.5], false, false, 1, 6, 0.8, 4.5, 0, 0, false, 0, [5, 0.75, 9.5, 9, silver], [3, 0.5]];
potentiometers = [BTT_encoder, KY_040_encoder, metric_pot, imperial_pot, imperial_pot_x2];
use <potentiometer.scad>