1.1 --- a/cartridge.scad Mon Apr 11 16:51:35 2016 +0200
1.2 +++ b/cartridge.scad Sat Apr 23 16:36:03 2016 +0200
1.3 @@ -28,6 +28,15 @@
1.4
1.5 MODEL = ROM_CARTRIDGE;
1.6
1.7 + /* Plug and socket options. Do not edit! */
1.8 +
1.9 + BACK_PLUG = 0;
1.10 + BACK_SOCKET = 1;
1.11 +
1.12 + /* Set this to the desired lug type. */
1.13 +
1.14 + BACK_LUG = BACK_PLUG;
1.15 +
1.16 /*
1.17 Configure the generated shapes.
1.18 For the absolute simplest shape (for basic 3D printers)...
1.19 @@ -39,6 +48,9 @@
1.20 To retain the back connecting piece instead, change the above to...
1.21
1.22 BACK_CONNECTOR_SECTION = 1;
1.23 +
1.24 + And set the following options...
1.25 +
1.26 EXTERNAL_BACK_CAVITY = 0;
1.27 EXTERNAL_BACK_CUTOUT = 1;
1.28
1.29 @@ -227,7 +239,12 @@
1.30 front_back_overlap = 1.0;
1.31 groove_width_overlap = front_back_overlap + groove_width_extra;
1.32
1.33 - /* Division of pieces into front and back, defining the extents. */
1.34 + /*
1.35 + Division of pieces into front and back, defining the extents. The back
1.36 + depth is extended by the front/back overlap, and thus the internal back
1.37 + depth calculated here is greater than the actual depth that the back
1.38 + portion can hold.
1.39 + */
1.40
1.41 int_front_depth = 4.5;
1.42 front_depth = int_front_depth + front;
1.43 @@ -422,12 +439,10 @@
1.44
1.45 pcb_lug_mating_depth = pcb_back_support_bump_depth + 1.0;
1.46
1.47 - pcb_lug_depth = pcb_back_support_depth +
1.48 + pcb_back_lug_depth = pcb_back_support_depth +
1.49 pcb_lug_mating_depth;
1.50 - pcb_lug_inner_radius = 1.0;
1.51 - pcb_lug_outer_radius = 5.5 / 2;
1.52 - pcb_lug_offset_from_bottom = 14.35;
1.53 - pcb_lug_offset_from_inside = 5.55;
1.54 + pcb_back_lug_inner_radius = 1.0;
1.55 + pcb_back_lug_outer_radius = 5.5 / 2;
1.56
1.57 /*
1.58 The cross detail on the back lug is intended to resist the front lug,
1.59 @@ -439,14 +454,44 @@
1.60 pcb_lug_mating_depth;
1.61 pcb_lug_cross_height = 1.4;
1.62
1.63 + /*
1.64 + The front depth is calculated similarly to the back depth, with the
1.65 + outer radius of the socket corresponding to the dimensions of the cross
1.66 + detail. The inner radius of the front's socket is the same as the outer
1.67 + radius of the back's plug, with friction holding the two together.
1.68 + */
1.69 +
1.70 pcb_front_lug_depth = pcb_front_support_depth +
1.71 pcb_lug_mating_depth;
1.72 - pcb_front_lug_inner_radius = pcb_lug_outer_radius;
1.73 + pcb_front_lug_inner_radius = pcb_back_lug_outer_radius;
1.74 pcb_front_lug_outer_radius = pow(
1.75 pow(pcb_lug_cross_width / 2, 2) +
1.76 pow(pcb_lug_cross_height / 2, 2),
1.77 0.5);
1.78
1.79 + /*
1.80 + With BACK_LUG as BACK_SOCKET, no overlap is desired, since both
1.81 + front and back provide sockets. The depth is accounted for as follows:
1.82 +
1.83 + int_payload_back_depth + payload_back == back_depth
1.84 + + int_front_depth - pcb_front_lug_depth == back lug space in the front
1.85 + - front_back_overlap == correction for overlap
1.86 +
1.87 + int_front_depth - pcb_front_lug_depth
1.88 + == pcb_front_support_depth - pcb_front_support_depth - pcb_lug_mating_depth
1.89 + == -pcb_lug_mating_depth
1.90 +
1.91 + Note that the lug starts at the outer back surface, which is why the
1.92 + payload_back quantity is included.
1.93 + */
1.94 +
1.95 + pcb_back_socket_lug_depth = back_depth - front_back_overlap - pcb_lug_mating_depth;
1.96 +
1.97 + /* Both front and back lugs need to be positioned in the same place. */
1.98 +
1.99 + pcb_lug_offset_from_bottom = 14.35;
1.100 + pcb_lug_offset_from_inside = 5.55;
1.101 +
1.102 wide_pcb_lug_offset_from_inside = 6.0;
1.103 wide_pcb_lug_offset_from_bottom = 6.0;
1.104
1.105 @@ -541,22 +586,42 @@
1.106 }
1.107 }
1.108
1.109 + /* Choose the kind of "lug" in the back piece. */
1.110 +
1.111 module pcb_lug(xdir) {
1.112 - pcb_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.113 - pcb_lug_offset_from_bottom);
1.114 + if (BACK_LUG == BACK_PLUG) {
1.115 + pcb_back_plug_lug(xdir);
1.116 + } else if (BACK_LUG == BACK_SOCKET) {
1.117 + pcb_back_socket_lug(xdir);
1.118 + }
1.119 }
1.120
1.121 module pcb_lug_wide(xdir) {
1.122 - pcb_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.123 + if (BACK_LUG == BACK_PLUG) {
1.124 + pcb_back_plug_lug_wide(xdir);
1.125 + } else if (BACK_LUG == BACK_SOCKET) {
1.126 + pcb_back_socket_lug_wide(xdir);
1.127 + }
1.128 + }
1.129 +
1.130 + /* The conventional back "lug" which is actually a plug. */
1.131 +
1.132 + module pcb_back_plug_lug(xdir) {
1.133 + pcb_back_plug_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.134 + pcb_lug_offset_from_bottom);
1.135 + }
1.136 +
1.137 + module pcb_back_plug_lug_wide(xdir) {
1.138 + pcb_back_plug_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.139 wide_pcb_lug_offset_from_bottom);
1.140 - pcb_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.141 + pcb_back_plug_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.142 wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom);
1.143 }
1.144
1.145 - module pcb_lug_explicit(xdir, pcb_lug_offset_from_centre, pcb_lug_offset_from_bottom) {
1.146 - translate([payload_centre + xdir * pcb_lug_offset_from_centre,
1.147 + module pcb_back_plug_lug_explicit(xdir, offset_from_centre, offset_from_bottom) {
1.148 + translate([payload_centre + xdir * offset_from_centre,
1.149 back_depth,
1.150 - int_payload_lower_extent + pcb_lug_offset_from_bottom
1.151 + int_payload_lower_extent + offset_from_bottom
1.152 ])
1.153 rotate([90, 0, 0])
1.154 difference() {
1.155 @@ -564,7 +629,7 @@
1.156 /* Cylinder with cross. */
1.157
1.158 union() {
1.159 - cylinder(h=pcb_lug_depth, r=pcb_lug_outer_radius);
1.160 + cylinder(h=pcb_back_lug_depth, r=pcb_back_lug_outer_radius);
1.161 cube_at(pcb_lug_cross_width,
1.162 pcb_lug_cross_height, pcb_lug_cross_depth,
1.163 0, 0, 1,
1.164 @@ -577,42 +642,134 @@
1.165
1.166 /* Hollowed out by a cylinder. */
1.167
1.168 - cylinder(h=pcb_lug_depth, r=pcb_lug_inner_radius);
1.169 + cylinder(h=pcb_back_lug_depth, r=pcb_back_lug_inner_radius);
1.170
1.171 /* Tapered off for easier connection. */
1.172
1.173 if (ROUND_CONNECTING_EDGES)
1.174 - translate([0, 0, pcb_lug_depth - pcb_lug_ro])
1.175 - fillet_torus(pcb_lug_outer_radius, pcb_lug_rr);
1.176 + translate([0, 0, pcb_back_lug_depth - pcb_lug_ro])
1.177 + fillet_torus(pcb_back_lug_outer_radius, pcb_lug_rr);
1.178 }
1.179 }
1.180
1.181 + /* The conventional front "lug" which is actually a socket. */
1.182 +
1.183 module pcb_front_lug(xdir) {
1.184 - pcb_front_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.185 - pcb_lug_offset_from_bottom);
1.186 + pcb_socket_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.187 + -int_front_depth + pcb_front_lug_depth,
1.188 + pcb_lug_offset_from_bottom,
1.189 + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.190 }
1.191
1.192 module pcb_front_lug_wide(xdir) {
1.193 - pcb_front_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.194 - wide_pcb_lug_offset_from_bottom);
1.195 - pcb_front_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.196 - wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom);
1.197 + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.198 + -int_front_depth + pcb_front_lug_depth,
1.199 + wide_pcb_lug_offset_from_bottom,
1.200 + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.201 + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.202 + -int_front_depth + pcb_front_lug_depth,
1.203 + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom,
1.204 + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.205 }
1.206
1.207 - module pcb_front_lug_explicit(xdir, pcb_lug_offset_from_centre, pcb_lug_offset_from_bottom) {
1.208 - translate([payload_centre + xdir * pcb_lug_offset_from_centre,
1.209 - -int_front_depth + pcb_front_lug_depth,
1.210 - int_payload_lower_extent + pcb_lug_offset_from_bottom
1.211 + /*
1.212 + The alternative back "lug" which is actually a socket as well, meaning
1.213 + that a cylinder runs from the front surface to the back, with the two
1.214 + sections meeting in the middle.
1.215 + */
1.216 +
1.217 + module pcb_back_socket_lug(xdir) {
1.218 + pcb_socket_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.219 + back_depth,
1.220 + pcb_lug_offset_from_bottom,
1.221 + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.222 + }
1.223 +
1.224 + module pcb_back_socket_lug_wide(xdir) {
1.225 + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.226 + back_depth,
1.227 + wide_pcb_lug_offset_from_bottom,
1.228 + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.229 + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.230 + back_depth,
1.231 + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom,
1.232 + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius);
1.233 + }
1.234 +
1.235 + /* The common implementation of the cylinder socket. */
1.236 +
1.237 + module pcb_socket_lug_explicit(xdir, offset_from_centre, depth_offset, offset_from_bottom,
1.238 + lug_depth, lug_outer_radius, lug_inner_radius) {
1.239 +
1.240 + translate([payload_centre + xdir * offset_from_centre,
1.241 + depth_offset,
1.242 + int_payload_lower_extent + offset_from_bottom
1.243 ])
1.244 rotate([90, 0, 0])
1.245 difference() {
1.246 - cylinder(h=pcb_front_lug_depth,
1.247 - r=pcb_front_lug_outer_radius);
1.248 - cylinder(h=pcb_front_lug_depth,
1.249 - r=pcb_front_lug_inner_radius);
1.250 + cylinder(h=lug_depth,
1.251 + r=lug_outer_radius);
1.252 + cylinder(h=lug_depth,
1.253 + r=lug_inner_radius);
1.254 }
1.255 }
1.256
1.257 + /* The holes in the front surface when socket lugs are used. */
1.258 +
1.259 + module pcb_front_socket_hole(xdir) {
1.260 + pcb_socket_hole_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.261 + -int_front_depth + extra,
1.262 + pcb_lug_offset_from_bottom,
1.263 + front + extra * 2, pcb_front_lug_inner_radius);
1.264 + }
1.265 +
1.266 + module pcb_front_socket_hole_wide(xdir) {
1.267 + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.268 + -int_front_depth + extra,
1.269 + wide_pcb_lug_offset_from_bottom,
1.270 + front + extra * 2, pcb_front_lug_inner_radius);
1.271 + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.272 + -int_front_depth + extra,
1.273 + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom,
1.274 + front + extra * 2, pcb_front_lug_inner_radius);
1.275 + }
1.276 +
1.277 + /* The holes in the back surface when socket lugs are used. */
1.278 +
1.279 + module pcb_back_socket_hole(xdir) {
1.280 + pcb_socket_hole_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside,
1.281 + back_depth + extra,
1.282 + pcb_lug_offset_from_bottom,
1.283 + payload_back + extra * 2, pcb_front_lug_inner_radius);
1.284 + }
1.285 +
1.286 + module pcb_back_socket_hole_wide(xdir) {
1.287 + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.288 + back_depth + extra,
1.289 + wide_pcb_lug_offset_from_bottom,
1.290 + payload_back + extra * 2, pcb_front_lug_inner_radius);
1.291 + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside,
1.292 + back_depth + extra,
1.293 + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom,
1.294 + payload_back + extra * 2, pcb_front_lug_inner_radius);
1.295 + }
1.296 +
1.297 + /*
1.298 + The common implementation of the circular hole used when both pieces
1.299 + employ the socket lug.
1.300 + */
1.301 +
1.302 + module pcb_socket_hole_explicit(xdir, offset_from_centre, depth_offset, offset_from_bottom,
1.303 + hole_depth, hole_radius) {
1.304 +
1.305 + translate([payload_centre + xdir * offset_from_centre,
1.306 + depth_offset,
1.307 + int_payload_lower_extent + offset_from_bottom
1.308 + ])
1.309 + rotate([90, 0, 0])
1.310 + cylinder(h=hole_depth, r=hole_radius);
1.311 + }
1.312 +
1.313 /* The actual shapes. */
1.314
1.315 module front_piece(front_displacement, front_displacement_together) {
1.316 @@ -753,6 +910,21 @@
1.317 top_label_depth]);
1.318 }
1.319
1.320 + /* Front socket holes depending on back lug choices. */
1.321 +
1.322 + if (BACK_LUG == BACK_SOCKET) {
1.323 +
1.324 + if (MODEL == ROM_CARTRIDGE) {
1.325 + pcb_front_socket_hole(-1);
1.326 + pcb_front_socket_hole(1);
1.327 + }
1.328 +
1.329 + if (MODEL == WIDE_CARTRIDGE) {
1.330 + pcb_front_socket_hole_wide(-1);
1.331 + pcb_front_socket_hole_wide(1);
1.332 + }
1.333 + }
1.334 +
1.335 /* Inner front edge cavity. */
1.336
1.337 translate([inner_front_edge_width / 2, -int_front_depth, lower_extent])
1.338 @@ -1092,6 +1264,23 @@
1.339 payload_centre, -groove_width_extra, upper_extent);
1.340 }
1.341
1.342 + /* Back socket holes. */
1.343 +
1.344 + if (BACK_LUG == BACK_SOCKET) {
1.345 +
1.346 + if (MODEL == ROM_CARTRIDGE) {
1.347 + pcb_back_socket_hole(-1);
1.348 + pcb_back_socket_hole(1);
1.349 + }
1.350 +
1.351 + if (MODEL == WIDE_CARTRIDGE) {
1.352 + pcb_back_socket_hole_wide(-1);
1.353 + pcb_back_socket_hole_wide(1);
1.354 + }
1.355 + }
1.356 +
1.357 + /* The connector section at the base of the back. */
1.358 +
1.359 if (BACK_CONNECTOR_SECTION) {
1.360
1.361 /* Provide an external cavity. */