-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
module_pir.scad
118 lines (100 loc) · 4.04 KB
/
module_pir.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Creates a module with an opening for a PIR motion sensor
/* [Case Dimensions] */
// diameter of the base
base_diameter = 62.8; //[62.8:Small, 80:Medium, 100:Large, 130:XLarge]
// thickness of outer wall
wall_thickness = 2; //[2:0.5:5]
// enable rim
enable_rim = true;
// rim height
rim_height = 1.2; // [.5: .1: 2]
/* [PIR Sensor Dimensions] */
// width of the PIR sensor
pir_sensor_width = 24.0; //[10:0.1:100]
// height of the PIR sensor
pir_sensor_height = 24.0; //[10:0.1:100]
// width of the pcb
pir_sensor_pcb_width = 26.0; //[10:0.1:100]
// height of the pcb
pir_sensor_pcb_height = 32.0; //[10:0.1:100]
// position of the sensor (lower edge)
pir_sensor_y_position = 4.0;
// diameter of pcb screw
pir_sensor_thread_diameter = 2.0;
// pitch of pcb screw
pir_sensor_thread_pitch = 0.4;
/* [Hidden] */
$fn = 128;
preview = false;
base_radius = base_diameter / 2;
use <common.scad>
use <module_empty.scad>
use <threads.scad>
module cutOuter(radius, module_height)
{
intersection() {
children();
cylinder(r=radius, h=module_height);
}
}
module cutInner(radius, module_height)
{
difference() {
children();
cylinder(r=radius, h=module_height);
}
}
module pir_sensor(base_radius, wall_thickness, pir_sensor_width, pir_sensor_height, pir_sensor_pcb_width, pir_sensor_pcb_height, pir_sensor_y_position) {
pir_sensor_module_height = pir_sensor_pcb_height + 2*wall_thickness;
rotate([0,0,180])
difference() {
difference() {
union() {
// base
empty(base_radius, pir_sensor_module_height, wall_thickness, enable_rim);
// frame
cutInner(base_radius - 2.5*wall_thickness, pir_sensor_module_height) {
cutOuter(base_radius - wall_thickness+0.1, pir_sensor_module_height) {
translate([base_radius-wall_thickness*2-1, -(pir_sensor_pcb_width/2 + wall_thickness/2), 0])
cube([base_radius, pir_sensor_pcb_width + wall_thickness, pir_sensor_pcb_height + wall_thickness * 2 + 0.1]);
};
};
}
// spacer for rim of module below
if (enable_rim) {
// make spacer 25% taller and 20% wider than the rim itself
rim(base_radius, 0, wall_thickness - 0.2, rim_height * 1.25, 1.2);
}
// sensor cutout
translate([0, -pir_sensor_width/2, pir_sensor_y_position + wall_thickness])
cube([base_radius, pir_sensor_width, pir_sensor_height]);
// pcb cutout
translate([-1, -pir_sensor_pcb_width/2, wall_thickness])
cube([base_radius - 1.5*wall_thickness, pir_sensor_pcb_width, pir_sensor_pcb_height]);
// outer recess
translate([base_radius - wall_thickness, -pir_sensor_width/2 - 2, pir_sensor_y_position + wall_thickness])
cube([base_radius - 2*wall_thickness, pir_sensor_width+4, pir_sensor_height]);
// chamfer top
translate([base_radius - wall_thickness, -pir_sensor_width/2 - 2, pir_sensor_y_position + pir_sensor_height + wall_thickness])
rotate([0,30,0])
cube([base_radius - 2*wall_thickness, pir_sensor_width+4, pir_sensor_height+4]);
// chamfer bottom
translate([base_radius - wall_thickness, -pir_sensor_width/2 - 2, pir_sensor_y_position + wall_thickness])
rotate([0,60,0])
cube([base_radius - 2*wall_thickness, pir_sensor_width+4, pir_sensor_height+4]);
// chamfer horizontal
/*
translate([base_radius - wall_thickness-4.1, -pir_sensor_width/2 - 12, pir_sensor_y_position + wall_thickness])
cube([base_radius - 2*wall_thickness, pir_sensor_width+24, pir_sensor_height]);
*/
}
// screw threads
render() translate([base_radius-2*wall_thickness-0.6, 0, wall_thickness + pir_sensor_pcb_height - pir_sensor_thread_diameter])
rotate([0,90,0])
metric_thread(diameter=pir_sensor_thread_diameter, pitch=pir_sensor_thread_pitch, length=2.5, internal=true, test=preview);
render() translate([base_radius-2*wall_thickness-0.6, 0, wall_thickness + pir_sensor_thread_diameter])
rotate([0,90,0])
metric_thread(diameter=pir_sensor_thread_diameter, pitch=pir_sensor_thread_pitch, length=2.5, internal=true, test=preview);
}
}
pir_sensor(base_radius, wall_thickness, pir_sensor_width, pir_sensor_height, pir_sensor_pcb_width, pir_sensor_pcb_height, pir_sensor_y_position);