# HG changeset patch # User Paul Boddie # Date 1461422163 -7200 # Node ID 3e2724bdfc7e5b597afd6d592757c181e46d9498 # Parent a12ac250b04cfaa5ad8c1790693d4742741162cf Added through-hole support as an alternative to the plug/socket mechanism. diff -r a12ac250b04c -r 3e2724bdfc7e cartridge.scad --- a/cartridge.scad Mon Apr 11 16:51:35 2016 +0200 +++ b/cartridge.scad Sat Apr 23 16:36:03 2016 +0200 @@ -28,6 +28,15 @@ MODEL = ROM_CARTRIDGE; + /* Plug and socket options. Do not edit! */ + + BACK_PLUG = 0; + BACK_SOCKET = 1; + + /* Set this to the desired lug type. */ + + BACK_LUG = BACK_PLUG; + /* Configure the generated shapes. For the absolute simplest shape (for basic 3D printers)... @@ -39,6 +48,9 @@ To retain the back connecting piece instead, change the above to... BACK_CONNECTOR_SECTION = 1; + + And set the following options... + EXTERNAL_BACK_CAVITY = 0; EXTERNAL_BACK_CUTOUT = 1; @@ -227,7 +239,12 @@ front_back_overlap = 1.0; groove_width_overlap = front_back_overlap + groove_width_extra; - /* Division of pieces into front and back, defining the extents. */ + /* + Division of pieces into front and back, defining the extents. The back + depth is extended by the front/back overlap, and thus the internal back + depth calculated here is greater than the actual depth that the back + portion can hold. + */ int_front_depth = 4.5; front_depth = int_front_depth + front; @@ -422,12 +439,10 @@ pcb_lug_mating_depth = pcb_back_support_bump_depth + 1.0; - pcb_lug_depth = pcb_back_support_depth + + pcb_back_lug_depth = pcb_back_support_depth + pcb_lug_mating_depth; - pcb_lug_inner_radius = 1.0; - pcb_lug_outer_radius = 5.5 / 2; - pcb_lug_offset_from_bottom = 14.35; - pcb_lug_offset_from_inside = 5.55; + pcb_back_lug_inner_radius = 1.0; + pcb_back_lug_outer_radius = 5.5 / 2; /* The cross detail on the back lug is intended to resist the front lug, @@ -439,14 +454,44 @@ pcb_lug_mating_depth; pcb_lug_cross_height = 1.4; + /* + The front depth is calculated similarly to the back depth, with the + outer radius of the socket corresponding to the dimensions of the cross + detail. The inner radius of the front's socket is the same as the outer + radius of the back's plug, with friction holding the two together. + */ + pcb_front_lug_depth = pcb_front_support_depth + pcb_lug_mating_depth; - pcb_front_lug_inner_radius = pcb_lug_outer_radius; + pcb_front_lug_inner_radius = pcb_back_lug_outer_radius; pcb_front_lug_outer_radius = pow( pow(pcb_lug_cross_width / 2, 2) + pow(pcb_lug_cross_height / 2, 2), 0.5); + /* + With BACK_LUG as BACK_SOCKET, no overlap is desired, since both + front and back provide sockets. The depth is accounted for as follows: + + int_payload_back_depth + payload_back == back_depth + + int_front_depth - pcb_front_lug_depth == back lug space in the front + - front_back_overlap == correction for overlap + + int_front_depth - pcb_front_lug_depth + == pcb_front_support_depth - pcb_front_support_depth - pcb_lug_mating_depth + == -pcb_lug_mating_depth + + Note that the lug starts at the outer back surface, which is why the + payload_back quantity is included. + */ + + pcb_back_socket_lug_depth = back_depth - front_back_overlap - pcb_lug_mating_depth; + + /* Both front and back lugs need to be positioned in the same place. */ + + pcb_lug_offset_from_bottom = 14.35; + pcb_lug_offset_from_inside = 5.55; + wide_pcb_lug_offset_from_inside = 6.0; wide_pcb_lug_offset_from_bottom = 6.0; @@ -541,22 +586,42 @@ } } + /* Choose the kind of "lug" in the back piece. */ + module pcb_lug(xdir) { - pcb_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, - pcb_lug_offset_from_bottom); + if (BACK_LUG == BACK_PLUG) { + pcb_back_plug_lug(xdir); + } else if (BACK_LUG == BACK_SOCKET) { + pcb_back_socket_lug(xdir); + } } module pcb_lug_wide(xdir) { - pcb_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + if (BACK_LUG == BACK_PLUG) { + pcb_back_plug_lug_wide(xdir); + } else if (BACK_LUG == BACK_SOCKET) { + pcb_back_socket_lug_wide(xdir); + } + } + + /* The conventional back "lug" which is actually a plug. */ + + module pcb_back_plug_lug(xdir) { + pcb_back_plug_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, + pcb_lug_offset_from_bottom); + } + + module pcb_back_plug_lug_wide(xdir) { + pcb_back_plug_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, wide_pcb_lug_offset_from_bottom); - pcb_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + pcb_back_plug_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom); } - module pcb_lug_explicit(xdir, pcb_lug_offset_from_centre, pcb_lug_offset_from_bottom) { - translate([payload_centre + xdir * pcb_lug_offset_from_centre, + module pcb_back_plug_lug_explicit(xdir, offset_from_centre, offset_from_bottom) { + translate([payload_centre + xdir * offset_from_centre, back_depth, - int_payload_lower_extent + pcb_lug_offset_from_bottom + int_payload_lower_extent + offset_from_bottom ]) rotate([90, 0, 0]) difference() { @@ -564,7 +629,7 @@ /* Cylinder with cross. */ union() { - cylinder(h=pcb_lug_depth, r=pcb_lug_outer_radius); + cylinder(h=pcb_back_lug_depth, r=pcb_back_lug_outer_radius); cube_at(pcb_lug_cross_width, pcb_lug_cross_height, pcb_lug_cross_depth, 0, 0, 1, @@ -577,42 +642,134 @@ /* Hollowed out by a cylinder. */ - cylinder(h=pcb_lug_depth, r=pcb_lug_inner_radius); + cylinder(h=pcb_back_lug_depth, r=pcb_back_lug_inner_radius); /* Tapered off for easier connection. */ if (ROUND_CONNECTING_EDGES) - translate([0, 0, pcb_lug_depth - pcb_lug_ro]) - fillet_torus(pcb_lug_outer_radius, pcb_lug_rr); + translate([0, 0, pcb_back_lug_depth - pcb_lug_ro]) + fillet_torus(pcb_back_lug_outer_radius, pcb_lug_rr); } } + /* The conventional front "lug" which is actually a socket. */ + module pcb_front_lug(xdir) { - pcb_front_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, - pcb_lug_offset_from_bottom); + pcb_socket_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, + -int_front_depth + pcb_front_lug_depth, + pcb_lug_offset_from_bottom, + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); } module pcb_front_lug_wide(xdir) { - pcb_front_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, - wide_pcb_lug_offset_from_bottom); - pcb_front_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, - wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom); + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + -int_front_depth + pcb_front_lug_depth, + wide_pcb_lug_offset_from_bottom, + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + -int_front_depth + pcb_front_lug_depth, + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom, + pcb_front_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); } - module pcb_front_lug_explicit(xdir, pcb_lug_offset_from_centre, pcb_lug_offset_from_bottom) { - translate([payload_centre + xdir * pcb_lug_offset_from_centre, - -int_front_depth + pcb_front_lug_depth, - int_payload_lower_extent + pcb_lug_offset_from_bottom + /* + The alternative back "lug" which is actually a socket as well, meaning + that a cylinder runs from the front surface to the back, with the two + sections meeting in the middle. + */ + + module pcb_back_socket_lug(xdir) { + pcb_socket_lug_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, + back_depth, + pcb_lug_offset_from_bottom, + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); + } + + module pcb_back_socket_lug_wide(xdir) { + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + back_depth, + wide_pcb_lug_offset_from_bottom, + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); + pcb_socket_lug_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + back_depth, + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom, + pcb_back_socket_lug_depth, pcb_front_lug_outer_radius, pcb_front_lug_inner_radius); + } + + /* The common implementation of the cylinder socket. */ + + module pcb_socket_lug_explicit(xdir, offset_from_centre, depth_offset, offset_from_bottom, + lug_depth, lug_outer_radius, lug_inner_radius) { + + translate([payload_centre + xdir * offset_from_centre, + depth_offset, + int_payload_lower_extent + offset_from_bottom ]) rotate([90, 0, 0]) difference() { - cylinder(h=pcb_front_lug_depth, - r=pcb_front_lug_outer_radius); - cylinder(h=pcb_front_lug_depth, - r=pcb_front_lug_inner_radius); + cylinder(h=lug_depth, + r=lug_outer_radius); + cylinder(h=lug_depth, + r=lug_inner_radius); } } + /* The holes in the front surface when socket lugs are used. */ + + module pcb_front_socket_hole(xdir) { + pcb_socket_hole_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, + -int_front_depth + extra, + pcb_lug_offset_from_bottom, + front + extra * 2, pcb_front_lug_inner_radius); + } + + module pcb_front_socket_hole_wide(xdir) { + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + -int_front_depth + extra, + wide_pcb_lug_offset_from_bottom, + front + extra * 2, pcb_front_lug_inner_radius); + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + -int_front_depth + extra, + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom, + front + extra * 2, pcb_front_lug_inner_radius); + } + + /* The holes in the back surface when socket lugs are used. */ + + module pcb_back_socket_hole(xdir) { + pcb_socket_hole_explicit(xdir, int_connector_width / 2 - pcb_lug_offset_from_inside, + back_depth + extra, + pcb_lug_offset_from_bottom, + payload_back + extra * 2, pcb_front_lug_inner_radius); + } + + module pcb_back_socket_hole_wide(xdir) { + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + back_depth + extra, + wide_pcb_lug_offset_from_bottom, + payload_back + extra * 2, pcb_front_lug_inner_radius); + pcb_socket_hole_explicit(xdir, int_payload_width / 2 - wide_pcb_lug_offset_from_inside, + back_depth + extra, + wide_pcb_height - edge_connector_height - wide_pcb_lug_offset_from_bottom, + payload_back + extra * 2, pcb_front_lug_inner_radius); + } + + /* + The common implementation of the circular hole used when both pieces + employ the socket lug. + */ + + module pcb_socket_hole_explicit(xdir, offset_from_centre, depth_offset, offset_from_bottom, + hole_depth, hole_radius) { + + translate([payload_centre + xdir * offset_from_centre, + depth_offset, + int_payload_lower_extent + offset_from_bottom + ]) + rotate([90, 0, 0]) + cylinder(h=hole_depth, r=hole_radius); + } + /* The actual shapes. */ module front_piece(front_displacement, front_displacement_together) { @@ -753,6 +910,21 @@ top_label_depth]); } + /* Front socket holes depending on back lug choices. */ + + if (BACK_LUG == BACK_SOCKET) { + + if (MODEL == ROM_CARTRIDGE) { + pcb_front_socket_hole(-1); + pcb_front_socket_hole(1); + } + + if (MODEL == WIDE_CARTRIDGE) { + pcb_front_socket_hole_wide(-1); + pcb_front_socket_hole_wide(1); + } + } + /* Inner front edge cavity. */ translate([inner_front_edge_width / 2, -int_front_depth, lower_extent]) @@ -1092,6 +1264,23 @@ payload_centre, -groove_width_extra, upper_extent); } + /* Back socket holes. */ + + if (BACK_LUG == BACK_SOCKET) { + + if (MODEL == ROM_CARTRIDGE) { + pcb_back_socket_hole(-1); + pcb_back_socket_hole(1); + } + + if (MODEL == WIDE_CARTRIDGE) { + pcb_back_socket_hole_wide(-1); + pcb_back_socket_hole_wide(1); + } + } + + /* The connector section at the base of the back. */ + if (BACK_CONNECTOR_SECTION) { /* Provide an external cavity. */