diff --git a/libtest.png b/libtest.png index 110b4e3..0a23fa4 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index 4f374d9..08da923 100644 --- a/libtest.scad +++ b/libtest.scad @@ -41,6 +41,7 @@ // include +use use use use @@ -83,6 +84,7 @@ use use use use +use use use use @@ -212,8 +214,8 @@ linear_bearings_y = leadnuts_y + 50; steppers_y = linear_bearings_y + 110; sheets_y = steppers_y + 55; pcbs_y = sheets_y + 60; -displays_y = pcbs_y + 170; -fans_y = displays_y + 80; +displays_y = pcbs_y + 140; +fans_y = displays_y + 110; transformers_y = fans_y + 120; psus_y = transformers_y + 190; @@ -427,9 +429,10 @@ extrusion_brackets_y = rails_y + 250; sk_brackets_y = extrusion_brackets_y + 80; kp_pillow_blocks_y = sk_brackets_y + 60; scs_bearing_blocks_y = kp_pillow_blocks_y + 60; -cable_strip_y = sheets_y; box_sections_y = batteries_y; -BLDC_y = steppers_y; +BLDC_y = scs_bearing_blocks_y + 120; +pot_y = BLDC_y + 40; +cable_strip_y = pot_y + 50; translate([0, transformers_y]) servo_motors(); @@ -468,6 +471,9 @@ translate([x4, scs_bearing_blocks_y]) translate([x4, BLDC_y]) bldc_motors(); +translate([x4, pot_y]) + potentiometers(); + translate([x2, box_sections_y]) box_sections(); diff --git a/readme.md b/readme.md index 0949bc8..61a611b 100644 --- a/readme.md +++ b/readme.md @@ -21,31 +21,32 @@ A list of changes classified as breaking, additions or fixes is maintained in [C ## Table of Contents - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + +
Vitamins A-H Vitamins I-Q Vitamins R-Z Printed Utilities Core Utilities
Axials IECs Rails Box Annotation BOM
BLDC_motors Inserts Ring_terminals Butt_box Bezier Clip
Ball_bearings Jack Rockers Cable_grommets Catenary Global
Batteries LDRs Rod Camera_housing Core_xy Polyholes
Bearing_blocks LED_meters SK_brackets Carriers Dogbones Rounded_rectangle
Belts LEDs SMDs Corner_block Fillet Sphere
Blowers Leadnuts SSRs Door_hinge Gears Teardrops
Box_sections Light_strips Screws Door_latch Hanging_hole
Bulldogs Linear_bearings Sealing_strip Drag_chain Horiholes
Buttons Magnets Servo_motors Fan_guard Layout
Cable_strips Mains_sockets Shaft_couplings Fixing_block Maths
Cameras Microswitches Sheets Flat_hinge Offset
Circlips Microview Spades Foot Quadrant
Components Modules Spools Handle Round
DIP Nuts Springs PCB_mount Rounded_cylinder
D_connectors O_ring Stepper_motors PSU_shroud Rounded_polygon
Displays Opengrab Swiss_clips Pocket_handle Rounded_triangle
Extrusion_brackets PCB Toggles Press_fit Sector
Extrusions PCBs Transformers Printed_box Sweep
Fans PSUs Tubings Printed_pulleys Thread
Fuseholder Panel_meters Variacs Ribbon_clamp Tube
Geared_steppers Pillars Veroboard SSR_shroud
Green_terminals Pillow_blocks Washers Screw_knob
Hot_ends Pin_headers Wire Socket_box
Hygrometer Pulleys Zipties Strap_handle
7_segments IECs Rails Box Annotation BOM
Axials Inserts Ring_terminals Butt_box Bezier Clip
BLDC_motors Jack Rockers Cable_grommets Catenary Global
Ball_bearings LDRs Rod Camera_housing Core_xy Polyholes
Batteries LED_meters SK_brackets Carriers Dogbones Rounded_rectangle
Bearing_blocks LEDs SMDs Corner_block Fillet Sphere
Belts Leadnuts SSRs Door_hinge Gears Teardrops
Blowers Light_strips Screws Door_latch Hanging_hole
Box_sections Linear_bearings Sealing_strip Drag_chain Horiholes
Bulldogs Magnets Servo_motors Fan_guard Layout
Buttons Mains_sockets Shaft_couplings Fixing_block Maths
Cable_strips Microswitches Sheets Flat_hinge Offset
Cameras Microview Spades Foot Quadrant
Circlips Modules Spools Handle Round
Components Nuts Springs PCB_mount Rounded_cylinder
DIP O_ring Stepper_motors PSU_shroud Rounded_polygon
D_connectors Opengrab Swiss_clips Pocket_handle Rounded_triangle
Displays PCB Toggles Press_fit Sector
Extrusion_brackets PCBs Transformers Printed_box Sweep
Extrusions PSUs Tubings Printed_pulleys Thread
Fans Panel_meters Variacs Ribbon_clamp Tube
Fuseholder Pillars Veroboard SSR_shroud
Geared_steppers Pillow_blocks Washers Screw_knob
Green_terminals Pin_headers Wire Socket_box
Hot_ends Potentiometers Zipties Strap_handle
Hygrometer Pulleys
--- @@ -2520,18 +2521,21 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | Qty | Module call | BOM entry | | ---:|:--- |:---| | 1 | `pcb(ArduinoLeonardo)` | Arduino Leonardo | +| 1 | `pcb(ArduinoNano)` | Arduino Nano | | 1 | `pcb(ArduinoUno3)` | Arduino Uno R3 | | 1 | `pcb(BTT_SKR_E3_TURBO)` | BigTreeTech SKR E3 Turbo | | 1 | `pcb(BTT_SKR_MINI_E3_V2_0)` | BigTreeTech SKR Mini E3 v2.0 | | 1 | `pcb(BTT_SKR_V1_4_TURBO)` | BigTreeTech SKR v1.4 Turbo | | 1 | | Cat 5 patch cable 300mm | -| 1 | `d_plug(DCONN15, pcb = true)` | D-type 15 way PCB mount plug | +| 1 | `d_plug(DCONN15, pcb = true)` | D-type 15 way PCB mount plug - not shown | | 1 | `pcb(DuetE)` | Duet 2 Ethernet electronics | | 1 | `pcb(Duex2)` | Duex2 expansion board - not shown | | 1 | `pcb(Duex5)` | Duex5 expansion board | | 1 | `pcb(ESP-01)` | ESP-01 | +| 1 | `pcb(ESP32_DOIT_V1)` | ESP32 DOIT DEV KIT V1 | | 1 | `pcb(EnviroPlus)` | Enviro+ | -| 1 | `pcb(ExtruderPCB)` | Extruder connection PCB | +| 1 | `pcb(ExtruderPCB)` | Extruder connection PCB - not shown | +| 1 | `pcb(KY_040)` | KY_-040 rotart encoder breakout | | 1 | `pcb(Keyes5p1)` | Keyes5.1 Arduino Uno expansion board - not shown | | 1 | `pcb(LIPO_fuel_gauge)` | LIPO fuel gauge | | 1 | `pcb(MP1584EN)` | MP1584EN 3A buck converter | @@ -2539,13 +2543,13 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 1 | `pcb(Melzi)` | Melzi electronics - not shown | | 4 | | Micro SD card | | 1 | | Micro SD card - not shown | -| 1 | `molex_254(2)` | Molex KK header 2 way | -| 1 | `molex_254(3)` | Molex KK header 3 way | +| 1 | `molex_254(2)` | Molex KK header 2 way - not shown | +| 1 | `molex_254(3)` | Molex KK header 3 way - not shown | | 20 | `nut(M2_nut, nyloc = true)` | Nut M2 x 1.6mm nyloc | | 30 | `nut(M2p5_nut, nyloc = true)` | Nut M2.5 x 2.2mm nyloc | -| 26 | `nut(M3_nut, nyloc = true)` | Nut M3 x 2.4mm nyloc | +| 28 | `nut(M3_nut, nyloc = true)` | Nut M3 x 2.4mm nyloc | | 8 | `nut(M4_nut, nyloc = true)` | Nut M4 x 3.2mm nyloc | -| 1 | `pcb(PI_IO)` | PI_IO V2 | +| 1 | `pcb(PI_IO)` | PI_IO V2 - not shown | | 1 | `pcb(PSU12V1A)` | PSU 12V 1A - not shown | | 1 | `pcb(PERF60x40)` | Perfboard 60 x 40mm | | 1 | `pcb(PERF70x30)` | Perfboard 70 x 30mm | @@ -2553,7 +2557,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 1 | `pcb(PERF70x51)` | Perfboard 70 x 51mm | | 1 | `pcb(PERF74x51)` | Perfboard 74 x 51mm | | 1 | `pcb(PERF80x20)` | Perfboard 80 x 20mm | -| 1 | `pin_socket(2p54header, 13, 2, right_angle = true)` | Pin socket 13 x 2 right_angle | +| 1 | `pin_socket(2p54header, 13, 2, right_angle = true)` | Pin socket 13 x 2 right_angle - not shown | | 1 | `pcb(RAMPSEndstop)` | RAMPS Endstop Switch | | 1 | `pcb(RPI3)` | Raspberry Pi 3 | | 1 | `pcb(RPI4)` | Raspberry Pi 4 | @@ -2562,24 +2566,23 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 8 | `screw(M2_cap_screw, 16)` | Screw M2 cap x 16mm | | 12 | `screw(M2_cap_screw, 20)` | Screw M2 cap x 20mm | | 2 | `screw(M2p5_cap_screw, 16)` | Screw M2.5 cap x 16mm | -| 4 | `screw(M2p5_cap_screw, 20)` | Screw M2.5 cap x 20mm | | 8 | `screw(M2p5_cap_screw, 25)` | Screw M2.5 cap x 25mm | -| 4 | `screw(M2p5_cap_screw, 30)` | Screw M2.5 cap x 30mm | +| 8 | `screw(M2p5_cap_screw, 30)` | Screw M2.5 cap x 30mm | | 4 | `screw(M2p5_pan_screw, 20)` | Screw M2.5 pan x 20mm | | 8 | `screw(M2p5_pan_screw, 25)` | Screw M2.5 pan x 25mm | -| 8 | `screw(M3_cap_screw, 16)` | Screw M3 cap x 16mm | -| 4 | `screw(M3_cap_screw, 25)` | Screw M3 cap x 25mm | +| 10 | `screw(M3_cap_screw, 16)` | Screw M3 cap x 16mm | | 14 | `screw(M3_cap_screw, 30)` | Screw M3 cap x 30mm | +| 4 | `screw(M3_cap_screw, 35)` | Screw M3 cap x 35mm | | 8 | `screw(M4_cap_screw, 35)` | Screw M4 cap x 35mm | | 1 | `pcb(XIAO)` | Seeeduino XIAO | | 1 | `pcb(TP4056)` | TP4056 Li-lon Battery charger module | -| 3 | `terminal_35(2)` | Terminal block 2 way 3.5mm | -| 2 | `green_terminal(gt_2p54, 4)` | Terminal block 4 way 0.1" | +| 3 | `terminal_35(2)` | Terminal block 2 way 3.5mm - not shown | +| 2 | `green_terminal(gt_2p54, 4)` | Terminal block 4 way 0.1" - not shown | | 1 | | USB A to Mini B lead - not shown | | 1 | `pcb(WD2002SJ)` | WD2002SJ Buck Boost DC-DC converter | | 20 | `washer(M2_washer)` | Washer M2 x 5mm x 0.3mm | | 30 | `washer(M2p5_washer)` | Washer M2.5 x 5.9mm x 0.5mm | -| 26 | `washer(M3_washer)` | Washer M3 x 7mm x 0.5mm | +| 28 | `washer(M3_washer)` | Washer M3 x 7mm x 0.5mm | | 8 | `washer(M4_washer)` | Washer M4 x 9mm x 0.8mm | | 1 | `pcb(ZC_A0591)` | ZC-A0591 ULN2003 driver PCB | @@ -2590,22 +2593,22 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 4 | pcb_spacer2070.stl | | 4 | pcb_spacer2080.stl | | 4 | pcb_spacer2090.stl | -| 4 | pcb_spacer25110.stl | | 4 | pcb_spacer25120.stl | -| 4 | pcb_spacer25130_2.stl | +| 4 | pcb_spacer25130.stl | | 4 | pcb_spacer25140_2.stl | -| 4 | pcb_spacer25160.stl | +| 4 | pcb_spacer25150_2.stl | | 4 | pcb_spacer25170.stl | +| 4 | pcb_spacer25180.stl | | 2 | pcb_spacer2550.stl | -| 4 | pcb_spacer2590.stl | -| 4 | pcb_spacer30150.stl | -| 5 | pcb_spacer30180.stl | +| 4 | pcb_spacer2580.stl | +| 4 | pcb_spacer30160.stl | | 5 | pcb_spacer30190.stl | -| 4 | pcb_spacer30200.stl | +| 5 | pcb_spacer30200.stl | +| 4 | pcb_spacer30210.stl | | 4 | pcb_spacer3050.stl | -| 4 | pcb_spacer3060.stl | -| 4 | pcb_spacer40210.stl | +| 6 | pcb_spacer3060.stl | | 4 | pcb_spacer40220.stl | +| 4 | pcb_spacer40230.stl |
Top @@ -2766,6 +2769,50 @@ Pin headers and sockets, etc. | 1 | `pin_socket(2p54header, 8, 1)` | Pin socket 8 x 1 | +Top + +--- + +## Potentiometers +Potentiometers and rotary encoders + +[vitamins/potentiometers.scad](vitamins/potentiometers.scad) Object definitions. + +[vitamins/potentiometer.scad](vitamins/potentiometer.scad) Implementation. + +[tests/potentiometers.scad](tests/potentiometers.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| `pot_body(type)` | Body diameter or width & depth, height and corner radius | +| `pot_boss_d(type)` | Boss diameter | +| `pot_boss_h(type)` | Boss height | +| `pot_face(type)` | Faceplate rib width, plate depth and plate height | +| `pot_gangs(type)` | Number of gangs for mult-gang pot | +| `pot_neck(type)` | Diameter and length of the shaft neck | +| `pot_shaft(type)` | Diameter, flat diameter, length and flat/slot length and colour. If flat diameter is less than the radius then it is a slot width | +| `pot_spigot(type)` | Spigot width, length and height above the boss | +| `pot_spigot_x(type)` | Spigot offset from the shaft centre | +| `pot_thread_d(type)` | Nomininal thread diameter | +| `pot_thread_h(type)` | Height of threaded part | +| `pot_thread_p(type)` | Thread pritch | +| `pot_wafer(type)` | Width, diameter and thickness of the track wafer plus true if curved | + +### Functions +| Function | Description | +|:--- |:--- | +| `pot_size(type)` | Get pot body dimensions | +| `pot_z(type)` | Ideal distance behind panel surface to get the nut on comfortably | + +### Modules +| Module | Description | +|:--- |:--- | +| `potentiometer(type, thickness = 3, shaft_length = undef)` | Draw a potentiometer with nut spaced by specified thickness | + +![potentiometers](tests/png/potentiometers.png) + + Top --- diff --git a/tests/PCB.scad b/tests/PCB.scad index 337dfc4..9906c78 100644 --- a/tests/PCB.scad +++ b/tests/PCB.scad @@ -141,7 +141,7 @@ test_pcb = ["test_pcb", "Test PCB", [ 52, 194, 0, "2p54socket", 8, 1, false, 0, false, "red" ], [ 50, 220, 0, "standoff", 5, 4.5, 12.5, 2.54], [ 50, 240, 0, "potentiometer"], - [ 75, 240, 0, "potentiometer", 7, 8], + [ 75, 240, 0, "potentiometer", KY_040_encoder, 8], [ 30, 85, -90, "7seg", WT5011BSR, 2], ], // accessories diff --git a/tests/PCBs.scad b/tests/PCBs.scad index e0dcb79..b0e184b 100644 --- a/tests/PCBs.scad +++ b/tests/PCBs.scad @@ -21,7 +21,7 @@ include <../vitamins/pcbs.scad> use <../utils/layout.scad> -function spacing(p) = let(w = pcb_width(p)) w < 22 ? w + 3 : w + 10; +function spacing(p) = let(w = pcb_width(p)) w < 22 ? w + 3 : w + 7; module pcbs() { layout([for(p = pcbs) spacing(p)], 0) @@ -29,9 +29,9 @@ module pcbs() { rotate(90) pcb_assembly(pcbs[$i], 5 + $i, 3); - translate([0, 45]) + translate([0, 65]) layout([for(p = tiny_pcbs) pcb_length(p)], 3) - translate([0, pcb_width(tiny_pcbs[$i]) / 2]) + translate([0, -pcb_width(tiny_pcbs[$i]) / 2]) pcb_assembly(tiny_pcbs[$i], 5 + $i, 3); translate([0, 120]) diff --git a/tests/png/pcb.png b/tests/png/pcb.png index c1a8712..9b9b633 100644 Binary files a/tests/png/pcb.png and b/tests/png/pcb.png differ diff --git a/tests/png/pcbs.png b/tests/png/pcbs.png index bbcbca5..8ca30b8 100644 Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ diff --git a/tests/png/potentiometers.png b/tests/png/potentiometers.png new file mode 100644 index 0000000..798edb4 Binary files /dev/null and b/tests/png/potentiometers.png differ diff --git a/tests/potentiometers.scad b/tests/potentiometers.scad new file mode 100644 index 0000000..62ebf79 --- /dev/null +++ b/tests/potentiometers.scad @@ -0,0 +1,31 @@ +// +// 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 . +// +//! Potentiometers and rotary encoders +include <../core.scad> +include <../utils/layout.scad> +include <../vitamins/potentiometers.scad> + +module potentiometers() + layout([for(p = potentiometers) pot_size(p).x]) + hflip() + potentiometer(potentiometers[$i], shaft_length = 30); + +if($preview) + let($show_threads = true) + potentiometers(); diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 02dbad2..06a8a6a 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -38,6 +38,7 @@ use use use use +include 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]); diff --git a/vitamins/pcbs.scad b/vitamins/pcbs.scad index 98a1c2a..99389ba 100644 --- a/vitamins/pcbs.scad +++ b/vitamins/pcbs.scad @@ -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]; diff --git a/vitamins/potentiometer.scad b/vitamins/potentiometer.scad new file mode 100644 index 0000000..1b302ce --- /dev/null +++ b/vitamins/potentiometer.scad @@ -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 . +// +//! 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); + } + } +} diff --git a/vitamins/potentiometers.scad b/vitamins/potentiometers.scad new file mode 100644 index 0000000..47cc558 --- /dev/null +++ b/vitamins/potentiometers.scad @@ -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 . +// +//! 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