summaryrefslogtreecommitdiff
path: root/body/veye_imx287.scad
blob: 85ebcf686164ab2e1321394707aebd518cea545a (plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
include <design.scad>
include <helpers.scad>

veye_imx287_pcb_w = 29;
veye_imx287_pcb_h = 29;
veye_imx287_pcb_thickness = 1.6;
veye_imx287_pcb_stack_h = 11;
imx287_thickness = 1.3;
veye_imx287_mount_plate_corner_radius = 2;
veye_imx287_mount_plate_thickness = 2;
veye_imx287_mount_plate_frame_w = 6;

function veye_imx287_mount_plate_offset() =
    // sensor has non-zero thickness, so put holder
    // closer to pcb (but avoid artifacts)
    [0, -imx287_thickness + $tiny_padding, 0] +
    // move to zero
    [0, veye_imx287_mount_plate_thickness / 2, 0];

module veye_imx287_wo_holes()
{
    pcb_w = veye_imx287_pcb_w;
    pcb_h = veye_imx287_pcb_h;
    pcb_stack_h = veye_imx287_pcb_stack_h;
    
    // connector size
    conn_w = 23;
    conn_h = 8;
    conn_d = 19;
    
    translate([0, -pcb_stack_h / 2, 0])
    cube([pcb_w, pcb_stack_h, pcb_h], center = true);
    
    translate([0, -conn_d / 2 - pcb_stack_h, -conn_h / 2 + pcb_h / 2])
    cube([conn_w, conn_d, conn_h], center = true);
}

module veye_imx287()
{
    hole_d = 2.05;
    center_to_hole_dist = 12.5;
    pcb_stack_h = veye_imx287_pcb_stack_h;
    
    difference()
    {
        veye_imx287_wo_holes();
        union()
        for (x_mult = [-1, 1], z_mult = [-1, 1])
        {
            dx = center_to_hole_dist * x_mult;
            dy = $tiny_padding;
            dz = center_to_hole_dist * z_mult;
            
            translate([dx, dy, dz])
            rotate([90, 0, 0])
            cylinder($fn = diameterToFn(hole_d), d = hole_d, h = pcb_stack_h + $tiny_padding * 2);
        }
    }
}

module veye_imx287_stl_front()
{
    pcb_w = veye_imx287_pcb_w;
    pcb_h = veye_imx287_pcb_h;
    
    rotate([90, 0, 0])
    translate([-pcb_w / 2, -pcb_h / 2, veye_imx287_pcb_thickness])
    import("PCB-RAW-IMX287-V11-0105-3D.stl");
}

module veye_imx287_stl_back(with_connector = true)
{
    pcb_w = veye_imx287_pcb_w;
    pcb_h = veye_imx287_pcb_h;
    
    rotate([90, 90, 0])
    translate([-pcb_w / 2, -pcb_h / 2, -veye_imx287_pcb_thickness])
    // fix not-centered source model
    //rotate([0, 0, 90])
    translate([-50, 121 + pcb_h])
    import("ADP-MV1-STEP.stl");
    
    if (with_connector)
    {
        // connector size
        conn_w = 23;
        conn_h = 8;
        conn_d = 19;
        
        // a bit of hardcode for connector
        cyl_d = 6;
        cyl_z_offset = -2;
        
        translate([0, -conn_d + cyl_d / 2, veye_imx287_pcb_h / 2 - cyl_d / 2 + cyl_z_offset])
        rotate([0, 90, 0])
        %cylinder($fn = diameterToFn(cyl_d), d = cyl_d, h = conn_w, center = true);
    }
}

*#veye_imx287();

// centered in senser center
module veye_imx287_natural()
{
    translate([0, -imx287_thickness, 0])
    union()
    {
        veye_imx287_stl_front();
        translate([0, -veye_imx287_pcb_stack_h, 0])
        veye_imx287_stl_back();
    }
}

module veye_imx287_mount_plate_outer()
{
    w = veye_imx287_pcb_w;
    h = veye_imx287_pcb_h;
    t = veye_imx287_mount_plate_thickness;
    cr = veye_imx287_mount_plate_corner_radius;

    translate(veye_imx287_mount_plate_offset())
    hull()
    {
        for (
            dx = [w / 2 - cr, -w / 2 + cr],
            dy = [h / 2 - cr, -h / 2 + cr])
        {
            translate([dx, 0, dy])
            translate([0, t / 2, 0])
            rotate([90, 0, 0])
            cylinder($fn = dToFn(cr * 2), r = cr, h = t);
        }
    }
}

// inner area to cut
module veye_imx287_mount_plate_inner()
{
    w = veye_imx287_pcb_w;
    h = veye_imx287_pcb_h;
    frame_w = veye_imx287_mount_plate_frame_w;
    iw = w - frame_w;
    ih = h - frame_w;
    t = veye_imx287_mount_plate_thickness;
    cr = veye_imx287_mount_plate_corner_radius;

    translate(veye_imx287_mount_plate_offset())
    hull()
    {
        for (
            dx = [iw / 2 - cr, -iw / 2 + cr],
            dy = [iw / 2 - cr, -iw / 2 + cr])
        {
            translate([dx, 0, dy])
            translate([0, t / 2 + $tiny_padding, 0])
            rotate([90, 0, 0])
            cylinder(
                $fn = dToFn(cr * 2),
                r = cr,
                h = t + $tiny_padding * 2);
        }
    }
}

// screw holes
module veye_imx287_mount_plate_holes()
{
    // holes
    hd = 2.05;
    hh = 10;

    // distance between holes
    h_delta = 25;

    translate(veye_imx287_mount_plate_offset())
    for (
        dx = [h_delta / 2, -h_delta / 2],
        dy = [h_delta / 2, -h_delta / 2])
    {
        translate([dx, 0, dy])
        translate([0, hh / 2, 0])
        rotate([90, 0, 0])
        cylinder($fn = dToFn(hd), d = hd, h = hh);
    }
}

module veye_imx287_mount_plate()
{
    w = veye_imx287_pcb_w;
    h = veye_imx287_pcb_h;
    frame_w = veye_imx287_mount_plate_frame_w;
    iw = w - frame_w;
    ih = h - frame_w;
    t = veye_imx287_mount_plate_thickness;
    cr = veye_imx287_mount_plate_corner_radius;
    
    // holes
    hd = 2.05;
    hh = 10;
    // distance between holes
    h_delta = 25;
    hr = hd / 2;
    
    difference()
    {
        // outer shape
        veye_imx287_mount_plate_outer();
        // to cut
        veye_imx287_mount_plate_inner();
        // holes
        veye_imx287_mount_plate_holes();
    }
}

color("yellow", 0.1)
*veye_imx287_natural();
color("green", 0.4)
*veye_imx287_mount_plate();

color("red", 0.1)
*veye_imx287_mount_plate_outer();
color("green", 0.3)
*veye_imx287_mount_plate_inner();

*difference()
{
    //color("brown", 0.4)
    veye_imx287_mount_plate_outer();
    //color("blue", 0.4)
    veye_imx287_mount_plate_inner();
}