forked from nophead/NopSCADlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveroboard.scad
174 lines (149 loc) · 6.74 KB
/
veroboard.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//
// 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 <https://www.gnu.org/licenses/>.
//
//
//! Veroboard with mounting holes, track breaks, removed tracks, solder points and components.
//
include <../core.scad>
use <pcb.scad>
function vero_assembly(type) = type[1]; //! Name of the assembly
function vero_holes(type) = type[2]; //! Number of holes in each strip
function vero_strips(type) = type[3]; //! Number of strips
function vero_pitch(type) = type[4]; //! Hole pitch
function vero_fr4(type) = type[5]; //! True if FR4 rather than SRBP
function vero_screw(type) = type[6]; //! Mounting screw type
function vero_mounting_holes(type) = type[7]; //! Positions of the mounting holes
function vero_breaks(type) = type[8]; //! Breaks in the tracks
function vero_no_track(type) = type[9]; //! Missing tracks
function vero_components(type) = type[10]; //! List of named components and their positions
function vero_joints(type) = type[11]; //! List of solder joints
function vero_thickness(type) = 1.6; //! Thickness of the substrate
function vero_track_thickness(type)= 0.035; //! Thickness of the tracks
function vero_track_width(type) = vero_pitch(type) * 0.8; //! The width of the tracks
function vero_length(type) = vero_holes(type) * vero_pitch(type); //! Length of the board
function vero_width(type) = vero_strips(type) * vero_pitch(type); //! Width of the board
module solder_meniscus(type) {
h = 1;
r = vero_track_width(type) / 2;
translate_z(vero_track_thickness(type))
color("silver") rotate_extrude()
difference() {
square([r, h]);
translate([r - eps, h + eps])
ellipse(r , h);
}
}
module vero_grid_pos(type, x, y) { //! Convert grid position to offset from the centre
holes = vero_holes(type);
strips = vero_strips(type);
translate([((x + holes) % holes) - holes / 2 + 0.5,
((y + strips) % strips) - strips / 2 + 0.5] * vero_pitch(type))
children();
}
module vero_mounting_hole_positions(type) //! Positions children at the mounting holes
for(p = vero_mounting_holes(type))
vero_grid_pos(type, p.x, p.y)
children();
module vero_mounting_holes(type, h = 100) //! Drill mounting holes in a panel
vero_mounting_hole_positions(type)
drill(screw_clearance_radius(vero_screw(type)), h);
module veroboard(type) { //! Draw specified veroboard with missing tracks and track breaks
holes = vero_holes(type);
strips = vero_strips(type);
pitch = vero_pitch(type);
length = holes * pitch;
width = strips * pitch;
hole_d = 1;
tw = vero_track_width(type);
colour = vero_fr4(type) ? "green" : "goldenrod";
tc = vero_fr4(type) ? "silver" : "darkorange";
no_track = vero_no_track(type);
vitamin(str("veroboard(", type[0], "): Veroboard ", holes, " holes x ", strips, "strips"));
color(colour) linear_extrude(height = vero_thickness(type))
difference() {
rounded_square([length, width], r = 0.5, center = true);
for(x = [0 : holes - 1], y = [0 : strips - 1])
vero_grid_pos(type, x, y)
circle(d = hole_d);
vero_mounting_hole_positions(type)
circle(r = screw_radius(vero_screw(type)));
}
color(tc) vflip() linear_extrude(height = vero_track_thickness(type))
difference() {
vflip()
for(y = [0 : strips -1])
translate([0, y * pitch - (strips - 1) * pitch / 2])
if(!in(no_track, y))
difference() {
square([length - (pitch - tw), tw], center = true);
for(x = [0 : holes - 1])
translate([x * pitch - (holes - 1) * pitch / 2, 0])
circle(d = hole_d);
}
vflip() {
vero_mounting_hole_positions(type)
for(y = [-1 : 1])
hull()
for(x = [-1, 1])
translate([x, y] * pitch)
circle(d = pitch * 1.1);
for(p = vero_breaks(type))
vero_grid_pos(type, p.x, p.y)
if(ceil(p.x) == p.x)
circle(d = pitch);
else
square([pitch * 0.2, pitch], center = true);
}
}
}
module vero_components(type, cutouts = false, angle = undef)
for(comp = vero_components(type))
vero_grid_pos(type, comp.x, comp.y)
translate_z(vero_thickness(type))
pcb_component(comp, cutouts, angle);
module vero_cutouts(type, angle = undef) vero_components(type, true, angle); //! Make cutouts to clear components
module veroboard_assembly(type, height, thickness, flip = false) //! Draw the assembly with components and fasteners in place
assembly(vero_assembly(type)) {
screw = vero_screw(type);
washer = screw_washer(screw);
nut = screw_nut(screw);
screw_length = screw_longer_than(height + thickness + vero_thickness(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true));
translate_z(height) {
veroboard(type);
vero_components(type);
for(r = vero_joints(type))
for(x = r.x, y = r.y)
vero_grid_pos(type, x, y)
vflip()
solder_meniscus(type);
}
vero_mounting_hole_positions(type) {
translate_z(height + vero_thickness(type))
if(flip)
nut_and_washer(nut, true);
else
screw_and_washer(screw, screw_length);
color(pp1_colour) pcb_spacer(screw, height);
translate_z(-thickness)
vflip()
if(flip)
screw_and_washer(screw, screw_length);
else
nut_and_washer(nut, true);
}
}