Home Documentation
Article Index
Documentation
G-codes samples: Surface Measure
G-codes samples: Tool Length Measure
G-codes samples: Homing
G-codes samples: Helical interpolation
Polar coordinates G16 G15
Plane selection G17 G18 G19
G68 G69 Coordinate system rotation
G65 Simple macro call
All Pages

Documentation.

(last updated 2015 Apr 22).

myCNC control software. User Manual (r49 updated 2015 Apr 7)

myCNC-ET1 controller User Manual (updated 2013 Dec 17)

myCNC-ET2 controller User Manual (updated 2011-0520)

myCNC-ET3 controller User Manual (updated 2013-0520)

myCNC-ET5 controller User Manual (updated 2014-0708) 

myServo-A01 servo driver/controller User Manual (updated 2011-0525)

G-codes implemented in myCNC control software.

PLC programming manual (updated 2012-0517).

Event Manager setup (updated 2012-0518)

Profile configuration example #1.

How to change current profile in myCNC

Obsolete documents:
myCNC-UP3 controller User Manual
myTHC-RU01 Torch Height controller User Manual (updated 2012-0424)

 

G-codes programming samples:



G-code programming samples.

Surface Measure procedure

Surface Measure procedure is implemented via macros layer with used-defined miscellaneous function M120 (can be redefined flexible).
Surface measuring is available from DNC program by using M120 code as well as from GUI by pressing Surface-Measure-on-screen button-

surface measure on-screen button

The button is connected to the same M120 miscellaneous function through configuration file cnc-config.xml

Listing for Surface Measure function-

 

(Surface measure)                                                                                       
(Tool is situated somewhere above the surface sensor)                                                   
(Surface Sensor Width is placed into Parameter #5490)                                                   
                                                                                                        
G28.2 Z0.                     (save current z position into Register1.Z (value with Z doesn't matter))        
G53 G38.2 Z-10.         (move down to z=-10., stop while sensor is pressed)                             
                                       (destination position should be lower than surface sensor)                      
G10 L70 P1 Z#5490  (set current work position as Z=0 (with offset depends on tool sensor width))   
G28.5 Z0.                     (return back to saved Z position in Register1.Z (value with Z doesn't matter))  

 

After running this procedure tool will be in the same position (machine position) as before start, but work coordinates (work position)
will be updated, so Z=0 on a blank surface.



Tool Length Measure Procedure.

Tool Length Measure procedure is implemented via macros layer with used-defined miscellaneous function M121 (can be redefined flexible).
Tool Length Measure is available from DNC program by using M121 code as well as from GUI by pressing Tool-Length-Measure on-screen button-

surface measure on-screen button

The button is connected to the same M121 miscellaneous function through configuration file cnc-config.xml

Listing for Tool Length Measure function-

 

(Tool length measure)
(Working cube values are situated in Parameters - )
( 5421 ... 5428 - Minimum point )
( 5431 ... 5438 - Maximum point )
(Position of Tool Sensor is situated in Parameters 5471 ... 5478 )


G28.2 Z0.                      (save current z position into Register1.Z (Z value is ignored))
G53 G0 Z#5433             (move tool up to safe position - Working Cube max Z)
G53 G0 X#5471 Y#5472 (move to XY Tool Sensor Position )
G53 G38.9 Z-10.            (move down to z=-10., stop while the sensor is touched/pressed)
                                    (When sensor is pressed, tool Z offset is saved for Current Tool).
G53 G0 Z#5433             (move tool up to safe position - Working Cube max Z)
G28.5 X0 Y0                 (go back to saved XY position in Register1.XY (XY values are ignored))
G28.5 Z0.                     (return back to saved Z position in Register1.Z)

 

After running this procedure tool will be in the same position (machine position) as before start,
Tool Length Z Offset will be saved for "Current Tool". Tool Length Offset will be calculated automatically
as difference between Tool Length Sensor position (stored in Parameters 5471 ... 5478,
particularly Z position, stored in 5473 Parameter) and measured position (Position when Tool Sensor
was pressed).

 


Automatic homing procedure.

Automatic Homing procedure is implemented via macro-layer with used-defined miscellaneous function M131 - M138 (can be redefined flexible).
Homing procedure is available from DNC program by using codes mentioned above as well as from GUI by pressing Auto-Homing on-screen button-

Autiomatic homing buttons

The button is connected to the same M131-M138 miscellaneous function through configuration file cnc-config.xml

Listing for Automatic Homing Procedure for X axis -

 

(Procedure for Zeroing - find zero-sensor in given axis and)                                           
(set machine coordinate to given position)                                                             
(given position is placed in Parameters #5451...#5459 )                                                
(#5451 - x)                                                                                            
(#5452 - y)                                                                                            
(#5453 - z)                                                                                            
(#5454 - a)                                                                                            
(#5455 - b)                                                                                            
(#5456 - c)                                                                                            
                                                                                                       
                                                                                                       
N01 G91 G38.2 X-5000. F200    (move tool up with given speed till probe sensor is pressed)           
N02 G91 G38.4 X500. F20          (move tool down with lower speed till probe sensor is resleaed)        
N10 G90 G10 L70 P0 X#5451    (set machine z position as given)                                      

 

While running procedure tool moves toward homing sensor with given speed till the sensor is pressed;
Then with lower speed tool moves back till the senosr is released;
Tool stops;
Current Position is programmed as "After Homing" value, stored in Registers #5451...#5459.


Initial values of Registers can be programmed in "cnc-config.xml" file or "cnc-variables.xml" file. If "cnc-variables.xml" is choosen, Initial values canm be changed from myCNC software GUI ion Cobfiguration dialogs.

 


Helical Interpolation.

myCNC software and controllers support helical interpolation - simultaneous two-axis circular motion with the linear motion along the remaining axes. A sample of helical interpolation is showed below:

 

(Helical interpolation sample)
%
N10 G90 G0 X0 Y0 Z0
G02 X0 Y0 R50 Z10 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z20 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z30 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z40 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z50 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z60 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z70 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z80 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z90 ( a circle in XY plane with Z motion )
G02 X0 Y0 R50 Z100 ( a circle in XY plane with Z motion )
M30

 myCNC-helical interpolation

 

 Similar motion can be programmed by using parametrical programming as shown below-

 

(Helical interpolation sample)
%
N10 G90 G0 X0 Y0 Z0
#40=0      (next Z position)                                    
#41=50    (Radius )                                            
#42=10    (Z step)                                             
#43=5+1 (number of turns)                                    
                                                             
M98 P333 L#43   (run subroutine 333 [L-1]-times)             

M30

O333
G02 X0 Y0 R#41 Z#40 ( a circle in XY plane with Z motion )
#40=#40+#42
M99
%

 myCNC helical sample 02

 

myCNC supports also "spiral" interpolation - some kind of circular interpolation with lenearly varying Radius.  

A sample is shown below-

(Spiral/Helical interpolation sample)
%
N10 G90 G0 X0 Y0 Z0
G02 X-10 Y0 I0  Z10 ( a spiral in XY plane with Z motion )
G02 X-20 Y0 I10 Z20 ( a spiral in XY plane with Z motion )
G02 X-30 Y0 I20 Z30 ( a spiral in XY plane with Z motion )
G02 X-40 Y0 I30 Z40 ( a spiral in XY plane with Z motion )
G02 X-50 Y0 I40 Z50 ( a spiral in XY plane with Z motion )
G02 X-60 Y0 I50 Z60 ( a spiral in XY plane with Z motion )
G02 X-70 Y0 I60 Z70 ( a spiral in XY plane with Z motion )
G02 X-80 Y0 I70 Z80 ( a spiral in XY plane with Z motion )
G02 X-90 Y0 I80 Z90 ( a spiral in XY plane with Z motion )
M30

%

 g-codes sample for spiral helical interpolation

 

 



Polar coordinates command.

 

A value of the end point coordinate can be set in polar coordinates (radius and angle).
The positive sign of the angle is counterclockwise of the selected plane, and the negativ sign of the angis is clockwise.
Both radius and angle can be commanded in either absolute or incremental command (G90, G91).

Polar coordinates is turned ON by G16 command
Polar coordinates is turned OFF by G15 command

Whille polar coordinates are active:

  • for G17 (XY plane) - the Radius value is programed as X value, the Angle value is programmed as Y value;
  • for G18 (XZ plane) - the Radius value is programed as X value, the Angle value is programmed as Z value;
  • for G19 (YZ plane) - the Radius value is programed as Y value, the Angle value is programmed as Z value;
The nc code sample, which uses Polar coordinates command is shown below:

 Polar coordinates command sample

(Polar coordinates command sample)
G90 (absolute) G21 (metric)                                                                                             
                                                                                                                        
#10=60 (number of rays)                                                                                                 
                                                                                                                        
#11=[180/#10] (angle increment)                                                                                         
#20=0  (start ray length)                                                                                               
#40=50 (basic length)                                                                                                   
                                                                                                                        
G16 (polar mode on)                                                                                                     
M98 P100 L#10                                                                                                           
G15 (polar mode off)                                                                                                    
M30                                                                                                                     
                                                                                                                        
O100                                                                                                                    
#30=ABS[#40*SIN[#20]]                                                                                                   
G1X#30Y#20 (draw ray)                                                                                                   
G0X0Y0                                                                                                                  
#20=[#20+#11] (next angle)                                                                                              
M99                                                                                                                     

 


 

Plane Selection

Codes G17 G18 G19 are used to select the planes for circular interpolation, cutter compensation, and
drilling by G–code.

  • G17 - XY plane;
  • G18 - XZ plane;
  • G19 - YZ plane;
The nc code sample, which uses Plane selsction is shown on a picture below:

G17 G18 G19 plane selection in myCNC

(Plane selection command sample)
G90G0X0Y0Z0                                                                                                             
G17.                                                                                                                    
G2 X400 R200                                                                                                            
X0 R200                                                                                                                 
G18                                                                                                                     
X400 R200                                                                                                               
X0 R200                                                                                                                 
X200 Z200 R200                                                                                                          
G19                                                                                                                     
Z-200 R200                                                                                                              
Z200 R200                                                                                                               
M2                                                                                                                                                                                                                                            

 

 


Coordinate system rotation.

 


By using codes G68/G69 a programmed shape can be rotated. Coordinate system rotation is turned on
by code G68 and turned off with G69.

In G68 block is programmed X, Y and Z values that are center of rotation and R value which is angle of rotation.
Positive R-value is counterclockwse rotation, negative value is clockwise rotation.

 

NC code samples, which uses coordinate rotation commands are shown below:

In the first sample ray is repeated by running O100 procedure many times (programmed in parameter). In  O100 procedure
the ray is rotated by using G68 code. The procedure is called three times for each plane selsction G17 (XY), G18(XZ),
G19(YZ).

 

 G68 G69 coordinate system rotation sample

(Coordinate system rotation sample)
G90G0X0Y0Z0

#200=100 (size)
#201=2   (delta angle)
#202=360/#201<->(number of lines)

(XY plane)
#100=0
#101=0
#102=#200

#103=#200
#104=0
#105=#200

G0 X#100 Y#101 Z#102
G17
M98 P101 L#202

(XZ plane)
#100=0
#101=#200
#102=0

#103=#200
#104=#200
#105=0

G0 X#100 Y#101 Z#102
G18
M98 P101 L#202

(YZ plane)
#100=#200

#101=0
#102=0

#103=#200
#104=#200
#105=0

G0 X#100 Y#101 Z#102
G19
M98 P101 L#202


o101
G68 X#100 Y#101 Z#102 R#110
G1 X#103 Y#104 Z#105
G1 X#100 Y#101 Z#102
G69
#110=#110+#201
M99
                                                                                                                  

In the second sample a shape defined in O100 subroutine is repeated a few times (parameter #11), each
time with rotation angle increment.

 g-code G68 G69 myCNC example

(Coordinate system rotation sample N2)
G90 G91.1
G0 X0 Y0 Z0

#10=0 (start angle)
#11=6 (number of shapes)
#12=360/#11 (angle increment)
M98 P100 L#11

O100
G90 G68 X0 Y0 Z0 R#10
G0 X20
G1 X30
G3 X35 Y5 I0 J5
G1 Y10
X15
Y5
G3 X20 Y0 I5 J0
#10=#10+#12
M99
                                                                                     

In the second sample a shape defined in O100 subroutine is repeated a few times (parameter #

 

 


G65 Simple Macro Call

When G65 is specified, the custom macro defined at address P is called.
G65 command format :

G65 P L <argument–specification>

  • P - address (number) of macro;
  • L - Repetition count (1 by default);
  • values, given in argument, assigned to local variables.

the arguments specification:

Address
Variable
number
Address
 Variable
number
Address
Variable
number
AddressVariable
number 
 A #1 D #7 R #18 X #24
 B #2 E #8 S #19 Y #25
 C #3 F #9 T #20 Z #26
 I #4
 H #11 U #21  
 J #5 M #13 V #22  
 K #6 Q #17 W #23  

 

A NC code sample, whith G65 simple macro call  is shown below. In the sample G65 code calls O9914 procedure to perform
deep peck drilling cycle (G83) 16 times along a circle with radius, gived as macro parameter.

 

g-code simple macro call G65 example

(Simple macro call example)
%.
(XY - position)
(I - radius)
(H - number of points)
(A - angle)

G90 G0X0Y0G0
G83 Z-3 Q2. R0.5 L0
G65 P9914 X20 Y15 I10 H16 A0.
M30
%