Stefan Schuermans commited on 2013-05-20 13:06:47
Showing 3 changed files, with 142 additions and 15 deletions.
| ... | ... |
@@ -37,10 +37,10 @@ |
| 37 | 37 |
|
| 38 | 38 |
<para> |
| 39 | 39 |
|
| 40 |
- To illustrate the usage of dxfngc, suppose a stencil for a logo shall be |
|
| 41 |
- cut with a CNC mill. The basic shape of the stencil is a circle. The |
|
| 42 |
- logo is formed by two holes with a specific shape (see <xref |
|
| 43 |
- linkend="logo_stencil"/>). |
|
| 40 |
+ To illustrate the usage of dxfngc, suppose a stencil for the |
|
| 41 |
+ <emphasis>BlinkenArea</emphasis> logo shall be cut with a CNC mill. The |
|
| 42 |
+ basic shape of the stencil is a circle. The logo is formed by two holes |
|
| 43 |
+ with a specific shape (see <xref linkend="logo_stencil"/>). |
|
| 44 | 44 |
|
| 45 | 45 |
</para> |
| 46 | 46 |
|
| ... | ... |
@@ -54,6 +54,10 @@ |
| 54 | 54 |
<caption>The logo stencil to be cut on the CNC mill.</caption> |
| 55 | 55 |
</figure> |
| 56 | 56 |
|
| 57 |
+ <sect2> |
|
| 58 |
+ |
|
| 59 |
+ <title>Creating the Drawing</title> |
|
| 60 |
+ |
|
| 57 | 61 |
<para> |
| 58 | 62 |
|
| 59 | 63 |
First, the 2D drawing is created with a CAD program in DXF format. The |
| ... | ... |
@@ -74,10 +78,139 @@ |
| 74 | 78 |
Border and holes are on separate layers.</caption> |
| 75 | 79 |
</figure> |
| 76 | 80 |
|
| 77 |
- <programlisting> |
|
| 78 |
-foo(); |
|
| 79 |
-bar(); |
|
| 80 |
- </programlisting> |
|
| 81 |
+ </sect2> |
|
| 82 |
+ |
|
| 83 |
+ <sect2> |
|
| 84 |
+ |
|
| 85 |
+ <title>Writing the Script</title> |
|
| 86 |
+ |
|
| 87 |
+ <para> |
|
| 88 |
+ |
|
| 89 |
+ The next step is to write the dxfngc script. Such a script is shown in |
|
| 90 |
+ <xref linkend="logo_script"/>. All lines starting with a hash |
|
| 91 |
+ character (<code>#</code>) are comments. They will be ignored by |
|
| 92 |
+ dxfngc. During processing of the script, dxfngc manages three three |
|
| 93 |
+ data objects in memory: the current settings, the current drawing and |
|
| 94 |
+ the list of G-code commands. Initially, the settings are set to some |
|
| 95 |
+ reasonable defaults. The drawing and the G-code are empty. |
|
| 96 |
+ |
|
| 97 |
+ </para> |
|
| 98 |
+ |
|
| 99 |
+ <para> |
|
| 100 |
+ |
|
| 101 |
+ The first section of the example script fills the G-code list with |
|
| 102 |
+ some setup commands to configure the CNC mill. This is done using |
|
| 103 |
+ the <code>cmd</code> command. All the text folloing <code>cmd</code> |
|
| 104 |
+ is treated as a G-code command and is appended as a new command to |
|
| 105 |
+ the G-code list in memory. Afterwards, the settings for processing the |
|
| 106 |
+ drawing to G-code are configured. This includes the Z coordinates |
|
| 107 |
+ and the feed rates for moving and cutting as well as the diameter of |
|
| 108 |
+ the cutting tool. Please see !!!TODO!!! for a description of all |
|
| 109 |
+ settings. |
|
| 110 |
+ |
|
| 111 |
+ </para> |
|
| 112 |
+ |
|
| 113 |
+ <para> |
|
| 114 |
+ |
|
| 115 |
+ The <code>read_dxf</code> reads a CAD drawing in DXF format. In this |
|
| 116 |
+ example, the logo drawing shown in <xref linkend="logo_drawing"/> is |
|
| 117 |
+ read. This loads all layers of the DXF file to memory. The layers can |
|
| 118 |
+ then be processed with the cutting commands (see !!!TODO!!!) to produce |
|
| 119 |
+ G-code. The <code>cut_inside</code> command is used here to cut the |
|
| 120 |
+ holes. It will calculate the path of the cutting tool to be half its |
|
| 121 |
+ diameter further to the inside of the holes. This makes sure the hole |
|
| 122 |
+ has the desired size and shape after cutting - or more precise as close |
|
| 123 |
+ to it as possible with the selected cutting tool. The |
|
| 124 |
+ <code>cut_outside</code> command is used for cutting the border of the |
|
| 125 |
+ stencil. It basically works the same way, but moves the path of the |
|
| 126 |
+ cutting tool further to the outside. |
|
| 127 |
+ |
|
| 128 |
+ </para> |
|
| 129 |
+ |
|
| 130 |
+ <para> |
|
| 131 |
+ |
|
| 132 |
+ After all G-code for cutting has been created, the G-code commands |
|
| 133 |
+ for finishing (e.g. turning off the CNC-mill) are appended using |
|
| 134 |
+ <code>cmd</code> like for the setup. Finally, the G-code accumulated |
|
| 135 |
+ in memory is written to an output file useg <code>write_ngc</code>. |
|
| 136 |
+ |
|
| 137 |
+ </para> |
|
| 138 |
+ |
|
| 139 |
+ <figure xml:id="logo_script"> |
|
| 140 |
+ <title>Logo Script</title> |
|
| 141 |
+ <programlisting><![CDATA[# add setup G-code commands |
|
| 142 |
+cmd G21 |
|
| 143 |
+cmd G90 |
|
| 144 |
+cmd G64 P0.01 |
|
| 145 |
+cmd G17 |
|
| 146 |
+cmd G40 |
|
| 147 |
+cmd G49 |
|
| 148 |
+ |
|
| 149 |
+# configure settings |
|
| 150 |
+set_precision 0.01 |
|
| 151 |
+set_tool_diameter 3 |
|
| 152 |
+set_move_z 5 |
|
| 153 |
+set_base_z 0 |
|
| 154 |
+set_cut_z -3.2 |
|
| 155 |
+set_cut_z_step 1.1 |
|
| 156 |
+set_feed_drill 100 |
|
| 157 |
+set_feed_mill 200 |
|
| 158 |
+set_layer_mode path_by_path |
|
| 159 |
+ |
|
| 160 |
+# read drawing |
|
| 161 |
+read_dxf logo.dxf |
|
| 162 |
+ |
|
| 163 |
+# generate G-code for actual cutting |
|
| 164 |
+cut_inside holes |
|
| 165 |
+cut_outside border |
|
| 166 |
+ |
|
| 167 |
+# add finishing G-code commands |
|
| 168 |
+cmd M2 |
|
| 169 |
+ |
|
| 170 |
+# write G-code to output file |
|
| 171 |
+write_ngc logo.ngc]]></programlisting> |
|
| 172 |
+ </figure> |
|
| 173 |
+ |
|
| 174 |
+ </sect2> |
|
| 175 |
+ |
|
| 176 |
+ <sect2> |
|
| 177 |
+ |
|
| 178 |
+ <title>Running the Script</title> |
|
| 179 |
+ |
|
| 180 |
+ <para> |
|
| 181 |
+ |
|
| 182 |
+ Once drawing and script are ready, the script can be run using the |
|
| 183 |
+ <code>dxfngc</code> tool. (It is assumed here it has already been |
|
| 184 |
+ compiled. See !!!TODO!!! for instruction for compiling.) As the script |
|
| 185 |
+ contains the filenames of input and output files, it is sufficient to |
|
| 186 |
+ provide the filename of the script file to dxfngc: |
|
| 187 |
+ |
|
| 188 |
+ </para> |
|
| 189 |
+ |
|
| 190 |
+ <programlisting><![CDATA[./dxfngc logo.txt]]></programlisting> |
|
| 191 |
+ |
|
| 192 |
+ <para> |
|
| 193 |
+ |
|
| 194 |
+ If everything goes well, this will produce a G-code file. Otherwise an |
|
| 195 |
+ error message will be printed that informs about what went wrong. |
|
| 196 |
+ (There might also be some output like <code>dimeModel::largestHandle: |
|
| 197 |
+ 65535</code>, which is coming from inside the DXF library used |
|
| 198 |
+ internally. This output can be ignored.) |
|
| 199 |
+ <xref linkend="logo_g-code"/> shows the produced G-code rendered by |
|
| 200 |
+ LinuxCNC. |
|
| 201 |
+ |
|
| 202 |
+ </para> |
|
| 203 |
+ |
|
| 204 |
+ <figure xml:id="logo_g-code"> |
|
| 205 |
+ <title>G-code for Logo Stencil</title> |
|
| 206 |
+ <mediaobject> |
|
| 207 |
+ <imageobject> |
|
| 208 |
+ <imagedata fileref="logo_g-code.png" format="PNG" width="100%"/> |
|
| 209 |
+ </imageobject> |
|
| 210 |
+ </mediaobject> |
|
| 211 |
+ <caption>G-code for the logo stencil, rendered by LinuxCNC.</caption> |
|
| 212 |
+ </figure> |
|
| 213 |
+ </sect2> |
|
| 81 | 214 |
|
| 82 | 215 |
</sect1> |
| 83 | 216 |
|
| ... | ... |
@@ -157,7 +157,7 @@ |
| 157 | 157 |
inkscape:pageshadow="2" |
| 158 | 158 |
inkscape:zoom="0.64325853" |
| 159 | 159 |
inkscape:cx="698.00317" |
| 160 |
- inkscape:cy="550.32306" |
|
| 160 |
+ inkscape:cy="547.21389" |
|
| 161 | 161 |
inkscape:document-units="px" |
| 162 | 162 |
inkscape:current-layer="layer1" |
| 163 | 163 |
showgrid="true" |
| ... | ... |
@@ -365,11 +365,5 @@ |
| 365 | 365 |
d="m -127.81164,843.46137 0,47.28752" |
| 366 | 366 |
id="path3758" |
| 367 | 367 |
sodipodi:nodetypes="cc" /> |
| 368 |
- <path |
|
| 369 |
- style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" |
|
| 370 |
- d="M 70.829681,1078.4858 49.83086,1049.8562" |
|
| 371 |
- id="path3788" |
|
| 372 |
- transform="translate(-177.6425,-182.75108)" |
|
| 373 |
- sodipodi:nodetypes="cc" /> |
|
| 374 | 368 |
</g> |
| 375 | 369 |
</svg> |