diff --git a/libtest.png b/libtest.png
index a171850..9dc6158 100644
Binary files a/libtest.png and b/libtest.png differ
diff --git a/readme.md b/readme.md
index aa54f4c..12f7f4e 100644
--- a/readme.md
+++ b/readme.md
@@ -18,30 +18,75 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa
## Table of Contents
+---
+
+## Axials
+Axial components for PCBs.
+
+
+[vitamins/axials.scad](vitamins/axials.scad) Object definitions.
+
+[vitamins/axial.scad](vitamins/axial.scad) Implementation.
+
+[tests/axials.scad](tests/axials.scad) Code for this example.
+
+### Properties
+| Function | Description |
+|:--- |:--- |
+| ```ax_res_colour(type)``` | Body colour |
+| ```ax_res_diameter(type)``` | Body diameter |
+| ```ax_res_end_d(type)``` | End cap diameter |
+| ```ax_res_end_l(type)``` | End cap length |
+| ```ax_res_length(type)``` | Body length |
+| ```ax_res_wattage(type)``` | Power rating |
+| ```ax_res_wire(type)``` | Wire diameter |
+
+### Modules
+| Module | Description |
+|:--- |:--- |
+| ```wire_link(d, l, h = 1)``` | Draw a wire jumper link. |
+
+
+
+### Vitamins
+| Qty | Module call | BOM entry |
+| ---:|:--- |:---|
+| 1 | ```pcb(PERF60x40)``` | Perfboard 60 x 40mm |
+| 1 | ```ax_res(res1_8, 1000)``` | Resistor 1000 Ohms 5% 0.125W |
+| 1 | ```ax_res(res1_8, 2200, tol = 1)``` | Resistor 2200 Ohms 1% 0.125W |
+| 1 | ```ax_res(res1_4, 39000, tol = 1)``` | Resistor 39000 Ohms 1% 0.25W |
+| 1 | ```ax_res(res1_4, 47000)``` | Resistor 47000 Ohms 5% 0.25W |
+| 1 | ```ax_res(res1_2, 8200)``` | Resistor 8200 Ohms 5% 0.5W |
+| 1 | ```ax_res(res1_2, 8250, tol = 1)``` | Resistor 8250 Ohms 1% 0.5W |
+
+
+Top
+
---
## Ball_bearings
@@ -2000,6 +2045,12 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| 1 | ```pin_socket(2p54header, 6, 1)``` | Pin socket 6 x 1 |
| 1 | ```pin_socket(2p54header, 8, 1)``` | Pin socket 8 x 1 |
| 1 | ```pin_socket(2p54header, 8, 1, right_angle = undef, height = undef, smt = undef)``` | Pin socket 8 x 1 |
+| 1 | ```ax_res(res1_2, 10, tol = 10)``` | Resistor 10 Ohms 10% 0.5W |
+| 1 | ```ax_res(res1_4, 100, tol = 2)``` | Resistor 100 Ohms 2% 0.25W |
+| 1 | ```ax_res(res1_8, 1000)``` | Resistor 1000 Ohms 5% 0.125W |
+| 1 | ```ax_res(res1_4, 10000)``` | Resistor 10000 Ohms 5% 0.25W |
+| 1 | ```ax_res(res1_2, 100000)``` | Resistor 100000 Ohms 5% 0.5W |
+| 1 | ```ax_res(res1_8, 1e+6, tol = 1)``` | Resistor 1e+6 Ohms 1% 0.125W |
| 1 | ```square_button(button_6mm)``` | Square button 6mm |
| 1 | ```pcb(TMC2130)``` | TMC2130 |
| 1 | ```green_terminal(gt_5p08, 2)``` | Terminal block 2 way 0.2" |
diff --git a/tests/DIP.scad b/tests/DIP.scad
index 516b70d..9ac047a 100644
--- a/tests/DIP.scad
+++ b/tests/DIP.scad
@@ -17,9 +17,7 @@
// If not, see .
//
include <../core.scad>
-include <../vitamins/dip.scad>
-
-use <../utils/layout.scad>
+use <../vitamins/dip.scad>
dips = [[6, "OPTO"], [8, "NE555"], [14, "74HC00"], [16, "ULN2003"], [18, "ULN2803"], [20, "74HC245"], [28, "ATMEGA328"]];
diff --git a/tests/PCB.scad b/tests/PCB.scad
index bf70ecf..ab7cda3 100644
--- a/tests/PCB.scad
+++ b/tests/PCB.scad
@@ -20,6 +20,7 @@ include <../core.scad>
include <../vitamins/microswitches.scad>
include <../vitamins/d_connectors.scad>
include <../vitamins/leds.scad>
+include <../vitamins/axials.scad>
use <../vitamins/pcb.scad>
@@ -79,6 +80,13 @@ test_pcb = ["TestPCB", "Test PCB",
[ 5, 218, 180, "hdmi"],
[ 3, 235, 180, "mini_hdmi"],
[ 6, 175, 180, "uSD", [12, 11.5, 1.4]],
+ [ 65, 12, 0, "ax_res", res1_8, 1000],
+ [ 65, 17, 0, "ax_res", res1_4, 10000],
+ [ 65, 22, 0, "ax_res", res1_2, 100000],
+
+ [ 80, 12, 0, "ax_res", res1_8, 1000000, 1, inch(0.1)],
+ [ 80, 17, 0, "ax_res", res1_4, 100, 2, inch(0.1)],
+ [ 80, 22, 0, "ax_res", res1_2, 10, 10, inch(0.2)],
[ 60, 3, 0, "flex"],
[ 50, 15, 0, "flat_flex"],
diff --git a/tests/axials.scad b/tests/axials.scad
new file mode 100644
index 0000000..15e1dbb
--- /dev/null
+++ b/tests/axials.scad
@@ -0,0 +1,43 @@
+//
+// 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 .
+//
+include <../core.scad>
+include <../vitamins/pcbs.scad>
+
+
+module axials() {
+ pcb = PERF60x40;
+ pcb(pcb);
+
+ pcb_grid(pcb, 0, 2)
+ rotate(90)
+ wire_link(0.8, inch(0.4));
+
+ for(i = [0 : len(ax_resistors) - 1]) {
+ pcb_grid(pcb, 2 * i + 1, 1 + [0, 0.5, 1.5][i])
+ rotate(90)
+ ax_res(ax_resistors[i], [1000, 47000, 8200][i], 5);
+
+ pcb_grid(pcb, 2 * i + 1, 6.5)
+ rotate(-90)
+ ax_res(ax_resistors[i], [2200, 39000, 8250][i], 1, inch(0.1));
+ }
+}
+
+if($preview)
+ axials();
diff --git a/tests/png/axial.png b/tests/png/axial.png
new file mode 100644
index 0000000..3381ddb
Binary files /dev/null and b/tests/png/axial.png differ
diff --git a/tests/png/axials.png b/tests/png/axials.png
new file mode 100644
index 0000000..a487181
Binary files /dev/null and b/tests/png/axials.png differ
diff --git a/tests/png/pcb.png b/tests/png/pcb.png
index 8b5591a..b4a010e 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 0daf9d1..082314e 100644
Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ
diff --git a/vitamins/axial.scad b/vitamins/axial.scad
new file mode 100644
index 0000000..7c35b57
--- /dev/null
+++ b/vitamins/axial.scad
@@ -0,0 +1,139 @@
+//
+// 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 .
+//
+
+//
+//! Axial components for PCBs.
+//
+include <../utils/core/core.scad>
+include <../utils/round.scad>
+
+module wire_link(d, l, h = 1) { //! Draw a wire jumper link.
+ r = d;
+ tail = 3;
+ $fn = 32;
+
+ color("silver") {
+ for(side = [-1, 1]) {
+ translate([side * l / 2, 0, -tail])
+ cylinder(d = d, h = tail + h - r);
+
+ translate([side * (l / 2 - r), 0, h - r])
+ rotate([90, 0, side * 90 - 90])
+ rotate_extrude(angle = 90)
+ translate([r, 0])
+ circle(d = d);
+ }
+
+ translate_z(h)
+ rotate([0, 90, 0])
+ cylinder(d = d, h = l - 2 * r, center = true);
+ }
+}
+
+function ax_res_wattage(type) = type[1]; //! Power rating
+function ax_res_length(type) = type[2]; //! Body length
+function ax_res_diameter(type)= type[3]; //! Body diameter
+function ax_res_end_d(type) = type[4]; //! End cap diameter
+function ax_res_end_l(type) = type[5]; //! End cap length
+function ax_res_wire(type) = type[6]; //! Wire diameter
+function ax_res_colour(type) = type[7]; //! Body colour
+
+module orient_axial(length, height, pitch, wire_d) {
+ min_pitch = ceil((length + 1) / inch(0.1)) * inch(0.1);
+ lead_pitch = pitch ? pitch : min_pitch;
+ if(lead_pitch >= min_pitch) {
+ wire_link(wire_d, lead_pitch, height);
+ translate_z(height)
+ rotate([0, 90, 0])
+ children();
+ }
+ else {
+ wire_link(wire_d, lead_pitch, length + 0.7 + wire_d);
+
+ translate([-pitch / 2, 0, length / 2 + 0.2])
+ children();
+ }
+}
+
+module ax_res(type, value, tol = 5, pitch = 0) {
+ vitamin(str("ax_res(", type[0], ", ", value, arg(tol, 5, "tol"), "): Resistor ", value, " Ohms ", tol, "% ",ax_res_wattage(type), "W"));
+
+ wire_d = ax_res_wire(type);
+ end_d = ax_res_end_d(type);
+ end_l = ax_res_end_l(type);
+ body_d = ax_res_diameter(type);
+ length = ax_res_length(type);
+ h = end_d / 2;
+ $fn = 32;
+ r = 0.3;
+
+ colours = ["gold", "silver", "black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"];
+
+ exp = floor(log(value) + eps);
+ mult = exp - (len(str(value / pow(10, exp - 1))) > 2 ? 2 : 1);
+ digits = str(value / pow(10, mult));
+ bands = [
+ for(d = digits)
+ colours[ord(d) - ord("0") + 2],
+ colours[mult + 2],
+ tol == 1 ? "brown" :
+ tol == 2 ? "red" :
+ tol == 5 ? "gold" :
+ tol == 10 ? "silver" : "error"
+ ];
+
+ module profile(o = 0)
+ intersection() {
+ offset(o) round(r)
+ union(){
+ translate([0, -length / 2])
+ square([body_d / 2, length]);
+
+ for(end = [-1, 1])
+ hull() {
+ translate([0, end * (length - end_l) / 2 - end_l / 2])
+ square([end_d / 2, end_l]);
+
+ translate([0, end * length / 2])
+ square([wire_d, 2 * r], center = true);
+ }
+ translate([-5, 0])
+ square([10 + wire_d, length + 4 * r], center = true);
+ }
+
+ translate([0, -50])
+ square([50, 100]);
+ }
+
+ orient_axial(length, h, pitch, wire_d) {
+ color(ax_res_colour(type))
+ rotate_extrude()
+ profile();
+
+ for(i = [0 : len(bands) - 1])
+ color(bands[i])
+ rotate_extrude()
+ intersection() {
+ profile(eps);
+
+ translate([0, length / 2 - end_l / 2 - i * (length - end_l) / (len(bands) - 1)])
+ square([end_d + 1, (length - end_l) / len(bands) / 2], center = true);
+ }
+ }
+}
diff --git a/vitamins/axials.scad b/vitamins/axials.scad
new file mode 100644
index 0000000..a9d976d
--- /dev/null
+++ b/vitamins/axials.scad
@@ -0,0 +1,30 @@
+//
+// 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 .
+//
+
+//
+//! Axial components
+//
+
+res1_8 = ["res1_8", 0.125, 3.3, 1.35, 1.7, 1, 0.33, "#FAE3AC"];
+res1_4 = ["res1_4", 0.25, 5.7, 1.85, 2.3, 1.5, 0.55, "#FAE3AC"];
+res1_2 = ["res1_2", 0.5, 10, 3.25, 3.7, 1.8, 0.70, "#FAE3AC"];
+
+ax_resistors = [res1_8, res1_4, res1_2];
+
+use
diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad
index 7408103..2e41ad9 100644
--- a/vitamins/pcb.scad
+++ b/vitamins/pcb.scad
@@ -35,6 +35,7 @@ use <../utils/tube.scad>
use
use
use
+use
function pcb_name(type) = type[1]; //! Description
function pcb_length(type) = type[2]; //! Length
@@ -825,6 +826,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
if(show(comp, "trimpot10")) trimpot10(param(4, false), cutouts);
if(show(comp, "led")) led(comp[4], comp[5], 2.6);
if(show(comp, "pdip")) pdip(comp[4], comp[5], param(6, false), param(7, inch(0.3)));
+ if(show(comp, "ax_res")) ax_res(comp[4], comp[5], param(6, 5), param(7, 0));
}
}
diff --git a/vitamins/pcbs.scad b/vitamins/pcbs.scad
index 23211f6..8957fb2 100644
--- a/vitamins/pcbs.scad
+++ b/vitamins/pcbs.scad
@@ -19,6 +19,7 @@
include
include
include
+include
//
// l w t r h l c b h
@@ -335,6 +336,7 @@ ZC_A0591 = ["ZC_A0591", "ZC-A0591 ULN2003 driver PCB", 35, 32, 1.6, 0, 2.5, 0, "
[ 5.5, 10.5, 0, "led", LED3mm, [1,1,1, 0.5]],
[ 5.5, 15, 0, "led", LED3mm, [1,1,1, 0.5]],
[ 5.5, 19.5, 0, "led", LED3mm, [1,1,1, 0.5]],
+ for(i = [0 : 3]) [5.5 + inch(0.1) * i, -5.5, -90, "ax_res", res1_8, 510, 5, 5.5]
], [], [], [], M2p5_pan_screw];