Help configuring G-code generator to allow for SXXX (power) embedded on G0 G1... commands

Hi all!

Newbie on the forum here and of course looking for a hand. I’m trying to configure LW to my laser cutter machine, just to generate G-Code.

I’m finishing a Workbee machine from Ooznest equipped with a laser unit from Optlasers. I’m using a duet maestro wifi board.

All goes well, the machine is nice and all is working sort of ok. My problem is generating G-code, I can’t find a free program that can deal with my needs. The laser unit is connected to the heatbed pin instead of the more common fan output. It works just fine and there must be a good reason for that.

My problem is that for that kind of working the G-Code is sort of special. Normally you turn the laser on, move from point A to point B and turn off the laser and so on. In my case, it doesn’t work like that but by appending an S parameter on each of the g commands (G0,G1, G2…) like in these samples:

G0 X0.0000 Y0.0000 Z10.0000 F10000 S0 ; Move Z at a speed of F and a laser power (S) of 0
G1 X10.0000 F5000 S20 ; Same for X but power 20 and speed 5000
G1 Y10.0000 F4000 S20 ; Similar for Y
G2 X20.0000 I5.0000 J0.0000 S30; an arc…
G1 X0.0000 Z20.0000 S255 ; Full power (PWM 0 to 255)

(Normally you would:
M3 S255 ; laser ON max power
G1 X10
M5 ;Laser Off
; or similar)

I hope that is clear so far. My problem is that I can not find a way to make the software append this F and S commands to the moves. Is it even possible? or maybe I’m missing something or doing something wrong …

Of course, I have tried with the sample files from the manufacturer and they work just fine, I have made by hand some G-Code files according to that principle and they work fine. It is just that I need an automated solution.

If you can help me and need any further info just ask !

Thanks for your help,

Pedro

Hi Pedro, welcme to Maker Forums.

The usage of the S parameter in G1-G3 commands is comming from CNC-Milling machines, where the S param defines the spindle rpm. It’s used by GRBL and Smoothieware and therefore is the default g-code type for LaserWeb.

In GRBL and Smoothieware G0 doesn’t have an S param (automatically set to 0), as G0 is a fast move, not for machining. Other firmwares might needed a M5 before each G0 and M3 (or M4) before G1 to G3.

To configure this in LaserWeb you should start with one of the preset generic machine profiles, like “generic SMOOTHIE machine” or “generic GRBL machine” and click “Apply” in the settings tab. Then go to the gcode section and set the folowing:

GCOE GENERATOR: default
TOOL ON: M3 S0
TOOL OFF: M5
PWM MAX S VALUE: 255

Then give this “New profile” a name and save it by clicking the green + button.

This will generategcode like this:

G21 ; Set units to mm
G90 ; Absolute positioning

;
; Operation: 0
; Type: Laser Cut
; Paths: 1
; Passes: 1
; Cut rate: 100 mm/s
;

; Pass 0

; Pass 0 Path 0
G0 X99.10 Y64.35
; Pass Z Height 50mm (Offset: 0mm)
G0 Z50.00

M3 S0
G1 X106.85 Y64.35 S255.00 F6000
G1 X106.85 Y61.35
G1 X112.85 Y61.35
G1 X112.85 Y64.35
G1 X118.85 Y64.35
M5
M2 ; End

The S and F params are modal which stay the same without repeating it on every line.

1 Like

Hi Claudio!

Thanks for your perfect answer, that makes a lot of sense. I have tried it and the gcode looks perfect as per your answer, the problem is that it still doesn’t work properly on the machine.

It generates de G-code as you say but in my machine, for some obscure reason, it only works with the S and F parameter ON EACH LINE of G1 commands.

With the raw file, it only works for the first line (the one with the embedded parameters) but the laser doesn’t fire on the rest. When I manually add the codes to each line it works.

I see two possibilities, I am doing something wrong (most probable) or there is something particular about my machine. The fact is that in the test files provided by the manufacturer each line has the parameters … so it looks like the right thing to do, I am just wondering if that is possible.

Again, thanks for your help!

Pedro

Just making sure, do you have the latest firmware for the Workbee?

I understand that their firmware is RepRapFirmware with their machine configurations.

Ooznest say that at least for Vectric you just choose the GRBL post, and they provide their own for Fusion360; no other mentions on their firmware page.

The RepRapFirmware documentation doesn’t mention anything at all about S/F being modal and I didn’t read the source so I have no idea whether they implemented that:

I assume you are using M452 to put your controller into laser mode?

Hi Michael!

Thanks for your answer, I’ll test and see if it makes me see where the problem is, appreciate it!

Pedro

2 Likes