neotrellis-grid/supports.scad

166 lines
6.5 KiB
OpenSCAD

// this SCAD file defines the support structures for the neotrellis grid. (potentially also bottom case)
// TODO fix mounting hole positions
pcb_size = 60; // the PCB is 60x60mm square
pcb_depth = 7.57; // the PCB is 7.57mm deep, overall (including connector + lEDs)
connector_depth=5.7; // the connector on the bottom of the PCB is 5.8mm thick.
pcb_thickness= 1.7; // the PCB itself (just the board, w/o components) is roughly 1.7mm thick
support_width=5; // width of support structure walls
support_depth=10; // depth of support structure wall
floor_depth = 1; // depth of the bottom floor of the support
tolerance = 0.4; // general tolerance
pcb_tolerance = 2; // tolerance for the size of the PCB
wall_height = (pcb_depth-connector_depth)+4; // height of walls above the top of the supports
wall_width = 5; // width of walls above the top of the supports
cutout_width=25; // width of the cutouts in the support structure, for wires etc
cutout_depth=5; // depth of the cutouts in the support structure
pcbs_wide=2; // how many trellis PCBs are in the grid, width-wise
pcbs_long=4; // how many trellis PCBs are in the grid, length-wise
hole_size = 4; // size of the holes in which the top plate pegs sit
hole_depth = 15; // depth of the holes in which the top plate pegs sit
// load and position the PCB grid as a reference
rotate([180,0,0]) {
translate([pcb_size/2,-pcb_size/2-pcb_size]) {
for(x=[0:pcbs_long-1]) {
for(y=[0:pcbs_wide-1]) {
translate([pcb_size*x,pcb_size*y,0]) {
%import("pcb-single.stl");
}
}
}
}
}
// translate everything down relative to the PCB reference
translate([0,0,-support_depth-pcb_thickness]) {
box();
}
// a support unit is the individual box underneath one trellis PCB. no cutouts are included in the module as these differ depending on position.
// if outer is true, an extra tolerance is added
module support_unit() {
// outer box - the size of the overall box
difference() {
cube([pcb_size,pcb_size,support_depth]);
translate([support_width,support_width,floor_depth]) {
// inner box - cuts a hole in the center of the box to create walls+floor
cube(
[pcb_size-(support_width*2),
pcb_size-(support_width*2),
support_depth+1.01]);
}
}
}
// the whole box. Made into a module for importing into an assembly later, maybe?
module box() {
// create basic grid of support units
difference() {
union() {
// create large outer box
translate([-(wall_width+pcb_tolerance),-(wall_width+pcb_tolerance)]) {
difference() {
// outer cube
cube(
[pcb_size*pcbs_long+(wall_width+pcb_tolerance)*2,
pcb_size*pcbs_wide+(wall_width+pcb_tolerance)*2,
support_depth+wall_height]);
// cutout to make it into a box
translate([wall_width+pcb_tolerance/2,wall_width+pcb_tolerance/2]) {
cube(
[pcb_size*pcbs_long+pcb_tolerance,
pcb_size*pcbs_wide+pcb_tolerance,
support_depth+wall_height+0.1]);
}
}
}
union() {
// support units for the PCBs
for(x=[0:pcbs_long-1]) {
for(y=[0:pcbs_wide-1]) {
translate([pcb_size*x,pcb_size*y,0]) {
support_unit();
}
}
}
// filler cubes to fill the tolerance.
// there is likely a better way to do this, but I don't know it.
// this is a bodge so I can move onto the next thing and hey,
// it hopefully works well enough.
translate([-pcb_tolerance,0,0]) {
// widthwise
cube([pcb_tolerance+1,pcbs_wide*pcb_size, support_depth]);
translate([pcbs_long*pcb_size+pcb_tolerance,0,0])
cube([pcb_tolerance+1, pcbs_wide*pcb_size+pcb_tolerance, support_depth]);
// lengthwise
translate([0,-pcb_tolerance,0])
cube([pcbs_long*pcb_size+pcb_tolerance*2, pcb_tolerance+1, support_depth]);
translate([0,(pcbs_wide*pcb_size),0])
cube([pcbs_long*pcb_size+pcb_tolerance*2, pcb_tolerance+1, support_depth]);
}
}
}
// add lengthwise internal cutouts
for(x=[0:pcbs_wide-1]) {
translate(
[pcb_size/2,
(pcb_size/2-cutout_width/2)+(pcb_size*x),
support_depth-cutout_depth]) {
cube([(pcb_size*(pcbs_long-1)),cutout_width,cutout_depth+1]);
}
}
// add widthwise internal cutouts
for(x=[0:pcbs_long-1]) {
translate(
[(pcb_size/2-cutout_width/2) + ((pcb_size)*x),
pcb_size/2,
support_depth-cutout_depth]) {
cube([cutout_width, pcb_size*(pcbs_wide-1), cutout_depth+1]);
}
}
// add cutout for USB port
translate(
[pcb_size*(pcbs_long-1)+wall_width+1+pcb_tolerance,
pcb_size/2-cutout_width/2+pcb_size,
support_depth-cutout_depth
]) {
cube([pcb_size, cutout_width, wall_width+pcb_tolerance]);
}
// mounting holes for plate
translate(
[-wall_width/2-pcb_tolerance/2,
-wall_width/2-pcb_tolerance/2,
wall_height+support_depth-hole_depth/2]){
cube([hole_size,hole_size,hole_depth+0.01], center=true);
}
translate(
[wall_width/2+(pcbs_long*pcb_size)+pcb_tolerance/2,
-wall_width/2-pcb_tolerance/2,
wall_height+support_depth-hole_depth/2]){
cube([hole_size,hole_size,hole_depth+0.01], center=true);
}
translate(
[wall_width/2+(pcbs_long*pcb_size)+pcb_tolerance/2,
wall_width/2+(pcbs_wide*pcb_size)+pcb_tolerance/2,
wall_height+support_depth-hole_depth/2]){
cube([hole_size,hole_size,hole_depth+0.01], center=true);
}
translate(
[-wall_width/2-pcb_tolerance/2,
wall_width/2+(pcbs_wide*pcb_size)+pcb_tolerance/2,
wall_height+support_depth-hole_depth/2]){
cube([hole_size,hole_size,hole_depth+0.01], center=true);
}
}
}