KiCad PCB EDA Suite
class_excellon.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2011-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef CLASS_EXCELLON_H
26 #define CLASS_EXCELLON_H
27 
28 
56 };
57 
58 
71 };
72 
73 // Helper struct to analyse Excellon commands
75 {
76  std::string m_Name; // key string
77  int m_Code; // internal code, used as id in functions
78  int m_asParams; // 0 = no param, -1 = skip params, 1 = read params
79 };
80 
81 
82 /* EXCELLON_IMAGE handle a drill image
83  * It is derived from GERBER_FILE_IMAGE because there is a lot of likeness
84  * between EXCELLON files and GERBER files
85  * DCode aperture are also similat to T Codes.
86  * So we can reuse GERBER_FILE_IMAGE to handle EXCELLON_IMAGE with very few new functions
87  */
88 
90 {
91 private:
93  READ_HEADER_STATE, // When we are in this state, we are reading header
94  READ_PROGRAM_STATE // When we are in this state, we are reading drill data
95  };
96 
97  excellon_state m_State; // state of excellon file analysis
98  bool m_SlotOn; // true during an oblong drill definition
99 
100 public: EXCELLON_IMAGE( int layer ) :
101  GERBER_FILE_IMAGE( layer )
102  {
103  m_State = READ_HEADER_STATE;
104  m_SlotOn = false;
105  }
106 
107 
109 
110  virtual void ResetDefaultValues() override
111  {
113  SelectUnits( false );
114  }
115 
116 
124  bool LoadFile( const wxString& aFullFileName );
125 
126 private:
127  bool Execute_HEADER_Command( char*& text );
128  bool Select_Tool( char*& text );
129  bool Execute_EXCELLON_G_Command( char*& text );
130  bool Execute_Drill_Command( char*& text );
131 
135  bool readToolInformation( char*& aText );
136 
137  int TCodeNumber( char*& aText )
138  {
139  return DCodeNumber( aText );
140  }
141 
142 
143  void SelectUnits( bool aMetric );
144 };
145 
146 
147 /*
148  * EXCELLON commands are given here.
149  * Pcbnew uses only few excellon commands
150  */
151 
152 /*
153  * see http://www.excellon.com/manuals/program.htm
154  */
155 
156 /* coordintes units:
157  * Coordinates are measured either in inch or metric (millimeters).
158  * Inch coordinates are in six digits (00.0000) with increments as small as 0.0001 (1/10,000).
159  * Metric coordinates can be measured in microns (thousandths of a millimeter)
160  * in one of the following three ways:
161  * Five digit 10 micron resolution (000.00)
162  * Six digit 10 micron resolution (0000.00)
163  * Six digit micron resolution (000.000)
164  *
165  * Leading and trailing zeros:
166  * Excellon (CNC-7) uses inches in six digits and metric in five or six digits.
167  * The zeros to the left of the coordinate are called leading zeros (LZ).
168  * The zeros to right of the coordinate are called trailing zeros (TZ).
169  * The CNC-7 uses leading zeros unless you specify otherwise through a part program.
170  * You can do so with the INCH/METRIC command.
171  * With leading zeros, the leading zeros must always be included.
172  * Trailing zeros are unneeded and may be left off.
173  * For trailing zeros, the reverse of the above is true.
174  */
175 
176 /*
177  * EXCELLON Commands Used in a Header
178  * The following table provides you with a list of commands which
179  * are the most used in a part program header.
180  * COMMAND DESCRIPTION
181  * AFS Automatic Feeds and Speeds
182  * ATC Automatic Tool Change
183  * BLKD Delete all Blocks starting with a slash (/)
184  * CCW Clockwise or Counter-clockwise Routing
185  * CP Cutter Compensation
186  * DETECT Broken Tool Detection
187  * DN Down Limit Set
188  * DTMDIST Maximum Rout Distance Before Toolchange
189  * EXDA Extended Drill Area
190  * FMAT Format 1 or 2
191  * FSB Turns the Feed/Speed Buttons off
192  * HPCK Home Pulse Check
193  * ICI Incremental Input of Part Program Coordinates
194  * INCH Measure Everything in Inches
195  * METRIC Measure Everything in Metric
196  * M48 Beginning of Part Program Header
197  * M95 End of Header
198  * NCSL NC Slope Enable/Disable
199  * OM48 Override Part Program Header
200  * OSTOP Optional Stop Switch
201  * OTCLMP Override Table Clamp
202  * PCKPARAM Set up pecking tool,depth,infeed and retract parameters
203  * PF Floating Pressure Foot Switch
204  * PPR Programmable Plunge Rate Enable
205  * PVS Pre-vacuum Shut-off Switch
206  * R,C Reset Clocks
207  * R,CP Reset Program Clocks
208  * R,CR Reset Run Clocks
209  * R,D Reset All Cutter Distances
210  * R,H Reset All Hit Counters
211  * R,T Reset Tool Data
212  * SBK Single Block Mode Switch
213  * SG Spindle Group Mode
214  * SIXM Input From External Source
215  * T Tool Information
216  * TCST Tool Change Stop
217  * UP Upper Limit Set
218  * VER Selection of X and Y Axis Version
219  * Z Zero Set
220  * ZA Auxiliary Zero
221  * ZC Zero Correction
222  * ZS Zero Preset
223  * Z+# or Z-# Set Depth Offset
224  * % Rewind Stop
225  * #/#/# Link Tool for Automatic Tool Change
226  * / Clear Tool Linking
227  */
228 
229 /*
230  * Beyond The Header: The Part Program Body
231  * COMMAND DESCRIPTION
232  * A# Arc Radius
233  * B# Retract Rate
234  * C# Tool Diameter
235  * F# Table Feed Rate;Z Axis Infeed Rate
236  * G00X#Y# Route Mode
237  * G01 Linear (Straight Line) Mode
238  * G02 Circular CW Mode
239  * G03 Circular CCW Mode
240  * G04 X# Variable Dwell
241  * G05 Drill Mode
242  * G07 Override current tool feed or speed
243  * G32X#Y#A# Routed Circle Canned Cycle
244  * CW G33X#Y#A# Routed Circle Canned Cycle
245  * CCW G34,#(,#) Select Vision Tool
246  * G35(X#Y#) Single Point Vision Offset (Relative to Work Zero)
247  * G36(X#Y#) Multipoint Vision Translation (Relative to Work Zero)
248  * G37 Cancel Vision Translation or Offset (From G35 or G36)
249  * G38(X#Y#) Vision Corrected Single Hole Drilling (Relative to Work Zero)
250  * G39(X#Y#) Vision System Autocalibration
251  * G40 Cutter Compensation Off
252  * G41 Cutter Compensation Left
253  * G42 Cutter Compensation Right
254  * G45(X#Y#) Single Point Vision Offset (Relative to G35 or G36)
255  * G46(X#Y#) Multipoint Vision Translation (Relative to G35 or G36)
256  * G47 Cancel Vision Translation or Offset (From G45 or G46)
257  * G48(X#Y#) Vision Corrected Single Hole Drilling (Relative to G35 or G36)
258  * G82(G81) Dual In Line Package
259  * G83 Eight Pin L Pack
260  * G84 Circle
261  * G85 Slot
262  * G87 Routed Step Slot Canned Cycle
263  * G90 Absolute Mode
264  * G91 Incremental Input Mode
265  * G93X#Y# Zero Set
266  * H# Maximum hit count
267  * I#J# Arc Center Offset
268  * M00(X#Y#) End of Program - No Rewind
269  * M01 End of Pattern
270  * M02X#Y# Repeat Pattern Offset
271  * M06(X#Y#) Optional Stop
272  * M08 End of Step and Repeat
273  * M09(X#Y#) Stop for Inspection
274  * M14 Z Axis Route Position With Depth Controlled Contouring
275  * M15 Z Axis Route Position
276  * M16 Retract With Clamping
277  * M17 Retract Without Clamping
278  * M18 Command tool tip check
279  * M25 Beginning of Pattern
280  * M30(X#Y#) End of Program Rewind
281  * M45,long message\ Long Operator message on multiple\ part program lines
282  * M47,text Operator Message
283  * M50,# Vision Step and Repeat Pattern Start
284  * M51,# Vision Step and Repeat Rewind
285  * M52(#) Vision Step and Repeat Offset Counter Control
286  * M02XYM70 Swap Axes
287  * M60 Reference Scaling enable
288  * M61 Reference Scaling disable
289  * M62 Turn on peck drilling
290  * M63 Turn off peck drilling
291  * M71 Metric Measuring Mode
292  * M72 Inch Measuring Mode
293  * M02XYM80 Mirror Image X Axis
294  * M02XYM90 Mirror Image Y Axis
295  * M97,text Canned Text
296  * M98,text Canned Text
297  * M99,subprogram User Defined Stored Pattern
298  * P#X#(Y#) Repeat Stored Pattern
299  * R#M02X#Y# Repeat Pattern (S&R)
300  * R#(X#Y#) Repeat Hole
301  * S# Spindle RPM
302  * T# Tool Selection; Cutter Index
303  * Z+# or Z-# Depth Offset
304  * % Beginning of Pattern (see M25 command)
305  * / Block Delete
306  */
307 
308 /*
309  * Example of a Header
310  * COMMAND PURPOSE
311  * M48 The beginning of a header
312  * INCH,LZ Use the inch measuring system with leading zeros
313  * VER,1 Use Version 1 X and Y axis layout
314  * FMAT,2 Use Format 2 commands
315  * 1/2/3 Link tools 1, 2, and 3
316  * T1C.04F200S65 Set Tool 1 for 0.040" with infeed rate of 200 inch/min Speed of 65,000 RPM
317  * DETECT,ON Detect broken tools
318  * M95 End of the header
319  */
320 
321 #endif // CLASS_EXCELLON_H
virtual void ResetDefaultValues() override
Class GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters ...
drill_G_code_t
bool Select_Tool(char *&text)
bool Execute_HEADER_Command(char *&text)
bool LoadFile(const wxString &aFullFileName)
Read and load a drill (EXCELLON format) file.
int DCodeNumber(char *&Text)
Definition: rs274d.cpp:432
bool Execute_Drill_Command(char *&text)
drill_M_code_t
std::string m_Name
EXCELLON_IMAGE(int layer)
excellon_state m_State
int TCodeNumber(char *&aText)
bool readToolInformation(char *&aText)
Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 and enter params in TCODE list...
bool Execute_EXCELLON_G_Command(char *&text)
void SelectUnits(bool aMetric)