blinkenstrip

Documentation: http://frombelow.net/projects/blinkenstrip/
Clone: git clone https://git.frombelow.net/blinkenstrip.git
Log | Files | Refs | README | LICENSE

case.scad (10135B)


      1 // Dimensions of the power supply (+ 1 mm on each side)
      2 power_supply_width = 97 + 1;
      3 power_supply_depth = 159 + 1;
      4 power_supply_height = 30 + 1;
      5 
      6 // Additional depth for the MCU compartment
      7 mcu_compartment_depth = 60;
      8 mcu_depth = 15;
      9 mcu_width=40;
     10 mcu_height=5;
     11 
     12 // Dimensions of power switch (+ 1 mm)
     13 power_switch_width = 18 + 1;
     14 power_switch_height = 12 + 1;
     15 
     16 // Diameters of cables ( + 2 mm)
     17 diameter_power_cable = 6 + 2;
     18 diameter_data_cable = 5 + 2;
     19 diameter_cord_grip_screw = 5 + 2;
     20 
     21 // Thickness of walls, guide rails, etc.
     22 wall_thickness = 2;
     23 
     24 // Interiour width must be big enough for power supply plus guide rails for
     25 // lid.
     26 inner_frame_width = power_supply_width + 2 * wall_thickness;
     27 inner_frame_depth = power_supply_depth + mcu_compartment_depth;
     28 // No wall on top, because we will place the lid there.
     29 inner_frame_height = power_supply_height + 2 * wall_thickness;
     30 
     31 // Create walls around empty box of given size. The top is left open.
     32 // Front does not have full height in order to leave room for the lid.
     33 module Frame(width, depth, height, wall_thickness) {
     34     // Add walls to inner frame
     35     outer_frame_width = width + 2 * wall_thickness;
     36     outer_frame_depth = depth + 2 * wall_thickness;
     37     outer_frame_height = height + 1 * wall_thickness;
     38     // Construct frame
     39     difference() {
     40         cube([outer_frame_width, outer_frame_depth, outer_frame_height]);
     41         translate([wall_thickness, wall_thickness, wall_thickness])
     42             cube([width, depth, height]);
     43         translate([wall_thickness, 0, outer_frame_height - wall_thickness * 2 ])
     44             cube([width, wall_thickness, wall_thickness * 2]);
     45     }
     46 }
     47 
     48 // Guide rails for lid and supporting structures.
     49 module Guide_Rails(width, depth, height, wall_thickness) {
     50     // Left top
     51     translate([wall_thickness, 0, height])
     52         cube([wall_thickness, depth + wall_thickness, wall_thickness]);
     53     // Left bottom
     54     translate([wall_thickness, 0, height - 2 * wall_thickness])
     55         cube([wall_thickness, depth + wall_thickness, wall_thickness]);
     56     // Right top
     57     translate([width, 0, height])
     58         cube([wall_thickness, depth + wall_thickness, wall_thickness]);
     59     // Right bottom
     60     translate([width, 0, height - 2 * wall_thickness])
     61         cube([wall_thickness, depth + wall_thickness, wall_thickness]);
     62     // Back top
     63     translate([wall_thickness, depth, height])
     64         cube([width, wall_thickness, wall_thickness]);
     65     // Back bottom
     66     translate([wall_thickness, depth, height - 2 * wall_thickness])
     67         cube([width, wall_thickness, wall_thickness]);
     68     // Support structure back
     69     translate([width/3, depth, wall_thickness])
     70         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     71     translate([width/3*2, depth, wall_thickness])
     72         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     73     // Support structure left side
     74     translate([wall_thickness, depth-depth/4, wall_thickness])
     75         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     76     translate([wall_thickness, depth-depth/4 * 2, wall_thickness])
     77         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     78     translate([wall_thickness, depth-depth/4 * 3, wall_thickness])
     79         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     80     // Support structure right side
     81     translate([width, depth-depth/4, wall_thickness])
     82         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     83     translate([width, depth-depth/4 * 2, wall_thickness])
     84         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     85     translate([width, depth-depth/4 * 3, wall_thickness])
     86         cube([wall_thickness, wall_thickness, height - 3 * wall_thickness]);
     87     // Fixation of power supply
     88     translate([wall_thickness, 
     89                     depth - (wall_thickness + power_supply_depth),
     90                     wall_thickness])
     91         cube([width, wall_thickness, wall_thickness]);
     92 }
     93 
     94 module Frame_with_Rails(width, depth, height, wall_thickness) {
     95     union () {
     96         Frame(width=width, depth=depth, height=height, wall_thickness=wall_thickness);
     97         Guide_Rails(width=width, depth=depth, height=height, wall_thickness=wall_thickness);
     98     }
     99 }
    100 
    101 // Holes for cords and power switch
    102 module  Frame_with_Rails_and_Holes(width, depth, height, wall_thickness) {
    103     difference() {
    104         Frame_with_Rails(width=width, depth=depth, height=height,
    105                                       wall_thickness=wall_thickness);
    106         // Hole for power switch
    107         translate([width/3 , 0, height /3])
    108             cube([power_switch_width, wall_thickness, power_switch_height]);
    109         // Hole for power cable
    110         translate([0 , depth/11, height /4])
    111             rotate([0, 90, 0]) cylinder(d=diameter_power_cable, h=wall_thickness+1,
    112                                                      center=false);
    113         // Hole for data cable
    114         translate([0 , depth/5.5, height /4])
    115             rotate([0, 90, 0]) cylinder(d=diameter_data_cable, h=wall_thickness+1,
    116                                                      center=false);
    117     }
    118 }
    119 
    120 module  Frame_with_Air_Vents(width, depth, height, wall_thickness) {
    121     difference() {
    122         Frame_with_Rails_and_Holes(width=width, depth=depth, height=height,
    123                                       wall_thickness=wall_thickness);
    124         // Left side vents
    125         for(vent_depth = [depth/40*11+wall_thickness: depth/40: depth-wall_thickness*2])
    126             translate([0, vent_depth, 2*wall_thickness])
    127                 cube([wall_thickness*2, depth/80, height/3*2]);
    128         // Right side vents
    129         for(vent_depth = [depth/40*11+wall_thickness: depth/40: depth-wall_thickness*2])
    130             translate([width, vent_depth, 2*wall_thickness])
    131                 cube([wall_thickness*2, depth/80, height/3*2]);
    132         // Back side vents
    133         for(vent_width = [wall_thickness*3: width/20: width-wall_thickness*2])
    134             translate([vent_width, depth, 2*wall_thickness])
    135                 cube([width/50, wall_thickness*2, height/3*2]);
    136     }
    137 }
    138 // Support structure for cord grip for power supply
    139 module Cord_Grip_for_Power_Supply(width, depth, height, wall_thickness,
    140                                                                 diameter_power_cable,
    141                                                                 diameter_cord_grip_screw) {
    142 // Cord grip for power supply
    143     translate([wall_thickness,
    144                     depth/10 + diameter_power_cable/2 +  wall_thickness,
    145                     wall_thickness])
    146         difference () {
    147             cube([width/5, wall_thickness, height-2*wall_thickness]);
    148                 translate([width/7,
    149                                wall_thickness,
    150                                height/2])
    151                     rotate([90, 0, 0]) cylinder(d=diameter_cord_grip_screw,
    152                                                              h=wall_thickness+2,
    153                                                              center=true); 
    154         }
    155     
    156 }
    157  
    158 // Mount for MCU
    159 module MCU_Mount(width, depth, mcu_width, mcu_depth, mcu_compartment_depth,
    160                                     wall_thickness) {
    161     translate([width-mcu_width+wall_thickness,
    162                     (mcu_compartment_depth-wall_thickness-mcu_depth)/1.5,
    163                       wall_thickness+mcu_height])
    164         cube([mcu_width, mcu_depth, wall_thickness]);
    165 }
    166 
    167 
    168 // Initials and year
    169 module Signature(width, wall_thickness) {
    170 translate([width+wall_thickness*2, wall_thickness*2, wall_thickness*2]) rotate([90, 0, 90]) linear_extrude(1) text(text="gb 2020", size=5, font="Arial Black");
    171 }
    172 
    173 
    174 // Complete Box
    175 module Box(){
    176     Frame_with_Air_Vents(width=inner_frame_width, 
    177                                                      depth=inner_frame_depth,
    178                                                      height=inner_frame_height,
    179                                                      wall_thickness=wall_thickness);
    180     
    181     Cord_Grip_for_Power_Supply(width=inner_frame_width, 
    182                                                       depth=inner_frame_depth,
    183                                                       height=inner_frame_height,
    184                                                       wall_thickness=wall_thickness,
    185                                                       diameter_power_cable=diameter_power_cable,
    186                                                       diameter_cord_grip_screw=diameter_cord_grip_screw);
    187     
    188     MCU_Mount(width=inner_frame_width, depth=inner_frame_depth,
    189                             mcu_width=mcu_width, mcu_depth=mcu_depth,
    190                             mcu_compartment_depth=mcu_compartment_depth,
    191                             wall_thickness=wall_thickness);
    192     
    193     Signature(width=inner_frame_width, wall_thickness=wall_thickness);
    194 }
    195 
    196 // Lid for the box
    197 // (rails leave 0.5 mm on each side)
    198 module Lid(){
    199 translate([wall_thickness+0.5, 0, inner_frame_height-wall_thickness])
    200      cube([inner_frame_width-1, inner_frame_depth+wall_thickness-1.5, wall_thickness]);
    201 translate([wall_thickness*2, 0, inner_frame_height])
    202      cube([inner_frame_width-2*wall_thickness,
    203                inner_frame_depth-1,
    204                wall_thickness]);
    205 }
    206 
    207 
    208 // Power supply (used for debugging)
    209 module Power_Supply() {
    210     translate([wall_thickness*2, mcu_compartment_depth, wall_thickness])
    211         cube([power_supply_width, power_supply_depth, power_supply_height]);
    212 }
    213 
    214 // MCU (used for debugging)
    215 module MCU() {
    216     translate([inner_frame_width-mcu_width+wall_thickness, (mcu_compartment_depth-mcu_depth-wall_thickness)/2, wall_thickness])
    217         cube([mcu_width, mcu_depth, mcu_height]);
    218 }
    219 
    220 // Sanity check: Box, lid, power supply, and MCU must not overlap
    221 module Check_for_Overlaps() {
    222     intersection() {
    223         Box();
    224         Lid();
    225     }
    226     intersection() {
    227         Box();
    228         Power_Supply();
    229     }
    230     intersection() {
    231         Power_Supply();
    232         Lid();
    233     }
    234     intersection() {
    235         Box();
    236         MCU();
    237     }
    238 }
    239 
    240 module Render_All() {
    241     Box();
    242     translate([0, 0, 40])
    243         Lid();
    244 }
    245 
    246 // Check_for_Overlaps();
    247 // Box();
    248 // Lid();
    249 Render_All();
    250