Welcome to Our Community

Some features disabled for guests. Register Today.

Grbl Laser On/Off

Discussion in 'OpenBuilds Forum Help' started by Bobbolink, Apr 2, 2021.

  1. Bobbolink

    Bobbolink New
    Builder

    Joined:
    Jul 25, 2019
    Messages:
    31
    Likes Received:
    1
    Laser commands M3/M4/M5 not working like I expect them too.
    Grbl is set to turn laser on.
    Openbuilds Cam 1510 setup in Cam changed tool initialization to laser on and off.
    I Updated 1510 Workbee with Black box to include a diode laser. Everything seems to function correctly until I run the program.
    I can manually set the laser to constant power and change the power settings; works great; but when I run the program transferred from Cam the M3/M4/M5 does not function like I expect them too. Experimented with them several different ways to run through the program; trying to turn laser on/off through the different modules. If the program starts with G0 laser does not turn on at all.
    For Example:
    M3 S###
    G0 X### Y### Z### S###
    M5
    Move to next module. Repeat.
    If I place G1 on the move it blinks on then off moves to next module blinks on then off .
    M3 S###
    G1 X### Y### Z### S###
    M5
    G0 X### Y### Z### (Move to next module)
    G1 ### Y### Z### S###
    Runs to end of program. No errors
    Any idea how to turn it on at the beginning of the module and shut off at the end of the module move to next module repeat till end of the program?
     
  2. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,283
    Likes Received:
    1,836
    you do need to read the GRLB wiki on github where it details how laser mode ($32=1) works

    I don't understand your use of the term 'modules'.
     
  3. Bobbolink

    Bobbolink New
    Builder

    Joined:
    Jul 25, 2019
    Messages:
    31
    Likes Received:
    1
    Read it. Does not help with program. Module is like reading a paragraph. Put period at end and start the next one.
     
  4. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,283
    Likes Received:
    1,836
    ah, ok on the modules.

    laser mode in a nutshell....

    laser mode only turns the laser on during cutting motion
    G0 is rapid motion, non-cutting, ergo laser off. you would use this to move between shapes that must be cut.
    G1 G2 G3 are cutting movements, ergo laser on to do the cutting.

    so if you want it on all the time, use G1 moves for everything.

    M3 mode arms the laser with no regard to cornering acceleration (but stays off until a G1/2/3 move is received)
    M4 mode scales laser power according to acceleration. this is to prevent overburn in sharp corners where the machine has to come to a stop before heading off in a new direction (arced corners are always better).
     
    Peter Van Der Walt likes this.
  5. Bobbolink

    Bobbolink New
    Builder

    Joined:
    Jul 25, 2019
    Messages:
    31
    Likes Received:
    1
    Read about M4 acceleration I don't understand it. Does this mean machine has to move at certain speed to receive the command? Logic just escapes me on this one.
    I tried G2/G3 but received errors arc, traced with offset definition missing IJK word. Lost me again on this one. I noticed if I placed G1 F### X### Y### Z### S### movement became real sluggish and the laser turn on low power. Have not figured that one out yet either. Little slow coming out of hibernation, my garage has no heat in it so I go back an forth to the house to get warmed back up. Also need to figure out ventilation system don't like the idea of running vacuum all the time lots of noise so need to look into something quite and still move lots of air. Will continue researching Grbl to see if I can figure things out.
     
  6. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,283
    Likes Received:
    1,836
    hmmm, so you are lacking the basics of Gcode! (any programming experience at all?)
    Please watch the first 4 results from this https://www.youtube.com/results?search_query=gcode+basics
    You can also read the definitions of the codes at G Codes but keep in mind that GRBL does not support all the codes listed there, but it follows
    those definitions for the codes is DOES support. See the GRBL wiki for supported codes and only read about those.

    Let's break that down:
    Sluggish means you set the feedrate low. (what is your max feedrate? look at the GRBL settings. Setting F## higher than the max will not make it go faster)
    Low power means you set the laser power low. (what is your power scale? check GRBL settings to make sure it is 0 to 1000)
    G1 says to the controller "do a cutting move at the given feedrate"
    F#### is the feedrate, given in mm/minute or inches/minute, set the units you want with G20 for inches and G21 for mm (once for the whole program)
    X### Y### Z### are the coordinates to move to. Gcode is "stateful", it knows where it is now, and only needs to be told where to go.
    S### is 'spindle speed' or 'laser power' and relies on there being a prior M3 or M4. The default settings in GRBL make this use the range 0 to 1000.

    F and S are remembered so you don't have to repeat them on every line unless they are actually changing for the current move.

    so a complete program to cut a 20mm square at half power, starting at X0 Y0 is
    Code:
    G90 G21 G49 G17 F450 ; set the modes we want, absolute positioning, metric, no tool offset, XY plane, default feedrate. Always do these, we cannot trust the state the last program left behind
    G00 X0.0 Y0.0  ; go to X0 Y0
    M04 S500   ; set laser  power scaling mode and half power
    G01 X20.0 F750   ; go to X20 at 750mm/min
    G01 Y20.0  ; go to Y20 at 750mm/min
    G01 X0.0  ; go to X0
    G01 Y0.0  ; go to Y0
    M05  ; turn laser off, note that even though GRBL is powering the laser only during G1 moves, our program must still do this, for safety we always leave the machine in a safe state.
    G00 X0 Y0 (home)  ; return to job 0,0, in this case does nothing because we are already there, but a nice indicator on complex programs that job is done
    M30 ; end program
    
    Note there are no Z moves because this program assumes the laser is at the correct focus height already. Not all laser cutters even have a Z axis.

    M4 mode.
    The motors on a CNC machine cannot go from stopped to cutting speed in an instant, they have to accelerate, and then decelerate to a stop at the other end because of the kinetic energy.
    This takes time and means that the laser is spending differing amounts of time over the material.
    A laser burns deeper the longer it stays in one place, so if you are trying to engrave at a constant depth, you have to maintain constant speed, or vary the power.
    But when the machine approaches a sharp corner it has to decelerate, stop, accelerate, which means the laser is now spending longer over that material, burning deeper.
    This is called overburn.

    M4 mode solves this by scaling the laser power from minimum to 'set power' at the same time that the movement is accelerating (or decelerating), so reducing power when the machine is moving, so that the overburn is reduced or even eliminated if you get the settings just right.

    M3 mode ignores all acceleration and just turns the laser on when moving (in a cut) and off when stopped or doing a G0 move.

    G0 is for moving to the start of the next cut, it moves at the maximum rate the machine can do, limited to the slowest axis rate. so if X and Y can do 10 meters a minute but Z can only do 1 meter a minute, combined X Y Z moves will be limited by the Z max rate.

    HTH
     
    Peter Van Der Walt likes this.
  7. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    3,283
    Likes Received:
    1,836
    Figure out what this program does then run it on your machine and see if you got it right (-:
    Code:
    G90 G21 G49 G17 F450
    G00 X0.0 Y0.0
    M04 S500
    G01 X20.0 F750
    G01 Y20.0
    G01 X0.0
    G01 Y0.0
    G00 X25.0
    G01 X45.0
    G01 Y20.0
    G01 X25.0
    G01 Y0.0
    G00 X0 Y0
    M05
    M30
    
     
    Peter Van Der Walt likes this.
  8. Bobbolink

    Bobbolink New
    Builder

    Joined:
    Jul 25, 2019
    Messages:
    31
    Likes Received:
    1
    Old business program COBOL language experience totally different. 30 yrs ago. Self teaching myself to pick up Grbl and CNC operation. What I am doing is drawing in paint save as bitmap, bring it up in Cam transfer it to said machine code, and then transfer to Open builds control board for running code. Sometimes have to edit the program because it will drop X,Y,Z entry on the drawing. Sometimes numerous cuts but not continuous cuts so Cam creates the different machine code and depending on the drawing it creates cutting blocks. I think the largest I have encountered is 16 sections in 1 drawing before program cutting ends. I have to read through each one till errors are removed before operating, even then errors do get trough so it is a slow process. So I rely on Open builds Cam program to bring it back as the proper machine code.
    Have not experienced the codes G90, G21, G49, G17 so greenie on those codes.
     
  9. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,024
    Likes Received:
    4,117
    Bitmaps are not really a CNC format. Use proper Vectors: docs:software:file-errors [OpenBuilds Documentation]

    From there, if you have OpenBuildsCAM, set up a Laser (m4) tool in Settings: Tool Initialisation, and have created Laser toolpaths, you will NOT need to do any hand editing.
    On the Grbl end, just make sure Laser Mode is Enabled
     
  10. Bobbolink

    Bobbolink New
    Builder

    Joined:
    Jul 25, 2019
    Messages:
    31
    Likes Received:
    1
    Ok, found what was causing problem with the Laser not working. It is Cam when selecting laser %%%. Even though you select 2 digits on S%% and say apply then generate the file it still places 3 digits into the program code. Took a while to find the problem but works great now. Might keep the digits in mind if someone else has a laser not shutting on/off during operation. Thank you for listening and helping.
     
  11. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,024
    Likes Received:
    4,117
    Toolpath Percentage = scaled between 0 and (default = 1000) value of $30 in Grbl settings for Gcode output.
    Read gnea/grbl and also gnea/grbl

    Check your Grbl settings matches what you told CAM to use in its settings.
     
    David the swarfer likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice