Laser Gcode S Sticky after G0 question



  • Hello, found this forum a great help hadn't had to ask a question up till now as the same questions had been asked and answered.

    I have added a laser to my duet cnc.
    I use lightburn to produce the gcode and edit the code to turn put duet in laser mode etc.

    This works well, the issue I'm having is every time there is a G0 move it turns laser off as it should but the next G1 has to have a S value to trigger the laser again. Lightburn appears to presume to preserve the S value for the next G1 move.

    My question is, is this how the duet works or is my code the issue.

    Here is my G code.

    code_text
    ; LightBurn 0.9.06
    ; absolute coords
    G00 G17 G21 G54
    G90
    
    M307 H3 A-1 C-1 D-1       ; Disable Heater output on H3
    M452 P3 S1 R255 F60         ; Enable Laser mode, on output 3 (heater 3), with max intensity being 255, and a PWM frequency of 200
    M571 P3 F200 S0
    
    M3
    
    G0X406.4Y585.8
    G1Y708.2S255F4200
    G1X553.2
    G1Y585.8
    G1X406.4
    G0X577.6Y702
    G1Y760 <<<<<I need to add S255 here to get laser to fire again
    G1X703
    G1Y702
    G1X577.6
    M107
    G1S0
    M5
    G90
    ; End
    
    
    

    Regards Mike



  • Welcome ot the wonderful world of CNC gcode and flavors..

    I'm unfamiliar with LightBurn, but a 1minute google implies it defaults to code for GRBL (cnc firmware) with laser mode on. This is actually different than the Duet laser mode.

    In this mode Grbl handles the laser power; you set the laser power once, set the cut feedrate, and Grbl scales the power during acceleration, corner slowdowns to maintain a constant intensity. During travel, or any sort of pause/dwell it will keep the beam off. Described Here: https://github.com/gnea/grbl/wiki/Grbl-v1.1-Laser-Mode

    AFIK (and others here probably understand this better than me) the Duet laser mode only handles the turning off part, so you are correct that you need to repeat the S parameter for each initial G1.

    Does LightBurn have a selector for the target firmware? if so you should be able to find one that handles this. Plenty of other CNC firmwares (including early Grbl vesions) need to be given specific 'on' and 'off' commands; so there should be an option?

    If not.. you might need to post-process the gcode. It's horrible, but far more common in the CNC world than with 3d printing.


  • administrators

    Yes that's how the firmware works. Maybe we should add a S2 option to M452 to specify the less safe option that laser power should be restored after a G0 command.



  • Thanks for both your replies.

    An S2 option would help me out would only mean changing the first 5lines or so lines of the gcode.

    As for lightburn it can output many controllers.
    Grbl
    Ruida
    Marlin
    Trocen AWC 608 and 708c
    Smoothie
    Maybe more than this.

    I use smoothie config as it seems to be the closest to what is needed.
    Greyscale Images work well as there is S on every G1 line.



  • @mikeisamonk
    I've been looking for an excuse to trial LightBurn, so I just had a play; It's a pretty good tool. I might even splash $40 on this for myself.

    But not adding S parameters to every initial G1 when cutting vectors (as opposed to ditering and grayscale) is most annoying. It would help if the Duet could have a less-safe 'on while in motion' option to M452 for this case.

    I found this:
    https://forum.lightburnsoftware.com/t/how-to-make-the-software-add-sx-to-the-end-of-the-first-g1-line-after-m3-sx-in-a-cut-operation/6551
    Where they recommend using the GRBL-M3 (non lasermode) profile; but having done some quick testing I do not think it would help for this problem; it will just fill your code with lots ofM3/M5's, without adding the S parameters where needed.

    Edit: Of course; you could select the GRBL-M3 mode, edit the header but leave lasermode OFF; and make darn sure you don't set anything on fire.. but it is a bad recommendation. Ok.



  • I do really like lightburn it also has good support well worth the money imo, I also have a k40 with C3D (smoothie) controller which is brilliant the problem is the space inside the k40 is limited.
    With the laser attached on the 1m² CNC mill I can engrave any ply I cut.

    I did try all of the different firmware outputs but the smoothie option seems the closest. (Might be biased as I'm more familiar with it).

    If the S2 option can't be implemented I will try writing a script to post process the gcode automatically.

    Mike



  • I just got my laser working on my printer. If you are ok with buying a program PicEngrave will produce the correct gcode.
    https://www.picengrave.com/PicEngrave_Pro_6_+_Laser.htm
    It will let you decide if you want the Sxx on the same line or on seperate line. It will also let you dictate what M code will control the laser (M106 or M3 etc.)



  • I am also interested in getting lightburn to work with the Duet. I have attatched a CO2 laser tube onto the gantry of my CNC router. Currently I use machinekit to drive it as it has support for 3d printing head that I use sometimes.

    I would like to use the duet for its ease of use and its ability to sync dual z axis and y axis motors. It also supports bed leveling which machinekit does not. I would like that very much as mesh leveling on a 6'x4' bed can be very useful for keeping the nozzle and laserhead at the correct height.

    From what I have read, lightburn is not currently supported. I would still be waiting on the duet 3 to push my nema 23 motors though. Is there plans to support lightburn's gcode in the near future?



  • At the moment I am loading gcode In notepad++

    notepadG1.png

    It should add an S value on all lines starting with G1
    This is only good if your using 1 level of power.

    Mike



  • @mrsolis93 said in Laser Gcode S Sticky after G0 question:

    Is there plans to support lightburn's gcode in the near future?

    It may be a better idea to ask the same of the LightBurn people; they could support Duet as a controller; add a more appropriate header to the code and a S parameter to every active G command.
    Even if Duet solves the resume problem andsupports persisting the level from cut-to-cut, the gcode preamble (headers) will still be wrong.

    The LightBurn developers have made a decision not to support custom headers and commands. The available devices (controllers) are in a dropdown; and they just offer a few options on a per-controller basis. Duet is not in that list, so you will always need to post-process, until they add it 😉

    I understand their reasoning (avoiding some support and 'you broke my machine' hassles), but it does mean they need to be proactive in supporting popular controllers.

    From my perspective this is ok since it's grbl-laser support is perfect and I'm using grbl-esp32 in my engraver. I'm going to give it a go since it's cheap and probably makes a great alternative to my current free open source toolchain, aka InkScape and LaserWeb4.


  • administrators

    I've made a change to the source code to preserve the laser power across G0 commands. It will be in the 2.04RC3 release. I've done the build already, but I won't have time to test it until Wednesday.



  • @dc42 thanks for the update.
    Going to save me a lot of post processing. 👍



  • @EasyTarget
    What headers are necessary for the duet to run lightburn?

    Wouldnt it be possible to just write a lightburn header Macro? I would have to use headers anyway for autoleveling since laser cutters don't usually support that anyway.



  • @mrsolis93 said in Laser Gcode S Sticky after G0 question:

    What headers are necessary for the duet to run lightburn?

    I dont really know.. not using my Dued for my CNC work I've never investigated; but if you look at the example given by @mikeisamonk in the OP you can see the sort of preamble that is needed.

    Wouldnt it be possible to just write a lightburn header Macro? I would have to use headers anyway for autoleveling since laser cutters don't usually support that anyway.

    It would indeed, the core problem being that LightBurn has nowhere to enter the header. So you'd need to post process, or persuade it's developers to add the Duet and support all the M307,452,571 combinations people might need.



  • @mrsolis93
    This is what I use. This is slightly different to the above code the max output is set to 1.00 as lightburn outputs from 0-1 when smoothie hardware is selected.

    What laser are you using?
    I had to invert and convert the ppm signal from 3.3 to 5v for my diode laser.

    G00 G17 G21 G54
    G90
    
    M307 H3 A-1 C-1 D-1       ; Disable Heater output on H3
    M452 P3 S1 R1.00 F2000         ; Enable Laser mode, on output 3 (heater 3), with max intensity being 1.00, and a PWM frequency of 2000
    M571 P3 F200 S0
    
    M3
    

    Mike



  • Thanks for the header information!

    I am using a 60w CO2 laser tube and power supply from amazon. Also picked up a mirror/lens kit to bounce it all around my CNC router.

    I am still playing with it and determining whether it is worth it to keep it on my machine or move it to a separate one. Part of that is finding a board that will support all the different tasks.


Log in to reply