Root/cameo/templates/mkmk-simple

1#!/bin/sh
2PATH=$PATH:/home/qi/cae-tools/cameo
3PATH=$PATH:/home/qi/cae-tools/gp2rml
4
5#
6# Parameters:
7#
8# NAME KiCad project name, required
9# X0, Y0 lower left corner of raw board, default: 0mm 0mm
10# X, Y position in array, default: 0 0
11# XN, YN number of boards in X/Y direction, default: 1 1
12# Z0 tool height when in contact with the surface
13# ROT board rotation, default: 0 degrees
14# DRILL drill diameter range, default: 13mil,14mil
15# MILL_IN diameter of mill for work inside the board, default: 35mil
16# MILL_OUT diameter of mill for board edge, default: 35mil
17# BOARD_Z board tickness, default: 0.8 mm
18# ANY set to "any" to use all remaining paths for milling,
19# irrespective of tool size. Default: unset / empty string.
20# CLEARANCE tool clearance above PCB surface, default: 2mm
21#
22
23while [ "$1" ]; do
24    eval "$1"
25    shift
26done
27
28if ! [ "$NAME" ]; then
29    echo "NAME is required" 1>&2
30    exit 1
31fi
32: ${X0:=0} ${Y0:=0}
33: ${X:=0} ${Y:=0}
34: ${XN:=1} ${YN:=1}
35: ${Z0:=-57.4}
36: ${DRILL:="13mil 14mil"}
37: ${MILL_IN:=35mil}
38: ${MILL_OUT:=35mil}
39: ${BOARD_Z:=0.8mm}
40: ${CLEARANCE:=2mm}
41
42rot=
43if [ "$ROT" ]; then
44    rot="rotate $ROT"
45fi
46
47edges=$NAME.gp
48[ -r "$edges" ] || edges=
49for n in PCB_Edges.gbr Edge_Cuts.gbr Edge_Cuts.pho Edge.Cuts.gm1; do
50    if [ -r "../$NAME-$n" ]; then
51    edges=../$NAME-$n
52    break
53    fi
54done
55if [ ! "$edges" ]; then
56    echo "no edges file found" 1>&2
57    exit 1
58fi
59
60write=write
61yi=0
62while [ $yi -lt $YN ]; do
63    xi=0
64    while [ $xi -lt $XN ]; do
65
66    cameo <<EOF || exit
67mm
68
69`if [ "$edges" != "${edges%.gp}" ]; then echo gnuplot 35mil $edges;
70 else echo gerber 35mil $edges; fi`
71$rot
72align 1 $X0 $Y0 # align relative to board corner
73translate 4mm 4mm # move to PCB zone assigned to project
74array +3mm +3mm `expr $X + $xi` `expr $Y + $yi`
75z 0 ${Z0}mm # board surface (tool extended)
76z -$BOARD_Z # board thickness
77z -0.5mm # tool extra depth
78clear
79
80`[ -r ../$NAME.drl ] && echo excellon ../$NAME.drl`
81`[ -r ../$NAME-PTH.drl ] && echo excellon ../$NAME-PTH.drl`
82`[ -r ../$NAME-NPTH.drl ] && echo excellon ../$NAME-NPTH.drl`
83drill $DRILL
84optimize
85$write drill.gp
86
87remainder
88mill $ANY $MILL_IN 0.01mm
89$write mill.gp
90
91remainder
92empty
93
94`if [ "$edges" != "${edges%.gp}" ]; then echo gnuplot $MILL_OUT $edges;
95 else echo gerber $MILL_OUT $edges; fi`
96offset
97append mill.gp
98EOF
99
100    write=append
101    xi=`expr $xi + 1`
102    done
103    yi=`expr $yi + 1`
104done
105
106gp2rml $CLEARANCE 0.5 0.5 mill.gp >mill.rml || exit
107gp2rml $CLEARANCE 0.1 0.5 drill.gp >drill.rml || exit
108
109
110cat <<EOF >Makefile.mkmk
111SPOOL=/home/moko/svn.openmoko.org/developers/werner/cncmap/spool/spool
112CNGT=/home/qi/cae-tools/cngt/cngt
113
114.PHONY: mill drill cng plot dplot
115
116mill:
117        PORT=/dev/ttyUSB0 \$(SPOOL) mill.rml
118
119drill:
120        PORT=/dev/ttyUSB0 \$(SPOOL) drill.rml
121
122cng:
123        \$(CNGT) $Z0 20 mill.gp
124
125plot:
126        echo 'set size ratio -1; \
127          plot "drill.gp" with points, "mill.gp" with lines' | \\
128          gnuplot -persist
129
130dplot:
131        echo 'set size ratio -1; \
132          plot "< sed /^\$\$/d drill.gp" with linespoints' | \\
133          gnuplot -persist
134
135clean::
136        rm -f mill.gp mill.rml drill.gp drill.rml
137EOF
138

Archive Download this file

Branches:
master



interactive