forked from robertstarr/ulp_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-connector.ulp
1236 lines (1017 loc) · 36.9 KB
/
make-connector.ulp
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
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#usage "<b>Make Connector Symbols</b> - v1.03 (11/23/11)<p>"
"This ULP generates single and dual row header connector symbols "
"packages and devices for basic connectors."
"<p>"
"<author>http://www.bobstarr.net</author>";
//////////////////////////////////////////////////////////////////////////////
//
// MAKE CONNECTOR
//
// Copyright (C) 2009-2010, Robert E. Starr (http://www.bobstarr.net)
//
// REVISION HISTORY:
//
// v1.00 - 02/13/2010 (RES) - Initial Release
//
// v1.01 - 07/16/2010 (RES) - Added y-long option for single row packages
// and pad diameter option
//
// v1.02 - 03/04/2011 (RES) - Added dual row pin order option.
//
// v1.03 - 11/23/2011 (RES) - Add more package row ordering options
//
//////////////////////////////////////////////////////////////////////////////
//
// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESSED OR IMPLIED. IF YOU DON'T LIKE IT, DON'T USE IT!
//
//////////////////////////////////////////////////////////////////////////////
string Version = "1.03";
string fileName;
int fScriptExec = 1; // execute script automatically after generating
int fMaleFemale = 0; // 0=male, 1=female
int fSingleDual = 0; // 0=single row, 1=dual row
int fMultiple = 1; // 0=gen one connector, 1=gen range of connectors
int fValueOn = 0; // 0=dev value off, 1=value on
int fGenSymbols = 1; // 1=gen connector symbols
int fGenPackages = 1; // 1=gen connector packages
int fGenDevices = 1; // 1=gen connector devices
int fGenFullPins = 1; // 1=gen full pin versions of devices
int fGenSinglePins = 0; // 1=gen single pin versions of devices
int fLongPad = 1; // 1=y-long pads for single row packages
int fNamePosPerRow = 0; // 1=gen dev/pkg names as pos per row (div by 2)
// This flag specifies the pin ordering for dual row connectors as follows:
// 0 = left to right
// 1 = right to left
int fPadOrder = 0;
int fFlipRows = 0;
int nFirstPinCount = 2; // pin count in first connector
int nLastPinCount = 16; // pin count in last connector
int nPadType = 0; // 0=thru-hole, 1=SMD
real dPadPitch = 100.0; // 100 mil pitch
real dRowSpacing = 100.0; // spacing between rows for DIP
real dDrillSize = 40.0; // 40 mil drill
real dPadDiameter = 0.0; // pad diameter (0=auto)
real dSmdSizeX = 40;
real dSmdSizeY = 100;
string strPackagePrefix = "PAC-";
string strPackageSuffix = "";
string strDevicePrefix = "DEV-";
string strDeviceSuffix = "";
string strDeviceDesc = "FE";
string strSymbolPrefixMale = "MA";
string strSymbolPrefixFemale = "FE";
string ConfigFilePath;
string ConfigFileName = "make-connector.cfg";
// Package Grid Units
int nGridUnits = 1;
int nPrevUnits = 1;
string strGridUnits[] = { "MM", "MIL", "INCH" };
real MM_PER_INCH = 0.0393700787;
real INCHES_PER_MM = 25.40;
//////////////////////////////////////////////////////////////////////////////
// Create male/female PLUG/JACK symbols for single pin male/female
// variations of connectors.
void CreateSymbolsPJ()
{
printf("Grid mm;\n");
if (fMaleFemale==0) // MALE is a PLUG
{
printf("Edit 'P-NV.sym';\n");
printf("Change Style Continuous;\n");
printf("Set Wire_Bend 2;\n");
printf("Layer 94;\n");
printf("Wire 0.1524 (0 0) (1.905 0) 0.254 (0.9525 0.635);\n");
printf("Wire 0.254 (1.905 0) (0.9525 -0.635);\n");
printf("Pin 'P' Pas None Short R0 Off 0 (-2.54 0);\n");
printf("Layer 95;\n");
printf("Change Size 1.016;\n");
printf("Change Ratio 12;\n");
printf("Text '>NAME' MR0 (0.635 0.635);\n");
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' MR0 (2.54 2.54);\n");
printf("Layer 95;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>PART' MR0 (2.54 5.08);\n");
printf("Edit 'P-N.sym';\n");
printf("Layer 94;\n");
printf("Wire 0.1524 (0 0) (1.905 0) 0.254 (0.9525 0.635);\n");
printf("Wire 0.254 (1.905 0) (0.9525 -0.635);\n");
printf("Pin 'P' Pas None Short R0 Off 0 (-2.54 0);\n");
printf("Layer 95;\n");
printf("Change Size 1.016;\n");
printf("Change Ratio 12;\n");
printf("Text '>NAME' MR0 (0.635 0.635);\n");
}
else if (fMaleFemale==1) // FEMALE is a JACK
{
printf("Edit 'J-NV.sym';\n");
printf("Change Style Continuous;\n");
printf("Set Wire_Bend 2;\n");
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Wire 0.1524 (0 0) (-1.905 0) 0.254 (-2.8575 0.635);\n");
printf("Wire 0.254 (-1.905 0) (-2.8575 -0.635);\n");
printf("Pin 'J' Pas None Short R180 Off 0 (2.54 0);\n");
printf("Layer 95;\n");
printf("Change Size 1.016;\n");
printf("Change Ratio 12;\n");
printf("Change Font Proportional;\n");
printf("Text '>NAME' R0 (-1.905 0.635);\n");
printf("Layer 96;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>VALUE' R0 (-2.54 2.54);\n");
printf("Layer 95;\n");
printf("Change Size 1.778;\n");
printf("Change Ratio 12;\n");
printf("Text '>PART' R0 (-2.54 5.08);\n");
printf("Edit 'J-N.sym';\n");
printf("Layer 94;\n");
printf("Wire 0.1524 (0 0) (-1.905 0) 0.254 (-2.8575 0.635);\n");
printf("Wire 0.254 (-1.905 0) (-2.8575 -0.635);\n");
printf("Pin 'J' Pas None Short R180 Off 0 (2.54 0);\n");
printf("Layer 95;\n");
printf("Change Size 1.016;\n");
printf("Change Ratio 12;\n");
printf("Text '>NAME' R0 (-1.905 0.635);\n");
}
printf("Grid mil;\n\n");
}
//////////////////////////////////////////////////////////////////////////////
// Create a single row N x 1 connector header symbol
void CreateSymbolSIP(int nNumPins, int nStyle)
{
int i, pin;
real x, y;
real xStart, yStart;
if (nNumPins < 2)
{
dlgMessageBox("You must create at least 2 or more pins!", "OK");
return;
}
if (nNumPins > 2)
{
yStart = (nNumPins / 2) * 100.0;
yStart = (yStart / 100.0) * 100.0;
}
else
{
yStart = 0.0;
}
xStart = 0.0;
printf("GRID MIL;\n");
printf("EDIT '%s%2.2d-1.sym'\n", (nStyle) ? strSymbolPrefixFemale : strSymbolPrefixMale, nNumPins);
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Set Wire_Bend 2;\n");
for (i=0, y=yStart; i < nNumPins; i++)
{
pin = i+1;
// Add the symbol pin
printf("Pin '%d' Pas None Middle R0 Pad 1 (%.2f %.2f);\n", pin, xStart-200.0, y);
if (nStyle)
{
// Draw the female pin symbol
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart, y, xStart+50, y-25);
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart, y, xStart+50, y+25);
}
else
{
// Draw the male pin symbol
printf("Wire 24 (%.2f %.2f) (%.2f %.2f);\n", xStart+50.0, y, xStart, y);
}
y -= 100.0;
}
real yEnd = y + 100;
// Draw a frame around all symbol pins
printf("Layer 94;\n");
// top side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-50, yStart+100, xStart+150, yStart+100);
// left side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-50, yStart+100, xStart-50, yEnd-100);
// right side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart+150, yStart+100, xStart+150, yEnd-100);
// bottom side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-50, yEnd-100, xStart+150, yEnd-100);
// Add the NAME field
printf("Layer 95;\n");
printf("Change Size 70;\n");
printf("Change Ratio 8;\n");
printf("Text '>NAME' R0 (%.2f %.2f);\n", xStart-50, yStart+125);
printf("Layer 94;\n");
// Add the VALUE field
printf("Layer 95;\n");
printf("Change Size 70;\n");
printf("Change Ratio 8;\n");
printf("Text '>VALUE' R0 (%.2f %.2f);\n\n", xStart-50, yEnd-200);
}
//////////////////////////////////////////////////////////////////////////////
// Create a single row N x 2 connector header symbol
void CreateSymbolDIP(int nNumPins, int nStyle)
{
int i, pin;
real x, y;
real xStart, yStart;
// must be at least 2 pins and an even number of pins
if (nNumPins < 2)
{
dlgMessageBox("You must create at least 2 or more pins!", "OK");
return;
}
int nPositions;
nPositions = nNumPins / 2;
yStart = (nPositions / 2) * 100.0;
yStart = (yStart / 100.0) * 100.0;
xStart = 0.0;
printf("GRID MIL;\n");
printf("EDIT '%s%2.2d-2.sym'\n", (nStyle) ? strSymbolPrefixFemale : strSymbolPrefixMale, nPositions);
printf("Layer 94;\n");
printf("Change Style Continuous;\n");
printf("Set Wire_Bend 2;\n");
pin = 1;
for (i=0, y=yStart; i < nPositions; i++)
{
// Add the left side(odd) symbol pin
printf("Pin '%d' Pas None Middle R0 Pad 1 (%.2f %.2f);\n", pin, xStart-300.0, y);
++pin;
// Add the right side(even) symbol pin
printf("Pin '%d' Pas None Middle R180 Pad 1 (%.2f %.2f);\n", pin, xStart+300.0, y);
++pin;
if (nStyle)
{
// Draw the female pin symbol
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-100, y, xStart-50, y-25);
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-100, y, xStart-50, y+25);
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart+100, y, xStart+50, y-25);
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart+100, y, xStart+50, y+25);
}
else
{
// Draw the male pin symbol
printf("Wire 24 (%.2f %.2f) (%.2f %.2f);\n", xStart-100.0, y, xStart-50, y);
printf("Wire 24 (%.2f %.2f) (%.2f %.2f);\n", xStart+100.0, y, xStart+50, y);
}
y -= 100.0;
}
real yEnd = y + 100;
// Draw a frame around all symbol pins
printf("Layer 94;\n");
// top side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-150, yStart+100, xStart+150, yStart+100);
// left side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-150, yStart+100, xStart-150, yEnd-100);
// right side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart+150, yStart+100, xStart+150, yEnd-100);
// bottom side
printf("Wire 16 (%.2f %.2f) (%.2f %.2f);\n", xStart-150, yEnd-100, xStart+150, yEnd-100);
// Add the NAME field
printf("Layer 95;\n");
printf("Change Size 70;\n");
printf("Change Ratio 8;\n");
printf("Text '>NAME' R0 (%.2f %.2f);\n", xStart-150, yStart+125);
printf("Layer 94;\n");
// Add the VALUE field
printf("Layer 95;\n");
printf("Change Size 70;\n");
printf("Change Ratio 8;\n");
printf("Text '>VALUE' R0 (%.2f %.2f);\n\n", xStart-150, yEnd-200);
}
//////////////////////////////////////////////////////////////////////////////
// Create a single row N x 1 package
void CreatePackageSIP(int nNumPins)
{
int i, pin;
real x, xStart;
if (nNumPins < 2)
{
dlgMessageBox("You must create at least 2 or more pins!", "OK");
return;
}
real dPitch = dPadPitch;
if (nNumPins > 2)
{
xStart = (nNumPins / 2) * dPitch;
xStart = (xStart / dPitch) * dPitch;
if ((nNumPins % 2) == 0)
xStart = -(xStart - (dPitch/2.0));
else
xStart = -(xStart);
}
else
{
xStart = 0.0;
}
printf("EDIT '%s%2.2d%s.pac'\n", strPackagePrefix, nNumPins, strPackageSuffix);
printf("GRID %s %.4f ON;\n", strGridUnits[nGridUnits], dPitch/2);
if (fMaleFemale)
printf("Description '<b>RECEPTACAL</b>';\n"); // female
else
printf("Description '<b>HEADER</b>';\n"); // male
if (nPadType)
{
// SMD PAD
printf("Change SMD %.4fx%.4f;\n", dSmdSizeX, dSmdSizeY);
}
else
{
// Thru-Hole Pad
printf("Change Drill %.4f;\n", dDrillSize);
}
x = xStart;
// 0 = left-to-right, 1 = right-to-left
if (fPadOrder > 0)
x = -x;
for (i=0; i < nNumPins; i++)
{
pin = i+1;
if (nPadType)
printf("SMD %.4f %.4f -0 '%d' (%.4f 0);\n", dSmdSizeX, dSmdSizeY, pin, x);
else
{
if (fLongPad)
printf("Pad '%d' Long %f R90 (%.4f 0);\n", pin, dPadDiameter, x);
else
{
if (i > 0)
printf("Pad '%d' Octagon %f R90 (%.4f 0);\n", pin, dPadDiameter, x);
else
printf("Pad '%d' Square %f R90 (%.4f 0);\n", pin, dPadDiameter, x);
}
}
// 0 = left-to-right, 1 = right-to-left
if (fPadOrder > 0)
x -= dPadPitch;
else
x += dPadPitch;
}
real xEnd = x + dPadPitch;
// Add the NAME/VALUE text fields
real xText = xStart - (dPitch / 2.0);
real yText = dPitch;
printf("Layer 25;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 18;\n");
printf("GRID LAST\n");
printf("Change Font Proportional;\n");
printf("Text '>NAME' R0 (%.4f %.4f);\n", xText, yText);
printf("Layer 27;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 10;\n");
printf("GRID LAST\n");
printf("Text '>VALUE' R0 (%.4f %.4f);\n\n", xText, -(yText+dPitch/4));
}
//////////////////////////////////////////////////////////////////////////////
// Create a dual row N x 2 package (row by column)
void CreatePackageDIPxRowByCol(int nNumPins)
{
int i, pin;
int nPositions;
real x, y;
real xStart, yStart;
if (nNumPins < 2)
{
dlgMessageBox("You must create at least 2 or more pins!", "OK");
return;
}
real dPitch = dPadPitch; // pad pitch
real dSpace = dRowSpacing / 2.0; // spacing between rows
nPositions = nNumPins / 2;
xStart = (nPositions / 2) * dPitch;
xStart = (xStart / dPitch) * dPitch;
if ((nPositions % 2) == 0)
xStart = -(xStart - (dPitch/2.0));
else
xStart = -(xStart);
yStart = 0.0;
int nNameNum = (fNamePosPerRow) ? nNumPins / 2 : nNumPins;
printf("EDIT '%s%2.2d%s.pac'\n", strPackagePrefix, nNameNum, strPackageSuffix);
printf("GRID %s %.4f ON;\n", strGridUnits[nGridUnits], dPitch/2);
if (fMaleFemale)
printf("Description '<b>RECEPTACAL</b>';\n"); // female
else
printf("Description '<b>HEADER</b>';\n"); // male
if (nPadType)
{
// SMD PAD
printf("Change SMD %.4fx%.4f;\n", dSmdSizeX, dSmdSizeY);
}
else
{
// Thru-Hole Pad
printf("Change Drill %.4f;\n", dDrillSize);
}
y = yStart;
x = xStart;
pin = 1;
// 0 = left-to-right, 1 = right-to-left
if (fPadOrder > 0)
x = -x;
for (i=0; i < nPositions; i++)
{
real ypos = fFlipRows ? y + dSpace : y - dSpace;
if (nPadType)
{
printf("SMD %.4f %.4f -0 '%d' (%.4f %.4f);\n", dSmdSizeX, dSmdSizeY, pin, x, ypos);
}
else
{
if (i > 0)
printf("Pad '%d' Octagon %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, ypos);
else
printf("Pad '%d' Square %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, ypos);
}
++pin;
ypos = fFlipRows ? y - dSpace : y + dSpace;
if (nPadType)
printf("SMD %.4f %.4f -0 '%d' (%.4f %.4f);\n", dSmdSizeX, dSmdSizeY, pin, x, ypos);
else
printf("Pad '%d' Octagon %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, ypos);
++pin;
if (fPadOrder > 0) // 0 = left-to-right, 1 = right-to-left
x -= dPadPitch;
else
x += dPadPitch;
}
real xEnd = x + dPadPitch;
// Add the NAME/VALUE text fields
real xText = xStart - (dPitch / 2.0);
real yText = dSpace + (dSpace / 2);
printf("Layer 25;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 18;\n");
printf("GRID LAST\n");
printf("Change Font Proportional;\n");
printf("Text '>NAME' R0 (%.4f %.4f);\n", xText, yText);
printf("Layer 27;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 10;\n");
printf("GRID LAST\n");
printf("Text '>VALUE' R0 (%.4f %.4f);\n\n", xText, -((yText+dPitch/4)));
}
// Create DIP package row by row (right to left)
void CreatePackageDIPxRowByRow(int nNumPins)
{
int i, pin;
int nPositions;
real x, y;
real xStart, yStart;
if (nNumPins < 2)
{
dlgMessageBox("You must create at least 2 or more pins!", "OK");
return;
}
real dPitch = dPadPitch; // pad pitch
real dSpace = dRowSpacing / 2.0; // spacing between rows
nPositions = nNumPins / 2;
xStart = (nPositions / 2) * dPitch;
xStart = (xStart / dPitch) * dPitch;
if ((nPositions % 2) == 0)
xStart = -(xStart - (dPitch/2.0));
else
xStart = -(xStart);
int nNameNum = (fNamePosPerRow) ? nNumPins / 2 : nNumPins;
printf("EDIT '%s%2.2d%s.pac'\n", strPackagePrefix, nNameNum, strPackageSuffix);
printf("GRID %s %.4f ON;\n", strGridUnits[nGridUnits], dPitch/2);
if (fMaleFemale)
printf("Description '<b>RECEPTACAL</b>';\n"); // female
else
printf("Description '<b>HEADER</b>';\n"); // male
if (nPadType)
{
// SMD PAD
printf("Change SMD %.4fx%.4f;\n", dSmdSizeX, dSmdSizeY);
}
else
{
// Thru-Hole Pad
printf("Change Drill %.4f;\n", dDrillSize);
}
pin = nNumPins;
yStart = 0.0;
y = yStart;
x = xStart;
// Add first row of pins
for (i=0; i < nPositions; i++)
{
if (fFlipRows)
dSpace = -dSpace;
if (nPadType)
{
printf("SMD %.4f %.4f -0 '%d' (%.4f %.4f);\n", dSmdSizeX, dSmdSizeY, pin, x, y+dSpace);
}
else
{
printf("Pad '%d' Octagon %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, y+dSpace);
}
--pin;
x += dPadPitch;
}
// Add second row of pins
x = xStart;
for (i=0; i < nPositions; i++)
{
if (fFlipRows)
dSpace = -dSpace;
if (nPadType)
{
printf("SMD %.4f %.4f -0 '%d' (%.4f %.4f);\n", dSmdSizeX, dSmdSizeY, pin, x, y-dSpace);
}
else
{
if (pin == 1)
printf("Pad '%d' Square %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, y-dSpace);
else
printf("Pad '%d' Octagon %f R90 (%.4f %.4f);\n", pin, dPadDiameter, x, y-dSpace);
}
--pin;
x += dPadPitch;
}
real xEnd = x + dPadPitch;
// Add the NAME/VALUE text fields
real xText = xStart - (dPitch / 2.0);
real yText = dSpace + (dSpace / 2);
printf("Layer 25;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 18;\n");
printf("GRID LAST\n");
printf("Change Font Proportional;\n");
printf("Text '>NAME' R0 (%.4f %.4f);\n", xText, yText);
printf("Layer 27;\n");
printf("GRID MIL\n");
printf("Change Size 40;\n");
printf("Change Ratio 10;\n");
printf("GRID LAST\n");
printf("Text '>VALUE' R0 (%.4f %.4f);\n\n", xText, -((yText+dPitch/4)));
}
//////////////////////////////////////////////////////////////////////////////
// Create a device from existing package and symbol.
void CreateStandardDevice(int nNumPins)
{
int i;
string strPrefix = (fMaleFemale) ? "J" : "P";
int nNameNum = (fNamePosPerRow) ? nNumPins / 2 : nNumPins;
printf("GRID MIL\n");
printf("EDIT '%s%2.2d%s.dev'\n", strDevicePrefix, nNameNum, strDeviceSuffix);
printf("Prefix '%s';\n", strPrefix);
printf("Description '<b>%s</b>';\n", (fMaleFemale) ? "RECEPTACAL" : "HEADER");
printf("Value %s;\n", fValueOn ? "On" : "Off");
if (fSingleDual == 0)
{
printf("Add '%s%2.2d-1' 'G$1' Next 1 (0 0);\n", (fMaleFemale) ? strSymbolPrefixFemale : strSymbolPrefixMale, nNumPins);
printf("Package '%s%2.2d%s' '''''';\n", strPackagePrefix, nNumPins, strPackageSuffix);
}
else
{
printf("Add '%s%2.2d-2' 'G$1' Next 1 (0 0);\n", (fMaleFemale) ? strSymbolPrefixFemale : strSymbolPrefixMale, nNumPins/2);
printf("Package '%s%2.2d%s' '''''';\n", strPackagePrefix, nNameNum, strPackageSuffix);
}
printf("Technology '';\n");
string strConnect = "Connect ";
for (i=0; i < nNumPins; i++)
{
string tmp;
sprintf(tmp, " 'G$1.%d' '%d'", i+1, i+1);
strConnect = strConnect + tmp;
if ((i % 6) == 5)
strConnect += "\\\n ";
}
printf("%s;\n\n", strConnect);
}
//////////////////////////////////////////////////////////////////////////////
// Create single pin device from existing package and symbol.
void CreateSinglePinsDevice(int nNumPins)
{
int i;
string strPrefix = (fMaleFemale) ? "J" : "P";
if (nNumPins < 2)
return;
int nNameNum = (fNamePosPerRow) ? nNumPins / 2 : nNumPins;
printf("GRID MIL\n");
printf("EDIT '%s%2.2d%s_S.dev'\n", strDevicePrefix, nNameNum, strDeviceSuffix);
printf("Prefix '%s';\n", strPrefix);
printf("Description '<b>%s</b>';\n", (fMaleFemale) ? "RECEPTACAL" : "HEADER");
printf("Value %s;\n", fValueOn ? "On" : "Off");
real y = 0.0;
for (i=0; i < nNumPins; i++)
{
string strTmp = (i==0) ? "NV": "N";
printf("Add %s-%s '-%d' Always 1 (0 %.2f);\n", strPrefix, strTmp, i+1, y);
y -= 100;
}
printf("Package '%s%2.2d%s' '''''';\n", strPackagePrefix, nNameNum, strPackageSuffix);
printf("Technology '';\n");
string strConnect = "Connect ";
for (i=0; i < nNumPins; i++)
{
string tmp;
sprintf(tmp, " '-%d.%s' '%d'", i+1, strPrefix, i+1);
strConnect = strConnect + tmp;
if ((i % 6) == 5)
strConnect += "\\\n ";
}
printf("%s;\n\n", strConnect);
}
//////////////////////////////////////////////////////////////////////////////
// Display the main application dialog
void OnUnitsChange()
{
switch(nGridUnits)
{
case 0: // MM
if (nPrevUnits == 1)
{
// MIL->MM
dPadPitch = (dPadPitch / 1000) * INCHES_PER_MM;
dRowSpacing = (dRowSpacing / 1000) * INCHES_PER_MM;
dDrillSize = (dDrillSize / 1000) * INCHES_PER_MM;
dPadDiameter = (dPadDiameter / 1000) * INCHES_PER_MM;
dSmdSizeX = (dSmdSizeX / 1000) * INCHES_PER_MM;
dSmdSizeY = (dSmdSizeY / 1000) * INCHES_PER_MM;
}
else
{
// INCH->MM
dPadPitch = dPadPitch * INCHES_PER_MM;
dRowSpacing = dRowSpacing * INCHES_PER_MM;
dDrillSize = dDrillSize * INCHES_PER_MM;
dPadDiameter = dPadDiameter * INCHES_PER_MM;
dSmdSizeX = dSmdSizeX * INCHES_PER_MM;
dSmdSizeY = dSmdSizeY * INCHES_PER_MM;
}
break;
case 1: // MIL
if (nPrevUnits == 2)
{
// INCH->MIL
dPadPitch = dPadPitch * 1000;
dRowSpacing = dRowSpacing * 1000;
dDrillSize = dDrillSize * 1000;
dPadDiameter = dPadDiameter * 1000;
dSmdSizeX = dSmdSizeX * 1000;
dSmdSizeY = dSmdSizeY * 1000;
}
else
{
// MM->MIL
dPadPitch = (dPadPitch * 1000) * MM_PER_INCH;
dRowSpacing = (dRowSpacing * 1000) * MM_PER_INCH;
dDrillSize = (dDrillSize * 1000) * MM_PER_INCH;
dPadDiameter = (dPadDiameter * 1000) * MM_PER_INCH;
dSmdSizeX = (dSmdSizeX * 1000) * MM_PER_INCH;
dSmdSizeY = (dSmdSizeY * 1000) * MM_PER_INCH;
}
break;
case 2: // INCH
if (nPrevUnits == 1)
{
// MIL->INCH
dPadPitch = dPadPitch / 1000;
dRowSpacing = dRowSpacing / 1000;
dDrillSize = dDrillSize / 1000;
dPadDiameter = dPadDiameter / 1000;
dSmdSizeX = dSmdSizeX / 1000;
dSmdSizeY = dSmdSizeY / 1000;
}
else
{
// MM->INCH
dPadPitch = dPadPitch * MM_PER_INCH;
dRowSpacing = dRowSpacing * MM_PER_INCH;
dDrillSize = dDrillSize * MM_PER_INCH;
dPadDiameter = dPadDiameter * MM_PER_INCH;
dSmdSizeX = dSmdSizeX * MM_PER_INCH;
dSmdSizeY = dSmdSizeY * MM_PER_INCH;
}
break;
}
nPrevUnits = nGridUnits;
}
int MainAppDialog()
{
string title = "Make Connector Symbols - v" + Version;
int nResult = dlgDialog(title)
{
dlgTabWidget
{
dlgTabPage("Connector")
{
dlgHBoxLayout
{
dlgGroup("Style")
{
dlgRadioButton("Male", fMaleFemale);
dlgRadioButton("Female", fMaleFemale);
}
dlgGroup("Type")
{
dlgRadioButton("Single Row", fSingleDual);
dlgRadioButton("Dual Row", fSingleDual);
}
dlgGroup("Symbol Prefix")
{
dlgGridLayout
{
dlgCell(1,0) dlgLabel("Male");
dlgCell(1,1) dlgStringEdit(strSymbolPrefixMale);
dlgCell(2,0) dlgLabel("Female");
dlgCell(2,1) dlgStringEdit(strSymbolPrefixFemale);
}
}
}
dlgHBoxLayout
{
dlgGroup("Generate")
{
dlgRadioButton("Single Connector", fMultiple);
dlgRadioButton("Range of Connectors", fMultiple);
}
dlgGroup("Pin/Pad Count")
{
dlgGridLayout
{
dlgCell(1,0) dlgLabel("First Connector Pin Count (1-200)");
dlgCell(1,1) dlgIntEdit(nFirstPinCount, 2, 200);
dlgCell(2,0) dlgLabel("Last Connector Pin Count (1-200)");
dlgCell(2,1) dlgIntEdit(nLastPinCount, 2, 200);
}
}
}
}
dlgTabPage("Package")
{
dlgHBoxLayout
{
dlgGroup("Package Parameters")
{
dlgGridLayout
{
dlgCell(1,0) dlgLabel("Pad Pitch");
dlgCell(1,1) dlgRealEdit(dPadPitch, 0.001, 1000.0);
dlgCell(2,0) dlgLabel("Row Spacing");
dlgCell(2,1) dlgRealEdit(dRowSpacing, 0.001, 1000.0);
dlgCell(3,0) dlgLabel("Pad Drill Size");
dlgCell(3,1) dlgRealEdit(dDrillSize, 0.001, 100.0);
dlgCell(4,0) dlgLabel("Pad Diameter (0=auto)");
dlgCell(4,1) dlgRealEdit(dPadDiameter, 0.0, 100.0);
dlgCell(5,0) dlgLabel("SMD X Size");
dlgCell(5,1) dlgRealEdit(dSmdSizeX, 0.001, 100.0);
dlgCell(6,0) dlgLabel("SMD Y Size");
dlgCell(6,1) dlgRealEdit(dSmdSizeY, 0.001, 100.0);
dlgCell(7,0) dlgLabel("Package Name Prefix");
dlgCell(7,1) dlgStringEdit(strPackagePrefix);
dlgCell(8,0) dlgLabel("Package Name Suffix");
dlgCell(8,1) dlgStringEdit(strPackageSuffix);
}
}
dlgVBoxLayout
{
dlgGroup("Pad Type")
{
dlgRadioButton("Thru-Hole Pads", nPadType);
dlgRadioButton("SMD Pads", nPadType);
dlgCheckBox("Y-Long Pads", fLongPad);
}
dlgGroup("Pad Ordering")
{
dlgRadioButton("L-to-R", fPadOrder);
dlgRadioButton("R-to-L", fPadOrder);
dlgCheckBox("Flip Rows", fFlipRows);
}
dlgGroup("Grid Units")
{
dlgRadioButton("MM", nGridUnits) OnUnitsChange();
dlgRadioButton("MIL", nGridUnits) OnUnitsChange();
dlgRadioButton("INCH", nGridUnits) OnUnitsChange();
}
dlgStretch(1);
}
}
}
dlgTabPage("Device")
{
dlgHBoxLayout
{
dlgGridLayout
{
dlgCell(1,0) dlgLabel("Device Name Prefix");
dlgCell(1,1) dlgStringEdit(strDevicePrefix);
dlgCell(2,0) dlgLabel("Device Name Suffix");
dlgCell(2,1) dlgStringEdit(strDeviceSuffix);
dlgCell(3,1) dlgCheckBox("Value On", fValueOn);
}
}
dlgStretch(1);
}
}
dlgVBoxLayout
{
dlgGroup("Options")
{
dlgGridLayout
{
dlgCell(1,0) dlgCheckBox("Generate Symbols", fGenSymbols);
dlgCell(2,0) dlgCheckBox("Generate Packages", fGenPackages);
dlgCell(3,0) dlgCheckBox("Generate Devices", fGenDevices);