reformat code, add filler for tolerances

This commit is contained in:
Nico 2021-07-20 16:47:48 +01:00
parent f78ad08feb
commit 5756e7ca2c
1 changed files with 47 additions and 16 deletions

View File

@ -1,4 +1,8 @@
// this SCAD file defines the support structures for the neotrellis grid. (potentially also bottom case)
// TODO add holes for pegs in corners
// TODO test prints
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.
@ -9,8 +13,10 @@ support_depth=10; // depth of support structure wall
floor_depth = 1; // depth of the bottom floor of the support
tolerance = 0.4;
wall_height = (pcb_depth-connector_depth)+4; // height of walls above the top of the supports
wall_width = 1; // width 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
@ -18,30 +24,54 @@ 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
tolerance = 0.4;
// translate everything down relative to the PCB reference
translate([0,0,-support_depth-pcb_thickness]) {
// create basic grid of support units
difference() {
union() {
// create large outer box
translate([-wall_width,-wall_width]) {
translate([-(wall_width+tolerance),-(wall_width+tolerance)]) {
difference() {
cube([pcb_size*pcbs_long+wall_width*2,pcb_size*pcbs_wide+wall_width*2,support_depth+wall_height]);
translate([wall_width,wall_width]) {
cube([pcb_size*pcbs_long,pcb_size*pcbs_wide,support_depth+wall_height+0.1]);
// outer cute
cube(
[pcb_size*pcbs_long+(wall_width+tolerance)*2,
pcb_size*pcbs_wide+(wall_width+tolerance)*2,
support_depth+wall_height]);
// cutout to make it into a box
translate([wall_width+tolerance/2,wall_width+tolerance/2]) {
cube(
[pcb_size*pcbs_long+tolerance,
pcb_size*pcbs_wide+tolerance,
support_depth+wall_height+0.1]);
}
}
}
}
}
for(x=[0:pcbs_long-1]) {
for(y=[0:pcbs_wide-1]) {
translate([pcb_size*x,pcb_size*y,0]) {
support_unit();
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([-tolerance,0,0]) {
// widthwise
cube([tolerance+1,pcbs_wide*pcb_size, support_depth]);
translate([pcbs_long*pcb_size+tolerance,0,0])
cube([tolerance+1, pcbs_wide*pcb_size+tolerance, support_depth]);
// lengthwise
translate([0,-tolerance,0])
cube([pcbs_long*pcb_size+tolerance*2, tolerance+1, support_depth]);
translate([0,pcbs_wide*pcb_size-tolerance,0])
cube([pcbs_long*pcb_size+tolerance*2, tolerance+1, support_depth]);
}
}
}
}
// add lengthwise internal cutouts
for(x=[0:pcbs_wide-1]) {
translate(
@ -77,7 +107,7 @@ rotate([180,0,0]) {
for(x=[0:pcbs_long-1]) {
for(y=[0:pcbs_wide-1]) {
translate([pcb_size*x,pcb_size*y,0]) {
%import("pcb-single.stl");
// %import("pcb-single.stl");
}
}
}
@ -85,7 +115,8 @@ rotate([180,0,0]) {
}
// a support unit is the individual box underneath one trellis PCB. no cutouts are included in the module as these differ depending on position.
module support_unit() {
// 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]);