Difference between revisions of "Pi3B Enclosure"

From HiveTool
Jump to: navigation, search
(Raspberry Pi Model 3 Enclosure)
Line 3: Line 3:
  
 
[[File:Screenshot 20200116 065902.png|thumb|800px]]
 
[[File:Screenshot 20200116 065902.png|thumb|800px]]
 +
 +
<br clear=all>
  
 
== OpenSCAD code ==
 
== OpenSCAD code ==

Revision as of 04:03, 16 January 2020

Raspberry Pi Model 3 Enclosure

Screenshot 20200116 065902.png


OpenSCAD code

/****************************************************************************
            Raspberry Pi Model 3 Enclosure
              bottom with camera cutout
            HiveTool.net
*****************************************************************************/
width=64;
length=94;
height=23;
wall_thickness = 2;
radius=wall_thickness/2;

difference()
   {
   union()
      {
       rounded_box(width, length, height, wall_thickness);           //  create the rounded box
        
       // add some standoff s for mounting
       translate([8.5,10.25,wall_thickness]) standoff(7,6,2.3);
       //translate([29,9.5,wall_thickness]) standoff(4,6,2.2);     //Pi Zero
       translate([57.5,10.25,wall_thickness]) standoff(7,6,2.3);
       translate([8.5,68.75,wall_thickness]) standoff(7,6,2.3);
       //translate([29,67.5,wall_thickness]) standoff(4,6,2.2);     //Pi Zero
       translate([57.5,68.75,wall_thickness]) standoff(7,6,2.3);

        // add some fillets for strength and printability
       translate([2,9.25,1])  cube([4,2,8]);
       translate([59.5,9.25,1])  cube([3.5,2,8]);
       translate([2,67.75,1])  cube([5,2,8]);
       translate([59.5,67.75,1])  cube([3.5,2,8]);
           
       // Standoffs for Camera 
     translate([(width-21-14.3), (length/2 + 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21-14.3), (length/2 - 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21+14.3), (length/2 - 14.3),wall_thickness])  standoff(2,6,2.3);
     translate([(width-21+14.3), (length/2 +14.3),wall_thickness])  standoff(2,6,2.3);
          
          
       // add alignment pins 
       translate ([wall_thickness,wall_thickness,height]) alignment_pin();     
       translate ([wall_thickness,length - wall_thickness,height]) rotate ([0,0,-90]) alignment_pin();
       translate ([width - wall_thickness,length - wall_thickness,height]) rotate ([0,0,180]) alignment_pin();
       translate ([width - wall_thickness,wall_thickness,height]) rotate ([0,0,90]) alignment_pin();
       
       translate ([wall_thickness+.4,wall_thickness+.4,height]) sphere(1.9, center=true, $fn=36);
        translate ([wall_thickness+.4,length - wall_thickness-.4,height]) sphere(1.9, center=true, $fn=36);
       translate ([width - wall_thickness-.4,length - wall_thickness-.4,height]) sphere(1.9, center=true, $fn=36);
       translate ([width - wall_thickness-.4,wall_thickness+.4,height])  sphere(1.9, center=true, $fn=36);
   }
   
   translate ([wall_thickness,length-wall_thickness-1,8]) cube([width-2*wall_thickness,2,4]);
   translate([42.5,91,10]) cube([16.8,4,16.5]);     // Ethernet
   translate([6,88,11]) cube(40,4,15.5);          // USBs

   // Camera mount
     translate([(width-21), (length/2), .5]) 
     difference() {
            cylinder(h=10, r=15, $fn=50);
            translate([0, 0, -5]) cylinder(h=10, r=14, $fn=50);
     }
       
// holes for camera mount  
  translate([(width-21-14.3), (length/2 + 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21-14.3), (length/2 - 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21+14.3), (length/2 - 14.3), .5]) cylinder(h=10, r=1.3, $fn=50);
  translate([(width-21+14.3), (length/2 +14.3), .5]) cylinder(h=10, r=1.3, $fn=50);

   translate([63,17.5,11.8])  rotate([90,0,90])  round_cutout2 (5,5,0,0,0) ;       // micro USB
   translate ([15,length-3,height-7]) cube([28,4,8]);    // shorten the spacers between USB/Ethernet cutouts
      
   translate([63,31,17.8]) hdmi_cutout();                                                      // hdmi
   translate([61,60.5,13.5]) rotate([0,90,0]) cylinder(h=4, r=3.2, $fn=50);   // Audio
   
   translate([width/2 - 1,3,height-5.5]) latch();     // latch    
   translate([1,length-14,height-5.5]) rotate([0,0,90]) latch();     // latch
   translate([width-1,length-14,height-5.5]) rotate([0,0,-90]) latch();     // latch
  }  

/* *****************************************************
           Create a solid cube with 8 rounded edges
           but not on the top where the cover will go.
*******************************************************/
module rounded_cube(width, length, height, wall_thickness){
hull()                                // wrap a hull around 4 cylinders with rounded bottoms
   {
   radius=wall_thickness/2; 
   // place 4 spheres in the corners, with the given radius offset vertically by the radius
   translate([(wall_thickness/2), (wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([(wall_thickness/2), length-(wall_thickness/2),radius]) sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), length-(wall_thickness/2), radius])  sphere(r=radius, $fn=50);
   translate([width-(wall_thickness/2), (wall_thickness/2), radius])   sphere(r=radius, $fn=50);
    
    // place 4 cylinders in the corners, with the given radius, 
    // offset vertically by the radius of the spheres
   translate([(wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);  
   translate([(width-wall_thickness/2), (length-wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   translate([(width-wall_thickness/2), (wall_thickness/2), radius])
        cylinder(h=height-radius, r=radius, $fn=50);
   }  
}

/**************************************************************
*           Create a hollow box with rounded edges inside and out
*           but not on the top where the cover will go
*           by subtracting a rounded cubes that is 2x the wall thickness smaller 
*           and shifted by the wall thicknes from the first rounded cube.
***************************************************************/
 module rounded_box(width, length, height, wall_thickness){
    difference()                                                  // subtract two rounded cubes
       {
       rounded_cube(width, length, height, wall_thickness);
       translate([ wall_thickness, wall_thickness, wall_thickness]) 
         rounded_cube(width-(2*wall_thickness), length-(2*wall_thickness), height, wall_thickness);
     }
 }

module standoff(height,diameter,hole){
difference() 
    {
    cylinder(h = height, r = diameter/2, $fn=6);
    cylinder(h = height+1, r = hole/2, $fn=6);
    }
}

module hdmi_cutout () {
    union()
    {
     rotate([0,-90,0]) linear_extrude(height = 4, center=true) polygon(points=[[0,0],[0,5],[-7,5],[-7,2],[-5,0]]);
     rotate([0,-90,0]) linear_extrude(height = 4, center=true) polygon(points=[[0,6],[0,10],[-7,10],[-7,6]]);
     rotate([0,-90,0]) linear_extrude(height = 4, center=true)polygon(points=[[0,11],[0,16],[-5,16],[-7,14],[-7,11]]);
     }
}

module round_cutout2 (height,width,x,y,z) {
difference()
    {
    linear_extrude(height = 4, center=true)
    hull()
       {
       translate([x-width/2,0,0])
       circle(height/2, center=true, $fn=100);
       translate([x+width/2,0,0])
       circle(height/2, center=true, $fn=100);
       }
   }
}

module square_cutout (height,width,x,y,z) {
difference()
    {
    translate([x,y,z])
    rotate([90,0,0])
    linear_extrude(height = 4, center=true)
    hull()
        {
        cube(width,wall_thickness,height);
        }
    }
}

module alignment_pin() {
        rotate([0,180,-90]) {    union() { intersection(){cube(4); sphere(3, $fn=36);}  }  }
}

module latch(){
      translate([-3,-1,0]) rotate([0,90,0]) cylinder(h=6, r=1.2, $fn=36);
}