Skip to content

Instantly share code, notes, and snippets.

@rambo
Created December 18, 2011 09:04
Show Gist options
  • Save rambo/1492786 to your computer and use it in GitHub Desktop.
Save rambo/1492786 to your computer and use it in GitHub Desktop.
lasercut enclosure design, triggers a bug in openscad 2011.12.13
/**
* Rough box measurements (based on the electronics board size)
*
* Height 15cm -> 10cm should be enough
* Width 30cm
* Depth 20cm
*
* Coilforms:
* 4.0” DIA
* 3.22” DIA
* Torus thickness 72mm
*
* Fans:
* 60mm*60mm (4mm mounting holes)
*
* Holes for the power and interrupter signal wires will be drilled/milled afterwards
*/
/**************************
* Basic units.
*
* Originally by Hans Häggström, 2010.
* Dual licenced under Creative Commons Attribution-Share Alike 3.0 and LGPL2 or later
*/
mm = 1;
cm = 10 * mm;
dm = 100 * mm;
m = 1000 * mm;
inch = 25.4 * mm;
M3 = 3*mm;
M4 = 4*mm;
M5 = 5*mm;
M6 = 6*mm;
M8 = 8*mm;
// When a small distance is needed to overlap shapes for boolean cutting, etc.
epsilon = 0.01*mm;
TAU = 6.2831853071; //2*PI, see http://tauday.com/
PI = TAU/2;
/************************/
/***********************
* Some globally needed variables
*/
material_z = 8*mm;
box_z = 10*cm + 2*material_z; // We need the 10cm on the *inside*
box_x = 30*cm;
box_y = 20*cm;
secondary_coil_r = (3.22*inch)/2;
primary_coil_r = (4.0*inch)/2;
front_top_slot_offset = 20;
front_left_slot_offset = 20;
front_leg_z=13;
/************************/
/***********************
* Coilforms for visually checking the design
*/
module coilform_3d(cr,ch)
{
$fa=0.5;
$fs=0.1;
difference()
{
cylinder(r=cr, h=ch);
translate([0,0,-1])
{
cylinder(r=cr-2, h=ch+2);
}
}
}
module secondary_coilform_3d()
{
cr=secondary_coil_r;
ch=11*inch;
coilform_3d(cr, ch);
translate([0,0,11*inch])
{
coilform_torus_3d(cr);
}
}
module coilform_torus_3d(cr)
{
th=72/2;
ri=cr;
$fn=50;
translate([0,0,th])
{
rotate_extrude(convexity = 10)
{
translate([ri, 0, 0])
{
circle(r = th);
}
}
}
}
module primary_coilform_3d()
{
cr=primary_coil_r;
ch=62;
coilform_3d(cr, ch);
}
module coilforms_3d()
{
primary_coilform_3d();
secondary_coilform_3d();
}
//coilforms_3d();
/************************/
module slot_2d(w,d=material_z*1.1)
{
$fa=0.5;
$fs=0.1;
slot_corner_r=0.25;
union()
{
// These cylinders are to avoid weak points in the acrylic, see http://blog.ponoko.com/2010/06/17/how-to-make-snug-joints-in-acrylic/
square([w,d]);
circle(r=slot_corner_r);
translate([0,d,0])
{
circle(r=slot_corner_r);
}
translate([w,0,0])
{
circle(r=slot_corner_r);
translate([0,d,0])
{
circle(r=slot_corner_r);
}
}
}
}
//slot_2d(30);
module span(r_inner, width, tan_angle)
{
$fa=0.5;
$fs=0.1;
cr = width/2;
a_len = r_inner+width;
mirror([1,0,0])
{
union()
{
intersection()
{
// Full circle
difference()
{
circle(r=r_inner+width);
circle(r=r_inner);
}
// right-angled triagle
translate([0,a_len,0])
{
mirror([1,1,0])
{
polygon(points=[[0,0],[a_len,0],[0,tan(tan_angle) * a_len]], paths=[[0,1,2]]);
}
}
}
translate([0,r_inner+cr,0])
{
circle(r=cr, center=false);
}
rotate([0,0,tan_angle])
{
translate([0,r_inner+cr,0])
{
circle(r=cr, center=false);
}
}
}
}
}
//span(primary_coil_r*2+2, 5, 30);
module multi_span_test(tan_angle)
{
for(i=[0:(360/tan_angle)-1])
{
rotate([0,0,i*tan_angle])
{
span(primary_coil_r*2+2, 5, tan_angle);
}
}
}
//multi_span_test(30);
module slot_tight_2d(w,d=material_z*1.1)
{
$fa=0.5;
$fs=0.1;
tf=d/20;
difference()
{
slot_2d(w,d);
translate([-d+tf,d/2,0])
{
circle(r=d);
}
translate([w+d-tf,d/2,0])
{
circle(r=d);
}
}
}
//slot_tight_2d(30);
module front_back_top_bottom_slots()
{
translate([front_top_slot_offset,0])
{
slot_tight_2d(box_x-front_top_slot_offset*2);
}
}
module front_back_left_right_slots()
{
translate([0,front_left_slot_offset])
{
rotate([0,0,90])
{
slot_tight_2d(box_z-front_top_slot_offset*2);
}
}
}
module back_et_front_2d()
{
leg_w=25;
difference()
{
translate([0,-front_leg_z])
{
// Main face with "legs"
difference()
{
square([box_x, box_z+front_leg_z]);
translate([leg_w,-epsilon])
{
square([box_x-2*leg_w, front_leg_z-material_z/2]);
}
}
}
// Slot for top plate
translate([0,box_z-material_z+epsilon])
{
front_back_top_bottom_slots();
}
// Slot for bottom plate
translate([0,0])
{
front_back_top_bottom_slots();
}
// Slot for left plate
translate([material_z-epsilon,0])
{
front_back_left_right_slots();
}
// Slot for right plate
translate([box_x+epsilon,0])
{
front_back_left_right_slots();
}
}
}
//back_et_front_2d();
module back_2d()
{
lightning_holes = 5;
difference()
{
back_et_front_2d();
// 5 HV lightning shaped ventilation holes
for(i=[0:lightning_holes-1])
{
translate([((box_x-2*material_z)/lightning_holes)*i+6*material_z,20,0])
{
mirror([1,0,0])
{
scale([2,2,2])
{
hv_lightning();
}
}
}
}
}
// ventilation holes ?
}
module back_3d()
{
color([(34/255), (232/255), (234/255), 0.75])
{
translate([0,box_y,0])
{
rotate([90,0,0])
{
linear_extrude(height=material_z)
{
back_2d();
}
}
}
}
}
//back_3d();
module front_2d()
{
back_et_front_2d();
// ventilation holes ?
}
module front_3d()
{
color([(34/255), (232/255), (234/255), 0.75])
{
translate([0,material_z,0])
{
rotate([90,0,0])
{
linear_extrude(height=material_z)
{
front_2d();
}
}
}
}
}
//front_3d();
module top_bottom_front_back_slots()
{
translate([-epsilon,0])
{
slot_2d(front_top_slot_offset+2*epsilon);
}
translate([box_x-front_top_slot_offset,0])
{
slot_2d(front_top_slot_offset+epsilon);
}
}
module top_bottom_plate_2d()
{
difference()
{
square([box_x, box_y]);
translate([-epsilon,-epsilon])
{
top_bottom_front_back_slots();
}
translate([-epsilon, box_y-material_z+epsilon])
{
top_bottom_front_back_slots();
}
}
}
module top_2d()
{
$fa=0.5;
$fs=0.1;
primary_hole_width = 5; // mm
primary_hole_size = 10; // degrees
primary_hole_count = 8;
difference()
{
top_bottom_plate_2d();
translate([box_x/2, box_y/2]) // center
{
// Hole for securing the coilforms
circle(r=M5);
// Holes for passing through the primary coil wires (for various tunings)
for(i=[0:primary_hole_count-1])
{
rotate([0,0,i*(360/primary_hole_count)])
{
span(primary_coil_r+3, primary_hole_width, primary_hole_size);
}
}
}
}
}
//top_2d();
module top_3d()
{
color([(71/255), (48/255), (212/255), 0.75])
{
translate([0,0,box_z-material_z])
{
linear_extrude(height=material_z)
{
top_2d();
}
}
}
}
//top_3d();
module bottom_2d()
{
top_bottom_plate_2d();
// TODO: Add ventilation holes/slots ?
}
//bottom_2d();
module bottom_3d()
{
color([(71/255), (48/255), (212/255), 0.75])
{
linear_extrude(height=material_z)
{
bottom_2d();
}
}
}
//bottom_3d();
module left_right_front_back_slots()
{
//front_left_slot_offset
translate([-epsilon,0])
{
slot_2d(front_left_slot_offset-material_z);
}
translate([box_z-material_z-front_left_slot_offset+epsilon,0])
{
slot_2d(front_left_slot_offset-material_z);
}
}
module left_right_plate()
{
difference()
{
square([box_z-(2*material_z),box_y]);
translate([0,0])
{
left_right_front_back_slots();
}
translate([0,box_y-material_z+epsilon])
{
left_right_front_back_slots();
}
}
}
module left_2d()
{
lightning_holes = 3;
difference()
{
left_right_plate();
// 3 HV lightning shaped ventilation holes
for(i=[0:lightning_holes-1])
{
translate([40,((box_y-2*material_z)/lightning_holes)*i+5.5*material_z,0])
{
mirror([0,0,0])
{
rotate([0,0,-90])
{
hv_lightning();
}
}
}
}
// Ventilation hole, the leftover doubles as stiffener bottom plate
translate([material_z, 3*material_z,0])
{
square([front_leg_z, box_y-6*material_z]);
}
}
}
//left_2d();
module left_3d()
{
color([(34/255), (222/255), (52/255), 0.75])
{
translate([material_z,0,material_z])
{
rotate([0,-90,0])
{
linear_extrude(height=material_z)
{
left_2d();
}
}
}
}
}
//left_3d();
module right_2d()
{
lightning_holes = 3;
difference()
{
left_right_plate();
// 3 HV lightning shaped ventilation holes
for(i=[0:lightning_holes-1])
{
translate([40,((box_y-2*material_z)/lightning_holes)*i+4*material_z,0])
{
mirror([0,1,0])
{
rotate([0,0,-90])
{
hv_lightning();
}
}
}
}
// Ventilation hole, the leftover doubles as stiffener bottom plate
translate([material_z, 3*material_z,0])
{
square([front_leg_z, box_y-6*material_z]);
}
}
}
//right_2d();
module right_3d()
{
color([(34/255), (222/255), (52/255), 0.75])
{
translate([box_x,0,material_z])
{
rotate([0,-90,0])
{
linear_extrude(height=material_z)
{
right_2d();
}
}
}
}
}
//right_3d();
module box_3d()
{
bottom_3d();
top_3d();
back_3d();
front_3d();
left_3d();
right_3d();
}
//box_3d();
module rendering()
{
box_3d();
translate([box_x/2,box_y/2,box_z])
{
coilforms_3d();
}
}
//rendering();
module hv_lightning()
{
translate([-15,-148,0])
{
import(file="high_voltage_lightningonly.dxf");
}
}
//hv_lightning();
/**
* Seems front_2d module triggers some sort of infinite-loop (ran out of swapspace once because of that...)
* but only when used alone (the 3D extrusion [and cutting a projection from that] works fine...)
*/
module front_2d_fromprojection()
{
projection(cut=false)
{
rotate([90,0,0])
{
front_3d();
}
}
}
//front_2d_fromprojection();
/**
* Ditto for back_2d
*/
module back_2d_fromprojection()
{
projection(cut=false)
{
rotate([90,0,0])
{
back_3d();
}
}
}
//back_2d_fromprojection();
// Trigger bug
front_2d();
/**
* Calls to the 2D modules in single place for easier exporting
*
bottom_2d();
top_2d();
front_2d();
back_2d();
left_2d();
right_2d();
*/
999
DXF created by Inkscape
0
SECTION
2
HEADER
9
$ACADVER
1
AC1014
9
$HANDSEED
5
FFFF
9
$MEASUREMENT
70
1
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
VPORT
5
8
330
0
100
AcDbSymbolTable
70
4
0
VPORT
5
2E
330
8
100
AcDbSymbolTableRecord
100
AcDbViewportTableRecord
2
*ACTIVE
70
0
10
0.0
20
0.0
11
1.0
21
1.0
12
210.0
22
148.5
13
0.0
23
0.0
14
10.0
24
10.0
15
10.0
25
10.0
16
0.0
26
0.0
36
1.0
17
0.0
27
0.0
37
0.0
40
341.0
41
1.24
42
50.0
43
0.0
44
0.0
50
0.0
51
0.0
71
0
72
100
73
1
74
3
75
0
76
0
77
0
78
0
0
ENDTAB
0
TABLE
2
LTYPE
5
5
330
0
100
AcDbSymbolTable
70
1
0
LTYPE
5
14
330
5
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
2
BYBLOCK
70
0
3
72
65
73
0
40
0.0
0
LTYPE
5
15
330
5
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
2
BYLAYER
70
0
3
72
65
73
0
40
0.0
0
LTYPE
5
16
330
5
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
2
CONTINUOUS
70
0
3
Solid line
72
65
73
0
40
0.0
0
ENDTAB
0
TABLE
2
LAYER
5
2
100
AcDbSymbolTable
70
2
0
LAYER
5
50
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
0
70
0
6
CONTINUOUS
0
LAYER
5
51
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
Warstwa_1
70
0
6
CONTINUOUS
0
ENDTAB
0
TABLE
2
STYLE
5
3
330
0
100
AcDbSymbolTable
70
1
0
STYLE
5
11
330
3
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
2
STANDARD
70
0
40
0.0
41
1.0
50
0.0
71
0
42
2.5
3
txt
4
0
ENDTAB
0
TABLE
2
VIEW
5
6
330
0
100
AcDbSymbolTable
70
0
0
ENDTAB
0
TABLE
2
UCS
5
7
330
0
100
AcDbSymbolTable
70
0
0
ENDTAB
0
TABLE
2
APPID
5
9
330
0
100
AcDbSymbolTable
70
2
0
APPID
5
12
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD
70
0
0
ENDTAB
0
TABLE
2
DIMSTYLE
5
A
330
0
100
AcDbSymbolTable
70
1
0
DIMSTYLE
105
27
330
A
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
ISO-25
70
0
3
4
5
6
7
40
1.0
41
2.5
42
0.625
43
3.75
44
1.25
45
0.0
46
0.0
47
0.0
48
0.0
140
2.5
141
2.5
142
0.0
143
0.03937007874016
144
1.0
145
0.0
146
1.0
147
0.625
71
0
72
0
73
0
74
0
75
0
76
0
77
1
78
8
170
0
171
3
172
1
173
0
174
0
175
0
176
0
177
0
178
0
270
2
271
2
272
2
273
2
274
3
340
11
275
0
280
0
281
0
282
0
283
0
284
8
285
0
286
0
287
3
288
0
0
ENDTAB
0
TABLE
2
BLOCK_RECORD
5
1
330
0
100
AcDbSymbolTable
70
1
0
BLOCK_RECORD
5
1F
330
1
100
AcDbSymbolTableRecord
100
AcDbBlockTableRecord
2
*MODEL_SPACE
0
BLOCK_RECORD
5
1B
330
1
100
AcDbSymbolTableRecord
100
AcDbBlockTableRecord
2
*PAPER_SPACE
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
BLOCK
5
20
330
1F
100
AcDbEntity
8
0
100
AcDbBlockBegin
2
*MODEL_SPACE
70
0
10
0.0
20
0.0
30
0.0
3
*MODEL_SPACE
1
0
ENDBLK
5
21
330
1F
100
AcDbEntity
8
0
100
AcDbBlockEnd
0
BLOCK
5
1C
330
1B
100
AcDbEntity
67
1
8
0
100
AcDbBlockBegin
2
*PAPER_SPACE
1
0
ENDBLK
5
1D
330
1B
100
AcDbEntity
67
1
8
0
100
AcDbBlockEnd
0
ENDSEC
0
SECTION
2
ENTITIES
0
LINE
5
100
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
20.102183
20
182.000814
30
0.0
11
25.322995
21
181.197613
31
0.0
0
LINE
5
101
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
25.322995
20
181.197613
30
0.0
11
19.098181
21
166.539179
31
0.0
0
LINE
5
102
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
19.098181
20
166.539179
30
0.0
11
26.929399
21
170.956790
31
0.0
0
LINE
5
103
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
26.929399
20
170.956790
30
0.0
11
23.114192
21
153.687953
31
0.0
0
LINE
5
104
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
23.114192
20
153.687953
30
0.0
11
24.720595
21
153.687953
31
0.0
0
LINE
5
105
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
24.720595
20
153.687953
30
0.0
11
21.507786
21
148.065539
31
0.0
0
LINE
5
106
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
21.507786
20
148.065539
30
0.0
11
20.302985
21
154.491155
31
0.0
0
LINE
5
107
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
20.302985
20
154.491155
30
0.0
11
22.110189
21
154.089553
31
0.0
0
LINE
5
108
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
22.110189
20
154.089553
30
0.0
11
23.114192
21
166.338381
31
0.0
0
LINE
5
109
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
23.114192
20
166.338381
30
0.0
11
15.082173
21
162.924774
31
0.0
0
LINE
5
10a
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
15.082173
20
162.924774
30
0.0
11
20.102183
21
182.000814
31
0.0
0
LINE
5
10b
100
AcDbEntity
8
Warstwa_1
62
7
100
AcDbLine
10
20.102183
20
182.000814
30
0.0
11
20.102183
21
182.000814
31
0.0
0
ENDSEC
0
SECTION
2
OBJECTS
0
DICTIONARY
5
C
330
0
100
AcDbDictionary
3
ACAD_GROUP
350
D
3
ACAD_MLINESTYLE
350
17
0
DICTIONARY
5
D
330
C
100
AcDbDictionary
0
DICTIONARY
5
1A
330
C
100
AcDbDictionary
0
DICTIONARY
5
17
330
C
100
AcDbDictionary
3
STANDARD
350
18
0
DICTIONARY
5
19
330
C
100
AcDbDictionary
0
ENDSEC
0
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment