diff --git a/lib.scad b/lib.scad index ff7c14d..046b386 100644 --- a/lib.scad +++ b/lib.scad @@ -40,6 +40,7 @@ include include include include +include include include include @@ -63,7 +64,6 @@ include include use -use use use diff --git a/libtest.png b/libtest.png index 1fc6784..3d6c608 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index 88563fd..ecd9e2a 100644 --- a/libtest.scad +++ b/libtest.scad @@ -48,7 +48,7 @@ use use use use -use +use use use use @@ -280,16 +280,16 @@ components_y = toggles_y + 40; translate([x2, leds_y]) leds(); -translate([x2 + 40, leds_y]) +translate([x2 + 35, leds_y]) ldrs(); translate([x2 + 8, carriers_y]) carriers(); -translate([x2+ 38, carriers_y]) - meters(); +translate([x2 + 20, carriers_y]) + led_meters(); -translate([x2 + 68, carriers_y]) +translate([x2 + 70, leds_y]) fuseholders(); translate([x2, spades_y]) diff --git a/readme.md b/readme.md index d411974..5aad303 100644 --- a/readme.md +++ b/readme.md @@ -21,12 +21,12 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa Axials Jack Rails Box Annotation BOM Ball_bearings KP_pillow_blocks Ring_terminals Butt_box Bezier Clip Batteries LDRs Rockers Cable_grommets Dogbones Global - Belts LEDs Rod Carriers Fillet Polyholes - Blowers Leadnuts SCS_bearing_blocks Corner_block Hanging_hole Rounded_rectangle - Bulldogs Light_strips SK_brackets Door_hinge Layout Sphere - Buttons Linear_bearings SMDs Door_latch Maths Teardrops - Cable_strips Mains_sockets SSRs Fan_guard Offset - Circlips Meter Screws Fixing_block Quadrant + Belts LED_meters Rod Carriers Fillet Polyholes + Blowers LEDs SCS_bearing_blocks Corner_block Hanging_hole Rounded_rectangle + Bulldogs Leadnuts SK_brackets Door_hinge Layout Sphere + Buttons Light_strips SMDs Door_latch Maths Teardrops + Cable_strips Linear_bearings SSRs Fan_guard Offset + Circlips Mains_sockets Screws Fixing_block Quadrant Components Microswitches Sealing_strip Flat_hinge Round DIP Microview Sheets Foot Rounded_cylinder D_connectors Modules Spades Handle Rounded_polygon @@ -71,7 +71,7 @@ Axial components for PCBs. | Module | Description | |:--- |:--- | | ```ax_res(type, value, tol = 5, pitch = 0)``` | Through hole axial resistor. If ```pitch``` is zero the minimum is used. If below the minimum the resistor is placed vertical. | -| ```wire_link(d, l, h = 1)``` | Draw a wire jumper link. | +| ```wire_link(d, l, h = 1, tail = 3)``` | Draw a wire jumper link. | ![axials](tests/png/axials.png) @@ -1406,6 +1406,68 @@ Nuts for leadscrews. | 1 | ```leadnut(LSN8x8)``` | Leadscrew nut 8 x 8 RobotDigg | +Top + +--- + +## LED_meters +LED voltmeter and ammeter modules available from China and a printed bezel that allows the voltmeter to be mounted into a +CNC cut panel. The meter is held in the bezel by melting the stakes with a soldering iron set to 200°C. The +bezel is fixed in the panel with hot glue. + +The 7 SEGMENT.TTF font from the [docs](docs) directory needs to be installed to get realistic digits. + + +[vitamins/led_meters.scad](vitamins/led_meters.scad) Object definitions. + +[vitamins/led_meter.scad](vitamins/led_meter.scad) Implementation. + +[tests/LED_meters.scad](tests/LED_meters.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| ```meter_hole_pitch(type)``` | Lug hole pitch | +| ```meter_hole_radius(type)``` | Lug hole radius | +| ```meter_lug_offset(type)``` | Lug position, 0 = center, +1 = top | +| ```meter_lug_size(type)``` | Lug length and width | +| ```meter_offset(type)``` | Display position, 0 = center, +1 = top | +| ```meter_pcb_size(type)``` | PCB size excluding lugs | +| ```meter_shunt(type)``` | Ampmeter shunt wire | +| ```meter_size(type)``` | Size of display | + +### Functions +| Function | Description | +|:--- |:--- | +| ```meter_bezel_length(type)``` | Printed bezel length | +| ```meter_bezel_rad(type)``` | Printed bezel corner radius | +| ```meter_bezel_wall(type)``` | Printed bezel wall thickness | +| ```meter_bezel_width(type)``` | Printed bezel width | + +### Modules +| Module | Description | +|:--- |:--- | +| ```meter(type, colour = "red", value = "888", display_colour = false)``` | Draw a meter with optional colour and display value | +| ```meter_assembly(type, colour = "red", value = "888", display_colour = false)``` | Meter assembled into the bezel | +| ```meter_bezel(type)``` | Generate the STL for the meter bezel | +| ```meter_bezel_hole(type, h = 100)``` | Make a hole to fit the meter Bezel | +| ```meter_hole_positions(type)``` | Position children over the holes | + +![led_meters](tests/png/led_meters.png) + +### Vitamins +| Qty | Module call | BOM entry | +| ---:|:--- |:---| +| 1 | ```meter(led_ameter, colour = "blue")``` | LED ammeter blue | +| 1 | ```meter(led_meter, colour = "blue")``` | LED voltmeter blue | +| 1 | ```meter(led_meter)``` | LED voltmeter red | + +### Printed +| Qty | Filename | +| ---:|:--- | +| 1 | meter_bezel.stl | + + Top --- @@ -1612,68 +1674,6 @@ UK 13A sockets at the moment. | 1 | ```mains_socket(MKLOGIC)``` | Mains socket 13A, switched | -Top - ---- - -## Meter -LED volt meter modules available from China and a printed bezel that allows them to be mounted into a -CNC cut panel. The meter is held in the bezel by melting the stakes with a soldering iron set to 200°C. The -bezel is fixed in the panel with hot glue. - -The 7 SEGMENT.TTF font from the [docs](docs) directory needs to be installed to get realistic digits. - - -[vitamins/meter.scad](vitamins/meter.scad) Implementation. - -[tests/meter.scad](tests/meter.scad) Code for this example. - -### Properties -| Function | Description | -|:--- |:--- | -| ```meter_height(type = led_meter)``` | Height of body excluding PCB | -| ```meter_hole_pitch(type = led_meter)``` | Lug hole pitch | -| ```meter_hole_radius(type = led_meter)``` | Lug hole radius | -| ```meter_length(type = led_meter)``` | Length of body | -| ```meter_lug_length(type = led_meter)``` | PCB length including lugs | -| ```meter_lug_width(type = led_meter)``` | Lug width | -| ```meter_pcb_length(type = led_meter)``` | PCB length excluding lugs | -| ```meter_pcb_thickness(type = led_meter)``` | PCB thickness | -| ```meter_pcb_width(type = led_meter)``` | PCB width | -| ```meter_width(type = led_meter)``` | Width of body | - -### Functions -| Function | Description | -|:--- |:--- | -| ```meter()``` | Default meter type | -| ```meter_bezel_length(type = led_meter)``` | Printed bezel length | -| ```meter_bezel_rad(type = led_meter)``` | Printed bezel corner radius | -| ```meter_bezel_wall(type = led_meter)``` | Printed bezel wall thickness | -| ```meter_bezel_width(type = led_meter)``` | Printed bezel width | - -### Modules -| Module | Description | -|:--- |:--- | -| ```meter(type = led_meter, colour = "red", value = "888", display_colour = false)``` | Draw a meter with optional colour and display value | -| ```meter_assembly(type = led_meter, colour = "red", value = "888", display_colour = false)``` | Meter assembled into the bezel | -| ```meter_bezel(type = led_meter)``` | Generate the STL for the meter bezel | -| ```meter_bezel_hole(type = led_meter, h = 100)``` | Make a hole to fit the meter Bezel | -| ```meter_hole_positions(type = led_meter)``` | Position children over the holes | - -![meter](tests/png/meter.png) - -### Vitamins -| Qty | Module call | BOM entry | -| ---:|:--- |:---| -| 1 | ```meter(led_meter, colour = "blue")``` | LED meter blue | -| 2 | ```meter(led_meter)``` | LED meter red | - -### Printed -| Qty | Filename | -| ---:|:--- | -| 2 | meter_bezel.stl | - - Top --- diff --git a/tests/meter.scad b/tests/LED_meters.scad similarity index 63% rename from tests/meter.scad rename to tests/LED_meters.scad index 4944ecc..2fe88d9 100644 --- a/tests/meter.scad +++ b/tests/LED_meters.scad @@ -17,23 +17,21 @@ // If not, see . // include <../utils/core/core.scad> +include <../utils/layout.scad> -use <../vitamins/meter.scad> +include <../vitamins/led_meters.scad> -module meters() - if($preview) { - meter_assembly(); +module led_meters() + layout([for(m = led_meters) meter_bezel_length(m)], 5) let(m = led_meters[$i]) + if($preview) { + hflip() + meter(m, colour = "blue", value = "123"); - translate([0, meter_bezel_width() + 5]) - vflip() - meter_assembly(); + if(!$i) + translate([0, meter_bezel_width(m)]) + meter_assembly(m, value = "123"); + } + else + meter_bezel(m); - translate([0, -meter_bezel_width()]) - rotate([0, 180, 0]) - meter(colour = "blue", value = "123"); - } - else - meter_bezel(); - - -meters(); +led_meters(); diff --git a/tests/png/led_meters.png b/tests/png/led_meters.png new file mode 100644 index 0000000..b916d65 Binary files /dev/null and b/tests/png/led_meters.png differ diff --git a/vitamins/axial.scad b/vitamins/axial.scad index 9cc2a28..521417a 100644 --- a/vitamins/axial.scad +++ b/vitamins/axial.scad @@ -23,9 +23,8 @@ include <../utils/core/core.scad> include <../utils/round.scad> -module wire_link(d, l, h = 1) { //! Draw a wire jumper link. +module wire_link(d, l, h = 1, tail = 3) { //! Draw a wire jumper link. r = d; - tail = 3; $fn = 32; color("silver") { diff --git a/vitamins/led_meter.scad b/vitamins/led_meter.scad new file mode 100644 index 0000000..5d2ef79 --- /dev/null +++ b/vitamins/led_meter.scad @@ -0,0 +1,145 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// 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 . +// + +// +//! LED voltmeter and ammeter modules available from China and a printed bezel that allows the voltmeter to be mounted into a +//! CNC cut panel. The meter is held in the bezel by melting the stakes with a soldering iron set to 200°C. The +//! bezel is fixed in the panel with hot glue. +//! +//! The 7 SEGMENT.TTF font from the [docs](docs) directory needs to be installed to get realistic digits. +// +include <../utils/core/core.scad> +use + +function meter_size(type) = type[1]; //! Size of display +function meter_offset(type) = type[2]; //! Display position, 0 = center, +1 = top +function meter_pcb_size(type) = type[3]; //! PCB size excluding lugs +function meter_lug_size(type) = type[4]; //! Lug length and width +function meter_lug_offset(type) = type[5]; //! Lug position, 0 = center, +1 = top +function meter_hole_pitch(type) = type[6]; //! Lug hole pitch +function meter_hole_radius(type) = type[7]; //! Lug hole radius +function meter_shunt(type) = type[8]; //! Ampmeter shunt wire + +function meter_pos(type) = (meter_pcb_size(type).y - meter_size(type).y) * meter_offset(type) / 2; +function meter_lug_pos(type) = (meter_pcb_size(type).y - meter_lug_size(type).y) * meter_lug_offset(type) / 2; + +module meter_hole_positions(type) //! Position children over the holes + for(side = [-1, 1]) + translate([side * meter_hole_pitch(type) / 2, meter_lug_pos(type)]) + children(); + +module meter(type, colour = "red", value = "888", display_colour = false) //! Draw a meter with optional colour and display value +{ + vitamin(str("meter(", type[0], arg(colour, "red", "colour"), "): LED ", meter_shunt(type) ? "am" : "volt", "meter ", colour)); + + size = meter_size(type); + + color("grey") + translate([0, meter_pos(type), size.z / 2]) + cube(size, center = true); + + color("green") + translate_z(meter_size(type).z) + linear_extrude(meter_pcb_size(type).z) + difference() { + union() { + square([meter_pcb_size(type).x, meter_pcb_size(type).y], center = true); + + translate([0, meter_lug_pos(type)]) + square([meter_lug_size(type).x, meter_lug_size(type).y], center = true); + } + meter_hole_positions(type) + circle(meter_hole_radius(type)); + } + + color(display_colour ? display_colour : colour) + linear_extrude(0.2, center = true) + mirror([1, 0, 0]) + translate([-size.x / 2 + 1, meter_pos(type)]) + resize([size.x - 2, size.y - 2]) { + text(value, font = "7 segment", valign = "center"); + + square(eps); // Tiny invisible pixel at the origin so numbers starting with 1 scale correctly. + } + + shunt = meter_shunt(type); + if(shunt) + translate([0, -meter_pcb_size(type).y / 2 + meter_pos(type), size.z]) + vflip() + color("#b87333") + wire_link(shunt.y, shunt.x, shunt.z, tail = 2); +} + +clearance = 0.1; +overlap = 1; +flange_t = 1; + +function meter_bezel_wall(type) = (meter_lug_size(type).x - meter_size(type).x) / 2; //! Printed bezel wall thickness +function meter_bezel_rad(type) = meter_bezel_wall(type); //! Printed bezel corner radius +function meter_bezel_length(type) = meter_size(type).x + 2 * (meter_bezel_wall(type) + overlap); //! Printed bezel length +function meter_bezel_width(type) = meter_size(type).y + 2 * (meter_bezel_wall(type) + overlap); //! Printed bezel width + +module meter_bezel_hole(type, h = 100) { //! Make a hole to fit the meter Bezel + wall = meter_bezel_wall(type) + clearance; + rad = meter_bezel_rad(type) + clearance; + l = meter_size(type).x; + w = meter_size(type).y; + + extrude_if(h) + rounded_square([l + 2 * wall, w + 2 * wall], rad); +} + +module meter_bezel(type) { //! Generate the STL for the meter bezel + stl("meter_bezel"); + + wall = meter_bezel_wall(type); + rad = meter_bezel_rad(type); + l = meter_size(type).x; + w = meter_size(type).y; + h = meter_size(type).z; + + union() { + linear_extrude(h) + difference() { + rounded_square([l + 2 * wall, w + 2 * wall], rad); + + square([l + 2 * clearance, w + 2 * clearance], center = true); + } + + linear_extrude(flange_t) + difference() { + rounded_square([l + 2 * wall + 2 * overlap, w + 2 * wall + 2 * overlap], rad + overlap); + + square([l + 2 * clearance, w + 2 * clearance], center = true); + } + translate([0, -meter_pos(type)]) + meter_hole_positions(type) + cylinder(r = meter_hole_radius(type), h = h + meter_pcb_size(type).z * 2); + } +} + +module meter_assembly(type, colour = "red", value = "888", display_colour = false) { //! Meter assembled into the bezel + hflip() + translate_z(-flange_t) { + color("dimgrey") meter_bezel(type); + + translate([0, -meter_pos(type)]) + meter(type, colour, value, display_colour); + } +} diff --git a/vitamins/led_meters.scad b/vitamins/led_meters.scad new file mode 100644 index 0000000..51c1844 --- /dev/null +++ b/vitamins/led_meters.scad @@ -0,0 +1,26 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// 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 . +// + +// display size offset pcb size lug size offset hole pitch and size +led_meter = ["led_meter", [22.72, 10.14, 6.3], 0, [22.72, 11.04, 0.96], [30, 4.2], 0, 26, 2.2 / 2, false]; +led_ameter = ["led_ameter", [22.72, 14.05, 7.3], 1, [27.5, 18.54, 1.2], [35, 6.25], 1, 29, 3.0 / 2, [15.5, 1.5, 7.75]]; + +led_meters = [led_meter, led_ameter]; + +use diff --git a/vitamins/meter.scad b/vitamins/meter.scad deleted file mode 100644 index a3eab03..0000000 --- a/vitamins/meter.scad +++ /dev/null @@ -1,130 +0,0 @@ -// -// NopSCADlib Copyright Chris Palmer 2018 -// 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 . -// - -// -//! LED volt meter modules available from China and a printed bezel that allows them to be mounted into a -//! CNC cut panel. The meter is held in the bezel by melting the stakes with a soldering iron set to 200°C. The -//! bezel is fixed in the panel with hot glue. -//! -//! The 7 SEGMENT.TTF font from the [docs](docs) directory needs to be installed to get realistic digits. -// -include <../utils/core/core.scad> - -led_meter = ["led_meter", 22.72, 10.14, 6.3, 22.72, 11.04, 0.96, 30, 4.2, 26, 2.2 / 2]; - -function meter() = led_meter; //! Default meter type - -function meter_length(type = led_meter) = type[1]; //! Length of body -function meter_width(type = led_meter) = type[2]; //! Width of body -function meter_height(type = led_meter) = type[3]; //! Height of body excluding PCB -function meter_pcb_length(type = led_meter) = type[4]; //! PCB length excluding lugs -function meter_pcb_width(type = led_meter) = type[5]; //! PCB width -function meter_pcb_thickness(type = led_meter) = type[6]; //! PCB thickness -function meter_lug_length(type = led_meter) = type[7]; //! PCB length including lugs -function meter_lug_width(type = led_meter) = type[8]; //! Lug width -function meter_hole_pitch(type = led_meter) = type[9]; //! Lug hole pitch -function meter_hole_radius(type = led_meter) = type[10]; //! Lug hole radius - -module meter_hole_positions(type = led_meter) //! Position children over the holes - for(side = [-1, 1]) - translate([side * meter_hole_pitch(type) / 2, 0]) - children(); - -module meter(type = led_meter, colour = "red", value = "888", display_colour = false) //! Draw a meter with optional colour and display value -{ - vitamin(str("meter(", type[0], arg(colour, "red", "colour"), "): LED meter ", colour)); - - color("grey") - translate_z(meter_height(type) / 2) - cube([meter_length(type), meter_width(type), meter_height(type)], center = true); - - color("green") - translate_z(meter_height(type)) - linear_extrude(meter_pcb_thickness(type)) - difference() { - union() { - square([meter_pcb_length(type), meter_pcb_width(type)], center = true); - - square([meter_lug_length(type), meter_lug_width(type)], center = true); - } - meter_hole_positions(type) - circle(meter_hole_radius(type)); - } - - color(display_colour ? display_colour : colour) - linear_extrude(0.2, center = true) - mirror([1,0,0]) - text(value, font = "7 segment", valign = "center", halign = "center", size = meter_width(type) - 2, spacing = 1.2); -} - -clearance = 0.1; -overlap = 1; -flange_t = 1; - -function meter_bezel_wall(type = led_meter) = (meter_lug_length(type) - meter_length(type)) / 2; //! Printed bezel wall thickness -function meter_bezel_rad(type = led_meter) = meter_bezel_wall(type); //! Printed bezel corner radius -function meter_bezel_length(type = led_meter) = meter_length(type) + 2 * (meter_bezel_wall(type) + overlap); //! Printed bezel length -function meter_bezel_width(type = led_meter) = meter_width(type) + 2 * (meter_bezel_wall(type) + overlap); //! Printed bezel width - -module meter_bezel_hole(type = led_meter, h = 100) { //! Make a hole to fit the meter Bezel - wall = meter_bezel_wall(type) + clearance; - rad = meter_bezel_rad(type) + clearance; - l = meter_length(type); - w = meter_width(type); - - extrude_if(h) - rounded_square([l + 2 * wall, w + 2 * wall], rad); -} - -module meter_bezel(type = led_meter) { //! Generate the STL for the meter bezel - stl("meter_bezel"); - - wall = meter_bezel_wall(type); - rad = meter_bezel_rad(type); - l = meter_length(type); - w = meter_width(type); - h = meter_height(type); - - union() { - linear_extrude(h) - difference() { - rounded_square([l + 2 * wall, w + 2 * wall], rad); - - square([l + 2 * clearance, w + 2 * clearance], center = true); - } - - linear_extrude(flange_t) - difference() { - rounded_square([l + 2 * wall + 2 * overlap, w + 2 * wall + 2 * overlap], rad + overlap); - - square([l + 2 * clearance, w + 2 * clearance], center = true); - } - meter_hole_positions(type) - cylinder(r = meter_hole_radius(type), h = h + meter_pcb_thickness(type) * 2); - } -} - -module meter_assembly(type = led_meter, colour = "red", value = "888", display_colour = false) { //! Meter assembled into the bezel - vflip() - translate_z(-flange_t) { - color("dimgrey") meter_bezel(type); - - meter(type, colour, value, display_colour); - } -}