-
Notifications
You must be signed in to change notification settings - Fork 4
/
motormounts.jscad
949 lines (773 loc) · 66.8 KB
/
motormounts.jscad
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
include('/mechanics/isothread.jscad');
include('/mechanics/screwclamp.jscad');
include('/mechanics/stepperNema17.jscad');
include('/mechanics/bearingLM8LUU.jscad');
include('/mechanics/bearingLM8UU.jscad');
include('/mechanics/motedisDelrin.jscad');
include('/mechanics/aluprofile.jscad');
if(typeof window === 'undefined') { window = new Object(); }
if(typeof window.jscad !== 'object') { window.jscad = new Object(); }
if(typeof window.jscad.tspi !== 'object') { window.jscad.tspi = new Object(); }
if(typeof window.jscad.tspi.miniecm !== 'object') { window.jscad.tspi.miniecm = new Object(); }
window.jscad.tspi.miniecm.motormount = function(printer, params) {
let knownParameters = [
{ name: 'sledCarriageType', type: 'boolean', default: false },
{ name: 'guiderodClampM', type: 'number', default: 6 },
{ name: 'guiderodClampScrewLength', type: 'number', default: 16 },
{ name: 'guiderodDiameter', type: 'number', default: 8 },
{ name: 'lm8uuGrubScrewM', type: 'number', default: 3 },
{ name: 'lm8uuGrubScrewLength', type: 'number', default: 6 },
{ name: 'guiderodClampMinWall', type: 'number', default: 2 },
{ name: 'minWallThickness', type: 'number', default: 1 },
{ name: 'sledSizeInside', type: 'number', default: 50 },
{ name: 'sledSizeOutsideMin', type: 'number', default: 0 },
{ name: 'sledSizeWallMin', type: 'number', default: 0 },
{ name: 'sledBearingsLong', type: 'boolean', default: false },
{ name: 'stepperZLength', type: 'number', default: 30 },
{ name: 'onlyPrintedPart', type: 'boolean', default: false },
// Default values should not be changed:
{ name: 'spacingThroughHole', type: 'number', default: 2 },
];
let knownPrinterParameters = [
{ name: 'scale', type: 'number', default: 1 },
{ name: 'correctionInsideDiameter', type: 'number', default: 0 },
{ name: 'correctionOutsideDiameter', type: 'number', default: 0 },
{ name: 'resolutionCircle', type: 'number', default: 32 /*360*/ },
{ name: 'guiderodClampDiaCorrection', type: 'number', default: 0.1 },
{ name: 'lm8uuInsertDiameterScale', type: 'number', default: 1.05 },
];
this.parameters = { };
this.printer = { };
this.error = false;
for(var i = 0; i < knownParameters.length; i++) {
if(typeof(params[knownParameters[i].name]) === knownParameters[i].type) {
this.parameters[knownParameters[i].name] = params[knownParameters[i].name];
} else if(knownParameters[i].default != -1) {
this.parameters[knownParameters[i].name] = knownParameters[i].default;
} else {
this.error = true;
}
}
for(i = 0; i < knownPrinterParameters.length; i++) {
if(typeof(printer[knownPrinterParameters[i].name]) === knownPrinterParameters[i].type) {
this.printer[knownPrinterParameters[i].name] = printer[knownPrinterParameters[i].name];
} else if(knownPrinterParameters[i].default != -1) {
this.printer[knownPrinterParameters[i].name] = knownPrinterParameters[i].default;
} else {
this.error = true;
}
}
/* Instantiate templates */
this.knownClamp = new window.jscad.tspi.mechanics.basicScrewclamp(printer, { m : this.parameters['guiderodClampM'], screwLength : this.parameters['guiderodClampScrewLength'], rodDiameter : this.parameters['guiderodDiameter'], onlyPrintedPart : this.parameters['onlyPrintedPart'], minWallThickness : this.parameters['guiderodClampMinWall']});
this.stepper = new window.jscad.tspi.mechanics.stepperNEMA17(printer, { length: this.parameters['stepperZLength'] });
this.knownClampNut = new window.jscad.tspi.isoNut(printer, { m : this.parameters['guiderodClampM'] });
this.knownGrubNut = new window.jscad.tspi.isoNut(printer, { m : 3 });
this.knownGrubScrew = new window.jscad.tspi.iso4762Screw(printer, { m : this.parameters['lm8uuGrubScrewM'], l : this.parameters['lm8uuGrubScrewLength'], corehole : true, throughhole : false });
this.knownProfileScrew = new window.jscad.tspi.iso4762Screw(printer, { m : 4, l : 25, corehole : false, throughhole : true });
if(this.parameters['sledBearingsLong']) {
this.bearing = new window.jscad.tspi.mechanics.bearings.LM8LUU(printer, { hollow : true });
} else {
this.bearing = new window.jscad.tspi.mechanics.bearings.LM8UU(printer, { hollow : true });
}
/* Sled calculations */
this.requiredWallWidth = Math.max(
this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + 2*this.parameters['minWallThickness'] + this.knownGrubScrew.l + this.knownGrubScrew.k,
this.bearing.getLength()+this.parameters['minWallThickness']
);
this.sledRealSizeX = this.parameters['sledSizeInside']+2*this.requiredWallWidth - this.parameters['guiderodDiameter'];
this.sledRealSizeY = this.parameters['sledSizeInside']+2*this.requiredWallWidth - this.parameters['guiderodDiameter'];
let minRequiredSize = 2 * this.knownClamp.getClampSizeX() + this.knownClampNut.getHeight()*1.5;
if(this.sledRealSizeX < minRequiredSize) { this.sledRealSizeX = minRequiredSize; }
if(this.sledRealSizeY < minRequiredSize) { this.sledRealSizeY = minRequiredSize; }
if(this.parameters['sledSizeOutsideMin'] > this.sledRealSizeX) { this.sledRealSizeX = this.parameters['sledSizeOutsideMin']; this.requiredWallWidth = (this.sledRealSizeX - this.parameters['sledSizeInside'])/2; }
if(this.parameters['sledSizeOutsideMin'] > this.sledRealSizeY) { this.sledRealSizeY = this.parameters['sledSizeOutsideMin']; this.requiredWallWidth = (this.sledRealSizeY - this.parameters['sledSizeInside'])/2; }
this.insideSizeX = this.sledRealSizeX - (this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + this.parameters['minWallThickness']);
this.insideSizeY = this.sledRealSizeY - (this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + this.parameters['minWallThickness']);
this.getModel = function() {
let sledSizeX = this.sledRealSizeX; // (this.bearing.getOutsideDiameter() + 2*this.parameters['minWallThickness']) * 2;
let sledSizeY = Math.max(this.knownClamp.getClampSizeX(), this.requiredWallWidth, 36); // 36 is the width of the anti backlash nut on top ... change or remove in case another mechanism is used
let sledDYByScrew = (Math.max(0, this.requiredWallWidth-this.knownClamp.getClampSizeX()))/2;
let sledSizeZ =2 * this.knownClamp.getClampSizeY();
let upperLeadScrewPositionZ = sledSizeZ + 15 + 13/2;
let upperCaseY = this.parameters['stepperZLength'] + 5 + 2*this.parameters['minWallThickness'];
// 1.02 for press fit on my machine ...
let guiderod = cylinder({ d : this.parameters['guiderodDiameter']*1.02, h : 500, center : true, fn : 256 }).rotateX(90).translate([-this.knownClamp.getClampSizeX()/2-sledDYByScrew,0,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]).setColor([0.8,0.8,0.8]);
let guiderod2 = cylinder({ d : this.parameters['guiderodDiameter']*1.02, h : 500, center : true, fn : 256 }).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([0,sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]).translate([0,-5,0]).setColor([0.8,0.8,0.8]);
printable = [];
nonPrintable = [];
let carrier1 = difference(
cube({ size : [ 42.3 + 4*this.parameters['minWallThickness'], upperCaseY, 42.3 + 4*this.parameters['minWallThickness']]}).translate([-sledSizeY/2 - 42.3/2 - 2*this.parameters['minWallThickness'], -this.parameters['stepperZLength'], upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']]),
union(
this.stepper.getModel().scale(1.02).rotateZ(-90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2,0,upperLeadScrewPositionZ]),
cylinder({ d : 10, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7])
)
);
let carrier1_2 = difference(
cube({ size : [ 42.8 + 4*this.parameters['minWallThickness'], upperCaseY, 42.3 + 4*this.parameters['minWallThickness']]}).translate([-sledSizeY/2 - 42.3/2 - 2*this.parameters['minWallThickness'], -this.parameters['stepperZLength'], upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']]),
union(
this.stepper.getModel().scale(1.02).rotateZ(90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2,0,upperLeadScrewPositionZ]),
cylinder({ d : 10, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7]),
cylinder({ d : 4, h : upperCaseY, center : true }).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7])
)
);
let carrier2 = carrier1_2.rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], -(upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']) - (42.3 + 4*this.parameters['minWallThickness'])/2 -15 -13/2]);
let bodyZSize = 3*(42.3 + 4*this.parameters['minWallThickness']) + 15 + 13/2 + 18;
let bodyXSize = 42.3 + 4*this.parameters['minWallThickness'] + 20;
let body = difference(
union(
cube({ size : [bodyXSize, upperCaseY, bodyZSize], center : true}).translate([0,0,bodyZSize/2-9]).translate([-bodyXSize/2 -4.8+20+10-1,upperCaseY/2 - this.parameters['stepperZLength'], 2*(-15 - 13/2) - 2*this.parameters['minWallThickness'] - 10]),
cube({ size : [bodyXSize-20+0.8, upperCaseY, bodyZSize], center : true}).translate([-10,0,bodyZSize/2-9]).translate([-bodyXSize/2 -4.8+20+10,upperCaseY/2 - this.parameters['stepperZLength'], 2*(-15 - 13/2) - 2*this.parameters['minWallThickness']]).rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], 0 - 10])
),
union(
cube({ size : [ 42.3 + 4*this.parameters['minWallThickness'], upperCaseY, 42.3 + 4*this.parameters['minWallThickness']]}).translate([-sledSizeY/2 - 42.3/2 - 2*this.parameters['minWallThickness'], -this.parameters['stepperZLength'], upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']]),
cube({ size : [ 42.3 + 4*this.parameters['minWallThickness'], upperCaseY, 42.3 + 4*this.parameters['minWallThickness']]}).translate([-sledSizeY/2 - 42.3/2 - 2*this.parameters['minWallThickness'], -this.parameters['stepperZLength'], upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']]).rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], -(upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']) - (42.3 + 4*this.parameters['minWallThickness'])/2 -15 -13/2]),
cube({ size : [ 20, 20, 4*bodyZSize], center : true }).translate([-4.8+20, -30.1+10, 0]),
guiderod,
guiderod2,
cube({ size : [ 2, 5*upperCaseY, 15 ], center : true }).translate([-this.knownClamp.getClampSizeX()/2-sledDYByScrew,0,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
cube({ size : [ 5*upperCaseY, 2, 15 ], center : true }).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).translate([0,sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]).translate([0,-5,-10]),
/* Screws for profile mount */
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateX(-90).translate([-4.8+20,-30.1+20,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2+60+9]),
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateX(-90).translate([-4.8+20,-30.1+20,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2-7]),
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateX(-90).translate([-4.8+20,-30.1+20,-42.3-4*this.parameters['minWallThickness'] - 17/2]),
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateY(-90).translate([20-4.8-10,-30.1+20-10,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2+60+9]),
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateY(-90).translate([20-4.8-10,-30.1+20-10,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2-7]),
union(
this.knownProfileScrew.getTemplate(),
cylinder({d : 8, h : 50, center : true}).translate([0,0,50/2+this.knownProfileScrew.l+this.knownProfileScrew.k]).setColor([1,0,0])
).rotateY(-90).translate([20-4.8-10,-30.1+20-10,-42.3-4*this.parameters['minWallThickness'] - 17/2]),
/* Access to motor mount screws */
cylinder({d : 8, h : 50, center : true}).translate([0,0,-50+6.5]).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]),
cylinder({d : 8, h : 50, center : true}).translate([0,0,-50+6.5]).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2+15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7]),
cylinder({d : 8, h : 50, center : true}).translate([0,0,-50+6.5]).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ+15.7]).rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], -(upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']) - (42.3 + 4*this.parameters['minWallThickness'])/2 -15 -13/2]),
cylinder({d : 8, h : 50, center : true}).translate([0,0,-50+6.5]).translate([0,0,upperCaseY/2]).rotateX(90).translate([-sledSizeY/2-15.7,-this.parameters['stepperZLength']+upperCaseY,upperLeadScrewPositionZ-15.7]).rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], -(upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']) - (42.3 + 4*this.parameters['minWallThickness'])/2 -15 -13/2]),
/* Space for flexible coupler */
cylinder({d : 25, h : 50, center : true, fn : 256 }).translate([0,0,50/2]).rotateZ(-90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2,0,upperLeadScrewPositionZ]),
cylinder({d : 25, h : 50, center : true, fn : 256 }).translate([0,0,50/2]).rotateZ(-90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2,0,upperLeadScrewPositionZ]).rotateZ(90).translate([-5, this.parameters['minWallThickness']+this.parameters['stepperZLength'], -(upperLeadScrewPositionZ-42.3/2 - 2*this.parameters['minWallThickness']) - (42.3 + 4*this.parameters['minWallThickness'])/2 -15 -13/2])
)
);
/*
nonPrintable.push(
union(
this.knownProfileScrew.getTemplate().rotateX(-90).translate([-4.8+20,-30.1+20,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2+60+9]),
this.knownProfileScrew.getTemplate().rotateX(-90).translate([-4.8+20,-30.1+20,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownProfileScrew.getTemplate().rotateX(-90).translate([-4.8+20,-30.1+20,-42.3-4*this.parameters['minWallThickness'] - 17/2]),
this.knownProfileScrew.getTemplate()rotateY(-90).translate([20-4.8-10,-30.1+20-10,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2+60+9]),
this.knownProfileScrew.getTemplate().rotateY(-90).translate([20-4.8-10,-30.1+20-10,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownProfileScrew.getTemplate().rotateY(-90).translate([20-4.8-10,-30.1+20-10,-42.3-4*this.parameters['minWallThickness'] - 17/2])
)
);
*/
return difference(
union(
carrier1,
carrier2,
/* guiderod,
guiderod2, */
body
// this.stepper.getModel().scale(1.02).rotateZ(90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2,0,upperLeadScrewPositionZ])
),
cube({ size : [17, 5, 13 ], center : true}).translate([0,0,50/2]).rotateZ(-90).rotateX(90).rotateZ(180).rotateY(180).translate([-sledSizeY/2-21.5,-2*this.parameters['stepperZLength']+11,upperLeadScrewPositionZ])
);
printable.push(carrier1);
if(!this.parameters['onlyPrintedPart']) {
nonPrintable.push(this.stepper.getModel().rotateX(90).rotateZ(180).rotateY(180).translate([0,0,upperLeadScrewPositionZ]));
}
model = union(printable);
if(!this.parameters['onlyPrintedPart']) {
model = union(model, union(nonPrintable));
}
return model;
}
}
window.jscad.tspi.miniecm.carriagexy = function(printer, params) {
let knownParameters = [
{ name: 'sledCarriageType', type: 'boolean', default: false },
{ name: 'guiderodClampM', type: 'number', default: 6 },
{ name: 'guiderodClampScrewLength', type: 'number', default: 16 },
{ name: 'lm8uuGrubScrewM', type: 'number', default: 3 },
{ name: 'lm8uuGrubScrewLength', type: 'number', default: 6 },
{ name: 'guiderodClampMinWall', type: 'number', default: 2 },
{ name: 'minWallThickness', type: 'number', default: 1 },
{ name: 'sledSizeInside', type: 'number', default: 50 },
{ name: 'sledSizeOutsideMin', type: 'number', default: 0 },
{ name: 'sledSizeWallMin', type: 'number', default: 0 },
{ name: 'sledBearingsLong', type: 'boolean', default: false },
{ name: 'onlyPrintedPart', type: 'boolean', default: false },
// Default values should not be changed:
{ name: 'spacingThroughHole', type: 'number', default: 2 },
];
let knownPrinterParameters = [
{ name: 'scale', type: 'number', default: 1 },
{ name: 'correctionInsideDiameter', type: 'number', default: 0 },
{ name: 'correctionOutsideDiameter', type: 'number', default: 0 },
{ name: 'resolutionCircle', type: 'number', default: 32 /*360*/ },
{ name: 'guiderodClampDiaCorrection', type: 'number', default: 0.1 },
{ name: 'lm8uuInsertDiameterScale', type: 'number', default: 1.05 },
];
this.parameters = { };
this.printer = { };
this.error = false;
for(var i = 0; i < knownParameters.length; i++) {
if(typeof(params[knownParameters[i].name]) === knownParameters[i].type) {
this.parameters[knownParameters[i].name] = params[knownParameters[i].name];
} else if(knownParameters[i].default != -1) {
this.parameters[knownParameters[i].name] = knownParameters[i].default;
} else {
this.error = true;
}
}
for(i = 0; i < knownPrinterParameters.length; i++) {
if(typeof(printer[knownPrinterParameters[i].name]) === knownPrinterParameters[i].type) {
this.printer[knownPrinterParameters[i].name] = printer[knownPrinterParameters[i].name];
} else if(knownPrinterParameters[i].default != -1) {
this.printer[knownPrinterParameters[i].name] = knownPrinterParameters[i].default;
} else {
this.error = true;
}
}
this.parameters['guiderodDiameter'] = 8+this.printer['guiderodClampDiaCorrection']; /* Fixed since we use LM8LUU bearings */
if(this.parameters['sledBearingsLong']) {
this.bearing = new window.jscad.tspi.mechanics.bearings.LM8LUU(printer, { hollow : true });
} else {
this.bearing = new window.jscad.tspi.mechanics.bearings.LM8UU(printer, { hollow : true });
}
this.knownClamp = new window.jscad.tspi.mechanics.basicScrewclamp(printer, { m : this.parameters['guiderodClampM'], screwLength : this.parameters['guiderodClampScrewLength'], rodDiameter : this.parameters['guiderodDiameter'], onlyPrintedPart : this.parameters['onlyPrintedPart'], minWallThickness : this.parameters['guiderodClampMinWall']});
this.knownGrubNut = new window.jscad.tspi.isoNut(printer, { m : 3 });
this.knownClampNut = new window.jscad.tspi.isoNut(printer, { m : this.parameters['guiderodClampM'] });
this.knownGrubScrew = new window.jscad.tspi.iso4762Screw(printer, { m : this.parameters['lm8uuGrubScrewM'], l : this.parameters['lm8uuGrubScrewLength'], corehole : true, throughhole : false });
this.requiredWallWidth = Math.max(
this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + 2*this.parameters['minWallThickness'] + this.knownGrubScrew.l + this.knownGrubScrew.k,
this.bearing.getLength()+this.parameters['minWallThickness']
);
if(this.parameters['sledSizeWallMin'] > this.requiredWallWidth) { this.requiredWallWidth = this.parameters['sledSizeWallMin']; }
this.sledRealSizeX = this.parameters['sledSizeInside']+2*this.requiredWallWidth - this.parameters['guiderodDiameter'];
this.sledRealSizeY = this.parameters['sledSizeInside']+2*this.requiredWallWidth - this.parameters['guiderodDiameter'];
let minRequiredSize = 2 * this.knownClamp.getClampSizeX() + this.knownClampNut.getHeight()*1.5;
if(this.sledRealSizeX < minRequiredSize) { this.sledRealSizeX = minRequiredSize; }
if(this.sledRealSizeY < minRequiredSize) { this.sledRealSizeY = minRequiredSize; }
if(this.parameters['sledSizeOutsideMin'] > this.sledRealSizeX) { this.sledRealSizeX = this.parameters['sledSizeOutsideMin']; this.requiredWallWidth = (this.sledRealSizeX - this.parameters['sledSizeInside'])/2; }
if(this.parameters['sledSizeOutsideMin'] > this.sledRealSizeY) { this.sledRealSizeY = this.parameters['sledSizeOutsideMin']; this.requiredWallWidth = (this.sledRealSizeY - this.parameters['sledSizeInside'])/2; }
this.insideSizeX = this.sledRealSizeX - (this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + this.parameters['minWallThickness']);
this.insideSizeY = this.sledRealSizeY - (this.knownClamp.getClampSizeX()/2 + Math.max(this.parameters['guiderodDiameter']/2, this.bearing.getOutsideDiameter()/2) + this.parameters['minWallThickness']);
this.rawPrinterObject = printer;
this.getModel = function() {
let sledSizeX = this.sledRealSizeX; // (this.bearing.getOutsideDiameter() + 2*this.parameters['minWallThickness']) * 2;
let sledSizeY = Math.max(this.knownClamp.getClampSizeX(), this.requiredWallWidth, 36); // 36 is the width of the anti backlash nut on top ... change or remove in case another mechanism is used
let sledDYByScrew = (Math.max(0, this.requiredWallWidth-this.knownClamp.getClampSizeX()))/2;
let sledSizeZ =2 * this.knownClamp.getClampSizeY();
let axis2Height = this.knownClamp.getClampSizeY();
let sled = {};
let nonprinted = {};
let motedisDelrinNut = new window.jscad.tspi.motedis.delrinTR8x1_5Template(this.rawPrinterObject,{});
let motedisDelrinNutPressfitFixtureM5Nut = new window.jscad.tspi.isoNut(this.rawPrinterObject, { m : 5 });
// let motedisDelrinNutPressfitFixtureM5Screw = window.jscad.tspi.iso4762Screw(this.rawPrinterObject, { m : 5, l : 20 });
if(!this.parameters['sledCarriageType']) {
sled = cube({ size : [ sledSizeX, sledSizeY, sledSizeZ/2 ] }).translate([0,0,sledSizeZ/2]);
sled = union(
sled,
this.knownClamp.getModel().rotateX(90).translate([this.knownClamp.getClampSizeX()/2+sledDYByScrew,this.knownClamp.getClampThickness(),this.knownClamp.getOffsetBelowRod()]),
this.knownClamp.getModel().rotateX(90).rotateZ(180).translate([-sledDYByScrew-this.knownClamp.getClampSizeX()/2+sledSizeX,0,this.knownClamp.getOffsetBelowRod()])
);
sled = difference(
sled,
cylinder({ d : this.parameters['guiderodDiameter']+this.parameters['spacingThroughHole'], h : sledSizeX, center : true }).translate([-this.knownClamp.getClampSizeY()-this.knownClamp.getOffsetBelowRod()-this.parameters['guiderodDiameter']/2, this.knownClamp.getClampSizeX()/2 + sledDYByScrew, sledSizeX/2]).rotateY(90)
);
sled = difference(
sled,
union(
this.bearing.getTemplate().scale(this.printer['lm8uuInsertDiameterScale']).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([0,sledDYByScrew,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getTemplate().scale(this.printer['lm8uuInsertDiameterScale']).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([sledSizeX-this.bearing.getLength(),sledDYByScrew,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
)
);
let grubScrewOffset = (this.bearing.getLength() - this.bearing.getGrooveDistance() + this.bearing.getGrooveDepth())/2;
let grubScrewRealLen = this.knownGrubScrew.l + this.knownGrubScrew.k;
sled = difference(
sled,
union(
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset,grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset,grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
)
);
let grubScrewNutCutDiameter = this.knownGrubNut.getHeight()*1.2;
let grubScrewNutCutDepth = this.knownClamp.getClampSizeY() - this.knownClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter']/2 + this.knownGrubNut.getRadiusOutside();
let grubScrewNutCutWidth = this.knownGrubNut.getRadiusOutside()*2;
/* sled = difference(
sled,
union(
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([grubScrewOffset,grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2 + sledSizeZ - grubScrewNutCutDepth]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2 + sledSizeZ - grubScrewNutCutDepth]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([sledSizeX-grubScrewOffset,grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2 + sledSizeZ - grubScrewNutCutDepth]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2 + sledSizeZ - grubScrewNutCutDepth])
)
); */
nonprinted = union(
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset,grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset,grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getModel().translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([0,sledDYByScrew,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getModel().translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([sledSizeX-this.bearing.getLength(),sledDYByScrew,this.knownClamp.getClampSizeY()+this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
);
nonprinted = union(
nonprinted,
motedisDelrinNut.getModel().rotateZ(90).translate([sledSizeX/2,+36/2,sledSizeZ + 15])
// motedisDelrinNutPressfitFixtureM5Screw.getTemplate().translate([sledSizeX/2+8.25,8,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2]),
// motedisDelrinNutPressfitFixtureM5Screw.getTemplate().translate([sledSizeX/2+8.25,28,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2])
);
sled = union(
sled,
cube({ size : [36, sledSizeY, 15], center : true }).translate([sledSizeX/2,+36/2,sledSizeZ + 15/2])
);
sled = difference(
sled,
union(
motedisDelrinNutPressfitFixtureM5Nut.getModel().scale([1,1,1.5]).translate([sledSizeX/2-8.25,8,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2+15]),
motedisDelrinNutPressfitFixtureM5Nut.getModel().scale([1,1,1.5]).translate([sledSizeX/2-8.25,28,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2+15]),
cylinder({ d : 5.8, h : motedisDelrinNutPressfitFixtureM5Nut.getHeight(), center : true }).translate([sledSizeX/2-8.25,8,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2+15]),
cylinder({ d : 5.8, h : motedisDelrinNutPressfitFixtureM5Nut.getHeight(), center : true }).translate([sledSizeX/2-8.25,28,sledSizeZ - motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2+15])
)
);
} else {
sled = cube({ size : [ sledSizeX, sledSizeY, sledSizeZ/2 ] }).translate([0,0,0]);
sled = union(
sled,
this.knownClamp.getModel().rotateX(90).translate([this.knownClamp.getClampSizeX()/2+sledDYByScrew,this.knownClamp.getClampThickness(),this.knownClamp.getOffsetBelowRod()+sledSizeZ/2]),
this.knownClamp.getModel().rotateX(90).rotateZ(180).translate([-sledDYByScrew-this.knownClamp.getClampSizeX()/2+sledSizeX,0,this.knownClamp.getOffsetBelowRod()+sledSizeZ/2])
);
sled = difference(
sled,
cylinder({ d : this.parameters['guiderodDiameter']+this.parameters['spacingThroughHole'], h : sledSizeX, center : true }).translate([-this.knownClamp.getOffsetBelowRod()-this.parameters['guiderodDiameter']/2, this.knownClamp.getClampSizeX()/2 + sledDYByScrew, sledSizeX/2]).rotateY(90)
);
sled = difference(
sled,
union(
this.bearing.getTemplate().scale(this.printer['lm8uuInsertDiameterScale']).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([0,sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getTemplate().scale(this.printer['lm8uuInsertDiameterScale']).translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([sledSizeX-this.bearing.getLength(),sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
)
);
let grubScrewOffset = (this.bearing.getLength() - this.bearing.getGrooveDistance() + this.bearing.getGrooveDepth())/2;
let grubScrewRealLen = this.knownGrubScrew.l + this.knownGrubScrew.k;
sled = difference(
sled,
union(
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset,grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset,grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
)
);
let grubScrewNutCutDiameter = this.knownGrubNut.getHeight()*1.2;
let grubScrewNutCutDepth = this.knownClamp.getClampSizeY() - this.knownClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter']/2 + this.knownGrubNut.getRadiusOutside();
let grubScrewNutCutWidth = this.knownGrubNut.getRadiusOutside()*2;
/* sled = difference(
sled,
union(
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([grubScrewOffset,grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([sledSizeX-grubScrewOffset,grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2]),
cube({ size : [grubScrewNutCutWidth, grubScrewNutCutDiameter, grubScrewNutCutDepth], center: true}).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewNutCutDiameter/2+this.parameters['minWallThickness']+this.knownGrubScrew.k, grubScrewNutCutDepth/2])
)
); */
sled = union(
sled,
cube({ size : [36, sledSizeY, 15], center : true }).translate([sledSizeX/2,+36/2,-15/2])
);
sled = difference(
sled,
union(
motedisDelrinNutPressfitFixtureM5Nut.getModel().scale([1,1,1.5]).translate([sledSizeX/2-8.25,8,motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2-15]),
motedisDelrinNutPressfitFixtureM5Nut.getModel().scale([1,1,1.5]).translate([sledSizeX/2-8.25,28,motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2-15]),
cylinder({ d : 5.8, h : 2*motedisDelrinNutPressfitFixtureM5Nut.getHeight(), center : true }).translate([sledSizeX/2-8.25,8,motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2-15]),
cylinder({ d : 5.8, h : 2*motedisDelrinNutPressfitFixtureM5Nut.getHeight(), center : true }).translate([sledSizeX/2-8.25,28,motedisDelrinNutPressfitFixtureM5Nut.getHeight()/2-15])
)
);
nonprinted = union(
motedisDelrinNut.getModel().rotateZ(90).translate([sledSizeX/2,+36/2,-15-13]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset,grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([grubScrewOffset+this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset,grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.knownGrubScrew.getTemplate().rotateX(90).translate([sledSizeX-grubScrewOffset-this.bearing.getGrooveDistance(),grubScrewRealLen,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getModel().translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([0,sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2]),
this.bearing.getModel().translate([0,this.knownClamp.getClampSizeX()/2,this.bearing.getLength()/2]).rotateY(90).translate([sledSizeX-this.bearing.getLength(),sledDYByScrew,this.knownClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2])
);
}
if(!this.parameters['onlyPrintedPart']) {
sled = union(sled, nonprinted);
}
return sled;
}
}
/* START OF DEPENDENCIES */
/* Dependency for this specific model (ToDo: Move into local library ...) */
if(typeof window.jscad.tspi.miniecm.tool !== 'object') { window.jscad.tspi.miniecm.tool = new Object(); }
window.jscad.tspi.miniecm.tool.ztower01 = function(printer, params) {
let knownParameters = [
{ name: 'wireclampScrewM', type: 'number', default: 3 },
{ name: 'wireclampScrewLength', type: 'number', default: 6 },
{ name: 'wireclampWireDiameter', type: 'number', default: 2.4 },
{ name: 'wireclampExtendsBottom', type: 'number', default: 10 },
{ name: 'wireclampWireLength', type: 'number', default: 175 },
{ name: 'toolHeight', type: 'number', default: 50 },
{ name: 'onlyPrintedPart', type: 'boolean', default: false },
{ name: 'wireclampSlitWidth', type: 'number', default: 0 },
{ name: 'wireclampMinWallThickness', type: 'number', default: 1 },
{ name: 'guiderodClampM', type: 'number', default: 6 },
{ name: 'guiderodClampScrewLength', type: 'number', default: 16 },
{ name: 'lm8uuGrubScrewM', type: 'number', default: 3 },
{ name: 'lm8uuGrubScrewLength', type: 'number', default: 6 },
{ name: 'guiderodClampMinWall', type: 'number', default: 2 },
{ name: 'minWallThickness', type: 'number', default: 1 },
{ name: 'bedmountScrewM', type: 'number', default: 6 },
{ name: 'bedmountScrewLength', type: 'number', default: 16 },
{ name: 'leadscrewDiameter', type: 'number', default: 8 },
{ name: 'leadscrewBearingOD', type: 'number', default: 22 },
{ name: 'leadscrewBearingH', type: 'number', default: 7 },
{ name: 'stepperZLength', type: 'number', default: 30 },
{ name: 'stepperCouplerH', type: 'number', default: 25 },
{ name: 'stepperCouplerD', type: 'number', default: 19 },
{ name: 'lowerBallDiameter', type: 'number', default: 3 },
{ name: 'toolmountScrewM', type: 'number', default: 6 },
{ name: 'toolmountScrewLength', type: 'number', default: 16 },
{ name: 'zDistance', type: 'number', default: 60 },
{ name: 'zTowerLayerHeight', type: 'number', default: 5 },
{ name: 'zTowerWidthOutsideMin', type: 'number', default: 0 },
{ name: 'zTowerDepthOutsideMin', type: 'number', default: 0 },
{ name: 'sacrificialBridgeSize', type: 'number', default: 0.14 },
{ name: 'displayMountPlate', type: 'boolean', default: false },
];
let knownPrinterParameters = [
{ name: 'scale', type: 'number', default: 1 },
{ name: 'correctionInsideDiameter', type: 'number', default: 0 },
{ name: 'correctionOutsideDiameter', type: 'number', default: 0 },
{ name: 'resolutionCircle', type: 'number', default: 360 },
{ name: 'guiderodClampDiaCorrection', type: 'number', default: 0.1 },
{ name: 'lm8uuInsertDiameterScale', type: 'number', default: 1.05 },
];
this.rawprinter = printer;
this.parameters = { };
this.printer = { };
this.error = false;
for(var i = 0; i < knownParameters.length; i++) {
if(typeof(params[knownParameters[i].name]) === knownParameters[i].type) {
this.parameters[knownParameters[i].name] = params[knownParameters[i].name];
} else if(knownParameters[i].default != -1) {
this.parameters[knownParameters[i].name] = knownParameters[i].default;
} else {
this.error = true;
}
}
for(i = 0; i < knownPrinterParameters.length; i++) {
if(typeof(printer[knownPrinterParameters[i].name]) === knownPrinterParameters[i].type) {
this.printer[knownPrinterParameters[i].name] = printer[knownPrinterParameters[i].name];
} else if(knownPrinterParameters[i].default != -1) {
this.printer[knownPrinterParameters[i].name] = knownPrinterParameters[i].default;
} else {
this.error = true;
}
}
this.rawprinter = printer;
this.parameters['guiderodDiameter'] = 8+this.printer['guiderodClampDiaCorrection']; /* Fixed since we use LM8UU bearings */
this.guiderodClamp = new window.jscad.tspi.mechanics.basicScrewclamp(printer, { m : this.parameters['guiderodClampM'], screwLength : this.parameters['guiderodClampScrewLength'], rodDiameter : this.parameters['guiderodDiameter'], onlyPrintedPart : this.parameters['onlyPrintedPart'], minWallThickness : this.parameters['guiderodClampMinWall']});
this.stepper = new window.jscad.tspi.mechanics.stepperNEMA17(printer, { length: this.parameters['stepperZLength'] });
this.ballbearingAxial = difference(cylinder({d : this.parameters['leadscrewBearingOD'], h : this.parameters['leadscrewBearingH'], center : true}), cylinder({d : this.parameters['leadscrewDiameter'], h : this.parameters['leadscrewBearingH'], center : true})).translate([0,0,this.parameters['leadscrewBearingH']/2]).setColor([1,0,0]);
let zHeight = 2 * this.parameters['zDistance'];
this.zTowerHeight_MotorPosition = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] + zHeight + Math.max(3 + this.parameters['leadscrewBearingH'], this.parameters['zTowerLayerHeight']) + this.parameters['stepperCouplerH'] + 2 + this.parameters['zTowerLayerHeight'];
this.zTowerHeight_Level3Position = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] + zHeight + Math.max(3 + this.parameters['leadscrewBearingH'], this.parameters['zTowerLayerHeight']) + this.parameters['stepperCouplerH'] + 2;
this.zTowerHeight_CouplerPosition = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] + zHeight + Math.max(3 + this.parameters['leadscrewBearingH'], this.parameters['zTowerLayerHeight']) + 1;
this.zTowerHeight_UpperBearingPosition = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] + zHeight + Math.max(3 + this.parameters['leadscrewBearingH'], this.parameters['zTowerLayerHeight']) - this.parameters['leadscrewBearingH'];
this.zTowerHeight_Level2Position = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] + zHeight;
this.zTowerHeight_LowerBearingPosition = this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'];
this.zTowerHeight_LowerBallPosition = this.parameters['zTowerLayerHeight'];
this.leadscrewLength = (this.zTowerHeight_CouplerPosition - this.zTowerHeight_LowerBearingPosition) + (this.parameters['stepperCouplerH'] / 2);
this.towerOutsideWidth = Math.max(this.parameters['zTowerWidthOutsideMin'], 42.3-10 + 2*this.guiderodClamp.getClampSizeY());
this.towerOutsideDepth = Math.max(this.parameters['zTowerDepthOutsideMin'], 42.3, this.guiderodClamp.getClampSizeX());
this.linearBearing = new window.jscad.tspi.mechanics.bearings.LM8UU(printer, {});
this.stepperMountScrew = new window.jscad.tspi.iso4762Screw(printer, { m : 3, l : 25 });
this.towerMountScrew = new window.jscad.tspi.iso4762Screw(printer, { m : this.parameters['bedmountScrewM'], l : this.parameters['bedmountScrewLength'] });
this.getModel = function() {
let nonPrintable = union(
this.stepper.getModel().rotateX(180).scale(this.printer['lm8uuInsertDiameterScale']).translate([0,0,this.zTowerHeight_MotorPosition]),
cylinder({ d : this.parameters['stepperCouplerD'], h : this.parameters['stepperCouplerH'], center : true }).translate([0,0,this.zTowerHeight_CouplerPosition + this.parameters['stepperCouplerH']/2]).setColor([0,1,0]),
cylinder({ d : this.parameters['leadscrewDiameter']+2, h : this.leadscrewLength, center : true}).translate([0,0,this.leadscrewLength/2 + this.zTowerHeight_LowerBearingPosition]).setColor([0,1,0]),
this.ballbearingAxial.scale(this.printer['lm8uuInsertDiameterScale']).translate([0,0,this.zTowerHeight_UpperBearingPosition]),
this.ballbearingAxial.scale(this.printer['lm8uuInsertDiameterScale']).translate([0,0,this.zTowerHeight_LowerBearingPosition]),
sphere({ r : this.parameters['lowerBallDiameter']/2, center : true }).translate([0,0,this.parameters['lowerBallDiameter']/2+this.zTowerHeight_LowerBallPosition]).setColor([1,0,0]),
cylinder({ d : this.parameters['guiderodDiameter']+0.5, h : this.zTowerHeight_MotorPosition-this.parameters['guiderodClampMinWall'], center : true, fn: this.printer['resolutionCircle'] }).translate([0,(this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod(),this.zTowerHeight_MotorPosition/2 + this.parameters['guiderodClampMinWall']]).setColor([1,0,0]),
cylinder({ d : this.parameters['guiderodDiameter']+0.5, h : this.zTowerHeight_MotorPosition-this.parameters['guiderodClampMinWall'], center : true, fn: this.printer['resolutionCircle'] }).translate([0,-(this.towerOutsideWidth/2)+this.guiderodClamp.getOffsetBelowRod(),this.zTowerHeight_MotorPosition/2 + this.parameters['guiderodClampMinWall']]).setColor([1,0,0]),
this.stepperMountScrew.getTemplate().rotateX(180).translate([15.5, 15.5, this.zTowerHeight_Level3Position+this.stepperMountScrew.l]),
this.stepperMountScrew.getTemplate().rotateX(180).translate([15.5, -15.5, this.zTowerHeight_Level3Position+this.stepperMountScrew.l]),
this.stepperMountScrew.getTemplate().rotateX(180).translate([-15.5, 15.5, this.zTowerHeight_Level3Position+this.stepperMountScrew.l]),
this.stepperMountScrew.getTemplate().rotateX(180).translate([-15.5, -15.5, this.zTowerHeight_Level3Position+this.stepperMountScrew.l]),
this.towerMountScrew.getTemplate().translate([0, ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter'] - this.parameters['leadscrewBearingOD']/2)/2 + this.parameters['leadscrewBearingOD']/2, this.zTowerHeight_LowerBearingPosition + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k]),
this.towerMountScrew.getTemplate().translate([0, -(((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter'] - this.parameters['leadscrewBearingOD']/2)/2 + this.parameters['leadscrewBearingOD']/2), this.zTowerHeight_LowerBearingPosition + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k])
);
let wallwidth = this.parameters['zTowerLayerHeight'];
let middleCutFront = (this.towerOutsideDepth - Math.max(this.parameters['leadscrewBearingOD']+2*this.parameters['guiderodClampMinWall'], this.guiderodClamp.getClampSizeX()))/2;
let insideSizeHalf = ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() + this.linearBearing.getOutsideDiameter()/2 + this.parameters['guiderodClampMinWall'] + 1);
let printables = union(
cube({ size : [this.towerOutsideDepth, 2*insideSizeHalf, this.parameters['zTowerLayerHeight']], center : true }).translate([0,0,this.parameters['zTowerLayerHeight']/2 + this.zTowerHeight_Level3Position]),
cube({ size : [this.towerOutsideDepth-middleCutFront, 2*insideSizeHalf, this.parameters['zTowerLayerHeight']], center : true }).translate([middleCutFront/2,0,this.parameters['zTowerLayerHeight']/2 + this.zTowerHeight_Level2Position]),
cube({ size : [this.towerOutsideDepth, 2*insideSizeHalf, this.parameters['zTowerLayerHeight']+this.parameters['lowerBallDiameter']+this.parameters['leadscrewBearingH']], center : true }).translate([0,0,(this.parameters['zTowerLayerHeight']+this.parameters['lowerBallDiameter']+this.parameters['leadscrewBearingH'])/2]),
this.guiderodClamp.getModel().rotateZ(-90).mirroredY().translate([0, (this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod(), this.zTowerHeight_Level2Position+this.parameters['zTowerLayerHeight']]),
this.guiderodClamp.getModel().rotateZ(-90).translate([0, -((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod()), this.zTowerHeight_Level2Position+this.parameters['zTowerLayerHeight']]),
cube({ size : [this.towerOutsideDepth/2-this.guiderodClamp.getClampSizeY()+this.guiderodClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2, this.guiderodClamp.getClampSizeX(), this.guiderodClamp.getClampThickness()]}).translate([0,0,this.zTowerHeight_Level2Position+this.parameters['zTowerLayerHeight']]).translate([this.guiderodClamp.getClampSizeY()/2 + this.parameters['guiderodDiameter']/2, insideSizeHalf-this.guiderodClamp.getClampSizeX(), 0]),
cube({ size : [this.towerOutsideDepth/2-this.guiderodClamp.getClampSizeY()+this.guiderodClamp.getOffsetBelowRod()+this.parameters['guiderodDiameter']/2, this.guiderodClamp.getClampSizeX(), this.guiderodClamp.getClampThickness()]}).translate([0,0,this.zTowerHeight_Level2Position+this.parameters['zTowerLayerHeight']]).translate([this.guiderodClamp.getClampSizeY()/2 + this.parameters['guiderodDiameter']/2, -insideSizeHalf, 0]),
cube({ size : [wallwidth, 2*insideSizeHalf+2*wallwidth, this.zTowerHeight_MotorPosition], center : true }).translate([this.towerOutsideDepth/2+wallwidth/2, 0, this.zTowerHeight_MotorPosition/2]),
cube({ size : [this.towerOutsideDepth, wallwidth, this.zTowerHeight_MotorPosition], center : true}).translate([0, insideSizeHalf+wallwidth/2, this.zTowerHeight_MotorPosition/2]),
cube({ size : [this.towerOutsideDepth, wallwidth, this.zTowerHeight_MotorPosition], center : true}).translate([0, -insideSizeHalf-wallwidth/2, this.zTowerHeight_MotorPosition/2])
);
printables = difference(
printables,
union(
nonPrintable,
cylinder({ d : 12, h : this.parameters['zTowerLayerHeight'], center : true}).translate([0,0,this.parameters['zTowerLayerHeight']/2 + this.zTowerHeight_Level3Position])
)
);
/*
let mountplateThickness = this.parameters['zTowerLayerHeight'];
let mountplate = difference(
cube({ size : [this.towerOutsideDepth, 2*insideSizeHalf, mountplateThickness], center : true}).translate([0,0,-mountplateThickness/2]),
union(
this.towerMountScrew.getTemplate().translate([0, ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter'] - this.parameters['leadscrewBearingOD']/2)/2 + this.parameters['leadscrewBearingOD']/2, this.zTowerHeight_LowerBearingPosition + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k]),
this.towerMountScrew.getTemplate().translate([0, -(((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter'] - this.parameters['leadscrewBearingOD']/2)/2 + this.parameters['leadscrewBearingOD']/2), this.zTowerHeight_LowerBearingPosition + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k])
)
);
*/
/* Add sacrificial bridges */
printables = union(
printables,
cube({ size : [this.towerOutsideDepth, 2*insideSizeHalf, this.parameters['sacrificialBridgeSize']], center : true }).translate([0,0,this.parameters['sacrificialBridgeSize']/2 + this.zTowerHeight_Level3Position]).setColor([0,0,0]),
cube({ size : [this.towerOutsideDepth-middleCutFront, 2*insideSizeHalf, this.parameters['sacrificialBridgeSize']], center : true }).translate([middleCutFront/2,0,this.parameters['sacrificialBridgeSize']/2 + this.zTowerHeight_Level2Position]).setColor([0,0,0])
);
// Holes for inductive / capacitive sensors
printables = difference(
union(
printables,
cube({ size : [this.towerOutsideDepth+wallwidth, 1, 20], center : true}).translate([wallwidth/2, insideSizeHalf+wallwidth+1/2+5, this.zTowerHeight_Level2Position-this.parameters['zTowerLayerHeight']-20/2]),
// cube({ size : [5, 5, 20], center : true}).translate([-this.towerOutsideDepth/2+5/2, insideSizeHalf+wallwidth+5/2, this.zTowerHeight_Level2Position-this.parameters['zTowerLayerHeight']-20/2]),
// cube({ size : [5, 5, 20], center : true}).translate([this.towerOutsideDepth/2-5/2+wallwidth, insideSizeHalf+wallwidth+5/2, this.zTowerHeight_Level2Position-this.parameters['zTowerLayerHeight']-20/2]),
cube({ size : [this.towerOutsideDepth+wallwidth, 1, 20], center : true}).translate([wallwidth/2, insideSizeHalf+wallwidth+1/2+5, this.zTowerHeight_LowerBearingPosition+this.parameters['leadscrewBearingH']+20/2]),
// cube({ size : [5, 5, 20], center : true}).translate([-this.towerOutsideDepth/2+5/2, insideSizeHalf+wallwidth+5/2, this.zTowerHeight_LowerBearingPosition+this.parameters['leadscrewBearingH']+20/2]),
// cube({ size : [5, 5, 20], center : true}).translate([this.towerOutsideDepth/2-5/2+wallwidth, insideSizeHalf+wallwidth+5/2, this.zTowerHeight_LowerBearingPosition+this.parameters['leadscrewBearingH']+20/2])
cube({ size : [5, 5+1, this.zTowerHeight_MotorPosition], center : true}).translate([-this.towerOutsideDepth/2+5/2, insideSizeHalf+wallwidth+5/2+0.5, this.zTowerHeight_MotorPosition/2]),
cube({ size : [5, 5+1, this.zTowerHeight_MotorPosition], center : true}).translate([this.towerOutsideDepth/2-5/2+wallwidth, insideSizeHalf+wallwidth+5/2+0.5, this.zTowerHeight_MotorPosition/2])
),
union(
cylinder({ d : 13, h : wallwidth, center : true}).rotateX(90).translate([0, insideSizeHalf+wallwidth/2, this.zTowerHeight_Level2Position-this.parameters['zTowerLayerHeight']-20/2]),
cylinder({ d : 13, h : wallwidth, center : true}).rotateX(90).translate([0, insideSizeHalf+wallwidth/2+5+1, this.zTowerHeight_Level2Position-this.parameters['zTowerLayerHeight']-20/2]),
cylinder({ d : 13, h : wallwidth, center : true}).rotateX(90).translate([0, insideSizeHalf+wallwidth/2, this.zTowerHeight_LowerBearingPosition+this.parameters['leadscrewBearingH']+20/2]),
cylinder({ d : 13, h : wallwidth, center : true}).rotateX(90).translate([0, insideSizeHalf+wallwidth/2+5+1, this.zTowerHeight_LowerBearingPosition+this.parameters['leadscrewBearingH']+20/2])
)
);
// alert("Axis distance (from center): "+()+", Dimensions: "+(this.towerOutsideWidth+2*wallwidth)+"x"+(this.towerOutsideDepth+wallwidth)+"x"+this.zTowerHeight_MotorPosition);
//printables = union(printables, mountplate);
if(this.parameters['onlyPrintedPart']) {
return printables;
} else {
return union(nonPrintable, printables);
}
}
this.getGuiderailDistance = function() { return (this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod(); }
this.getDimensionXReal = function() {
let wallwidth = this.parameters['zTowerLayerHeight'];
let insideSizeHalf = ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() + this.linearBearing.getOutsideDiameter()/2 + this.parameters['guiderodClampMinWall'] + 1);
return 2*insideSizeHalf+2*wallwidth+5+1;
}
this.getDimensionYReal = function() {
let wallwidth = this.parameters['zTowerLayerHeight'];
let insideSizeHalf = ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() + this.linearBearing.getOutsideDiameter()/2 + this.parameters['guiderodClampMinWall'] + 1);
return this.towerOutsideDepth+1*wallwidth;
}
this.getDimensionXRealAsymmetry = function() {
return 3;
}
this.getDimensionYRealAsymmetry = function() {
return this.parameters['zTowerLayerHeight'] / 2;
}
this.getBedMountScrewOffsetY = function() {
return ((this.towerOutsideWidth/2)-this.guiderodClamp.getOffsetBelowRod() - this.parameters['guiderodDiameter'] - this.parameters['leadscrewBearingOD']/2)/2 + this.parameters['leadscrewBearingOD']/2;
};
}
window.jscad.tspi.miniecm.tool.mountplate = function(printer, params) {
let knownParameters = [
{ name: 'wireclampScrewM', type: 'number', default: 3 },
{ name: 'wireclampScrewLength', type: 'number', default: 6 },
{ name: 'wireclampWireDiameter', type: 'number', default: 2.4 },
{ name: 'wireclampExtendsBottom', type: 'number', default: 10 },
{ name: 'wireclampWireLength', type: 'number', default: 175 },
{ name: 'toolHeight', type: 'number', default: 50 },
{ name: 'onlyPrintedPart', type: 'boolean', default: false },
{ name: 'wireclampSlitWidth', type: 'number', default: 0 },
{ name: 'wireclampMinWallThickness', type: 'number', default: 1 },
{ name: 'guiderodClampM', type: 'number', default: 6 },
{ name: 'guiderodClampScrewLength', type: 'number', default: 16 },
{ name: 'lm8uuGrubScrewM', type: 'number', default: 3 },
{ name: 'lm8uuGrubScrewLength', type: 'number', default: 6 },
{ name: 'guiderodClampMinWall', type: 'number', default: 2 },
{ name: 'minWallThickness', type: 'number', default: 1 },
{ name: 'bedmountScrewM', type: 'number', default: 6 },
{ name: 'bedmountScrewLength', type: 'number', default: 16 },
{ name: 'leadscrewDiameter', type: 'number', default: 8 },
{ name: 'leadscrewBearingOD', type: 'number', default: 22 },
{ name: 'leadscrewBearingH', type: 'number', default: 7 },
{ name: 'stepperZLength', type: 'number', default: 30 },
{ name: 'stepperCouplerH', type: 'number', default: 25 },
{ name: 'stepperCouplerD', type: 'number', default: 19 },
{ name: 'lowerBallDiameter', type: 'number', default: 3 },
{ name: 'toolmountScrewM', type: 'number', default: 6 },
{ name: 'toolmountScrewLength', type: 'number', default: 16 },
{ name: 'zDistance', type: 'number', default: 60 },
{ name: 'zTowerLayerHeight', type: 'number', default: 5 },
{ name: 'zTowerWidthOutsideMin', type: 'number', default: 0 },
{ name: 'zTowerDepthOutsideMin', type: 'number', default: 0 },
{ name: 'sacrificialBridgeSize', type: 'number', default: 0.14 },
{ name: 'displayMountPlate', type: 'boolean', default: false },
];
let knownPrinterParameters = [
{ name: 'scale', type: 'number', default: 1 },
{ name: 'correctionInsideDiameter', type: 'number', default: 0 },
{ name: 'correctionOutsideDiameter', type: 'number', default: 0 },
{ name: 'resolutionCircle', type: 'number', default: 360 },
{ name: 'guiderodClampDiaCorrection', type: 'number', default: 0.1 },
{ name: 'lm8uuInsertDiameterScale', type: 'number', default: 1.05 },
];
this.rawprinter = printer;
this.parameters = { };
this.printer = { };
this.error = false;
for(var i = 0; i < knownParameters.length; i++) {
if(typeof(params[knownParameters[i].name]) === knownParameters[i].type) {
this.parameters[knownParameters[i].name] = params[knownParameters[i].name];
} else if(knownParameters[i].default != -1) {
this.parameters[knownParameters[i].name] = knownParameters[i].default;
} else {
this.error = true;
}
}
for(i = 0; i < knownPrinterParameters.length; i++) {
if(typeof(printer[knownPrinterParameters[i].name]) === knownPrinterParameters[i].type) {
this.printer[knownPrinterParameters[i].name] = printer[knownPrinterParameters[i].name];
} else if(knownPrinterParameters[i].default != -1) {
this.printer[knownPrinterParameters[i].name] = knownPrinterParameters[i].default;
} else {
this.error = true;
}
}
this.rawprinter = printer;
this.parameters['onlyPrintedPart'] = false;
let tower = new window.jscad.tspi.miniecm.tool.ztower01(params, params);
/*
this.stepperMountScrew = new window.jscad.tspi.iso4762Screw(printer, { m : 3, l : 25 });
this.towerMountScrew = new window.jscad.tspi.iso4762Screw(printer, { m : this.parameters['bedmountScrewM'], l : this.parameters['bedmountScrewLength'] });
*/
this.toolmountNut = new window.jscad.tspi.isoNut(printer, { m : this.parameters['bedmountScrewM'] });
this.towerMountScrew = new window.jscad.tspi.iso4762Screw(printer, { m : this.parameters['bedmountScrewM'], l : this.parameters['bedmountScrewLength'] });
let towerMountScrewScaleZ = 1.2;
let screwPenetrationLength = - (this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k);
let mountplateOverlap = 5;
let mountplateThickness = screwPenetrationLength + mountplateOverlap;
let mountscrewWallThickness = screwPenetrationLength - this.toolmountNut.getHeight()*towerMountScrewScaleZ;
this.tower = tower;
let outsideWallWidth = 1;
this.mountplateSizeX = this.tower.getDimensionYReal()+2*outsideWallWidth;
this.mountplateSizeY = this.tower.getDimensionXReal()+2*outsideWallWidth;
this.mountplateAsymX = this.tower.getDimensionYRealAsymmetry();
this.mountplateAsymY = this.tower.getDimensionXRealAsymmetry();
this.getModel = function() {
let outsideWallWidth = 1;
let mountplate = difference(
cube({ size : [this.tower.getDimensionYReal()+2*outsideWallWidth, this.tower.getDimensionXReal()+2*outsideWallWidth, mountplateThickness], center : true}).translate([this.tower.getDimensionYRealAsymmetry(), this.tower.getDimensionXRealAsymmetry(), -mountplateThickness/2 + mountplateOverlap]),
tower.getModel().scale(1.01)
);
mountplate = difference(
mountplate,
this.toolmountNut.getModel().scale([1,1,towerMountScrewScaleZ]).translate([0, tower.getBedMountScrewOffsetY(), this.toolmountNut.getHeight()*towerMountScrewScaleZ/2-(mountplateThickness-mountplateOverlap)])
);
mountplate = difference(
mountplate,
this.toolmountNut.getModel().scale([1,1,towerMountScrewScaleZ]).translate([0, -tower.getBedMountScrewOffsetY(), this.toolmountNut.getHeight()*towerMountScrewScaleZ/2-(mountplateThickness-mountplateOverlap)])
);
// Cut slits to insert nuts from the side ...
mountplate = difference(
mountplate,
cube({ size : [(this.tower.getDimensionYReal()+2*outsideWallWidth)/2, this.toolmountNut.getRadiusInside(), this.toolmountNut.getHeight()*towerMountScrewScaleZ], center : true }).translate([(this.tower.getDimensionYReal()+2*outsideWallWidth)/4+this.tower.getDimensionYRealAsymmetry(), -tower.getBedMountScrewOffsetY(), this.toolmountNut.getHeight()*towerMountScrewScaleZ/2-(mountplateThickness-mountplateOverlap)]),
cube({ size : [(this.tower.getDimensionYReal()+2*outsideWallWidth)/2, this.toolmountNut.getRadiusInside(), this.toolmountNut.getHeight()*towerMountScrewScaleZ], center : true }).translate([(this.tower.getDimensionYReal()+2*outsideWallWidth)/4+this.tower.getDimensionYRealAsymmetry(), tower.getBedMountScrewOffsetY(), this.toolmountNut.getHeight()*towerMountScrewScaleZ/2-(mountplateThickness-mountplateOverlap)])
);
// Add a sacrificial bridge immediatly on top of the nut
mountplate = union(
mountplate,
cube({ size : [this.tower.getDimensionYReal()+2*outsideWallWidth, this.tower.getDimensionXReal()+2*outsideWallWidth, this.parameters['sacrificialBridgeSize']] , center : true }).translate([this.tower.getDimensionYRealAsymmetry(), this.tower.getDimensionXRealAsymmetry(),-mountscrewWallThickness + this.parameters['sacrificialBridgeSize']/2]).setColor([0,0,0])
)
return union(
mountplate
// this.towerMountScrew.getTemplate().translate([0,0,(this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k) + screwPenetrationLength])
// this.towerMountScrew.getTemplate().translate([0,tower.getBedMountScrewOffsetY(),(this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k)]),
// this.towerMountScrew.getTemplate().translate([0,-tower.getBedMountScrewOffsetY(),(this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k)])
);
}
this.getMountplateLowerZPosition = function() {
let screwPenetrationLength = - (this.parameters['zTowerLayerHeight'] + this.parameters['lowerBallDiameter'] + this.parameters['leadscrewBearingH'] - this.towerMountScrew.l - this.towerMountScrew.k);
return -screwPenetrationLength;
}
this.getMountplateWidth = function() {
return this.tower.getDimensionYReal()+2*outsideWallWidth;
}
this.getMountplateLength = function() {
return this.tower.getDimensionXReal()+2*outsideWallWidth;
}
}
/* END OF DEPENDENCIES */
function getParameterDefinitions() {
return [
{ name : 'grpSled', type : 'Group', caption : 'Sled' },
{ name : 'sledBearingsLong', type : 'checkbox', checked : false, caption: 'Use long bearings' },
{ name : 'sledCarriageType', type : 'checkbox', checked : false, caption: 'Type A/B' },
{ name : 'grpDisplay', type : 'Group', caption : 'Display' },
{ name : 'onlyPrintedPart', type : 'checkbox', checked : false, caption: 'Show only printed part' },
{ name : 'grpPrinter', type : 'Group', caption : 'Printer' },
{ name: 'resolutionCircle', type: 'float', initial: 32, caption: 'Circle resolution', min : 32 },
{ name: 'scale', type : 'float', initial : 1, caption : 'Scale' },
{ name: 'correctionInsideDiameter', type : 'float', initial : 0, caption : 'Inside diameter correction' },
{ name: 'correctionOutsideDiameter', type : 'float', initial : 0, caption : 'Outside diameter correction' }
];
}
function main(params) {
let mountplate = new window.jscad.tspi.miniecm.tool.mountplate(params, params);
params['sledSizeOutsideMin'] = Math.max(mountplate.getMountplateWidth(), mountplate.getMountplateLength());
params['sledSizeInside'] = 45;
let sled1 = (new window.jscad.tspi.miniecm.carriagexy(params, params)).getModel();
params['sledCarriageType'] = true;
let sled2 = (new window.jscad.tspi.miniecm.carriagexy(params, params)).getModel();
return (new window.jscad.tspi.miniecm.motormount(params, params)).getModel().translate([0,-10,0]);
return union(
/* sled1.rotateZ(90).scale([1.01083032491, 1.00214745884, 1]).translate([0,60,0]),
sled2.rotateZ(0).scale([1.01083032491, 1.00214745884, 1]).translate([-180,-15,0]), */
(new window.jscad.tspi.miniecm.motormount(params, params)).getModel().translate([0,-10,0])
// (new window.jscad.tspi.mechanics.aluprofile.b20x20n6({}, { l : 520 })).getTemplate().translate([-4.8+20, -30.1, 0]) // -36/2 - 42.3/2 - 2
);
}