chiark / gitweb /
298c5a66613a4f0eb85ee1d6919225cf60405e39
[reprap-play.git] / anke-gps-bracket.scad
1 // -*- C -*-
2
3 // todo
4 // nestlecube does not fit
5 // nestlecube doveclip at wrong angle
6
7 include <doveclip.scad>
8
9 // Dimensions of the main GPS body
10 outerw = 120;
11 outerh =  75;
12 outert =  15;
13 outerbackbevel = 3;
14
15 // Dimensions for the holder
16 holder_outerw = outerw - 0.0;
17 holder_outerh = outerh + 0.0;
18 holder_outert = outert + 0.0;
19
20 // Dimensions for the model
21 model_outerw = outerw + 2.5;
22 model_outerh = outerh - 0.2;
23 model_outert = outert - 1.0;
24
25 // Dimensions of the bezel area round the edges
26 bezelw =    11 - 0.5;
27 bezelboth = 11 - 0.5;
28 bezeltoph =  7 - 0.5;
29
30 // Dimensions of the speaker at the back
31 spkrdia =  22;
32 spkr2bot = 19;
33 spkr2rhs = 25;
34
35 // Dimensions of the plug and wire
36 plugw =      12;
37 plugh =       9;
38 plug2bot =   11;
39 plug2lhs =   11;
40 plugtotald = 15;
41 pluggapd =    5;
42
43 // Dimensions of the hole in the tray
44 //   width and height (vertical) at the top
45 nestleh = 53;
46 nestlew = 55.4 - 0.5;
47 //   depths (back to front distance):
48 nestledl = 38.8 - 0.5;
49 nestledr = 42.7 - 0.5;
50 //   differences in width, depth, at bottom:
51 nestledwl = 3.0;
52 nestledwr = 2.4;
53 nestleddf = 4.0;
54 nestleddbl = 3.3;
55 nestleddbr = 3.6;
56
57 nestlewallmin = 4;
58 nestleceilmin = 4;
59
60 // Adjustment for the GPS attitude and position
61 gpsazimuth = 45;
62 gpselevation = 40;
63 gpsrightwardoffset = 5;
64 gpsrearwardoffset = 2;
65 gpsrightwardoffsetonbar = 0;
66
67 // Amount of wire protrusion to allow for
68 plugwiremoreh = 25;
69
70 // Slops and steps etc.
71 plugslop = 0.5;
72 plughstep = 1.5;
73 bodylhsrhsslop = 0.5;
74 holderhgap = 5;
75 holderbezelmore = 2;
76
77 // Dimensions for strength only
78 screent = 1.0;
79 plugstrutw = 4;
80 plugstrutt = min(model_outert, 5);
81 nestledoveclipw = 20;
82 holderh = model_outerh * 0.5;
83 holderwallt = 2.5;
84 holderbackt = 2.8;
85 holderdccount = 2;
86 holderdoveclipl = 15;
87 chassish = 13;
88 chassist = 13;
89
90 // Consequential values
91 holderdcw = DoveClipPairSane_width(holderdccount);
92
93 module GpsPlugPlug(slop){
94   effhslop = slop - plughstep;
95   effplugw = plugw + slop*2;
96   effplugh = plugh + effhslop*2;
97   translate([plug2lhs-slop, plug2bot-effhslop, -1])
98     cube([effplugw, effplugh, model_outert+2]);
99 }
100
101 module GpsBodyOuterBevel(len){
102   translate([0,-1,0]) {
103     rotate([-90,0,0]) {
104       linear_extrude(height=len+2) {
105         polygon([[-outerbackbevel, 0],
106                  [ 0, outerbackbevel],
107                  [outerbackbevel, 0],
108                  [ 0, -outerbackbevel]]);
109       }
110     }
111   }
112 }
113
114 module GpsBody() { ////toplevel
115   difference(){
116     union(){
117       difference(){
118         cube([model_outerw, model_outerh, model_outert]);
119         translate([bezelw, bezelboth, screent])
120           cube([model_outerw-bezelw*2,
121                 model_outerh-bezelboth-bezeltoph,
122                 model_outert]);
123         translate([model_outerw-spkr2rhs, spkr2bot, -1])
124           cylinder(r=spkrdia/2, h=model_outert+2);
125       }
126       translate([plug2lhs+plugw/2, plug2bot+plugh/2, 0])
127         cylinder(r=(plugw+plugh)/2, h=model_outert);
128       for (x=[plug2lhs-plugstrutw, plug2lhs+plugw])
129         translate([x, 0.1, 0])
130           cube([plugstrutw, model_outerh-0.2, plugstrutt-0.10]);
131     }
132     GpsPlugPlug(0);
133     for (x=[0,model_outerw]) translate([x,0,0]) GpsBodyOuterBevel(model_outerh);
134     for (y=[0,model_outerh]) translate([0,y,0])
135       rotate([0,0,-90]) GpsBodyOuterBevel(model_outerw);
136   }
137 }
138
139 module GpsPlug() {
140   plugwireh = plug2bot + plugwiremoreh;
141   translate([-plugslop,0,0]) GpsPlugPlug(-plugslop);
142   mirror([0,0,1]) translate([plug2lhs, plug2bot, 0]) {
143     cube([plugw, plugh, plugtotald-0.05]);
144     translate([0, -plugwireh, pluggapd])
145       cube([plugw, plugwireh+0.05, plugtotald-pluggapd]);
146   }
147 }
148
149 lhsteethu = 2;
150
151 module GpsLHSMask(xslop=0){
152   translate([plug2lhs + plugw+plugh+plugstrutw,
153              0,
154              -50]) {
155     for (iter=[-100/lhsteethu : 100/lhsteethu]) {
156       translate([0, iter*lhsteethu*2, 0]) {
157         linear_extrude(height=100) {
158           polygon([[-300,     0],
159                    [   0,     0],
160                    [lhsteethu,lhsteethu],
161                    [   0,     lhsteethu*2],
162                    [-300,     lhsteethu*2+0.1]]);
163         }
164       }
165     }
166   }
167 }
168
169 module GpsAssembled(){ ////toplevel
170   GpsBody();
171   GpsPlug();
172 }
173
174 module GpsBodyLT(){
175   intersection(){
176     GpsBody();
177     GpsLHSMask();
178   }
179 }
180
181 module GpsBodyRT(){
182   difference(){
183     GpsBody();
184     GpsLHSMask(bodylhsrhsslop);
185   }
186 }
187
188 module GpsPlugT(){ ////toplevel
189   rotate([0,-90,0]) GpsPlug();
190 }
191
192 module NestleCubeCutout(ca,cb,d){
193   dist = cb - ca;
194   mirror([0,1,0]){
195     rotate([90,0,0]){
196       linear_extrude(height=d){
197         polygon([[ca, -nestleh-1],
198                  [ca, -dist/2],
199                  [(ca+cb)/2, 0],
200                  [cb, -dist/2],
201                  [cb, -nestleh-1]]);
202       }
203     }
204   }
205 }
206
207 module NestleCube(){ ////toplevel
208   midw = nestlew/2;
209   midd = min(nestledl,nestledr);
210   midddb = max(nestleddbl,nestleddbr);
211
212   based0 = nestleddf;
213   based1 = midd - midddb;
214   basew0 = -nestledwr;
215   basew1 = +nestledwl-nestlew;
216
217   cutd0 = based0 + nestlewallmin;
218   cutd1 = based1 - nestlewallmin;
219   cutw0 = basew0 - nestlewallmin;
220   cutw1 = basew1 + nestlewallmin;
221
222   translate([-(basew0+basew1)/2, -(based0+based1)/2, 0]) difference(){
223     polyhedron
224       (points=[[          +0      ,            +0,        0], // 0
225                [          +0      ,            +nestledr, 0], // 1
226                [          -midw   ,            +midd,     0], // 2
227                [          -nestlew,            +nestledl, 0], // 3
228                [          -nestlew,            +0,        0], // 4
229                [-nestledwr+0      , +nestleddf +0,        -nestleh], // 5
230                [-nestledwr+0      , -nestleddbr+nestledr, -nestleh], // 6
231                [          -midw   , -midddb    +midd,     -nestleh], // 7
232                [+nestledwl-nestlew, -nestleddbl+nestledl, -nestleh], // 8
233                [+nestledwl-nestlew, +nestleddf +0,        -nestleh]], // 9
234        triangles=[[0,1,6],[6,5,0],
235                   [1,2,7],[7,6,1],
236                   [2,3,8],[8,7,2],
237                   [3,4,9],[9,8,3],
238                   [4,0,5],[5,9,4],
239                   [4,3,2],[2,1,0],[0,4,2],
240                   [7,8,9],[5,6,7],[7,9,5]],
241        convexity=3);
242     intersection(){
243       NestleCubeCutout(cutw1, cutw0, max(nestledl,nestledr));
244       rotate([0,0,90]) NestleCubeCutout(cutd0, cutd1, nestlew);
245     }
246   }
247
248   translate([gpsrightwardoffset,-gpsrearwardoffset,0])
249     rotate([0,0,gpsazimuth])
250     translate([nestledoveclipw/2,0,DoveClip_depth()-0.5])
251     rotate([0,-90,0])
252     DoveClipPairSane(count=3, h=nestledoveclipw);
253 }
254
255 module NestleCubePin(){ ////toplevel
256   DoveClipPin(nestledoveclipw*0.4);
257 }
258
259 module HolderSideL(){ ////toplevel
260   minz = -(bezelw - holderbezelmore) - holderbackt;
261   holdert = holder_outert + holderwallt*2;
262   cylr = 0.5*sqrt(holderdcw*holderdcw + holderdoveclipl*holderdoveclipl);
263   difference(){
264     translate([-holderh,
265                -holderwallt,
266                minz]) {
267       cube([holderh + holderhgap + cylr,
268             holdert,
269             -minz]);
270       translate([holderh + holderhgap + cylr, holdert/2, 0]) {
271         cylinder(r=cylr, h=-minz);
272         rotate([0,0,gpselevation])
273           translate([0, -holderdoveclipl/2, -minz + DoveClip_depth()])
274           rotate([0,-90,-90])
275           DoveClipPairSane(count=holderdccount, h=holderdoveclipl);
276       }
277     }
278     translate([-holderh-1,
279                0,
280                minz + holderbackt])
281       cube([holderh+1,
282             holder_outert,
283             bezelw]);
284   }
285 }
286
287 module HolderSideR(){ ////toplevel
288   mirror([0,1,0]) HolderSideL();
289 }
290
291 module ChassisBar(){ ////toplevel
292   dist = holder_outerw - 2*((bezelw - holderbezelmore) + DoveClip_depth());
293   cliph = holderdcw;
294   for (mir=[0,1]) {
295     mirror([mir,0,0]) {
296       translate([dist/2, cliph/2, 0])
297         DoveClipPairSane(h=holderdoveclipl, count=holderdccount);
298       translate([-1, 0, 0])
299         cube([dist/2 - DoveClip_depth() + 1.1, chassish, chassist]);
300     }
301   }
302   translate([-gpsrightwardoffsetonbar, -DoveClip_depth(), 0])
303     rotate([0,0,-90])
304     DoveClipPairSane(h=nestledoveclipw, count=3,
305                      baseextend=chassist/2);
306 }
307
308 module HolderSidePin(){ ////toplevel
309   DoveClipPin(holderdoveclipl*0.5);
310 }
311
312 module Pins(){ ///toplevel
313   for (i=[1:4*holderdccount]) {
314     translate([i*10, 0, 0]) HolderSidePin();
315   }
316   for (i=[1:6]) {
317     translate([i*10, 20, 0]) NestleCubePin();
318   }
319 }
320
321 //GpsPlugT();
322 //GpsAssembled();
323 //GpsBody();
324 //NestleCube();
325 //NestleCubePin();
326 //HolderSideL();
327 //HolderSideR();
328 //HolderSidePin();
329 //ChassisBar();
330 //Pins();