<< Click to Display Table of Contents > 

USC-3 Manual > G-Code (CNC) > G-Code examples > G-Code Example Code

G-Code Example Code
Previous pageReturn to chapter overviewNext page

Example Program for YAG laser:

;----------------------------------------------------------------------------------

G17                                        ; Set XY plane as working area

G71                                        ; Set mm as unit

G90                                        ; Set position values to absolute

   $SC_DEFINES = 1                        ; Start of the definitions

       $SC_LASERPORT = 3                  ; Set DAC_A as laser port

       $SC_FIELDXMIN      = -50.0         ; [mm]

       $SC_FIELDYMAX      =  50.0         ; [mm]

       $SC_FIELDYMIN      = -50.0         ; [mm]

       $SC_FIELDXMAX      =  50.0         ; [mm]

       $SC_FIELDXGAIN     =   1.0

       $SC_FIELDYGAIN     =   1.0

       $SC_FIELDXOFFSET   =   0.0         ; [mm]

       $SC_FIELDYOFFSET   =   0.0         ; [mm]

       $SC_FIELDAXISSTATE =   0           ; Set axes state to neutral

 

       SC_TOOL_LOAD[1]                    ; Pen 1 definitions

           $SC_LASERPOWER      =   90.0   ; [%]

           $SC_FREQUENCY       =   40.0   ; [kHz]

           $SC_YAGPULSELENGTH  =   10.0   ; [µs]

           $SC_STDBYPERIOD     =    0.0   ; [µs]

           $SC_STDBYPULSEWIDTH =    0.0   ; [µs]

           $SC_JUMPSPEED       = 9000.0   ; [mm/s]

           $SC_MARKSPEED       =   20.0   ; [mm/s]

           $SC_JUMPDELAY       =  100.0   ; [µs]

           $SC_MARKDELAY       =   50.0   ; [µs]

           $SC_POLYDELAY       =   50.0   ; [µs]

           $SC_LASERONDELAY    =   10.0   ; [µs]

           $SC_LASEROFFDELAY   =   45.0   ; [µs]

       SC_TOOL_SAVE[1]

 

       SC_TOOL_LOAD[2]                    ; Pen 2 definitions

           $SC_LASERPOWER      =   50.0   ; [%]

           $SC_FREQUENCY       =   20.0   ; [kHz]

           $SC_YAGPULSELENGTH  =   20.0   ; [µs]

           $SC_STDBYPERIOD     =    0.0   ; [µs]

           $SC_STDBYPULSEWIDTH =    0.0   ; [µs]

           $SC_JUMPSPEED       = 9000.0   ; [mm/s]

           $SC_MARKSPEED       =  300.0   ; [mm/s]

           $SC_JUMPDELAY       =  100.0   ; [µs]

           $SC_MARKDELAY       =   50.0   ; [µs]

           $SC_POLYDELAY       =   50.0   ; [µs]

           $SC_LASERONDELAY    =   10.0   ; [µs]

           $SC_LASEROFFDELAY   =   45.0   ; [µs]

       SC_TOOL_SAVE[2]

 

       SC_TOOL_LOAD[3]                    ; Pen 3 definitions

           $SC_LASERPOWER      =   25.0   ; [%]

           $SC_FREQUENCY       =   30.0   ; [kHz]

           $SC_YAGPULSELENGTH  =   15.0   ; [µs]

           $SC_STDBYPERIOD     =    0.0   ; [µs]

           $SC_STDBYPULSEWIDTH =    0.0   ; [µs]

           $SC_JUMPSPEED       = 9000.0   ; [mm/s]

           $SC_MARKSPEED       =  100.0   ; [mm/s]

           $SC_JUMPDELAY       =  100.0   ; [µs]

           $SC_MARKDELAY       =   50.0   ; [µs]

           $SC_POLYDELAY       =   50.0   ; [µs]

           $SC_LASERONDELAY    =   10.0   ; [µs]

           $SC_LASEROFFDELAY   =   45.0   ; [µs]

       SC_TOOL_SAVE[3]

 

       $SC_ArcStepMode = 1                ; Enable the dynamic segment number mode for arcs, ellipses and circles

   $SC_DEFINES = 0                        ; End of the definitions

 

   $SC_LoopCount = 2                      ; Rectangle, loop count = 2

   SC_Start_Entity

       SC_TOOL_LOAD[2]                    ; Load pen 2

           G0 X-45.0 Y-45.0               ; Perform a scanner jump

       SC_TOOL[1]                         ; Laser on

           G1 X-45.0 Y 45.0               ; Perform some linear scanner moves

           G1 X 45.0 Y 45.0

           G1 X 45.0 Y-45.0

           G1 X-45.0 Y-45.0

       SC_TOOL[0]                         ; Laser off

   SC_End_Entity

 

   CALL SmallSquare                       ; Small square function call

   

   $SC_ArcStepValue = 10                  ; Ellipse clockwise, ArcStepValue = 10

   SC_TOOL_LOAD[3]

       G0 X-7 Y10

   SC_TOOL[1]

       G2 X-7 Y10 I15 J-15

   SC_TOOL[0]

 

   CALL SmallSquare                       ; Small square function call

 

   $SC_LoopCount = 1                      ; Circle clockwise, ArcStepValue = 50

   SC_Start_Entity

       $SC_ArcStepValue = 50

       SC_TOOL_LOAD[2]

           G0 X5 Y-5

       SC_TOOL[1]

           G3 X5 Y-5 I-10 J10

       SC_TOOL[0]

   SC_End_Entity

M2                                         ; End of job

 

DFS SmallSquare                            ; Small square function definition

   SC_TOOL_LOAD[1]

       G0 X-5 Y-5

   SC_TOOL[1]

       G1 X-5 Y5

       G1 X5 Y5

       G1 X5 Y-5

       G1 X-5 Y-5

   SC_TOOL[0]

ENDDFS

;----------------------------------------------------------------------------------

 

The marking result will look like this:

GCode_Demo

Figure 32: G-Code example