Error:20 Unsupported or invalid g-code

Hi guys.

New controller with grbl (MKS DLC32) and I am new to grbl.
I have read all the posts in the forum regarding this error, but have not been able to solve it.
I tried to do a test by trying to carve a first test script.
I disabled the Z axis (even though it is actually there on my machine) but it still doesn’t work.

Starting stream
Layer INCISIONE
error:20
Unsupported or invalid g-code command found in block.
On or near line 4:
Job halted
Stream completed in 0:00
ok

First line of gcode:

1. ; LightBurn 1.4.00
2. ; GRBL device profile, user origin
3. ; Bounds: X20.32 Y30.06 to X106.57 Y50.83
4. G00 G17 G40 G21 G54
5. G90
6. G0 X2 Y2
7. G91
8. M4
9. ; Cut @ 2001 mm/min, 41% power
10. M9
11. G0 X7.941Y10.247
12. ; Layer INCISIONE
13. G1 X-1.034Y0.152S401F2001

Screenshot 2023-10-26 190706

Machine settings:

$0=10

$1=25

$2=0

$3=0

$4=0

$5=0

$6=1

$10=1

$11=0.010

$12=0.002

$13=0

$20=0

$21=1

$22=1

$23=7

$24=50.000

$25=500.000

$26=250.000

$27=3.000

$28=1920.000

$30=10000.000

$31=0.000

$32=1

$38=1

$40=1

$100=80.000

$101=80.000

$102=80.000

$103=100.000

$104=100.000

$105=100.000

$110=1000.000

$111=1000.000

$112=600.000

$113=1000.000

$114=1000.000

$115=1000.000

$120=30.000

$121=30.000

$122=30.000

$123=200.000

$124=200.000

$125=200.000

$130=220.000

$131=200.000

$132=300.000

$133=300.000

$134=300.000

$135=300.000

The Gcode looks okay. Clustering is not enabled. The other most likely thing is a USB communications issue. Less likely is a controller board issue.

One program or all?
Error in same place each time?
Try entering the Gcode lines in the Console one at a time. Does the error occur and if so, when?

thx for reply.

I am connected via wifi, this is the offending command: M4

G00 G17 G40 G21 G54

ok

ok

G90

ok

G0 X2 Y2

ok

G91

ok

M4

error:20

Unsupported or invalid g-code command found in block.

EDIT:I have just seen this post:Another M4 error with DLC32 V2.1.003
It seems to be a firmware problem.
Very bad for me,as I had to compile the source code to invert the Y-axis pins with the Z-axis ones (on the board there are 2 connectors for the Y-axis,on my machine I have 2 motors in the Z-axis) so I will have to look for the bug,but I don’t know where

In the controller source code, look for M3, M4 and M5. in the area of “spindle”.
M3 = spindle clockwise
M4 = spindle CCW (LB uses as a laser on command)
M5 = spindle stop (or off)

Ok,I think I got around the problem by enabling inLaserMode by default in the Spindle.cpp file of the firmware

bool Spindle::inLaserMode() {
        return true;  // default for basic spindle is false  //change in true
    }

in this way the error does not occur again but, the machine doesn’t know where it is, it bumps into the limit switches while working, maybe it’s set in inches? I noticed that even if I change the position of the test writing on the plan in lightburn, the frame always does so in the same point (approximately)

Odd, does the machine Home properly? Are the machine parameters the same as listed above?

Are you saying the Framing follows the position of the test writing when you move it around in the workspace?

yes,homing works perfectly,the settings are as above,they have not changed

I can move the test writing to any part of the lightburn workspace,framing always takes place in the same place,in the bottom left corner of the machine


Never read about this one before, but did find something similar.

Rather than play 20 questions for now, please upload the Lightburn file you used for these images. I will see if the issue duplicates on my machine.

This is the file
Test.lbrn2 (23,1 KB)

I will now take a look at that post and try to run that gcode from a sd card, see what happens.

Gcode does not carry the Framing info.

yeah,i have same error from sd card, x axis crashes into the limit switch.
I think it might be a firmware problem, I would like to try compiling the FluidNC project, it is not difficult, but I think the display is not supported, I will try anyway

I am thinking the same thing. I tried the framing test on my machine and found Frame follows the object location in the workspace. In other words, it behaved normally.

OK, I installed FluidNC, now the axes don’t hit the limit switches but both framing and engraving always take place at the bottom left of the working plane, I updated lightburn to the latest version.


EDIT: I have noticed a strange thing in the Gcode,on line 11,despite the fact that I change the position of the test writing,line 11 remains unchanged

1. ; LightBurn 1.4.03
2. ; GRBL device profile, user origin
3. ; Bounds: X74.95 Y169.69 to X135.05 Y188.32
4. G00 G17 G40 G21 G54
5. G90
6. G0 X0 Y0
7. G91
8. M4
9. ; Cut @ 2000 mm/min, 40% power
10. M9
11. G0 X4.72Y6.786 
12. ; Layer INCISIONE
13. G1 X-0.219Y0.067S400F2000
14. G1 X-0.214Y0.083
15. G1 X-0.206Y0.099
16. G1 X-0.199Y0.114

1. ; LightBurn 1.4.03
2. ; GRBL device profile, user origin
3. ; Bounds: X144.95 Y14.69 to X205.05 Y33.32
4. G00 G17 G40 G21 G54
5. G90
6. G0 X0 Y0
7. G91
8. M4
9. ; Cut @ 2000 mm/min, 40% power
10. M9
11. G0 X4.72Y6.786
12. ; Layer INCISIONE
13. G1 X-0.219Y0.067S400F2000
14. G1 X-0.214Y0.083
15. G1 X-0.206Y0.099
16. G1 X-0.199Y0.114
17. G1 X-0.19Y0.13
18. G1 X-0.18Y0.144

I do not know anything about framing in FluidNC, but if two software packages give you the same results, that would eliminate
the PC and software running on it. I doubt the USB cable would do it, so that leaves the controller.

Idea: Look at the Gcode (Save Gcode) for the project and see if it is generating the initial X & Y positions in the right place.

If you Run the project, does it go to the correct place (back left in your current image)?

This Framing thing really just does not make sense. Another Idea: In the Console window, click on Show All. Then click the Frame button and see what the Gcode looks like in the Console window. The window will show the Gcode sent to the controller and whatever the controller responds with.

To be honest, I am not 100% positive it is not a Lightburn, and possibly FluidNC settings issue.

I have edited the previous post with some additional info, please have a look

Switch to Absolute Positioning and see what happens.

Ok,Understend,this is the way,THX.

Screenshot 2023-10-29 190942

Yes. The only time I use User is with the rotary. But that is a different game.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.