Hi all,
my boss yesterday asked me to write a script using G-code commands for our laser and 3-axis stage system.

instead of moving the laser beam, he wants to have the beam fixed and move the stage system onto which the work piece is held.

the task is fairly straightforward by nature; in essence, cross-hatching inside a rectangle, with a hatch distance of 2.5mm in both directions.(x and y)

the rectangle is 200mm by 100mm, so I would have 40 horizontal lines and 20 vertical lines.

my script is as follows:

G91 ; relative movement
F 12 ;feedrate 12mm/sec

i=1 ;counter i, to make horizontal lines
WHILE i<20
i=i+1

M3000 ;turn on laser
G4 F.01 ;laser on delay 0.01 second
G1 X200 ;move 200 mm in +x direction

M4000 ;turn off laser
G4 F.01 ;laser off delay 0.01 second
G1 Y-2.5 ;move 2.5mm in -y direction

M3000
G4 F.01
G1 X-200

M4000
G4 F.01
G1 Y-2.5
ENDWHILE
G1 Y2.5

j=1 ; counter j, to make vertical lines
WHILE j<10
j=j+1

M3000
G4 F.01
G1 Y100
M4000
G4 F.01
G1 X2.5
M3000
G4 F.01
G1 Y-100
M4000
G4 F.01
G1 X2.5
ENDWHILE

somehow, the interface keeps telling me there's sth wrong with the "WHILE" syntax. as you can see, im completely new to CNC programminmg and would appreciate very much if any of you could help me out. Thanks very much