585,660 active members*
3,368 visitors online*
Register for free
Login
IndustryArena Forum > MetalWorking Machines > CNC "do-it-yourself" > Why the Heck is it doing this? G code for my laser
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2020
    Posts
    3

    Why the Heck is it doing this? G code for my laser

    This is a diode laser I bought for my Shapeoko. The laser itself is fine and it communicates through a variety
    of software packages.
    I've been trying to write some code but it's doing something I don't understand.

    It will start off fine but ends up cutting during transition. I'm trying to cut a matrix of circles, 5 wide, 6 high.

    Here's an abbreviated copy of the early codes where the problem occurs. Obviously, this set up responds to Spindle codes as laser commands.

    T1
    G17
    G20
    G1M5F20
    G0X0.0000Y0.0000
    G0X0.2035Y0.527
    G1M3S100
    G1X0.2037Y0.5173F25.0
    >>>>>>>>>>>>>>>>>>>>>>>
    <<<<<<<<<<<<<<<<<<<<<<<
    G1X0.7496Y1.4119
    G1M5
    G0X0.6035Y1.8443S0
    G1M3S100F20.0
    G1X0.6137Y1.8444F25.0
    G1X0.6239Y1.8448

    I've tried many scenarios without success.
    A little guidance would be VERY appreciated.
    Alex

  2. #2
    Join Date
    May 2016
    Posts
    316

    Re: Why the Heck is it doing this? G code for my laser

    Assuming your controller uses M3 for laser on, M5 for laser off, and Sxxx for laser percentage output...

    G1M5F20 - this is odd, I think you're confused about standard G-code.
    G1 is a linear feed move, not a precursor command for the laser (spindle). So a G1 with no axis locations on the same line will either throw an error or be ignored.
    F20 is feed rate, in units per minute (depending on the 'mode' - feed/minute, feed/rev, whatever)

    So that line means "Linear move to nowhere, stop laser, Feedrate of 20"

    G1M3S100 - again, you have a G1 before the laser ON command.

    Before pulling your hair out debugging your program, do some tests with a very simple program to test how the laser reacts to M3 & M5 commands. Laser should move in a box pattern and burn two lines in X.

    N100 G0 X0 Y0 (start at origin)
    N110 M3 S100 (turn laser on)
    N120 G1 X3 F20 (Move to X3 at feedrate)
    N130 M5 (turn off laser)
    N140 G0 Y3 (rapid to Y3, hopefully the laser is off)
    N150 M3 S100 (turn on laser)
    N160 G1 X0 (move back to X0 with laser on at feedrate from line N120)
    N170 M5 (turn off laser)
    N180 G0 Y0 (rapid back to origin)

    The point of this is to make sure the M5 is turning off the laser when you expect. Make sure to add whatever G-codes you need for absolute coordinate system (G91?), plus G17 for X/Y plane, and G20 for inch mode.

    If the laser doesn't turn off at M5 properly before the G0 moves you need to re-read both the laser documentation and your controller manual.

  3. #3
    Join Date
    Dec 2020
    Posts
    3

    Re: Why the Heck is it doing this? G code for my laser

    Many thanks for your reply.
    Your test code runs, sorta.
    The laser goes where it should and turns off as expected how ever as soon as it begins to move to a new location, the laser comes back on.
    As a result, it's cutting a box as opposed to two parallel lines.
    Very strange!

  4. #4
    Join Date
    May 2016
    Posts
    316

    Re: Why the Heck is it doing this? G code for my laser

    Couple of thoughts:
    What control system are you using? (hardware and software)
    What laser? (i.e. how does the laser fire? PWM signal or just an on/off thing?)
    When the laser comes back on, is it at full power or reduced?

    The thing to figure out next is:
    Is the laser reacting properly to a command signal (albeit unintended by you) from your controller, or is the laser triggering due to electrical noise or improper wiring?

  5. #5
    Join Date
    Dec 2020
    Posts
    3

    Re: Why the Heck is it doing this? G code for my laser

    Quote Originally Posted by spumco View Post
    Couple of thoughts:
    What control system are you using? (hardware and software) HARDWARE IS A "LASER INK" LASER ORIGINALLY BUILT FOR THE SHAPEOKO 3. THIS LASER WAS INTENDED TO BE DRIVEN BY "OBJECT WORKS" SOFTWARE WHICH I HAVE TRIED (IT DOES WORK WELL WITH RASTER FILES)HOWEVER, DESPITE CLAIMS TO THE CONTRARY, IT DOESN'T PROCESS VECTOR FILES WELL----IF AT ALL! IT DOES VARY POWER VIA PWM.
    What laser? (i.e. how does the laser fire? PWM signal or just an on/off thing?)
    When the laser comes back on, is it at full power or reduced? FULL POWER

    The thing to figure out next is:
    Is the laser reacting properly to a command signal (albeit unintended by you) from your controller, or is the laser triggering due to electrical noise or improper wiring?
    IT APPEARS TO WORK PROPERLY WITHOUT GLITCHES HOWEVER, AFTER CUTTING ONE COPY OF THE DESIGN WHICH IT DOES WELL, IT SETS OFF TO THE NEXT COORDS BUT TURNS THE LASER BACK ON BEFORE IT BEGINS TO MOVE.
    THE DESIGN IS AN ARRAY OF CIRCLES SO IT BURNS A CIRCLE, LASER SHUTS OFF, LASER COMES BACK ON AND IT TRANSITIONS TO THE NEXT START COORD. CUTS THAT CIRCLE, LASER SHUTS OFF, LASER TURNS ON, TRANSITIONS TO NEXT START POINT. ETC, ETC.
    SO I END UP WITH A BUNCH OF CIRCLES WITH LINES CUT THROUGH THEM!!

  6. #6
    Join Date
    May 2016
    Posts
    316

    Re: Why the Heck is it doing this? G code for my laser

    Ok.. please, no ALL CAPS from now on. Makes it hard to read.

    Sounds like the laser is working properly. If every circle gets an unwanted cut line through it at exactly the same time, then this isn't random electrical noise.

    Next test: Try the simple square pattern (or your circle pattern) at reduced power, maybe 30%. Edit the file so all "S" values are 30, not 100.

    If the 'unwanted' cuts during transitions are also at reduced power, then this will confirm that the controller is the problem and not the laser or a stray signal.

    If that's the case - it's the control software/hardware and not the laser - then I suggest you research Lightburn software. They have a very good forum, and that software will be able to control your Shapeoko/laser combo directly - no G-code.

    The Shapeoko runs on GRBL (machine language), which Lightburn can manage just fine.

    Lightburn is superb software. Extremely easy to use, tons of features that make laser engraving/cutting a breeze.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •