User:Dorkmo/Ideas/Battery/SCAD: Difference between revisions

From Open Source Ecology
Jump to navigation Jump to search
(used the mirror function to mirror mesh on both sides)
No edit summary
 
(60 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[User:Dorkmo/Ideas/Battery/SCAD/Sandbox]]
[[User:Dorkmo/Ideas/Battery/SCAD/Sandbox]]
[[User:Dorkmo/Ideas/Battery/SCAD/201510]]
[[User:Dorkmo/Ideas/Battery/SCAD/201509]]
[[User:Dorkmo/Ideas/Battery/SCAD/201411]]
=parts to be printed=
make sure all the variables are the same for each part
==cage==




===inside cage===
  <nowiki>
  <nowiki>


height = 60;
height = 90;
tub_width = 95;
tub_width = 36;
tub_length = 70;
tub_length = 70;
outsidewall = 5;
basethickness = 5;
basethickness = 5;
tub_wall = 5;
tub_wall = 2;
tub_outsidewall = 4;


spacing = 5;
tubs_rows    = 5;
cage_height = 40;
tubs_columns = 2;
cage_wall = 10;
 
cage_endwall = 5;
spacing = 1.940055;
center_dividers = 00; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;
cage_base = 5;
wedge_hieght = 10;


mesh_opening = 1 ;
mesh_opening = 1.5 ;
mesh_angle = 35;
mesh_angle = 45;
mesh_spacing = 2;
mesh_spacing = 3.5;
mesh_width = 17;
 
mesh_height = 10;
wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;


module half()
//begin underlying cage module
module cage()
  {
  {
difference()
  difference()
{
  {
cube(size = [(tub_width-(spacing*3))/2,tub_length-(spacing*2),cage_height], center=false);
    cube(size = [(tub_width-(spacing*3))/2,tub_length-(spacing*2),cage_height], center=false);
//delete half of it
//cut hole for powder to sit in
cube(size = [((tub_width-(spacing*3))/2)/2,(tub_length-(spacing*2)),cage_height], center=false);
    translate([cage_wall, cage_endwall, cage_base])
translate([cage_wall, cage_endwall, cage_base])
      cube(size = [((tub_width-(spacing*3))/2)-(cage_wall*2),(tub_length-(spacing*2))-(cage_endwall*2),cage_height-cage_base+1], center=false);
cube(size = [((tub_width-(spacing*3))/2)-(cage_wall*2),(tub_length-(spacing*2))-(cage_endwall*2),cage_height-cage_base+1], center=false);
  }
  translate([((tub_width-(spacing*3))/2)-cage_wall-((sin(mesh_angle)*sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/2), cage_endwall-(mesh_spacing/2)+(((((tub_length-(spacing*2))-(cage_endwall*2))-(((floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing))*mesh_spacing)+sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/2), cage_base])
}
//end cage
   
//begin mesh hole grid module
module holes()
{
intersection()
{
translate([0,-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))),0])
cube([cage_wall+0.2,1+((((tub_length-(spacing*2))-(cage_endwall*2)))),cage_height], center=false);
 
 
//need to translate closer to the cube here with llarge holes
 
translate([0,0,-mesh_spacing])
{
 
rotate([0,-mesh_angle,0])
 
scale([1,1,(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/sin(90-mesh_angle))*sin(90))])
{
//for - pair of rows to height
 
  for (h = [1 : floor(((cage_height-cage_base-((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle))))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
   {
   {
     for (h = [1 : floor(((cage_height-cage_base-((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle))))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
     translate(h*[0,0,mesh_spacing])
    {
{
      translate(h*[0,0,mesh_spacing])
 
      {
//for - second row
        scale([1,1,(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/sin(90-mesh_angle))*sin(90))])
 
        {
for (w = [1 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
        rotate([0,90-mesh_angle,0])
        {
        {
//translate second row
          for (w = [1 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
        translate([0,-mesh_spacing/2,mesh_spacing/2])
           {
           {
//make second row copies
             translate(w*[0,mesh_spacing,0])
             translate(w*[0,mesh_spacing,0])
             {
             {
               rotate([0,0,45])
               rotate([45,0,0])
               {
               {
//could put a scale command here to make opening a perfect square
    cube(size = [(cage_wall*2)+(cage_height/sin(90))*sin(mesh_angle),mesh_opening,mesh_opening], center=false);
                cube(size = [mesh_opening,mesh_opening,(mesh_opening*2)+(sin(90)*(cage_wall/sin(90-mesh_angle)))], center=false);
 
               }
               }
             }
             }
           }
           }
//begin second row
        }
        #for (w = [0 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
 
          {
//for - create first row
            translate([mesh_spacing/2,mesh_spacing/2,-mesh_spacing/2])
for (w = [0 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
 
             {
             {
               translate(w*[0,mesh_spacing,0])
               translate(w*[0,mesh_spacing,0])
              {
 
                rotate([0,0,45])
{
                {
  rotate([45,0,0])
//could put a scale command here to make opening a perfect square
  {
                cube(size = [mesh_opening,mesh_opening,(mesh_opening*2)+(sin(90)*(cage_wall/sin(90-mesh_angle)))], center=false);
//need to tweak
                }
    cube(size = [(cage_wall*2)+(cage_height/sin(90))*sin(mesh_angle),mesh_opening,mesh_opening],center=false);
              }
  }
            }
}
}
}
}
}
////end cube
}
}
}
////end mesh hole grid module
 
//////divot
module divot_sphere()
{
difference()
{
translate([(cage_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (cage_divot_height/2)/sin(45));
}
translate([(cage_divot_height/2)/sin(45),0,0])
cube(size = [((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2)], center=true);
}
}
////end divot module
 
//begin final cage construction
difference()
{
  cage();
//begin holes
  translate([(((tub_width-(spacing*3))/2)-cage_wall)+0.0, cage_endwall+((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/2)+(((((tub_length-(spacing*2))-(cage_endwall*2))-(((floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing))*mesh_spacing)+sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/2), cage_base])
  {
    holes();
  }
    translate([(cage_wall)-0.0,cage_endwall+((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/2)+(((((tub_length-(spacing*2))-(cage_endwall*2))-(((floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing))*mesh_spacing)+sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/2), cage_base])
  {
 
  mirror([1,0,0])
    {
      #holes();
    }
  }
//end holes
 
//begin divots
 
//1
      translate([cage_wall,(((tub_length-(spacing*2))-(cage_endwall*2))*1/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
      {
        #divot_sphere();
      }
//2
      translate([cage_wall,(((tub_length-(spacing*2))-(cage_endwall*2))*3/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
      {
        #divot_sphere();
      }
//3
      translate([cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(((tub_length-(spacing*2))-(cage_endwall*2))*1/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
      {
        mirror([1,0,0])
        {
          #divot_sphere();
        }
      }
//4
      translate([cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(((tub_length-(spacing*2))-(cage_endwall*2))*3/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
      {
        mirror([1,0,0])
        {
          #divot_sphere();
        }
      }
//end divots
}
//end cage
 
 
//calculate mesh wall minimum thickness
echo(sin(45)*((mesh_spacing-((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/sin(90)));
 
 
//calculate verticle height of mesh holes to take away from max height of holes
//works okay up to 45 then bugs out. might be because its before the scale down
echo((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle)));
 
 
 
echo("cage cavity y",((tub_width-(spacing*3))/2)-(cage_wall*2));
 
echo("cage cavity x",(tub_length-(spacing*2))-(cage_endwall*2));
 
echo("cage cavity z",cage_height-cage_base);
 
echo("powder volume per cage",((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10,"cm3");
 
echo("grams nickle hydroxide per cage",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10),"grams");//density is 4.10
 
echo("total grams nickle hydroxide",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10)*(tubs_columns*tubs_rows),"grams");
 
//calculate mesh wall minimum thickness
echo("mesh dividers thickness",sin(45)*((mesh_spacing-((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/sin(90)));
 
 
</nowiki>
 
==cage lid with divots and cleat==
 
<nowiki>
height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;
 
tubs_rows    = 5;
tubs_columns = 2;
 
spacing = 1.940055;
center_dividers = 00; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;
 
mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;
 
wire_count = 7; //number of wires into each cage
wire_diameter = 1.4;
wire_holeoffc = 0;
cage_lid_cut = 0; //1 yes 0 no cavity in lid or not?
cage_minicleat = 2;
yn_cage_minicleat = 1; //1 yes 0 no
yn_cage_cleat = 0; //1 yes 0 no
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;
 
shrink_cage_lid = 0.5;
base_chamfer_depth = 0.9; //max 1.0
base_wire_cone = 0.2; //diameter added to wire_diameter
 
union()
{
  difference()
  {
    union()
    {
      translate([shrink_cage_lid/2,shrink_cage_lid/2,0])
      {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))-shrink_cage_lid,((tub_length-(spacing*2))-(cage_endwall*2))-shrink_cage_lid,cage_lid_depthinto], center=false);
      }
      translate([-1,-1,cage_lid_depthinto])
      {
        cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+2,((tub_length-(spacing*2))-(cage_endwall*2))+2,2], center=false);
      }
//spheres lock ins
//1
      translate([(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*1/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
      {
        divot_sphere();
      }
//2
      translate([(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*3/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
      {
        divot_sphere();
      }
//3
      translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))-(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*1/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
      {
        mirror([1,0,0])
        {
          divot_sphere();
        }
      }
//4
      translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))-(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*3/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
      {
        mirror([1,0,0])
        {
          divot_sphere();
        }
      }
//end spheres
 
//minicleats
//1
translate([((((((tub_width-(spacing*3))/2)-(cage_wall*2))+2)/2)-cage_minicleat)+((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,((((tub_length-(spacing*2))-(cage_endwall*2))*1/2))+(wire_diameter/2),cage_lid_depthinto+2])
  {
 
for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
{
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
  {
if (yn_cage_minicleat==1) mini_cleat(cage_minicleat,1);
}
}
}
 
//2
translate([-((((((tub_width-(spacing*3))/2)-(cage_wall*2))+2)/2)-cage_minicleat)+((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,((((tub_length-(spacing*2))-(cage_endwall*2))*1/2))+(wire_diameter/2),cage_lid_depthinto+2])
  {
mirror([1,0,0])
{
for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
{
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
  {
if (yn_cage_minicleat==1) mini_cleat(cage_minicleat,1);
}
}
}
}
 
//end mini cleats
 
 
    }
//end union begin difference
  translate([1,1,1])
  {
    if (cage_lid_cut==1) cube(size = [((tub_width-(spacing*3))/2)-(cage_wall*2)-2,(tub_length-(spacing*2))-(cage_endwall*2)-2,cage_lid_depthinto+3], center=false);
  }
//chamfer underside of lip
  translate([-2,-1,cage_lid_depthinto-1])
  {
    rotate([45,0,0])
    {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-2,(tub_length-(spacing*2))-(cage_endwall*2)+1,cage_lid_depthinto-1])
  {
    rotate([45,0,0])
    {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-1,-2,cage_lid_depthinto-1])
  {
    rotate([45,0,90])
    {
      cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))+1,-2,cage_lid_depthinto-1])
  {
    rotate([45,0,90])
    {
      cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
//end chamfer
 
 
//chamfer base
  translate([-2,base_chamfer_depth-1,-1])
  {
    rotate([45,0,0])
    {
      #cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-2,(tub_length-(spacing*2))-(cage_endwall*2)+1-base_chamfer_depth,-1])
  {
    rotate([45,0,0])
    {
      #cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-1+base_chamfer_depth,-2,-1])
  {
    rotate([45,0,90])
    {
      #cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))+1-base_chamfer_depth,-2,-1])
  {
    rotate([45,0,90])
    {
      #cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
    }
  }
//end chamfer
 
//begin wire holes
  translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2),-1])
  {
 
for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
{
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
  {
//wire hole
    #cylinder(r2 = wire_diameter/2, r1 = (wire_diameter+base_wire_cone)/2, h = cage_lid_depthinto+2+2);
 
  }
}
 
 
  }
//end wire holes
 
 
//end difference
}
//begin union
 
//cleat
    translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2)-(wire_diameter*1.5)-1+wire_holeoffc,0])
    {
        if (yn_cage_cleat==1) cleat(2,cage_lid_depthinto+2);
    }
    translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2)+(wire_diameter*1.5)+1+wire_holeoffc,0])
    {
      mirror([0,1,0])
      {
        if (yn_cage_cleat==1) cleat(2,cage_lid_depthinto+2);
      }
    }
//end cleat
}
 
 
//divot
module divot_sphere()
{
difference()
{
translate([(cage_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (cage_divot_height/2)/sin(45));
}
translate([(cage_divot_height/2)/sin(45),0,0])
cube(size = [((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2)], center=true);
}
}
 
////cleat module
module cleat(size,height)
{
  translate([0,0,-size])
  {
  difference()
  {
    rotate([45,0,0])
    {
      rotate([0,0,45])
      {
        cube(size = [size,size,height/sin(45)], center=false);
      }
    }
    translate([-size*3/2,-size*3/2,0])
    {
      #cube(size = [size*3,size*3,size],center=false);
    }
  }
}
}
//end cleat
 
//mini_cleat module
module mini_cleat(sides,height)
{
union()
{
#cube(size = [sides,sides,height]);
translate([0,0,height])
{
polyhedron
  (points = [ [0,0,0],[sides,0,0],[sides,sides,0],[0,sides,0],
          [sides,0,sides],[sides*2,0,sides],[sides*2,sides,sides],[sides,sides,sides]
        ],
  faces = [ [0,1,2],[0,2,3], //
          [0,5,1],[0,4,5],  //
          [1,5,6],[1,6,2], 
          [2,6,7],[2,7,3],
          [3,7,4],[3,4,0],
          [4,7,6],[4,6,5]
        ]
);
}
}
}
//end mini cleat module
 
 
 
</nowiki>
 
==multi cell tub==
 
<nowiki>
height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;
 
tubs_rows    = 1;
tubs_columns = 1;
 
spacing = 1.940055;
wall_spacers_yn = 0; //1 yes 0 no
center_dividers = 0; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;
 
mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;
 
wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;
 
 
 
union()
{
 
//tubs
for (c = [0 : tubs_columns-1])
{
  translate([0,c*(tub_length+tub_wall),0])
  {
    for (r = [0 : tubs_rows-1])
    {
    translate([r*(tub_width+tub_wall),0,0])
      {
      tub();
      }
    }
  }
}
//end tubs
 
//outer walls
translate([-tub_outsidewall+tub_wall,-tub_outsidewall+tub_wall,0])
{
  difference()
  {
    cube(size = [((tub_width+tub_wall)*tubs_rows)+(tub_outsidewall*2)-tub_wall,((tub_length+tub_wall)*tubs_columns)+(tub_outsidewall*2)-tub_wall,height]);
    translate([tub_outsidewall,tub_outsidewall,0])
    {
      #cube(size = [(((tub_width+tub_wall)*tubs_rows)+tub_wall)-(tub_wall*2),(((tub_length+tub_wall)*tubs_columns)+tub_wall)-(tub_wall*2),height+1]);
    }
  }
}
 
//end outer walls
 
} //end union
 
//tub module
module tub()
{
union()
{
//walls
difference()
  {
  cube(size = [tub_width+(tub_wall*2), tub_length+(tub_wall*2), height], center=false);
  translate([tub_wall,tub_wall,basethickness])
    {
    cube(size = [tub_width, tub_length, height-basethickness+1], center=false);
    }
  }
//end walls
 
//spheres lock ins
//1
      translate([tub_wall,(tub_length*1/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([1,0,0])
        {
          #divot_sphere();
        }
      }
//2
      translate([tub_wall,(tub_length*3/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([1,0,0])
        {
          divot_sphere();
        }
      }
//3
      translate([tub_width+tub_wall,(tub_length*1/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([0,0,0])
        {
          divot_sphere();
        }
      }
//4
      translate([tub_width+tub_wall,(tub_length*3/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([0,0,0])
        {
          divot_sphere();
        }
      }
//5
      translate([(tub_width*1/2)+tub_wall,tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([0,1,0])
        {
          rotate([0,0,90])
          {
            #divot_sphere();
           }
           }
//end second row
         }
         }
      }
//6
      translate([(tub_width*1/2)+tub_wall,tub_length+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
      {
        mirror([0,0,0])
        {
          rotate([0,0,90])
          {
            #divot_sphere();
          }
        }
      }
//end spheres
//begin spacers
//1
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_wall,cage_height*4/5])
{
if (center_dividers==1) divider();
}
//2
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_wall,height-((spacing+cage_endwall+2)*2)-(sin(45)*(sin(45)*(spacing-1)))-(height*5/8)])
{
if (center_dividers==1) divider();
}
//3
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_length+tub_wall,cage_height*4/5])
{
mirror([0,1,0])
{
if (center_dividers==1) divider();
}
}
//4
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_length+tub_wall,height-((spacing+cage_endwall+2)*2)-(sin(45)*(sin(45)*(spacing-1)))-(height*5/8)])
{
mirror([0,1,0])
{
if (center_dividers==1) divider();
}
}
//the end_wall's side spacers
//s1
translate([(tub_width+(tub_wall*2))*1/4,tub_wall,(cage_height/2)+basethickness])
{
rotate([0,0,90])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s2
translate([(tub_width+(tub_wall*2))*3/4,tub_wall,(cage_height/2)+basethickness])
{
rotate([0,0,90])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s3
translate([(tub_width+(tub_wall*2))*1/4,tub_wall+tub_length,(cage_height/2)+basethickness])
{
rotate([0,0,270])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s4
translate([(tub_width+(tub_wall*2))*3/4,tub_wall+tub_length,(cage_height/2)+basethickness])
{
rotate([0,0,270])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//walls spacers
//w1
translate([tub_wall,(tub_length+(tub_wall*2))/2,(cage_height/2)+basethickness])
{
rotate([0,0,0])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//w2
translate([(tub_width+tub_wall),(tub_length+(tub_wall*2))/2,(cage_height/2)+basethickness])
{
rotate([0,0,180])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//base spacers
//b1
translate([(tub_width+(tub_wall*2))/2,(tub_length+(tub_wall*2))*1/5,basethickness])
{
rotate([0,270,90])
{
tub_spacer(tub_width-(spacing*2));
}
}
//b2
translate([(tub_width+(tub_wall*2))/2,(tub_length+(tub_wall*2))*4/5,basethickness])
{
rotate([0,270,90])
{
tub_spacer(tub_width-(spacing*2));
}
}
////end spacers
}
////endall
}
//divider modules
module divider()
{
  difference()
  {
    union()
    {
      cube(size=[spacing-1,spacing+cage_endwall+2,(spacing+cage_endwall+2)*2]);
      translate([0,0,(spacing+cage_endwall+2)*2])
      {
        rotate([0,45,0])
        {
          cube(size=[(sin(45)*(spacing-1)),spacing+cage_endwall+2,(sin(45)*(spacing-1))]);
         }
         }
      }
    }
    translate([0,spacing+cage_endwall+2,-(((spacing+cage_endwall+2)/sin(45))/sin(45))/2])
    {
      rotate([45,0,0])
      {
        cube(size=[spacing-1,((spacing+cage_endwall+2)/sin(45)),((spacing+cage_endwall+2)/sin(45))]);     
       }
       }
     }
     }
   }
   }
  }
  }
}
//end divider module


half();
//spacer module
mirror([1,0,0])
module tub_spacer(length)
  {
  {
  translate([-((tub_width-(spacing*3))/2),0,0])
translate([-(spacing-1),-length/2,0])
  {
  difference()
   {
   {
  half();
    rotate([0,45,0])
    {
      cube(size = [((spacing-1)/sin(45)),length,((spacing-1)/sin(45))]);
    }
    translate([-(spacing-1)-0.1,0,-(spacing-1)])
    {
      #cube(size = [((spacing-1)/sin(45))/sin(45),length,((spacing-1)/sin(45))/sin(45)]);
    }
   }
   }
  }
  }
}
//end spacer
//divot
module divot_sphere()
{
difference()
{
translate([(tub_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (tub_divot_height/2)/sin(45));
}
translate([(tub_divot_height/2)/sin(45),0,0])
cube(size = [((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2)], center=true);
}
}
//end divot
////calculations
echo("space above cages for extra fluid is", height-basethickness-spacing-cage_height-tub_lid_depthinto);
echo("tub print area x",((tub_width+tub_wall)*tubs_rows)+(tub_outsidewall*2)-tub_wall);
echo("tub print area y",((tub_length+tub_wall)*tubs_columns)+(tub_outsidewall*2)-tub_wall);
echo("tub print area z",height);


//calculate verticle height of mesh holes to take away from max height of holes
echo("cage cavity y",((tub_width-(spacing*3))/2)-(cage_wall*2));
//works okay up to 45 then bugs out. might be because its before the scale down
 
echo((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle)));
echo("cage cavity x",(tub_length-(spacing*2))-(cage_endwall*2));
 
echo("cage cavity z",cage_height-cage_base);
 
echo("powder volume per cage",((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10,"cm3");
 
echo("grams nickle hydroxide per cage",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10),"grams");//density is 4.10


echo("total grams nickle hydroxide",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10)*(tubs_columns*tubs_rows),"grams");




Line 101: Line 847:
  </nowiki>
  </nowiki>


===single cell tub===
==tub lid==


  <nowiki>
  <nowiki>
height = 60;
height = 90;
oa_width = 80;
tub_width = 36;
oa_length = 105;
tub_length = 70;
outsidewall = 5;
basethickness = 5;
basethickness = 5;
membranethickness = 5;
tub_wall = 2;
tub_wall = 5;
tub_outsidewall = 4;
 
tubs_rows    = 5;
tubs_columns = 2;


spacing = 5;
spacing = 1.940055;
cage_height = 40;
center_dividers = 00; //1 yes 0 no
cage_wall = 10;
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;
cage_base = 5;


mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;
wire_count = 6; //number of wires into each cage
wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;
union()
{
  difference()
  {
    union()
    {
      cube(size = [tub_width,tub_length,tub_lid_depthinto], center=false);
      translate([-1,-1,tub_lid_depthinto])
      {
        cube(size = [tub_width+2,tub_length+2,2], center=false);
      }
    }
//end union begin difference
//main cavity
  translate([2,2,2])
  {
    cube(size = [tub_width-4,tub_length-4,tub_lid_depthinto+2], center=false);
  }
//end cavity
//spheres lock ins
//1
      translate([0,tub_length*1/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([1,0,0])
        {
          divot_sphere();
        }
      }
//2
      translate([0,tub_length*3/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([1,0,0])
        {
          divot_sphere();
        }
      }
//3
      translate([tub_width,tub_length*1/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([0,0,0])
        {
          divot_sphere();
        }
      }
//4
      translate([tub_width,tub_length*3/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([0,0,0])
        {
          divot_sphere();
        }
      }
//5
      translate([tub_width*1/2,0,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([0,1,0])
        {
          rotate([0,0,90])
          {
            #divot_sphere();
          }
        }
      }
//6
      translate([tub_width*1/2,tub_length,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
      {
        mirror([0,0,0])
        {
          rotate([0,0,90])
          {
            #divot_sphere();
          }
        }
      }
//end spheres
//chamfer underside of lip
  translate([-2,-1,tub_lid_depthinto-1])
  {
    rotate([45,0,0])
    {
      cube(size = [tub_width+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-2,tub_length+1,tub_lid_depthinto-1])
  {
    rotate([45,0,0])
    {
      cube(size = [tub_width+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([-1,-2,tub_lid_depthinto-1])
  {
    rotate([45,0,90])
    {
      cube(size = [tub_length+4,sqrt(2),sqrt(2)], center=false);
    }
  }
  translate([tub_width+1,-2,tub_lid_depthinto-1])
  {
    rotate([45,0,90])
    {
      cube(size = [tub_length+4,sqrt(2),sqrt(2)], center=false);
    }
  }
//end chamfer
//begin wire holes
  translate([(tub_width/2)-(spacing/2)-cage_wall-(((tub_width-(spacing*3))/2)-(cage_wall*2)),(tub_length/2)-wire_holeoffc,-1])
  {
    cylinder(r = wire_diameter/2*wire_count*1.05, h = 4);
  }
  translate([(tub_width/2)+(spacing/2)+cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(tub_length/2)-wire_holeoffc,-1])
  {
    cylinder(r = wire_diameter/2*wire_count*1.05, h = 4);
  }
//end wire hole
//end difference
}
//begin union
//begin terminal
    translate([tub_width/2,tub_length-30,2])
    {
      rotate([0,0,90])
      {
        terminal(3);
      }
    }
//end terminal
}
//divot
module divot_sphere()
{
difference()
difference()
{
{
cube(size = [oa_width, oa_length, height], center=false);
translate([(tub_divot_height/2)/sin(45)*sin(45),0,0])
translate([outsidewall,outsidewall,basethickness])
{
cube(size = [oa_width-(outsidewall*2), oa_length-(outsidewall*2), height-basethickness], center=false);
sphere(r = (tub_divot_height/2)/sin(45));
}
}
 
translate([(tub_divot_height/2)/sin(45),0,0])
cube(size = [((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2)], center=true);
}
}


///////////change to terminal block cleat module
module terminal(holed)
{
  translate([0,-1.5,0])
  {
  difference()
  {
    union()
    {
//1
      translate([0,-10-holed,0])
      {
        cube(size=[20,3,6+holed], center=false);
      }
//2
      translate([0,0,0])
      {
        cube(size=[20,3,6+holed], center=false);
      }
//3
      translate([0,10+holed,0])
      {
        cube(size=[20,3,6+holed], center=false);
      }
//cross
      translate([9,-10-holed,0])
      {
        cube(size=[3,23+(holed*2),5+holed], center=false);
      }
    }
//begin difference
//holes
//1
    translate([8,-3.5-(holed/2),3+(holed/2)])
    {
      rotate([0,90,0])
      {
        cylinder(r=holed/2, h =5);
      }
    }
//2
    translate([8,6.5+(holed/2),3+(holed/2)])
    {
      rotate([0,90,0])
      {
        cylinder(r=holed/2, h =5);
      }
    }
//end holes
  }
  }
}
////
  </nowiki>
  </nowiki>

Latest revision as of 01:25, 5 October 2015

User:Dorkmo/Ideas/Battery/SCAD/Sandbox

User:Dorkmo/Ideas/Battery/SCAD/201510

User:Dorkmo/Ideas/Battery/SCAD/201509

User:Dorkmo/Ideas/Battery/SCAD/201411


parts to be printed

make sure all the variables are the same for each part

cage


height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;

tubs_rows    = 5;
tubs_columns = 2;

spacing = 1.940055;
center_dividers = 00; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;

mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;

wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;

//begin underlying cage module
module cage()
 {
  difference()
   {
    cube(size = [(tub_width-(spacing*3))/2,tub_length-(spacing*2),cage_height], center=false);
//cut hole for powder to sit in
     translate([cage_wall, cage_endwall, cage_base])
      cube(size = [((tub_width-(spacing*3))/2)-(cage_wall*2),(tub_length-(spacing*2))-(cage_endwall*2),cage_height-cage_base+1], center=false);
   }
 }
//end cage
     
//begin mesh hole grid module
module holes()
 {
intersection()
{
translate([0,-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))),0])
cube([cage_wall+0.2,1+((((tub_length-(spacing*2))-(cage_endwall*2)))),cage_height], center=false);


//need to translate closer to the cube here with llarge holes

translate([0,0,-mesh_spacing])
{

rotate([0,-mesh_angle,0])

scale([1,1,(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/sin(90-mesh_angle))*sin(90))])
{
//for - pair of rows to height

  for (h = [1 : floor(((cage_height-cage_base-((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle))))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
   {
    translate(h*[0,0,mesh_spacing])
{

//for - second row

 for (w = [1 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])
        {
//translate second row
         translate([0,-mesh_spacing/2,mesh_spacing/2])
           {
//make second row copies
            translate(w*[0,mesh_spacing,0])
             {
              rotate([45,0,0])
               {
    cube(size = [(cage_wall*2)+(cage_height/sin(90))*sin(mesh_angle),mesh_opening,mesh_opening], center=false);

               }
             }
           }
         }

//for - create first row
for (w = [0 : floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing)])

             {
              translate(w*[0,mesh_spacing,0])

 {
  rotate([45,0,0])
   { 
//need to tweak
    cube(size = [(cage_wall*2)+(cage_height/sin(90))*sin(mesh_angle),mesh_opening,mesh_opening],center=false);
   }
 }
}
}
}
}
////end cube
}
}
}
////end mesh hole grid module

//////divot
module divot_sphere()
{
difference()
{
translate([(cage_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (cage_divot_height/2)/sin(45));
}
translate([(cage_divot_height/2)/sin(45),0,0])
cube(size = [((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2)], center=true);
}
}
////end divot module

//begin final cage construction
difference()
 {
  cage();
//begin holes
  translate([(((tub_width-(spacing*3))/2)-cage_wall)+0.0, cage_endwall+((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/2)+(((((tub_length-(spacing*2))-(cage_endwall*2))-(((floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing))*mesh_spacing)+sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/2), cage_base])
   {
    holes();
   }
    translate([(cage_wall)-0.0,cage_endwall+((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/2)+(((((tub_length-(spacing*2))-(cage_endwall*2))-(((floor((((tub_length-(spacing*2))-(cage_endwall*2))-(sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening))))/mesh_spacing))*mesh_spacing)+sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/2), cage_base])
   {

  mirror([1,0,0])
     {
      #holes();
     }
   }
//end holes

//begin divots

//1
      translate([cage_wall,(((tub_length-(spacing*2))-(cage_endwall*2))*1/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
       {
        #divot_sphere();
       }
//2
      translate([cage_wall,(((tub_length-(spacing*2))-(cage_endwall*2))*3/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
       {
        #divot_sphere();
       }
//3
      translate([cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(((tub_length-(spacing*2))-(cage_endwall*2))*1/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
       {
        mirror([1,0,0])
         {
          #divot_sphere();
         }
       }
//4
      translate([cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(((tub_length-(spacing*2))-(cage_endwall*2))*3/4)+cage_endwall,cage_height-(((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2))])
       {
        mirror([1,0,0])
         {
          #divot_sphere();
         }
       }
//end divots
 }
//end cage


//calculate mesh wall minimum thickness
echo(sin(45)*((mesh_spacing-((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/sin(90)));


//calculate verticle height of mesh holes to take away from max height of holes
//works okay up to 45 then bugs out. might be because its before the scale down
echo((((((sin(90)*(cage_wall/sin(90-mesh_angle))))-((sin(mesh_angle)*((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))/(sin(90))))))/sin(90))*sin(mesh_angle)));



echo("cage cavity y",((tub_width-(spacing*3))/2)-(cage_wall*2));

echo("cage cavity x",(tub_length-(spacing*2))-(cage_endwall*2));

echo("cage cavity z",cage_height-cage_base);

echo("powder volume per cage",((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10,"cm3");

echo("grams nickle hydroxide per cage",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10),"grams");//density is 4.10

echo("total grams nickle hydroxide",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10)*(tubs_columns*tubs_rows),"grams");

//calculate mesh wall minimum thickness
echo("mesh dividers thickness",sin(45)*((mesh_spacing-((sqrt((mesh_opening*mesh_opening)+(mesh_opening*mesh_opening)))))/sin(90)));


 

cage lid with divots and cleat

height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;

tubs_rows    = 5;
tubs_columns = 2;

spacing = 1.940055;
center_dividers = 00; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;

mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;

wire_count = 7; //number of wires into each cage
wire_diameter = 1.4;
wire_holeoffc = 0;
cage_lid_cut = 0; //1 yes 0 no cavity in lid or not?
cage_minicleat = 2;
yn_cage_minicleat = 1; //1 yes 0 no
yn_cage_cleat = 0; //1 yes 0 no
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;

shrink_cage_lid = 0.5;
base_chamfer_depth = 0.9; //max 1.0
base_wire_cone = 0.2; //diameter added to wire_diameter

union()
 {
  difference()
   {
    union()
     {
      translate([shrink_cage_lid/2,shrink_cage_lid/2,0])
       {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))-shrink_cage_lid,((tub_length-(spacing*2))-(cage_endwall*2))-shrink_cage_lid,cage_lid_depthinto], center=false);
       }
      translate([-1,-1,cage_lid_depthinto])
       {
        cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+2,((tub_length-(spacing*2))-(cage_endwall*2))+2,2], center=false);
       }
//spheres lock ins
//1
      translate([(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*1/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
       {
        divot_sphere();
       }
//2
      translate([(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*3/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
       {
        divot_sphere();
       }
//3
      translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))-(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*1/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
       {
        mirror([1,0,0])
         {
          divot_sphere();
         }
       }
//4
      translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))-(shrink_cage_lid/2),((tub_length-(spacing*2))-(cage_endwall*2))*3/4,((cage_lid_depthinto-cage_divot_height)/2)+(cage_divot_height/2)])
       {
        mirror([1,0,0])
         {
          divot_sphere();
         }
       }
//end spheres

//minicleats
//1
translate([((((((tub_width-(spacing*3))/2)-(cage_wall*2))+2)/2)-cage_minicleat)+((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,((((tub_length-(spacing*2))-(cage_endwall*2))*1/2))+(wire_diameter/2),cage_lid_depthinto+2])
   {

for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
 {
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
   {
if (yn_cage_minicleat==1) mini_cleat(cage_minicleat,1);
}
}
}

//2
translate([-((((((tub_width-(spacing*3))/2)-(cage_wall*2))+2)/2)-cage_minicleat)+((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,((((tub_length-(spacing*2))-(cage_endwall*2))*1/2))+(wire_diameter/2),cage_lid_depthinto+2])
   {
mirror([1,0,0])
{
for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
 {
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
   {
if (yn_cage_minicleat==1) mini_cleat(cage_minicleat,1);
}
}
}
}

//end mini cleats


     }
//end union begin difference
  translate([1,1,1])
   {
    if (cage_lid_cut==1) cube(size = [((tub_width-(spacing*3))/2)-(cage_wall*2)-2,(tub_length-(spacing*2))-(cage_endwall*2)-2,cage_lid_depthinto+3], center=false);
   }
//chamfer underside of lip
  translate([-2,-1,cage_lid_depthinto-1])
   {
    rotate([45,0,0])
     {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-2,(tub_length-(spacing*2))-(cage_endwall*2)+1,cage_lid_depthinto-1])
   {
    rotate([45,0,0])
     {
      cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-1,-2,cage_lid_depthinto-1])
   {
    rotate([45,0,90])
     {
      cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))+1,-2,cage_lid_depthinto-1])
   {
    rotate([45,0,90])
     {
      cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
//end chamfer


//chamfer base
  translate([-2,base_chamfer_depth-1,-1])
   {
    rotate([45,0,0])
     {
      #cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-2,(tub_length-(spacing*2))-(cage_endwall*2)+1-base_chamfer_depth,-1])
   {
    rotate([45,0,0])
     {
      #cube(size = [(((tub_width-(spacing*3))/2)-(cage_wall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-1+base_chamfer_depth,-2,-1])
   {
    rotate([45,0,90])
     {
      #cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([(((tub_width-(spacing*3))/2)-(cage_wall*2))+1-base_chamfer_depth,-2,-1])
   {
    rotate([45,0,90])
     {
      #cube(size = [((tub_length-(spacing*2))-(cage_endwall*2))+4,sqrt(2),sqrt(2)], center=false);
     }
   }
//end chamfer

//begin wire holes
  translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2),-1])
   {

for(w = [-(wire_count-1)/2 : (wire_count-1)/2])
 {
  translate(w*[0,((((tub_length-(spacing*2))-(cage_endwall*2)-2))/(wire_count+1)),0])
   {
//wire hole
    #cylinder(r2 = wire_diameter/2, r1 = (wire_diameter+base_wire_cone)/2, h = cage_lid_depthinto+2+2);

   }
 } 


   }
//end wire holes


//end difference
 }
//begin union

//cleat
    translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2)-(wire_diameter*1.5)-1+wire_holeoffc,0])
     {
        if (yn_cage_cleat==1) cleat(2,cage_lid_depthinto+2);
     }
    translate([((((tub_width-(spacing*3))/2)-(cage_wall*2)))/2,(((tub_length-(spacing*2))-(cage_endwall*2))*1/2)+(wire_diameter*1.5)+1+wire_holeoffc,0])
     {
      mirror([0,1,0])
       {
        if (yn_cage_cleat==1) cleat(2,cage_lid_depthinto+2);
       }
     }
//end cleat
}


//divot
module divot_sphere()
{
difference()
{
translate([(cage_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (cage_divot_height/2)/sin(45));
}
translate([(cage_divot_height/2)/sin(45),0,0])
cube(size = [((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2),((cage_divot_height/2)/sin(45)*2)], center=true);
}
}

////cleat module
module cleat(size,height)
 {
  translate([0,0,-size])
  {
  difference()
   {
    rotate([45,0,0])
     {
      rotate([0,0,45])
       {
        cube(size = [size,size,height/sin(45)], center=false);
       }
     }
    translate([-size*3/2,-size*3/2,0])
     {
      #cube(size = [size*3,size*3,size],center=false);
     }
   }
 }
}
//end cleat

//mini_cleat module
module mini_cleat(sides,height)
{
union()
{
#cube(size = [sides,sides,height]);
translate([0,0,height])
{
polyhedron
  (points = [ [0,0,0],[sides,0,0],[sides,sides,0],[0,sides,0],
           [sides,0,sides],[sides*2,0,sides],[sides*2,sides,sides],[sides,sides,sides]
         ],
  faces = [ [0,1,2],[0,2,3], //
          [0,5,1],[0,4,5],   //
          [1,5,6],[1,6,2],   
          [2,6,7],[2,7,3],
          [3,7,4],[3,4,0],
          [4,7,6],[4,6,5]
        ]
);
}
}
}
//end mini cleat module



 

multi cell tub

height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;

tubs_rows    = 1;
tubs_columns = 1;

spacing = 1.940055;
wall_spacers_yn = 0; //1 yes 0 no
center_dividers = 0; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;

mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;

wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;



union()
 {

//tubs
for (c = [0 : tubs_columns-1])
 {
  translate([0,c*(tub_length+tub_wall),0])
   {
    for (r = [0 : tubs_rows-1])
    {
     translate([r*(tub_width+tub_wall),0,0])
      {
       tub();
      }
    }
   }
 }
//end tubs

//outer walls
translate([-tub_outsidewall+tub_wall,-tub_outsidewall+tub_wall,0])
 {
  difference()
   {
    cube(size = [((tub_width+tub_wall)*tubs_rows)+(tub_outsidewall*2)-tub_wall,((tub_length+tub_wall)*tubs_columns)+(tub_outsidewall*2)-tub_wall,height]);
    translate([tub_outsidewall,tub_outsidewall,0])
     {
      #cube(size = [(((tub_width+tub_wall)*tubs_rows)+tub_wall)-(tub_wall*2),(((tub_length+tub_wall)*tubs_columns)+tub_wall)-(tub_wall*2),height+1]);
     }
   }
 }

//end outer walls

} //end union

//tub module
module tub()
{
union()
{
//walls
 difference()
  {
   cube(size = [tub_width+(tub_wall*2), tub_length+(tub_wall*2), height], center=false);
   translate([tub_wall,tub_wall,basethickness])
    {
     cube(size = [tub_width, tub_length, height-basethickness+1], center=false);
    }
  }
//end walls

//spheres lock ins
//1
      translate([tub_wall,(tub_length*1/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([1,0,0])
         {
          #divot_sphere();
         }
       }
//2
      translate([tub_wall,(tub_length*3/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([1,0,0])
         {
          divot_sphere();
         }
       }
//3
      translate([tub_width+tub_wall,(tub_length*1/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([0,0,0])
         {
          divot_sphere();
         }
       }
//4
      translate([tub_width+tub_wall,(tub_length*3/4)+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([0,0,0])
         {
          divot_sphere();
         }
       }
//5
      translate([(tub_width*1/2)+tub_wall,tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([0,1,0])
         {
          rotate([0,0,90])
           {
            #divot_sphere();
           }
         }
       }
//6
      translate([(tub_width*1/2)+tub_wall,tub_length+tub_wall,height-(((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2))])
       {
        mirror([0,0,0])
         {
          rotate([0,0,90])
           {
            #divot_sphere();
           }
         }
       }
//end spheres

//begin spacers
//1
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_wall,cage_height*4/5])
{
if (center_dividers==1) divider();
}
//2
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_wall,height-((spacing+cage_endwall+2)*2)-(sin(45)*(sin(45)*(spacing-1)))-(height*5/8)])
{
if (center_dividers==1) divider();
}
//3
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_length+tub_wall,cage_height*4/5])
{
mirror([0,1,0])
{
if (center_dividers==1) divider();
}
}
//4
translate([((tub_width+(tub_wall*2))/2)-((spacing-1)/2),tub_length+tub_wall,height-((spacing+cage_endwall+2)*2)-(sin(45)*(sin(45)*(spacing-1)))-(height*5/8)])
{
mirror([0,1,0])
{
if (center_dividers==1) divider();
}
}
//the end_wall's side spacers
//s1
translate([(tub_width+(tub_wall*2))*1/4,tub_wall,(cage_height/2)+basethickness])
{
rotate([0,0,90])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s2
translate([(tub_width+(tub_wall*2))*3/4,tub_wall,(cage_height/2)+basethickness])
{
rotate([0,0,90])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s3
translate([(tub_width+(tub_wall*2))*1/4,tub_wall+tub_length,(cage_height/2)+basethickness])
{
rotate([0,0,270])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//s4
translate([(tub_width+(tub_wall*2))*3/4,tub_wall+tub_length,(cage_height/2)+basethickness])
{
rotate([0,0,270])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}

//walls spacers
//w1
translate([tub_wall,(tub_length+(tub_wall*2))/2,(cage_height/2)+basethickness])
{
rotate([0,0,0])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//w2
translate([(tub_width+tub_wall),(tub_length+(tub_wall*2))/2,(cage_height/2)+basethickness])
{
rotate([0,0,180])
{
if (wall_spacers_yn==1) tub_spacer(8);
}
}
//base spacers
//b1
translate([(tub_width+(tub_wall*2))/2,(tub_length+(tub_wall*2))*1/5,basethickness])
{
rotate([0,270,90])
{
tub_spacer(tub_width-(spacing*2));
}
}
//b2
translate([(tub_width+(tub_wall*2))/2,(tub_length+(tub_wall*2))*4/5,basethickness])
{
rotate([0,270,90])
{
tub_spacer(tub_width-(spacing*2));
}
}

////end spacers
}
////endall
}

//divider modules
module divider()
 {
  difference()
   {
    union()
     {
      cube(size=[spacing-1,spacing+cage_endwall+2,(spacing+cage_endwall+2)*2]);
      translate([0,0,(spacing+cage_endwall+2)*2])
       {
        rotate([0,45,0])
         {
          cube(size=[(sin(45)*(spacing-1)),spacing+cage_endwall+2,(sin(45)*(spacing-1))]);
         }
       }
     }
    translate([0,spacing+cage_endwall+2,-(((spacing+cage_endwall+2)/sin(45))/sin(45))/2])
     {
      rotate([45,0,0])
       {
        cube(size=[spacing-1,((spacing+cage_endwall+2)/sin(45)),((spacing+cage_endwall+2)/sin(45))]);       
       }
     }
   }
 }
//end divider module

//spacer module
module tub_spacer(length)
 {
translate([-(spacing-1),-length/2,0])
  {
  difference()
   {
    rotate([0,45,0])
     {
      cube(size = [((spacing-1)/sin(45)),length,((spacing-1)/sin(45))]);
     }
    translate([-(spacing-1)-0.1,0,-(spacing-1)])
     {
      #cube(size = [((spacing-1)/sin(45))/sin(45),length,((spacing-1)/sin(45))/sin(45)]);
     }
   }
 }
}
//end spacer

//divot
module divot_sphere()
{
difference()
{
translate([(tub_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (tub_divot_height/2)/sin(45));
}
translate([(tub_divot_height/2)/sin(45),0,0])
cube(size = [((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2)], center=true);
}
}
//end divot

////calculations

echo("space above cages for extra fluid is", height-basethickness-spacing-cage_height-tub_lid_depthinto);


echo("tub print area x",((tub_width+tub_wall)*tubs_rows)+(tub_outsidewall*2)-tub_wall);

echo("tub print area y",((tub_length+tub_wall)*tubs_columns)+(tub_outsidewall*2)-tub_wall);

echo("tub print area z",height);

echo("cage cavity y",((tub_width-(spacing*3))/2)-(cage_wall*2));

echo("cage cavity x",(tub_length-(spacing*2))-(cage_endwall*2));

echo("cage cavity z",cage_height-cage_base);

echo("powder volume per cage",((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10,"cm3");

echo("grams nickle hydroxide per cage",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10),"grams");//density is 4.10

echo("total grams nickle hydroxide",(((((tub_width-(spacing*3))/2)-(cage_wall*2)))/10*(((tub_length-(spacing*2))-(cage_endwall*2)))/10*(cage_height-cage_base-cage_lid_depthinto)/10)*(4.10)*(tubs_columns*tubs_rows),"grams");







 

tub lid

height = 90;
tub_width = 36;
tub_length = 70;
basethickness = 5;
tub_wall = 2;
tub_outsidewall = 4;

tubs_rows    = 5;
tubs_columns = 2;

spacing = 1.940055;
center_dividers = 00; //1 yes 0 no
cage_height = 60;
cage_wall = 5.5;
cage_endwall = 2;
cage_base = 5;

mesh_opening = 1.5 ;
mesh_angle = 45;
mesh_spacing = 3.5;

wire_count = 6; //number of wires into each cage
wire_diameter = 2;
wire_holeoffc = 0;
cage_lid_depthinto = 7;
cage_divot_height = 5.5;
tub_lid_depthinto = 7;
tub_divot_height = 5.5;



union()
 {
  difference()
   {
    union()
     {
      cube(size = [tub_width,tub_length,tub_lid_depthinto], center=false);
      translate([-1,-1,tub_lid_depthinto])
       {
        cube(size = [tub_width+2,tub_length+2,2], center=false);
       }




     }
//end union begin difference
//main cavity
  translate([2,2,2])
   {
    cube(size = [tub_width-4,tub_length-4,tub_lid_depthinto+2], center=false);
   }
//end cavity

//spheres lock ins
//1
      translate([0,tub_length*1/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([1,0,0])
         {
          divot_sphere();
         }
       }
//2
      translate([0,tub_length*3/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([1,0,0])
         {
          divot_sphere();
         }
       }
//3
      translate([tub_width,tub_length*1/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([0,0,0])
         {
          divot_sphere();
         }
       }
//4
      translate([tub_width,tub_length*3/4,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([0,0,0])
         {
          divot_sphere();
         }
       }
//5
      translate([tub_width*1/2,0,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([0,1,0])
         {
          rotate([0,0,90])
           {
            #divot_sphere();
           }
         }
       }
//6
      translate([tub_width*1/2,tub_length,((tub_lid_depthinto-tub_divot_height)/2)+(tub_divot_height/2)])
       {
        mirror([0,0,0])
         {
          rotate([0,0,90])
           {
            #divot_sphere();
           }
         }
       }
//end spheres

//chamfer underside of lip
  translate([-2,-1,tub_lid_depthinto-1])
   {
    rotate([45,0,0])
     {
      cube(size = [tub_width+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-2,tub_length+1,tub_lid_depthinto-1])
   {
    rotate([45,0,0])
     {
      cube(size = [tub_width+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([-1,-2,tub_lid_depthinto-1])
   {
    rotate([45,0,90])
     {
      cube(size = [tub_length+4,sqrt(2),sqrt(2)], center=false);
     }
   }
  translate([tub_width+1,-2,tub_lid_depthinto-1])
   {
    rotate([45,0,90])
     {
      cube(size = [tub_length+4,sqrt(2),sqrt(2)], center=false);
     }
   }
//end chamfer

//begin wire holes
  translate([(tub_width/2)-(spacing/2)-cage_wall-(((tub_width-(spacing*3))/2)-(cage_wall*2)),(tub_length/2)-wire_holeoffc,-1])
   {
    cylinder(r = wire_diameter/2*wire_count*1.05, h = 4);
   }

  translate([(tub_width/2)+(spacing/2)+cage_wall+(((tub_width-(spacing*3))/2)-(cage_wall*2)),(tub_length/2)-wire_holeoffc,-1])
   {
    cylinder(r = wire_diameter/2*wire_count*1.05, h = 4);
   }

//end wire hole



//end difference
 }
//begin union

//begin terminal
    translate([tub_width/2,tub_length-30,2])
     {
      rotate([0,0,90])
       {
        terminal(3);
       }
     }
//end terminal
}


//divot
module divot_sphere()
{
difference()
{
translate([(tub_divot_height/2)/sin(45)*sin(45),0,0])
{
sphere(r = (tub_divot_height/2)/sin(45));
}
translate([(tub_divot_height/2)/sin(45),0,0])
cube(size = [((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2),((tub_divot_height/2)/sin(45)*2)], center=true);
}
}

///////////change to terminal block cleat module
module terminal(holed)
 {
  translate([0,-1.5,0])
   {
  difference()
   {
    union()
     {
//1
      translate([0,-10-holed,0])
       {
        cube(size=[20,3,6+holed], center=false);
       }
//2
      translate([0,0,0])
       {
        cube(size=[20,3,6+holed], center=false);
       }
//3
      translate([0,10+holed,0])
       {
        cube(size=[20,3,6+holed], center=false);
       }
//cross
      translate([9,-10-holed,0])
       {
        cube(size=[3,23+(holed*2),5+holed], center=false);
       }
     }
//begin difference
//holes
//1
    translate([8,-3.5-(holed/2),3+(holed/2)])
     {
      rotate([0,90,0])
       {
        cylinder(r=holed/2, h =5);
       }
     }
//2
    translate([8,6.5+(holed/2),3+(holed/2)])
     {
      rotate([0,90,0])
       {
        cylinder(r=holed/2, h =5);
       }
     }
//end holes
   }
   }
 }
////