-
Notifications
You must be signed in to change notification settings - Fork 0
/
pogo_pin_jig.scad
112 lines (95 loc) · 3.36 KB
/
pogo_pin_jig.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* OpenSCAD Pogo Pin Rendering Tool (PPRT)
*
* Copyright (2019) Brian 'redbeard' Harrington, <redbeard@dead-city.org>
*
* PPRT is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PPRT 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PPRT. If not, see <https://www.gnu.org/licenses/>.
*/
// These options can be overridden when calling "make", e.g.:
// make svg
// Pin definitions
// Number of rows to be placed in the jig (along X axis)
ROWS = 2;
// Number of columns to be placed in the jig (along Y axis)
COLS = 5;
// Pitch spacing between each pin
PITCH = 2.54;
// Diameter of the hole for the pin
// Note: 3D printers typically undersize the holes, thus you may need to make
// this bigger than expected. Make a 1x2 or 2x2 version and test for optimal
// sizing.
PIN_DIAMETER = 1;
// Block size (if using, set AUTOSIZE=false)
LENGTH = 1;
WIDTH = 1;
HEIGHT = 5;
AUTOSIZE = true;
IS_CENTERED = true;
OFFSET_X = 0;
OFFSET_Y = 0;
// Global configurations, these shouldn't need to be changed
2D = false;
debug = true;
assert (PIN_DIAMETER < PITCH,
"Your PIN_DIAMETER is larger than your pin PITCH.");
// helpers
pin_block_length = PITCH * COLS;
pin_block_width = PITCH * ROWS;
render_length = (AUTOSIZE && (LENGTH < pin_block_length)) ? pin_block_length + 1 : LENGTH;
render_width = (AUTOSIZE && (WIDTH < pin_block_width)) ? pin_block_width + 1 : WIDTH;
render_height = HEIGHT;
// check if pin block should be "centered"
pinblock_start_X = (IS_CENTERED) ? (render_length - pin_block_length) / 2 : 0;
pinblock_start_Y = (IS_CENTERED) ? (render_width - pin_block_width) / 2 : 0;
// print calculations to the console if needed
if (debug) {
echo("pin_block_length: ", pin_block_length);
echo("pin_block_width: ", pin_block_width);
echo("pinblock_start_X: ", pinblock_start_X);
echo("pinblock_start_Y: ", pinblock_start_Y);
echo("render_length: ", render_length);
echo("render_width: ", render_width);
echo("render_height: ", render_height);
}
module gen_pinblock(rows=ROWS, cols=COLS) {
assert(rows > 0, "ROWS must be greater than 0");
assert(cols > 0, "COLS must be greater than 0");
for (row = [1:rows]) {
for (col = [1:cols]) {
translate ([(col* PITCH) - PITCH/2, (row* PITCH) - PITCH/2, 0])
cylinder(h=HEIGHT, d=PIN_DIAMETER, $fn=30);
};
}
}
/*
create the rectangle as frame, then execute a loop to generate the
pin structure and remove the pin material
note, the cut=2D specifies if this should be a two dimensional slice versus
a three dimensional render.
*/
if (2D) {
projection(cut=true)
difference(){
cube([render_length,render_width,render_height]);
translate ([pinblock_start_X + OFFSET_X,pinblock_start_Y + OFFSET_Y,0])
gen_pinblock();
}
} else {
difference(){
cube([render_length,render_width,render_height]);
translate ([pinblock_start_X + OFFSET_X,pinblock_start_Y + OFFSET_Y,0])
gen_pinblock();
}
}
// vim: ts=2 sw=2 et tw=80